|
@@ -142,7 +142,7 @@
|
|
|
// let lineMesh = null;
|
|
|
let radius = 50; //全景图半径-全景图是个球体
|
|
|
let fingerCount = 0;
|
|
|
- let lastPosition = new THREE.Vector3(0, -10, -10);
|
|
|
+ let lastPosition = new THREE.Vector3(0, -20, -27.49);
|
|
|
let boundingBox = null;
|
|
|
init();
|
|
|
// this.clearEvent = clearEvent;
|
|
@@ -163,17 +163,6 @@
|
|
|
camera.position.set(that.cameraStarPosition.x, that.cameraStarPosition.y, that.cameraStarPosition.z);
|
|
|
scene.add(camera);
|
|
|
that.camera = camera;
|
|
|
-
|
|
|
- // 环境光会均匀的照亮场景中的所有物体
|
|
|
- // const ambientLight = new THREE.AmbientLight(0xFFEFE0, 3.5);
|
|
|
- // scene.add(ambientLight);
|
|
|
- // 辅助方格
|
|
|
- // const axesHelper = new THREE.AxesHelper( 50 );
|
|
|
- // scene.add( axesHelper );
|
|
|
- // const gridHelper = new THREE.GridHelper(50, 10, 0xcccccc, 0xcccccc);
|
|
|
- // gridHelper.position.y = 0;
|
|
|
- // gridHelper.position.x = 0;
|
|
|
- // scene.add(gridHelper);
|
|
|
|
|
|
//加载环境720贴图
|
|
|
// const loader = new THREE.TextureLoader();
|
|
@@ -481,27 +470,39 @@
|
|
|
});
|
|
|
// 设置拖拽控制器的监听器
|
|
|
dragControls.addEventListener('drag', function (event) {
|
|
|
+ // 获取mesh的位置
|
|
|
+ let position = event.object.position.clone();
|
|
|
+ // // 获取包围球的中心点和半径
|
|
|
+ let sphereCenter = new THREE.Vector3(0, 0, 0);//原点
|
|
|
+ let sphereRadius = radius - 16;
|
|
|
+ // 将mesh的位置限制在圆球范围内
|
|
|
+ position.sub(sphereCenter).normalize().multiplyScalar(sphereRadius).add(sphereCenter);
|
|
|
+ event.object.position.copy(position);
|
|
|
+ let distance = position.distanceTo(sphereCenter);
|
|
|
+ // console.warn("****position**",position,distance)
|
|
|
+ // let rad = radius - 16;
|
|
|
// // 将拖拽的点转换为球面坐标
|
|
|
// var vector = new THREE.Vector3(
|
|
|
- // (event.object.position.x / 10),
|
|
|
- // (event.object.position.y / 10),
|
|
|
- // (event.object.position.z / 10)
|
|
|
+ // (event.object.position.x / rad),
|
|
|
+ // (event.object.position.y / rad),
|
|
|
+ // (event.object.position.z / rad)
|
|
|
// ).normalize();
|
|
|
|
|
|
// // 更新物体的位置
|
|
|
// event.object.position.copy(vector.multiplyScalar(10));
|
|
|
//限制在只能在水平面上移动
|
|
|
- event.object.position.y = -10;
|
|
|
- let position = event.object.position;
|
|
|
- // 获取包围球的中心点和半径
|
|
|
- let sphereCenter = new THREE.Vector3(0, 0, 0);//原点
|
|
|
- // 计算mesh和圆球中心点之间的距离
|
|
|
- let distance = position.distanceTo(sphereCenter);
|
|
|
- // 判断是否超过包围球的半径-1的距离,是的话则限制
|
|
|
- if (distance > (radius-1)) {
|
|
|
- const direction = new THREE.Vector3().subVectors(position, sphereCenter).normalize();
|
|
|
- event.object.position.copy(sphereCenter).addScaledVector(direction, (radius-1));
|
|
|
- }
|
|
|
+ // event.object.position.y = -10;
|
|
|
+ //限制不能超过球体
|
|
|
+ // let position = event.object.position;
|
|
|
+ // // 获取包围球的中心点和半径
|
|
|
+ // let sphereCenter = new THREE.Vector3(0, 0, 0);//原点
|
|
|
+ // // 计算mesh和圆球中心点之间的距离
|
|
|
+ // let distance = position.distanceTo(sphereCenter);
|
|
|
+ // // 判断是否超过包围球的半径-1的距离,是的话则限制
|
|
|
+ // if (distance > (radius-1)) {
|
|
|
+ // const direction = new THREE.Vector3().subVectors(position, sphereCenter).normalize();
|
|
|
+ // event.object.position.copy(sphereCenter).addScaledVector(direction, (radius-1));
|
|
|
+ // }
|
|
|
});
|
|
|
dragControls.addEventListener('dragend', function ( event ) {
|
|
|
controls.enabled = true;
|
|
@@ -539,6 +540,9 @@
|
|
|
return false
|
|
|
}
|
|
|
let sca = (data - 50)/50 + 1;
|
|
|
+ if(sca >= 1){
|
|
|
+ sca = sca *2;
|
|
|
+ }
|
|
|
videoMesh.scale.x = sca
|
|
|
videoMesh.scale.y = sca
|
|
|
}
|