|
@@ -143,6 +143,7 @@
|
|
|
let radius = 50; //全景图半径-全景图是个球体
|
|
|
let fingerCount = 0;
|
|
|
let lastPosition = new THREE.Vector3(0, -10, -10);
|
|
|
+ let boundingBox = null;
|
|
|
init();
|
|
|
// this.clearEvent = clearEvent;
|
|
|
// this.attendEvent = attendEvent;
|
|
@@ -150,6 +151,7 @@
|
|
|
this.stopRender = stopRender; //对外暴露停止渲染的方法
|
|
|
this.videoHandle = videoHandle; //视频处理方法
|
|
|
this.getVideoPosition = getVideoPosition; //获取视频位置信息
|
|
|
+ this.getVideoScale = getVideoScale; //获取视频缩放数据
|
|
|
this.videoMeshChange = videoMeshChange; //数字人缩放方法
|
|
|
if(window.__wxjs_environment === 'miniprogram'){
|
|
|
this.navbar.showCapsule = 0;
|
|
@@ -204,8 +206,11 @@
|
|
|
var sphereGeometry = new THREE.SphereGeometry(radius, 60, 40);
|
|
|
var sphereMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 });
|
|
|
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
|
|
|
+ sphere.position.set(0,0,0);
|
|
|
+ sphere.geometry.computeBoundingBox();
|
|
|
+
|
|
|
// 计算球体的包围盒
|
|
|
- var boundingBox = new THREE.Box3().setFromObject(sphere);
|
|
|
+ boundingBox = new THREE.Box3().copy(sphere.geometry.boundingBox).applyMatrix4( sphere.matrixWorld);
|
|
|
// 监听相机移动事件-限制只能在当前空间范围内移动
|
|
|
controls.addEventListener('change', () => {
|
|
|
// 检查相机位置是否超出边界框
|
|
@@ -482,6 +487,16 @@
|
|
|
// 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));
|
|
|
+ }
|
|
|
});
|
|
|
dragControls.addEventListener('dragend', function ( event ) {
|
|
|
controls.enabled = true;
|
|
@@ -507,6 +522,13 @@
|
|
|
let _position = JSON.stringify(videoMesh.position);
|
|
|
return _position;
|
|
|
}
|
|
|
+ function getVideoScale() {
|
|
|
+ if(!videoMesh){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ let scale = JSON.stringify(videoMesh.scale);
|
|
|
+ return scale;
|
|
|
+ }
|
|
|
function videoMeshChange(data = 50) {
|
|
|
if(!videoMesh){
|
|
|
return false
|