修改三维界面声音返回和退出播放bug,更换音轨
This commit is contained in:
parent
2cd39f6fbd
commit
dfef5a28e9
@ -104,16 +104,18 @@ export function JLmapDriving(dom, data, skinCode) {
|
|||||||
camera.updateProjectionMatrix();
|
camera.updateProjectionMatrix();
|
||||||
|
|
||||||
let listener = new THREE.AudioListener();
|
let listener = new THREE.AudioListener();
|
||||||
|
listener.position.y = -2;
|
||||||
camera.add( listener );
|
camera.add( listener );
|
||||||
|
|
||||||
let sound = new THREE.Audio( listener );
|
let sound = new THREE.Audio( listener );
|
||||||
sound.soundswitch = true;
|
|
||||||
// load a sound and set it as the Audio object's buffer
|
// load a sound and set it as the Audio object's buffer
|
||||||
let audioLoader = new THREE.AudioLoader();
|
let audioLoader = new THREE.AudioLoader();
|
||||||
audioLoader.load( '../../static/audio/trainmove.ogg', function( buffer ) {
|
audioLoader.load( '../../static/audio/trainmove.ogg', function( buffer ) {
|
||||||
sound.setBuffer( buffer );
|
sound.setBuffer( buffer );
|
||||||
sound.setLoop( true );
|
sound.setLoop( true );
|
||||||
sound.setVolume( 0.8 );
|
sound.setVolume( 0 );
|
||||||
|
sound.volswitch = false;
|
||||||
sound.play();
|
sound.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -133,6 +135,7 @@ export function JLmapDriving(dom, data, skinCode) {
|
|||||||
var timer = setInterval(function() {
|
var timer = setInterval(function() {
|
||||||
if(mapdata.trainlisttest.group){
|
if(mapdata.trainlisttest.group){
|
||||||
if(mapdata.trainlisttest.group.children[0]){
|
if(mapdata.trainlisttest.group.children[0]){
|
||||||
|
|
||||||
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
|
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
|
||||||
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
|
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
@ -249,6 +252,7 @@ export function JLmapDriving(dom, data, skinCode) {
|
|||||||
mixers = null;
|
mixers = null;
|
||||||
scope.actions = null;
|
scope.actions = null;
|
||||||
scope.Subscribe = null;
|
scope.Subscribe = null;
|
||||||
|
sound.stop();
|
||||||
// console.log(scope);
|
// console.log(scope);
|
||||||
// scope = null;
|
// scope = null;
|
||||||
};
|
};
|
||||||
@ -317,6 +321,7 @@ export function JLmapDriving(dom, data, skinCode) {
|
|||||||
// 窗口自适应
|
// 窗口自适应
|
||||||
window.addEventListener( 'resize', onWindowResized, false );
|
window.addEventListener( 'resize', onWindowResized, false );
|
||||||
|
|
||||||
|
sound.volswitch = true;
|
||||||
// controls.update();
|
// controls.update();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -326,6 +331,9 @@ export function JLmapDriving(dom, data, skinCode) {
|
|||||||
document.getElementById('jlsimulation').removeEventListener( 'mousedown', onselect, false );
|
document.getElementById('jlsimulation').removeEventListener( 'mousedown', onselect, false );
|
||||||
// 窗口自适应
|
// 窗口自适应
|
||||||
window.removeEventListener( 'resize', onWindowResized, false );
|
window.removeEventListener( 'resize', onWindowResized, false );
|
||||||
|
|
||||||
|
sound.volswitch = false;
|
||||||
|
sound.setVolume( 0 );
|
||||||
};
|
};
|
||||||
|
|
||||||
this.updatecamera = function(mesh, type) {
|
this.updatecamera = function(mesh, type) {
|
||||||
|
@ -106,6 +106,7 @@ export function Jl3dDriving(updatemmi,sound) {
|
|||||||
break;
|
break;
|
||||||
case 'Simulation_Driver_Change':
|
case 'Simulation_Driver_Change':
|
||||||
drivingcode = data.body.code;
|
drivingcode = data.body.code;
|
||||||
|
sound.volswitch = true;
|
||||||
updatemmi.updatedrivingcode( data.body.code);
|
updatemmi.updatedrivingcode( data.body.code);
|
||||||
break;
|
break;
|
||||||
case 'SJL3D_TrainStatus':
|
case 'SJL3D_TrainStatus':
|
||||||
@ -165,18 +166,7 @@ export function Jl3dDriving(updatemmi,sound) {
|
|||||||
// if (data.body[tl].v >0) {
|
// if (data.body[tl].v >0) {
|
||||||
// updatemmi.updatenowspeed(data.body[tl].v);
|
// updatemmi.updatenowspeed(data.body[tl].v);
|
||||||
// } else {
|
// } else {
|
||||||
if(trainlisttest.list[code].speeds == 0){
|
|
||||||
if(sound.soundswitch == true){
|
|
||||||
sound.stop();
|
|
||||||
sound.soundswitch = false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(sound.soundswitch == false){
|
|
||||||
sound.play();
|
|
||||||
sound.soundswitch = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sound.setVolume( data.body[tl].v/100 );
|
|
||||||
updatemmi.updatenowspeed(Math.abs(data.body[tl].v));
|
updatemmi.updatenowspeed(Math.abs(data.body[tl].v));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@ -185,6 +175,10 @@ export function Jl3dDriving(updatemmi,sound) {
|
|||||||
|
|
||||||
|
|
||||||
if (code == drivingcode) {
|
if (code == drivingcode) {
|
||||||
|
if(sound.volswitch == true){
|
||||||
|
sound.setVolume( data.body[tl].v/100 );
|
||||||
|
}
|
||||||
|
|
||||||
if (data.body[tl].atpv) {
|
if (data.body[tl].atpv) {
|
||||||
updatemmi.updateatpspeed(data.body[tl].atpv);
|
updatemmi.updateatpspeed(data.body[tl].atpv);
|
||||||
} else {
|
} else {
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user