Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
7a37e5cf5e
@ -481,6 +481,73 @@ export function JLmap3dEdit(dom, data, mapid) {
|
|||||||
objectparent.add(newAlignmentSection);
|
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() {
|
function onWindowResize() {
|
||||||
//窗口自适应
|
//窗口自适应
|
||||||
scope.camera.aspect = window.innerWidth / window.innerHeight;
|
scope.camera.aspect = window.innerWidth / window.innerHeight;
|
||||||
|
@ -845,6 +845,7 @@ export function SectionList() {
|
|||||||
extrudePath : closedSpline,
|
extrudePath : closedSpline,
|
||||||
};
|
};
|
||||||
var shape = new THREE.Shape();
|
var shape = new THREE.Shape();
|
||||||
|
|
||||||
if(newsection.railpoint[0].y != newsection.railpoint[2].y){
|
if(newsection.railpoint[0].y != newsection.railpoint[2].y){
|
||||||
shape.moveTo( -2, 0 );
|
shape.moveTo( -2, 0 );
|
||||||
shape.lineTo( 2, 0 );
|
shape.lineTo( 2, 0 );
|
||||||
|
@ -50,7 +50,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
this.renderer.gammaOutput = true;
|
this.renderer.gammaOutput = true;
|
||||||
this.renderer.vr.enabled = true;
|
this.renderer.vr.enabled = true;
|
||||||
this.dom.appendChild(this.renderer.domElement);
|
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);
|
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 = scope.renderer.vr.getController( 0 );
|
||||||
controller1.addEventListener( 'selectstart', onSelectStart );
|
controller1.addEventListener( 'selectstart', onSelectStart );
|
||||||
controller1.addEventListener( 'selectend', onSelectEnd );
|
controller1.addEventListener( 'selectend', onSelectEnd );
|
||||||
controller1.addEventListener( 'squeeze', squeezeStart );
|
controller1.addEventListener( 'squeezestart', squeezeStart );
|
||||||
|
controller1.addEventListener( 'squeezeend', squeezeEnd );
|
||||||
human.add( controller1 );
|
human.add( controller1 );
|
||||||
|
|
||||||
controller2 = scope.renderer.vr.getController( 1 );
|
controller2 = scope.renderer.vr.getController( 1 );
|
||||||
controller2.addEventListener( 'selectstart', onControlModelStart );
|
controller2.addEventListener( 'selectstart', onControlModelStart );
|
||||||
controller2.addEventListener( 'selectend', onControlModelEnd );
|
controller2.addEventListener( 'selectend', onControlModelEnd );
|
||||||
@ -103,14 +103,21 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
this.modelmanager = new ModelManagerVR();
|
this.modelmanager = new ModelManagerVR();
|
||||||
this.modelmanager.loadpromise(TrainRescueStatic,mixers);
|
this.modelmanager.loadpromise(TrainRescueStatic,mixers);
|
||||||
|
|
||||||
|
|
||||||
let timer=setInterval(function(){
|
let timer=setInterval(function(){
|
||||||
if(TrainRescueStatic.floorplane.mesh){
|
if(TrainRescueStatic.other.mesh){
|
||||||
console.log(TrainRescueStatic);
|
console.log(TrainRescueStatic);
|
||||||
scope.scene.add(TrainRescueStatic.animatemodel.mesh);
|
scope.scene.add(TrainRescueStatic.animatemodel.mesh);
|
||||||
scope.scene.add(TrainRescueStatic.controlmodel.mesh);
|
scope.scene.add(TrainRescueStatic.controlmodel.mesh);
|
||||||
scope.scene.add(TrainRescueStatic.floorplane.mesh);
|
scope.scene.add(TrainRescueStatic.floorplane.mesh);
|
||||||
TrainRescueStatic.floorplane.mesh.position.y = -0.2;
|
TrainRescueStatic.floorplane.mesh.position.y = -0.2;
|
||||||
scope.scene.add(TrainRescueStatic.other.mesh);
|
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);
|
// floors.push(TrainRescueStatic.floorplane.mesh);
|
||||||
animate();
|
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();
|
// console.log();
|
||||||
var controller = event.target;
|
var controller = event.target;
|
||||||
var intersections = getIntersections( controller );
|
var intersections = getIntersections( controller );
|
||||||
console.log(intersections);
|
|
||||||
if ( intersections) {
|
if ( intersections) {
|
||||||
console.log(intersections);
|
|
||||||
var intersection = intersections[0];
|
var intersection = intersections[0];
|
||||||
human.position.set( intersection.point.x, intersection.point.y+0.6, intersection.point.z );
|
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;
|
// 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(){
|
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 ) {
|
function getIntersections( controller ) {
|
||||||
@ -216,7 +256,6 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
let rayObject = raycastervr.intersectObjects( TrainRescueStatic.floorplane.mesh.children);
|
let rayObject = raycastervr.intersectObjects( TrainRescueStatic.floorplane.mesh.children);
|
||||||
|
|
||||||
if(rayObject.length>0){
|
if(rayObject.length>0){
|
||||||
console.log(rayObject);
|
|
||||||
return rayObject;
|
return rayObject;
|
||||||
}
|
}
|
||||||
// for(let i=0;i<1;i++){
|
// for(let i=0;i<1;i++){
|
||||||
@ -277,23 +316,76 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) {
|
|||||||
|
|
||||||
scope.renderer.setAnimationLoop( render );
|
scope.renderer.setAnimationLoop( render );
|
||||||
}
|
}
|
||||||
|
let delta;
|
||||||
function render() {
|
function render() {
|
||||||
|
|
||||||
intersectObjects( controller1 );
|
intersectObjects( controller1 );
|
||||||
let delta = clock.getDelta();
|
|
||||||
if (mixers) {
|
if (mixers){
|
||||||
for (let i = 0; i < mixers.length; i++) {
|
for (let k in mixers) {
|
||||||
if (mixers[i]) {
|
delta = clock.getDelta();
|
||||||
mixers[i].update(delta);
|
mixers[k].update(delta);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// scope.controls.update();
|
// scope.controls.update();
|
||||||
|
updateControlModel();
|
||||||
scope.renderer.render(scope.scene, scope.camera);
|
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(){
|
this.resetmodel = function(){
|
||||||
scope.animastats = true;
|
scope.animastats = true;
|
||||||
};
|
};
|
||||||
|
@ -27,6 +27,13 @@ var TrainRescueStatic = {
|
|||||||
deviceType: "other",
|
deviceType: "other",
|
||||||
type: "other",
|
type: "other",
|
||||||
url: "../../static/vrtest/trainrescue/TK.FBX"
|
url: "../../static/vrtest/trainrescue/TK.FBX"
|
||||||
|
},
|
||||||
|
handR: {
|
||||||
|
id: "5",
|
||||||
|
name: "handr",
|
||||||
|
deviceType: "handr",
|
||||||
|
type: "handr",
|
||||||
|
url: "../../static/vrtest/trainrescue/handr.FBX"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ export function ModelManagerVR(){
|
|||||||
initlist.push(fbxpromise(mixers,staticModel.controlmodel));
|
initlist.push(fbxpromise(mixers,staticModel.controlmodel));
|
||||||
initlist.push(fbxpromise(mixers,staticModel.floorplane));
|
initlist.push(fbxpromise(mixers,staticModel.floorplane));
|
||||||
initlist.push(fbxpromise(mixers,staticModel.other));
|
initlist.push(fbxpromise(mixers,staticModel.other));
|
||||||
|
initlist.push(fbxpromise(mixers,staticModel.handR));
|
||||||
|
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ function fbxpromise(mixers,model){
|
|||||||
model.action = mixer.clipAction( object.animations[ 0 ] );
|
model.action = mixer.clipAction( object.animations[ 0 ] );
|
||||||
model.action.setLoop(THREE.LoopOnce);
|
model.action.setLoop(THREE.LoopOnce);
|
||||||
model.action.clampWhenFinished = true;
|
model.action.clampWhenFinished = true;
|
||||||
mixers.push(mixer);
|
mixers[model.deviceType] = mixer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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="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'" @click="changeStationPos">自动对齐停车点</el-button>
|
||||||
|
|
||||||
<!-- <el-button v-if="selectmodel.meshtype == 'station'" type="vexscal" @click="vexScalVertical">高度改变</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");
|
this.$emit('vexscal',"vertical");
|
||||||
},
|
},
|
||||||
|
sectionFlat(){
|
||||||
|
this.$emit('flat',this.selectmodel.code);
|
||||||
|
},
|
||||||
|
|
||||||
changeStationPos(){
|
changeStationPos(){
|
||||||
this.$emit('changeStationPos',this.selectmodel);
|
this.$emit('changeStationPos',this.selectmodel);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<Edit-Action ref="action" @saction="saction" @actionevent="actionevent">
|
<Edit-Action ref="action" @saction="saction" @actionevent="actionevent">
|
||||||
</Edit-Action>
|
</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-Property>
|
||||||
|
|
||||||
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
|
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
|
||||||
@ -194,6 +194,9 @@
|
|||||||
|
|
||||||
this.jlmap3dedit.alignmentSection(alignmentCode,direct);
|
this.jlmap3dedit.alignmentSection(alignmentCode,direct);
|
||||||
},
|
},
|
||||||
|
flat(alignmentCode){
|
||||||
|
this.jlmap3dedit.flatSection(alignmentCode);
|
||||||
|
},
|
||||||
save() {
|
save() {
|
||||||
//console.log("save");
|
//console.log("save");
|
||||||
console.log(this.jlmap3dedit.assetManager);
|
console.log(this.jlmap3dedit.assetManager);
|
||||||
|
BIN
static/vrtest/trainrescue/handr.FBX
Normal file
BIN
static/vrtest/trainrescue/handr.FBX
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user