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