rt-sim-training-client/src/jlmap3d/edit/action/trainaction.js
2019-07-26 13:32:43 +08:00

69 lines
1.4 KiB
JavaScript

//列车对象操作
export function Trainaction(){
let scope = this;
//开关
this.on = true;
//修改名称
this.setname = function(){
if(scope.on == true){
}
}
//改变类型
this.settype = function(){
if(scope.on == true){
}
}
//改变坐标
this.setpos = function(){
if(scope.on == true){
}
}
//改变角度
this.setrota = function(){
if(scope.on == true){
}
}
//改变拉伸值
this.setscl = function(){
if(scope.on == true){
}
}
//点击事件
this.raycaster = function(data){
if(scope.on == true){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera( mouse, data.camera );
let intersects1;
for(let i=0;i<data.mapdata.trainlisttest.list.length;i++){
intersects1 = raycaster.intersectObjects( data.mapdata.trainlisttest.list[i].children);
if(intersects1[0]){
if(intersects1[0].object.name == data.mapdata.trainlisttest.list[i].name){
//console.log(intersects1[0].object.name);
console.log(data.mapdata.trainlisttest.list[i]);
return data.mapdata.trainlisttest.list[i];
}
}
}
return null;
}
}
}