xzw 4 hónapja
szülő
commit
e9b5a8f1bc
3 módosított fájl, 63 hozzáadás és 60 törlés
  1. 46 46
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 16 13
      src/sdk/cover/index.js

+ 46 - 46
public/lib/potree/potree.js

@@ -7427,7 +7427,7 @@
 	      } else if (info.quaternion) {
 	        endQuaternion = info.quaternion.clone();
 	      }
-	      if (endQuaternion && math.closeTo(Math.abs(this.direction.z), 1, 1e-4)) {
+	      if (this.rotMode != 'free' && endQuaternion && math.closeTo(Math.abs(this.direction.z), 1, 1e-4)) {
 	        //在垂直的视角下的quaternion刚开始突变的厉害,这时候可能渐变yaw比较好(如俯视时点击测量线)
 	        var a = this.clone();
 	        a.quaternion = endQuaternion;
@@ -22726,6 +22726,7 @@
 	};
 	Utils.tran4dkkVecInModel = (vec, model) => {
 	  //将四维看看里的坐标转换成在此平台模型上的坐标(主要是3dtiles需要平移) 见load4dkkpanos
+	  //if(model.fileType != '3dTiles') return Potree.math.convertVector.YupToZup(vec)
 	  return Potree.math.convertVector.YupToZup(vec).applyMatrix4(model.posRot1MatrixInvert); //若要全局坐标,可以直接像pano那样转换,多乘个matrix
 	};
 	BinaryLoader.prototype.load = function (node, callback) {
@@ -62281,6 +62282,8 @@
 	  quat2 = new Quaternion();
 	var cameraModel, loadingCamModel;
 
+	//测试场景:  http://192.168.0.25/mix3d/#/home/671  潘少  Aa123456  http://192.168.0.25/epg.html?m=YZL-jm-lrZcWxzPaPJ#/tag
+
 	//接收4dkk的监控 暂不支持修改   可以直接加到模型上,注意所附模型旋转90度后角度才对。
 	class Monitor extends Object3D {
 	  constructor(data, model) {
@@ -62317,7 +62320,7 @@
 	      } else {
 	        this.addEventListener('loadedmetadata', canPlayed);
 	      }
-	      if (Hls.isSupported() && data.videoType !== 2) {
+	      if (Hls.isSupported() && data.urlType == 1) {
 	        //似乎Hls不支持就无法播放
 	        var hls = new Hls();
 	        hls.loadSource(data.video);
@@ -62340,18 +62343,6 @@
 	      depthTest: false
 	    });
 
-	    /* this.normalMat = new DepthBasicMaterial({ --- 需要像测量线那样渲染
-	        color: new THREE.Color(0x00c8af),
-	        transparent: true,
-	        opacity: 0.1,
-	        side: THREE.DoubleSide,
-	        useDepth:true,
-	        clipDistance : 5,//消失距离    
-	        occlusionDistance: 1,//变为backColor距离 
-	        maxOcclusionFactor:0.9,
-	        maxClipFactor:1
-	    }) */
-
 	    // 监控视频材质
 	    this.videoMat = new BasicMaterial({
 	      map: new VideoTexture(this.video),
@@ -62370,7 +62361,7 @@
 	        }, model => {
 	          cameraModel = model.children[0].children[0];
 	          cameraModel.geometry.translate(30, 50, -10);
-	          cameraModel.quaternion.setFromEuler(new Euler(Math.PI / 2, Math.PI, 0));
+	          cameraModel.quaternion.setFromEuler(new Euler(Math.PI / 2 + 0.24, Math.PI, 0));
 	          cameraModel.name = 'cameraModel';
 	          console.log('load monitor glb', cameraModel.uuid);
 	          model.parent.remove(model);
@@ -62382,8 +62373,9 @@
 	      this.modelLoaded();
 	    }
 	    this.updateAspect();
-	    {
+	    if (data.showTitle) {
 	      var group = new Shim.FollowRootObject(this); //透明有问题,只有放到overlayScene里渲染了
+
 	      this.titleLabel = new TextSprite$2({
 	        text: data.name,
 	        backgroundColor: {
@@ -62418,6 +62410,7 @@
 	      group.name = 'monitorLabel';
 	    }
 	    {
+	      var _model$props$baseRota;
 	      this.posOri = new Vector3(parseFloat(data.data['posOri-x']), parseFloat(data.data['posOri-y']), parseFloat(data.data['posOri-z'])), this.posOffset = new Vector3(parseFloat(data.data['posOffset-x']), parseFloat(data.data['posOffset-y']), parseFloat(data.data['posOffset-z'])),
 	      // data.position && this.position.copy(data.position)
 	      this.position.copy(this.posOri).add(this.posOffset);
@@ -62435,6 +62428,10 @@
 	      data.data.pitch && (this.pitch = data.data.pitch);
 	      data.data.yaw && (this.yaw = data.data.yaw);
 	      data.data.roll && this.setRoll(this.data.data.roll);
+	      if (((_model$props$baseRota = model.props.baseRotation) === null || _model$props$baseRota === void 0 ? void 0 : _model$props$baseRota.x) == 0) {
+	        //该模型已经矫正,无需旋转90度,但是场景的数据需要,导致monitor和模型不匹配,需要再旋转
+	        this.quaternion.copy(Potree.math.convertQuaternion.YupToZup(this.quaternion));
+	      }
 	    }
 
 	    //this.updateInfo(true)
@@ -62460,11 +62457,11 @@
 	  }
 	  getVideoSrc() {
 	    if (this.data.urlType === 2) {
-	      var a = this.parent.props.raw.surveillancePath.split('/');
+	      var a = this.parent.props.raw.surveillancePath.split('/'); //用户上传的文件
 	      a.pop();
-	      return a.join('/') + '/' + data.fileName;
+	      return a.join('/') + '/' + this.data.fileName;
 	    } else {
-	      return data.playUrl;
+	      return this.data.playUrl;
 	    }
 	  }
 	  modelLoaded() {
@@ -62533,7 +62530,6 @@
 	      position: this.oldState.position,
 	      quaternion: this.oldState.quaternion,
 	      onUpdate: percent => {
-	        console.log(viewer.mainViewport.view.quaternion.toArray());
 	        camera.fov = this.fov * (1 - percent) + this.oldState.fov * percent;
 	        camera.updateProjectionMatrix();
 	      },
@@ -62599,6 +62595,7 @@
 	    this.video.pause();
 	  }
 	  dispose() {
+	    var _this$titleLabel;
 	    var index = viewer.scene.monitors.indexOf(this);
 	    if (index == -1) return;
 	    viewer.scene.monitors.splice(index, 1);
@@ -62613,7 +62610,7 @@
 	    viewer.removeModel(this);
 	    this.normalMat.dispose();
 	    this.videoMat.dispose();
-	    this.titleLabel.dispose();
+	    (_this$titleLabel = this.titleLabel) === null || _this$titleLabel === void 0 || _this$titleLabel.dispose();
 	    this.hlsVideoPlayer && this.hlsVideoPlayer.destroy();
 	  }
 	  highlight(state) {
@@ -62696,21 +62693,17 @@
 	      this.cylinder.line.geometry = new EdgesGeometry(this.cylinder.geometry);
 	    }
 	  }
+	  set pitch(pitch) {
+	    pitch = Math.min(Math.max(pitch, -89.9), 89.9); // 防止万向锁
 
-	  // 横滚角
-	  setRoll(angle) {
-	    this.roll = angle % 360;
-	    this.obj3d.quaternion.setFromAxisAngle(vec1.set /* (0,1,0) */(0, 0, -1), MathUtils.degToRad(angle));
-	  }
-	  get yaw() {
-	    // 左右转角
-	    var lookAt = vec1.copy(this.cylinder.bottom.position).applyQuaternion(this.quaternion);
-	    var lookAtXZ = lookAt.setY(0);
-	    var frontDir = vec2.set(0, 0, 1);
-	    var frontCross = vec3.set(1, 0, 0);
-	    var angle = (MathUtils.radToDeg(lookAtXZ.angleTo(frontDir) * Math.sign(lookAtXZ.dot(frontCross))) + 180) % 360;
-	    if (angle > 180) angle = angle - 360;
-	    return angle;
+	    var yaw = this.yaw < 0 ? this.yaw + 360 : this.yaw;
+	    var upDir = vec1.set(0, 1, 0);
+	    var rightDir = vec2.set(1, 0, 0); //.applyQuaternion(this.quaternion)
+	    var yawQuat = quat1.setFromAxisAngle(upDir, MathUtils.degToRad(yaw));
+	    var pitchQuat = quat2.setFromAxisAngle(rightDir, MathUtils.degToRad(pitch));
+	    this.quaternion.multiplyQuaternions(yawQuat, pitchQuat);
+
+	    //this.updateTarget()
 	  }
 	  set yaw(yaw) {
 	    var pitch = this.pitch; // 要先计算pitch,防止窜数据
@@ -62722,25 +62715,32 @@
 
 	    //this.updateTarget()
 	  }
+
+	  // 横滚角
+	  setRoll(angle) {
+	    //因加在子物体上,非0时播放视频是歪的(4dkk也这样)
+	    this.roll = angle % 360;
+	    this.obj3d.quaternion.setFromAxisAngle(vec1.set(0, 0, -1), MathUtils.degToRad(angle));
+	  }
 	  get pitch() {
 	    // 上下转角
+	    return this.data.data.pitch; //xzw改
 	    var lookAt = vec1.copy(this.cylinder.bottom.position).applyQuaternion(this.quaternion);
 	    var projectVec = vec2.copy(lookAt).projectOnPlane(vec3.set(0, 1, 0));
 	    var pitch = MathUtils.radToDeg(lookAt.angleTo(projectVec) * Math.sign(lookAt.y)) % 180;
 	    if (pitch > 90) pitch = 90 - pitch;
 	    return pitch;
 	  }
-	  set pitch(pitch) {
-	    pitch = Math.min(Math.max(pitch, -89.9), 89.9); // 防止万向锁
-
-	    var yaw = this.yaw < 0 ? this.yaw + 360 : this.yaw;
-	    var upDir = vec1.set(0, 1, 0);
-	    var rightDir = vec2.set(1, 0, 0); //.applyQuaternion(this.quaternion)
-	    var yawQuat = quat1.setFromAxisAngle(upDir, MathUtils.degToRad(yaw));
-	    var pitchQuat = quat2.setFromAxisAngle(rightDir, MathUtils.degToRad(pitch));
-	    this.quaternion.multiplyQuaternions(yawQuat, pitchQuat);
-
-	    //this.updateTarget()
+	  get yaw() {
+	    // 左右转角  
+	    return this.data.data.yaw; //xzw改  原先的计算不对,0变180
+	    var lookAt = vec1.copy(this.cylinder.bottom.position).applyQuaternion(this.quaternion);
+	    var lookAtXZ = lookAt.setY(0);
+	    var frontDir = vec2.set(0, 0, 1);
+	    var frontCross = vec3.set(1, 0, 0);
+	    var angle = (MathUtils.radToDeg(lookAtXZ.angleTo(frontDir) * Math.sign(lookAtXZ.dot(frontCross))) + 180) % 360;
+	    if (angle > 180) angle = angle - 360;
+	    return angle;
 	  }
 	}
 	function warnHls() {

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
public/lib/potree/potree.js.map


+ 16 - 13
src/sdk/cover/index.js

@@ -951,6 +951,8 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
             //if (props.type == 'obj') props.type = 'glb'
             props.scale && (props.scale /= 100)
             
+            
+             
             let getBaseRotation = () => {
                 if(ModelTypes[props.fromType]?.rot90 && props.type != 'obj'){
                     return new THREE.Euler(Math.PI / 2, 0, 0)
@@ -2571,8 +2573,20 @@ function load4dkkMedias(model){//加载四维看看的一些媒体物品
      
     if(sceneJsonPath){//box图片视频 
         Potree.loadFile(sceneJsonPath+ '?m='+Date.now(),null,(json)=>{
-            console.log(model,  'sceneJson', json)
-            //json.surveillances //监控开关? 'video'
+            //console.log(model.name,  'sceneJson', json,  json.surveillances)
+          
+            if(json.surveillances){//监控 
+                Potree.loadFile(surveillancePath + '?m='+Date.now(),null,(monitorJson)=>{ 
+                    //console.log(model.name, 'surveillance', monitorJson)
+                    monitorJson.forEach((e)=>{ 
+                        e.showTitle = json.controls.showCameraTitle
+                        viewer.addMonitor(e,model)
+                    })  
+                }) 
+            }
+    
+            
+            
             if(json.boxPhotos || json.boxVideos){
                  
                 let boxPhotos = json.boxPhotos ? JSON.parse(json.boxPhotos) : []
@@ -2599,17 +2613,6 @@ function load4dkkMedias(model){//加载四维看看的一些媒体物品
         })
         
     }
-    if(surveillancePath){//监控 
-        Potree.loadFile(surveillancePath + '?m='+Date.now(),null,(json)=>{
-            
-            console.log(model,  'surveillance', json)
-            json.forEach((e)=>{
-                viewer.addMonitor(e,model)
-            }) 
-            
-        })
-        
-    }