This commit is contained in:
zyy 2020-09-25 18:42:26 +08:00
commit 13f4cccaae
10 changed files with 214 additions and 42 deletions

View File

@ -17,6 +17,7 @@
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
},
"dependencies": {
"@vue/component-compiler-utils": "^3.1.2",
"axios": "0.18.0",
"echarts": "^4.7.0",
"element-ui": "^2.12.0",
@ -77,7 +78,8 @@
"serve-static": "^1.13.2",
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.2",
"vue-template-compiler": "2.6.11"
"vue-loader": "^15.9.3",
"vue-template-compiler": "^2.6.12"
},
"engines": {
"node": ">=8.9",

View File

@ -481,6 +481,73 @@ export function JLmap3dEdit(dom, data, mapid) {
objectparent.add(newAlignmentSection);
};
this.flatSection = function(alignmentCode){
let oldobject = scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh;
let alignmentModel = scope.mapdata.sectionlist.sections.datalist[alignmentCode];
let objectparent = oldobject.parent;
objectparent.remove(oldobject);
let newpointlist = [];
for(let i=0;i<alignmentModel.railpoint.length;i++){
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[i].x,alignmentModel.railpoint[0].y,alignmentModel.railpoint[i].z));
}
let closedSpline = new THREE.CatmullRomCurve3(newpointlist);
closedSpline.type = 'catmullrom';
closedSpline.closed = false;
let extrudeSettings = {
steps : 5,
curveSegments : 1,
bevelSegments : 1,
bevelEnabled : false,
extrudePath : closedSpline,
};
var shape = new THREE.Shape();
shape.moveTo( 0,-2 );
shape.lineTo( 0, 2 );
let selectmaterial = oldobject.material;
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
let newAlignmentSection = new THREE.Mesh( geometry, selectmaterial );
newAlignmentSection.code = oldobject.code;
newAlignmentSection.railpoint = [];
for(let i=0;i<newpointlist.length;i++){
newAlignmentSection.railpoint[i] = {
x:newpointlist[i].x,
y:newpointlist[i].y,
z:newpointlist[i].z
}
}
newAlignmentSection.lengthFact = closedSpline.arcLengthDivisions/4;
if(newpointlist.length>2){
newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5;
}
let len = newAlignmentSection.lengthFact;
// closedSpline.arcLengthDivisions;
let count = newAlignmentSection.geometry.attributes.position.count/3;
for(let i=0;i<count;i++){
let ui=i*6;
if(i%2 != 0){
newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}else{
newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}
}
newAlignmentSection.meshtype = "section";
scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newAlignmentSection;
objectparent.add(newAlignmentSection);
}
function onWindowResize() {
//窗口自适应
scope.camera.aspect = window.innerWidth / window.innerHeight;

View File

@ -845,6 +845,7 @@ export function SectionList() {
extrudePath : closedSpline,
};
var shape = new THREE.Shape();
if(newsection.railpoint[0].y != newsection.railpoint[2].y){
shape.moveTo( -2, 0 );
shape.lineTo( 2, 0 );

View File

@ -50,7 +50,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
this.renderer.gammaOutput = true;
this.renderer.vr.enabled = true;
this.dom.appendChild(this.renderer.domElement);
document.body.appendChild( VRButton.createButton( human,{x:30,y:1.38+0.6,z:0},this.renderer ) );
document.body.appendChild( VRButton.createButton( human,{x:25,y:1.3,z:1},this.renderer ) );
//定义相机
this.camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.01, 3000);
@ -67,9 +67,9 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
controller1 = scope.renderer.vr.getController( 0 );
controller1.addEventListener( 'selectstart', onSelectStart );
controller1.addEventListener( 'selectend', onSelectEnd );
controller1.addEventListener( 'squeeze', squeezeStart );
controller1.addEventListener( 'squeezestart', squeezeStart );
controller1.addEventListener( 'squeezeend', squeezeEnd );
human.add( controller1 );
controller2 = scope.renderer.vr.getController( 1 );
controller2.addEventListener( 'selectstart', onControlModelStart );
controller2.addEventListener( 'selectend', onControlModelEnd );
@ -103,14 +103,21 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
this.modelmanager = new ModelManagerVR();
this.modelmanager.loadpromise(TrainRescueStatic,mixers);
let timer=setInterval(function(){
if(TrainRescueStatic.floorplane.mesh){
if(TrainRescueStatic.other.mesh){
console.log(TrainRescueStatic);
scope.scene.add(TrainRescueStatic.animatemodel.mesh);
scope.scene.add(TrainRescueStatic.controlmodel.mesh);
scope.scene.add(TrainRescueStatic.floorplane.mesh);
TrainRescueStatic.floorplane.mesh.position.y = -0.2;
scope.scene.add(TrainRescueStatic.other.mesh);
// TrainRescueStatic.handR.mesh.geometry.computeBoundingBox();
// controller1.add(handrBox);
controller1.add( TrainRescueStatic.handR.mesh );
console.log(TrainRescueStatic.controlmodel.mesh);
// floors.push(TrainRescueStatic.floorplane.mesh);
animate();
@ -118,7 +125,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
}
},1000);
},2000);
@ -171,9 +178,8 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
// console.log();
var controller = event.target;
var intersections = getIntersections( controller );
console.log(intersections);
if ( intersections) {
console.log(intersections);
var intersection = intersections[0];
human.position.set( intersection.point.x, intersection.point.y+0.6, intersection.point.z );
}
@ -204,9 +210,43 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
// controller.userData.selected = undefined;
}
}
let handrBox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3());
let controlBox = new THREE.Box3(new THREE.Vector3(), new THREE.Vector3());
let controlMoveSwitch = false;
let nowControlModel = null;
function squeezeStart(){
TrainRescueStatic.handR.action.reset();
TrainRescueStatic.handR.action.time = TrainRescueStatic.handR.action._clip.duration;
TrainRescueStatic.handR.action.timeScale = 1;
TrainRescueStatic.handR.action.play();
var delta = clock.getDelta();
mixers["handr"].update(delta);
for(let i=1,leni=6;i<leni;i++){
controlBox.setFromObject(TrainRescueStatic.controlmodel.mesh.getObjectByName(""+i));
handrBox.setFromObject(TrainRescueStatic.handR.mesh);
if(handrBox.intersectsBox(controlBox)){
//两个物体相交了
controlMoveSwitch = true;
nowControlModel = TrainRescueStatic.controlmodel.mesh.getObjectByName(""+i);
i = leni;
}
}
}
function squeezeEnd(){
TrainRescueStatic.handR.action.reset();
TrainRescueStatic.handR.action.time = 0;
TrainRescueStatic.handR.action.timeScale = -1;
TrainRescueStatic.handR.action.play();
var delta = clock.getDelta();
mixers["handr"].update(delta);
controlMoveSwitch = false;
nowControlModel = null;
}
function getIntersections( controller ) {
@ -216,7 +256,6 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
let rayObject = raycastervr.intersectObjects( TrainRescueStatic.floorplane.mesh.children);
if(rayObject.length>0){
console.log(rayObject);
return rayObject;
}
// for(let i=0;i<1;i++){
@ -277,23 +316,76 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
scope.renderer.setAnimationLoop( render );
}
let delta;
function render() {
intersectObjects( controller1 );
let delta = clock.getDelta();
if (mixers) {
for (let i = 0; i < mixers.length; i++) {
if (mixers[i]) {
mixers[i].update(delta);
}
if (mixers){
for (let k in mixers) {
delta = clock.getDelta();
mixers[k].update(delta);
}
}
// scope.controls.update();
updateControlModel();
scope.renderer.render(scope.scene, scope.camera);
}
//
let controlStage = 0;
//animateStage 动画播放阶段
//0两侧千斤顶升降
//1中间千斤顶平移
//2中间千斤顶升降
let animateStage = 0;
function updateControlModel(){
if(controlMoveSwitch == true){
console.log(TrainRescueStatic.animatemodel.action.time);
// console.log(nowControlModel);
// console.log(TrainRescueStatic.handR.mesh);
let originPoint = new THREE.Vector3(nowControlModel.matrixWorld.elements[12],nowControlModel.matrixWorld.elements[13],nowControlModel.matrixWorld.elements[14]);
let overPoint = new THREE.Vector3(TrainRescueStatic.handR.mesh.matrixWorld.elements[12],TrainRescueStatic.handR.mesh.matrixWorld.elements[13],TrainRescueStatic.handR.mesh.matrixWorld.elements[14]);
// console.log(originPoint);
// rad *= ( endNorm.cross( startNorm ).dot( eye ) < 0 ? 1 : -1);
if(nowControlModel.name == "5"){
let v1 = new THREE.Vector3(-originPoint.x,5-originPoint.y,-originPoint.z);
let v2 = new THREE.Vector3(overPoint.z-originPoint.z,overPoint.y-originPoint.y,overPoint.x-originPoint.x);
let rad = v1.angleTo(v2);
console.log(rad);
if(rad>0.725 && rad<2.37){
nowControlModel.rotation.x = rad+Math.PI;
}
}else{
let v1 = new THREE.Vector3(-originPoint.x,5-originPoint.y,-originPoint.z);
let v2 = new THREE.Vector3(overPoint.x-originPoint.x,overPoint.y-originPoint.y,overPoint.z-originPoint.z);
let rad = v1.angleTo(v2);
console.log(rad);
if(rad>0.546 && rad<2.4){
if(rad>1.3){
TrainRescueStatic.animatemodel.action.timeScale = -1;
TrainRescueStatic.animatemodel.action.paused = false;
TrainRescueStatic.animatemodel.action.play();
}else if(rad<1.20){
TrainRescueStatic.animatemodel.action.timeScale = 1;
TrainRescueStatic.animatemodel.action.paused = false;
TrainRescueStatic.animatemodel.action.play();
}else{
TrainRescueStatic.animatemodel.action.paused = true;
rad = 1.25;
}
nowControlModel.rotation.y = rad-Math.PI/2.5;
}
}
}
}
this.resetmodel = function(){
scope.animastats = true;
};

View File

@ -27,6 +27,13 @@ var TrainRescueStatic = {
deviceType: "other",
type: "other",
url: "../../static/vrtest/trainrescue/TK.FBX"
},
handR: {
id: "5",
name: "handr",
deviceType: "handr",
type: "handr",
url: "../../static/vrtest/trainrescue/handr.FBX"
}
}

View File

@ -8,7 +8,7 @@ export function ModelManagerVR(){
initlist.push(fbxpromise(mixers,staticModel.controlmodel));
initlist.push(fbxpromise(mixers,staticModel.floorplane));
initlist.push(fbxpromise(mixers,staticModel.other));
initlist.push(fbxpromise(mixers,staticModel.handR));
return new Promise(function(resolve, reject){
@ -36,7 +36,7 @@ function fbxpromise(mixers,model){
model.action = mixer.clipAction( object.animations[ 0 ] );
model.action.setLoop(THREE.LoopOnce);
model.action.clampWhenFinished = true;
mixers.push(mixer);
mixers[model.deviceType] = mixer;
}

View File

@ -53,6 +53,8 @@
<el-button v-if="selectmodel.meshtype == 'section'" type="vexscal" @click="vexScalVertical">高度改变</el-button>
<el-button v-if="selectmodel.meshtype == 'section'" type="vexscal" @click="sectionFlat">区段平整</el-button>
<el-button v-if="selectmodel.meshtype == 'station'" @click="changeStationPos">自动对齐停车点</el-button>
<!-- <el-button v-if="selectmodel.meshtype == 'station'" type="vexscal" @click="vexScalVertical">高度改变</el-button> -->
@ -186,6 +188,9 @@ export default {
this.$emit('vexscal',"vertical");
},
sectionFlat(){
this.$emit('flat',this.selectmodel.code);
},
changeStationPos(){
this.$emit('changeStationPos',this.selectmodel);

View File

@ -8,7 +8,7 @@
<Edit-Action ref="action" @saction="saction" @actionevent="actionevent">
</Edit-Action>
<Edit-Property ref="property" :selectmodel='selectmodel' @alignment="alignment" @vexscal= "vexscal" @changeStationPos="changeStationPos">
<Edit-Property ref="property" :selectmodel='selectmodel' @alignment="alignment" @vexscal= "vexscal" @changeStationPos="changeStationPos" @flat="flat">
</Edit-Property>
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
@ -194,6 +194,9 @@
this.jlmap3dedit.alignmentSection(alignmentCode,direct);
},
flat(alignmentCode){
this.jlmap3dedit.flatSection(alignmentCode);
},
save() {
//console.log("save");
console.log(this.jlmap3dedit.assetManager);

View File

@ -26,7 +26,7 @@
@node-click="handleNodeClick"
>
<span :id="data.id" slot-scope="{ node, data }" class="custom-tree-node">
<span>{{ node.label }}</span>
<span>{{ data.labelName }}</span>
<span v-if="data.type">
<el-select :key="data.id" v-model="data.userId" placeholder="请选择" clearable size="mini" @change="nodeMemberChange($event, data)">
<el-option
@ -89,7 +89,7 @@ export default {
},
defaultProps: {
children: 'children',
label: 'label'
label: 'labelName'
},
simulationUserList: [],
stationList: [],
@ -99,19 +99,19 @@ export default {
doorList: [],
memberData: {},
treeData: [{
label: '行调',
labelName: '行调',
children: []
}, {
label: '车站值班员',
labelName: '车站值班员',
children: []
}, {
label: '司机',
labelName: '司机',
children: []
}, {
label: '通号',
labelName: '通号',
children: []
}, {
label: '车辆段',
labelName: '车辆段',
children: []
}]
};
@ -137,17 +137,12 @@ export default {
queryMember(val) {
this.$refs.tree.filter(val);
},
// '$store.state.socket.simulationRoleList':function(val) {
// if (val && val.length) {
// this.handlerMemberOnOff(val);
// }
// },
'$store.state.training.simulationUserList': function(val) {
this.simulationUserList = val;
},
'$store.state.training.memberList': function (val) {
if (val && val.length) {
this.memberData = JSON.parse(JSON.stringify(this.$store.state.training.memberData));
this.memberData = this.$store.state.training.memberData;
const dispatcherList = [];
const electricDispatcherList = [];
const depotDispatcherList = [];
@ -158,7 +153,7 @@ export default {
const device = this.$store.getters['map/getDeviceByCode'](item.deviceCode);
switch (item.type) {
case 'DISPATCHER':
this.memberData[item.id].label = '行调' + (item.name || '');
this.memberData[item.id].labelName = '行调' + (item.name || '');
dispatcherList.push(this.memberData[item.id]);
break;
case 'ELECTRIC_DISPATCHER':
@ -168,37 +163,37 @@ export default {
depotDispatcherList.push(this.memberData[item.id]);
break;
case 'STATION_SUPERVISOR':
this.memberData[item.id].label = '值班员-' + device.name;
this.memberData[item.id].labelName = '值班员-' + device.name;
stationSupervisorList.push(this.memberData[item.id]);
break;
case 'DRIVER':
this.memberData[item.id].label = '司机-列车' + item.deviceCode;
this.memberData[item.id].labelName = '司机-列车' + item.deviceCode;
driverList.push(this.memberData[item.id]);
break;
case 'MAINTAINER':
this.memberData[item.id].label = '通号' + (item.name || '');
this.memberData[item.id].labelName = '通号' + (item.name || '');
maintainerList.push(this.memberData[item.id]);
break;
}
});
this.treeData = [{
label: '行调',
labelName: '行调',
id: 'dispatcher',
children: dispatcherList
}, {
label: '车站值班员',
labelName: '车站值班员',
id: 'stationSupervisor',
children: stationSupervisorList
}, {
label: '司机',
labelName: '司机',
id: 'driver',
children: driverList
}, {
label: '通号',
labelName: '通号',
id: 'maintainer',
children: maintainerList
}, {
label: '车辆段',
labelName: '车辆段',
id: 'depotDispatcher',
children: depotDispatcherList
}];
@ -275,7 +270,7 @@ export default {
if (data.type && data.type === 'DRIVER' && !this.activeTrains.includes(data.deviceCode)) {
driverNoShow = false;
}
return (data.label.indexOf(value) !== -1 || flag) && driverNoShow;
return (data.labelName.indexOf(value) !== -1 || flag) && driverNoShow;
}
// handlerMemberOnOff(data) {
// this.$store.dispatch('training/updateMemberAndUser', { simulationUserList: data, userId: this.userId });

Binary file not shown.