Quellcode durchsuchen

3d页面无法行走的问题

57862207 vor 11 Monaten
Ursprung
Commit
beebfcc39f
3 geänderte Dateien mit 51 neuen und 39 gelöschten Zeilen
  1. 1 1
      src/store/modules/common/mutations.js
  2. 49 37
      src/uwb-sample.js
  3. 1 1
      src/views/ordinaryPage/index.vue

+ 1 - 1
src/store/modules/common/mutations.js

@@ -85,7 +85,7 @@ export default {
     state.isOpen3d = data;
   },
   toggle3dStatus(state) {
-    var element = document.getElementById('house-player').parentNode;
+    var element = document.getElementById('house-player');
     state.isOpen3d = !state.isOpen3d;
     
     if (state.isOpen3d) {

+ 49 - 37
src/uwb-sample.js

@@ -454,8 +454,25 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
         if (!sessionStorage.getItem('3dMode') || sessionStorage.getItem('3dMode') == 0) {
           window.sdkInstance.changeMode(finalMode);
           setTimeout(() => {
+            var element = document.getElementById('house-player');
             var container = document.getElementById("ordinary-map")
             container.style.opacity = 1;
+            let mapDom = document.getElementsByClassName("ordinary-map-container")[0];
+            let style = getComputedStyle(mapDom);
+            let width = parseFloat(style.width);
+            let height = parseFloat(style.height);
+
+            let ratio = 1.8;
+            window.renderWidth = width * ratio;
+            window.renderHeight = height * ratio;
+            window.sdkInstance.sceneRenderer.updateScreenSize(width * ratio, height * ratio);
+            element.style.marginLeft = ((width - (width * ratio)) / 2) + 'px';
+            element.style.marginTop = ((height - (height * ratio)) / 2) + 'px';
+            let playersmall = document.getElementById('playersmall')
+            playersmall.appendChild(element)
+            setTimeout(() => {
+              window.sdkInstance.changeMode('floorplan');
+            })
           }, 500)
         }
 
@@ -556,43 +573,38 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
             let bFirst = true;
             let bool = false;
             let bool1 = false;
-            // intersects.forEach(m => {
-            //   if (m.object.geometry.type != "PlaneBufferGeometry") {
-            //     if (m.object.userData && m.object.userData.benchFlag == true) {
-            //       if (!bool) {
-            //         bool = true;
-            //         //m.object.material = window.shader1;
-            //         ////m.object.scale.set(10, 10, 10)
-            //         //m.object.scale.set(5, 5, 5)
-            //         //outlineObj(m.object)
-            //         // let player = document.getElementById(domId)
-            //         // player.style.display = "none"
-
-            //         if (box) {
-            //           sdkInstance.sceneRenderer.scene.remove(box);
-            //         }
-            //         window.handleBenchClick(m.object.userData.benchId, m.object.userData.bShowRemoteButton)
-
-            //         box = new THREE.BoxHelper(m.object, '#ff0000');  //object 模型
-            //         sdkInstance.sceneRenderer.scene.add(box);
-
-            //         //let ambientLight = new THREE.AmbientLight(0xffffff); //设置环境光
-            //         //sdkInstance.sceneRenderer.scene.add(ambientLight); //将环境光添加到场景中
-            //         //let pointLight = new THREE.PointLight(0xffffff, 1, 0);
-            //         //pointLight.position.set(200, 200, 200); //设置点光源位置
-            //         //sdkInstance.sceneRenderer.scene.add(pointLight); //将点光源添加至场景
-            //       }
-            //       //outlineObj(m.object)
-
-            //       //m.object.material = FXAAShader
-            //     }
-
-            //   } else if (m.object.geometry.type == "PlaneBufferGeometry") {
-            //     if (m.object.userData && m.object.userData.benchFlag == true) {
-            //       window.handleListClick(m.object.userData.benchId)
-            //     }
-            //   }
-            // })
+            intersects.forEach(m => {
+               if (m.object.geometry.type != "PlaneBufferGeometry") {
+                 if (m.object.userData && m.object.userData.benchFlag == true) {
+                   if (!bool) {
+                     bool = true;
+                     //m.object.material = window.shader1;
+                     ////m.object.scale.set(10, 10, 10)
+                     //m.object.scale.set(5, 5, 5)
+                     //outlineObj(m.object)
+                     // let player = document.getElementById(domId)
+                     // player.style.display = "none
+                     if (box) {
+                       sdkInstance.sceneRenderer.scene.remove(box);
+                     }
+                     window.handleBenchClick(m.object.userData.benchId, m.object.userData.bShowRemoteButton)
+                     box = new THREE.BoxHelper(m.object, '#ff0000');  //object 模型
+                     sdkInstance.sceneRenderer.scene.add(box)
+                     //let ambientLight = new THREE.AmbientLight(0xffffff); //设置环境光
+                     //sdkInstance.sceneRenderer.scene.add(ambientLight); //将环境光添加到场景中
+                     //let pointLight = new THREE.PointLight(0xffffff, 1, 0);
+                     //pointLight.position.set(200, 200, 200); //设置点光源位置
+                     //sdkInstance.sceneRenderer.scene.add(pointLight); //将点光源添加至场景
+                   }
+                   //outlineObj(m.object
+                   //m.object.material = FXAAShader
+                 
+               } else if (m.object.geometry.type == "PlaneBufferGeometry") {
+                 if (m.object.userData && m.object.userData.benchFlag == true) {
+                   window.handleListClick(m.object.userData.benchId)
+                 }
+               }
+              }})
             bool = false;
             bool1 = false;
           }

+ 1 - 1
src/views/ordinaryPage/index.vue

@@ -820,7 +820,7 @@ export default {
     window.renderWidth = width * ratio;
     window.renderHeight = height * ratio;
     sessionStorage.setItem('3dMode', 0)
-    uwbMain('playersmall', width * ratio, height * ratio, "floorplan");
+    uwbMain('player', width * ratio, height * ratio, "floorplan");
     
     // window.sdkInstance.sceneRenderer.updateScreenSize(width * ratio, height * ratio);
     setTimeout(() => {