diff --git a/src/jlmap3d/jl3dpassflow/config.js b/src/jlmap3d/jl3dpassflow/config.js index 486cdc681..77ebe869e 100644 --- a/src/jlmap3d/jl3dpassflow/config.js +++ b/src/jlmap3d/jl3dpassflow/config.js @@ -24,16 +24,24 @@ var Staticmodel = { picUrl: "", assetUrl: "../../static/model/passflow/station.FBX" }, - zhaji: { + zhajiin: { id: "4", name: "闸机", - deviceType: "zhaji", + deviceType: "zhajiin", type: "hrb", picUrl: "", - assetUrl: "../../static/model/passflow/zhaji.FBX" + assetUrl: "../../static/model/passflow/zhajiin.FBX" + }, + zhajiout: { + id: "5", + name: "闸机", + deviceType: "zhajiout", + type: "hrb", + picUrl: "", + assetUrl: "../../static/model/passflow/zhajiout.FBX" }, monitor: { - id: "5", + id: "6", name: "摄像机", deviceType: "monitor", type: "hrb", diff --git a/src/jlmap3d/jl3dpassflow/jl3dpassflow.js b/src/jlmap3d/jl3dpassflow/jl3dpassflow.js index 73a67f440..45a4d5045 100644 --- a/src/jlmap3d/jl3dpassflow/jl3dpassflow.js +++ b/src/jlmap3d/jl3dpassflow/jl3dpassflow.js @@ -17,7 +17,8 @@ var humans = []; var checkdoor1 = []; var checkdoor2 = []; var station; -var zhaji; +var zhajiinmodel; +var zhajioutmodel; var monitor; let ids = 0; var rungroup = new THREE.Group(); @@ -30,6 +31,8 @@ let moveanimatelist = []; let zhajiin = []; let zhajiout = []; +let deviceaction = []; + for(let i=0;i<5;i++){ checkdoor1[i]={ id:"c1"+i, @@ -41,13 +44,22 @@ for(let i=0;i<5;i++){ for(let i=0;i<5;i++){ let zhaji = { - id:"in"+i, + id:"in0"+(i+1), status:0, waiting:0 } zhajiin.push(zhaji); } +for(let i=0;i<5;i++){ + let zhaji = { + id:"out0"+(i+1), + status:0, + waiting:0 + } + zhajiout.push(zhaji); +} + let stationleft = []; let stationright = []; @@ -201,11 +213,10 @@ export function Jl3dpassflow(dom) { this.modelmanager = new ModelManager(); this.modelmanager.loadpromise(Staticmodel, scope.mixers).then(function (data) { // console.log(scope.modelmanager); - station = scope.modelmanager.station.mesh; - zhaji = scope.modelmanager.zhaji.mesh; + initstationanimation(scope.modelmanager.station.mesh); + initzhajiinaimation(scope.modelmanager.zhajiin.mesh); + initzhajioutanimation(scope.modelmanager.zhajiout.mesh); monitor = scope.modelmanager.monitor.mesh; - scene.add(station); - scene.add(zhaji); scene.add(monitor); originhuman1 = scope.modelmanager.man1.mesh; originhuman2 = scope.modelmanager.man2.mesh; @@ -239,20 +250,11 @@ export function Jl3dpassflow(dom) { if(humans[i].status == 0){ if(humans[i].stage == 1){ - for(let j =0;j<5;j++){ - if(zhajiin[j].waiting == 0){ let points = []; points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z)); - points.push(new THREE.Vector3(6.5-j*1.5,10,18.5)); - points.push(new THREE.Vector3(6.5-j*1.5,10,13)); - humans[i].doors = j; - zhajiin[j].waiting = 1; - moveanimateinit(humans[i],i,points,i); - - j =5; - } - } - + points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z-5)); + zhajicontrol("in",humans[i].doors); + moveanimateinit(humans[i],i,points,i,0.02); } if(humans[i].stage == 2){ let points = []; @@ -274,7 +276,7 @@ export function Jl3dpassflow(dom) { humans[i].doors = j; stationright[j].waiting = 1; - moveanimateinit(humans[i],i,points,i); + moveanimateinit(humans[i],i,points,i,0.002); j =22; } } @@ -290,12 +292,12 @@ export function Jl3dpassflow(dom) { points.push(new THREE.Vector3(51-j*5,1.7,2)); humans[i].doors = j; stationright[j].waiting = 1; - moveanimateinit(humans[i],i,points,i); + moveanimateinit(humans[i],i,points,i,0.002); j =22; } } } - moveanimateinit(humans[i],i,points,i); + moveanimateinit(humans[i],i,points,i,0.002); } //出站 if(humans[i].stage == 3){ @@ -322,22 +324,26 @@ export function Jl3dpassflow(dom) { } points.push(new THREE.Vector3(-5,10,4)); points.push(new THREE.Vector3(14,10,3)); - moveanimateinit(humans[i],i,points,i); + var j = Math.floor(Math.random()*(4-1+1))+1; + points.push(new THREE.Vector3(19,10,-2+j*1.4)); + + humans[i].doors = j; + moveanimateinit(humans[i],i,points,i,0.002); } if(humans[i].stage == 4){ - var j = Math.floor(Math.random()*(4-1+1))+1; + let points = []; points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z)); - points.push(new THREE.Vector3(19,10,5-j*1.4)); - points.push(new THREE.Vector3(23,10,5-j*1.4)); - console.log(); + + points.push(new THREE.Vector3(humans[i].mesh.position.x+4,humans[i].mesh.position.y,humans[i].mesh.position.z)); + if(humans[i].direct == 1){ points.push(new THREE.Vector3(33,10,25)); }else{ points.push(new THREE.Vector3(33.5,10,-5)); } - humans[i].doors = j; - moveanimateinit(humans[i],i,points,i); + zhajicontrol("out",humans[i].doors); + moveanimateinit(humans[i],i,points,i,0.002); } } } @@ -382,7 +388,7 @@ export function Jl3dpassflow(dom) { } - function moveanimateinit(model,name,points,index){ + function moveanimateinit(model,name,points,index,speed){ let curve = new THREE.CatmullRomCurve3(points); curve.curvrtype = "chordal"; @@ -399,7 +405,7 @@ export function Jl3dpassflow(dom) { directchange:false, enable:true, status:"start", - speed:0.002, + speed:speed, }; humans[index].runrail = animate; humans[index].status = 1; @@ -420,45 +426,46 @@ export function Jl3dpassflow(dom) { if(humans[i].status == 1){ humans[i].runrail.enable = false; humans[i].runrail.progress = 1; - humans[i].mixer.runplay = false; - humans[i].action.stop(); - humans[i].status = 0; + humans[i].mixer.runplay = false; + humans[i].action.stop(); + humans[i].status = 0; - if(humans[i].stage == 4){ + if(humans[i].stage == 4){ - rungroup.remove(humans[i].mesh); - // humans.splice(i,1); + rungroup.remove(humans[i].mesh); + // humans.splice(i,1); + } + + if(humans[i].stage == 3){ + + if(humans[i].direct == 1){ + + stationleft[humans[i].doors].waiting = 0; + }else{ + + stationright[humans[i].doors].waiting = 0; } + humans[i].stage = 4; - if(humans[i].stage == 3){ + } - if(humans[i].direct == 1){ + if(humans[i].stage == 2){ + humans[i].stage = 3; - stationleft[humans[i].doors].waiting = 0; - }else{ + } - stationright[humans[i].doors].waiting = 0; - } - humans[i].stage = 4; + if(humans[i].stage == 1){ - } - if(humans[i].stage == 2){ - humans[i].stage = 3; + humans[i].stage = 2; - } + } - if(humans[i].stage == 1){ - - zhajiin[humans[i].doors].waiting = 0; - humans[i].stage = 2; - - } - - if(humans[i].stage == 0){ - - humans[i].stage = 1; - } + if(humans[i].stage == 0){ + console.log(humans[i].doors); + zhajiin[humans[i].doors].waiting = 0; + humans[i].stage = 1; + } moveanimatelist.splice(i,1); @@ -467,22 +474,19 @@ export function Jl3dpassflow(dom) { }else{ //根据动画进度获取动画轨迹上点 - let point = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress); + let point = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress); - //更新模型坐标 - humans[i].mesh.position.x = point.x; - humans[i].mesh.position.y = point.y; - humans[i].mesh.position.z = point.z; - if((humans[i].runrail.progress+0.001)<1){ - let tangent = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress+0.001); - humans[i].mesh.lookAt(new THREE.Vector3(tangent.x,humans[i].mesh.position.y,tangent.z)); - } - // = ; + //更新模型坐标 + humans[i].mesh.position.x = point.x; + humans[i].mesh.position.y = point.y; + humans[i].mesh.position.z = point.z; + if((humans[i].runrail.progress+0.001)<1){ + let tangent = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress+0.001); + humans[i].mesh.lookAt(new THREE.Vector3(tangent.x,humans[i].mesh.position.y,tangent.z)); + } - - //增加动画进度,释放点变量 - humans[i].runrail.progress += humans[i].runrail.speed; - point = null; + humans[i].runrail.progress += humans[i].runrail.speed; + point = null; } @@ -519,34 +523,298 @@ export function Jl3dpassflow(dom) { points.push(new THREE.Vector3(18,10,18)); } + let j = Math.floor(Math.random()*(4-1+1))+1; + points.push(new THREE.Vector3(-0.5+j*1.4,10,18.5)); + // zhajiin[j].waiting = 1; - let mixer = new THREE.AnimationMixer( newhuman ); - mixer.runplay = false; - let action = mixer.clipAction( newhuman.animations[ 0 ] ); + let mixer = new THREE.AnimationMixer( newhuman ); + mixer.runplay = false; + let action = mixer.clipAction( newhuman.animations[ 0 ] ); - var stationdirection = Math.floor(Math.random()*(2-1+1))+1; + var stationdirection = Math.floor(Math.random()*(2-1+1))+1; + let newone = { + id:humans.length, + mesh:newhuman, + status:1, + stage:0, + direct:stationdirection, + doorstatus:null, + doors:j, + action:action, + mixer:mixer, + runrail:null + }; - let newone = { - id:humans.length, - mesh:newhuman, - status:1, - stage:0, - direct:stationdirection, - doorstatus:null, - doors:null, - action:action, - mixer:mixer, - runrail:null - }; - humans.push(newone); - mixers.push(mixer); - rungroup.add(newhuman); + humans.push(newone); + mixers.push(mixer); + rungroup.add(newhuman); - moveanimateinit(newone,humans.length,points,newone.id); + moveanimateinit(newone,humans.length,points,newone.id,0.002); // return newone; } + + function initstationanimation(object){ + let mixer = new THREE.AnimationMixer( object ); + + let newclip = object.animations[ 0 ]; + for(let j=0;j