xzw 2 年 前
コミット
4675d1084c

+ 1 - 1
src/custom/objects/tool/Compass.js

@@ -109,7 +109,7 @@ class Compass extends THREE.EventDispatcher{
         this.createCompass()
         this.createCompass()
           
           
         viewer.addEventListener('camera_changed', e => {
         viewer.addEventListener('camera_changed', e => {
-            if (e.viewport == this.viewport && (e.changeInfo.positionChanged || e.changeInfo.quaternionChanged)) {
+            if (e.viewport == this.viewport && (/* e.changeInfo.positionChanged ||  */e.changeInfo.quaternionChanged)) {
                  this.update()
                  this.update()
             } 
             } 
         })
         })

+ 1 - 3
src/custom/viewer/ViewerNew.js

@@ -693,9 +693,7 @@ export class Viewer extends ViewerBase{
             
             
             
             
         } 
         } 
-        
-        
-         
+          
 	}
 	}
     
     
     
     

+ 2 - 1
src/custom/viewer/Viewport.js

@@ -61,6 +61,7 @@ export default class Viewport extends THREE.EventDispatcher{
                 quaternion: this.camera.quaternion.clone(),
                 quaternion: this.camera.quaternion.clone(),
                 active:this.active,
                 active:this.active,
                 resolution:this.resolution.clone(),
                 resolution:this.resolution.clone(),
+                resolution2:this.resolution2.clone(), //有时clientWidth没变但是ratio缩放了
             }; 
             }; 
         }
         }
         let projectionChanged = true, positionChanged = true, quaternionChanged = true, activeChanged = true, resolutionChanged = true
         let projectionChanged = true, positionChanged = true, quaternionChanged = true, activeChanged = true, resolutionChanged = true
@@ -75,7 +76,7 @@ export default class Viewport extends THREE.EventDispatcher{
             positionChanged = !this.camera.position.equals(this.previousState.position)  
             positionChanged = !this.camera.position.equals(this.previousState.position)  
             quaternionChanged = !this.camera.quaternion.equals(this.previousState.quaternion) 
             quaternionChanged = !this.camera.quaternion.equals(this.previousState.quaternion) 
             activeChanged = this.active != this.previousState.active
             activeChanged = this.active != this.previousState.active
-            resolutionChanged = !this.resolution.equals(this.previousState.resolution)
+            resolutionChanged = !this.resolution.equals(this.previousState.resolution) || !this.resolution2.equals(this.previousState.resolution2)
         }   
         }   
         copy() 
         copy() 
         
         

+ 12 - 12
src/custom/viewer/viewerBase.js

@@ -124,14 +124,15 @@ export class ViewerBase extends THREE.EventDispatcher{
 
 
             w = this.renderArea.clientWidth;
             w = this.renderArea.clientWidth;
             h = this.renderArea.clientHeight
             h = this.renderArea.clientHeight
-             
+            
+            
             if(w !== this.screenSizeInfo.W || h !== this.screenSizeInfo.H || o.forceUpdateSize || this.screenSizeInfo.pixelRatio != window.devicePixelRatio){
             if(w !== this.screenSizeInfo.W || h !== this.screenSizeInfo.H || o.forceUpdateSize || this.screenSizeInfo.pixelRatio != window.devicePixelRatio){
                 this.screenSizeInfo.W = w 
                 this.screenSizeInfo.W = w 
                 this.screenSizeInfo.H = h 
                 this.screenSizeInfo.H = h 
                 render = true 
                 render = true 
                 this.screenSizeInfo.pixelRatio = window.devicePixelRatio  //如果player放在小窗口了,也要监测devicePixelRatio,因为缩放时client宽高不会改变
                 this.screenSizeInfo.pixelRatio = window.devicePixelRatio  //如果player放在小窗口了,也要监测devicePixelRatio,因为缩放时client宽高不会改变
                 //config.isMobile ? (ratio = Math.min(window.devicePixelRatio, 2)) : (ratio = window.devicePixelRatio)
                 //config.isMobile ? (ratio = Math.min(window.devicePixelRatio, 2)) : (ratio = window.devicePixelRatio)
-                ratio = window.devicePixelRatio
+                ratio = window.devicePixelRatio 
             }     
             }     
         }
         }
         if (render) { 
         if (render) { 
@@ -189,19 +190,18 @@ export class ViewerBase extends THREE.EventDispatcher{
         }
         }
         
         
         
         
-        if(!onlyForTarget){//因为onlyForTarget不传递devicePixelRatio所以不发送了
+        /* if(!onlyForTarget){//因为onlyForTarget不传递devicePixelRatio所以不发送了
             this.emitResizeMsg({viewport:this.viewports[0],  deviceRatio:devicePixelRatio})
             this.emitResizeMsg({viewport:this.viewports[0],  deviceRatio:devicePixelRatio})
-        }
+        } */
          
          
     } 
     } 
     
     
     emitResizeMsg(e){//切换viewport渲染时就发送一次, 通知一些材质更新resolution。  
     emitResizeMsg(e){//切换viewport渲染时就发送一次, 通知一些材质更新resolution。  
-        if(!e.viewport.resolution.equals(this.oldResolution)){ 
-            this.dispatchEvent($.extend(e, {type:'resize'})) 
-            this.oldResolution.copy(e.viewport.resolution)
-        }
-        
-        
+        //if(!e.viewport.resolution.equals(this.oldResolution)||!e.viewport.resolution2.equals(this.oldResolution2)){ 
+        this.dispatchEvent($.extend(e, {type:'resize'})) 
+        /* this.oldResolution.copy(e.viewport.resolution)
+        this.oldResolution2.copy(e.viewport.resolution2) */
+        //} 
     }
     }
     
     
     
     
@@ -229,9 +229,9 @@ export class ViewerBase extends THREE.EventDispatcher{
                     //this.changeTime = (this.changeTime || 0) +1
                     //this.changeTime = (this.changeTime || 0) +1
                 //}
                 //}
                 viewport.needRender = true  //直接写这咯  
                 viewport.needRender = true  //直接写这咯  
-                if(viewport.resolutionChanged){
+                if(changeInfo.resolutionChanged){
                     this.emitResizeMsg({viewport})
                     this.emitResizeMsg({viewport})
-                }
+                } 
                   
                   
             }                
             }                
         }
         }

+ 48 - 79
src/viewer/NavigationCube.js

@@ -61,27 +61,13 @@ class base{
         l
         l
     }
     }
      
      
-    createWireframe(e, lineWidth) {
-        /* for (var t = new THREE.LineGeometry, i = [], n = 0; n < e.length; n++) {
-            var o = e[n];
-            i.push(o.x, o.y, o.z)
-        }
-        t.setPositions(i);
-        var s = new THREE.LineMaterial({
-            color: this.wireframeDefaultColor,
-            linewidth: 1
-        });
-        s.resolution.set(160, 160);
-        var r = new THREE.Line2(t,s);
-        return r.componentId = this.componentId,
-        r */
-        
+    createWireframe(e ) { 
         let line = LineDraw.createFatLine(e,{
         let line = LineDraw.createFatLine(e,{
 	        color: Colors.gray , 
 	        color: Colors.gray , 
-			lineWidth ,
+			lineWidth : 2,
             viewer:   navCubeViewer,
             viewer:   navCubeViewer,
             depthTest:true, depthWrite:true,
             depthTest:true, depthWrite:true,
-            //transparent:true
+             transparent:true
 	    });
 	    });
         line.renderOrder = 3;
         line.renderOrder = 3;
         return line
         return line
@@ -114,7 +100,7 @@ class base{
 
 
 
 
 
 
-
+/* 
 
 
 class Edge extends base{
 class Edge extends base{
     constructor(t, i, n) {
     constructor(t, i, n) {
@@ -206,7 +192,7 @@ class Edge extends base{
     }
     }
     
     
 } 
 } 
-
+ */
 
 
 
 
 
 
@@ -248,12 +234,12 @@ class Corner extends base{
         e.push(a),
         e.push(a),
         this.cornerVertices = e 
         this.cornerVertices = e 
         this.mesh = this.createMesh([n, s, a]) 
         this.mesh = this.createMesh([n, s, a]) 
-         this.wireframeMesh = this.createWireframe([n, s, a, n], 2),
+        /*  this.wireframeMesh = this.createWireframe([n, s, a, n], 2),
         this.buildCornerFace() 
         this.buildCornerFace() 
-         this.buildCornerWireframe()
+         this.buildCornerWireframe() */
     }
     }
     
     
-    highlight() {
+    /* highlight() {
         this.wireframeMesh.material.color.setHex(this.wireframeHighlightColor),
         this.wireframeMesh.material.color.setHex(this.wireframeHighlightColor),
         this.wireframeMesh.renderOrder = 100,
         this.wireframeMesh.renderOrder = 100,
         this.mesh.material.color.setHex(this.faceHighlightColor),
         this.mesh.material.color.setHex(this.faceHighlightColor),
@@ -270,13 +256,13 @@ class Corner extends base{
         this.mesh.material.color.setHex(this.faceDefaultColor),
         this.mesh.material.color.setHex(this.faceDefaultColor),
         this.transparent(this.cornerFace),
         this.transparent(this.cornerFace),
         this.cornerWireframe.visible = !1
         this.cornerWireframe.visible = !1
-    }
+    } 
   
   
     buildCornerFace() {
     buildCornerFace() {
         if (!this.cornerFace) {
         if (!this.cornerFace) {
             var e = this.cornerVertices;
             var e = this.cornerVertices;
-            e.push(e[1]),
-            this.cornerFace = this.createMesh(e),
+            e.push(e[1]) 
+            this.cornerFace = this.createMesh(e) 
             this.transparent(this.cornerFace)
             this.transparent(this.cornerFace)
         }
         }
     }
     }
@@ -300,7 +286,7 @@ class Corner extends base{
             this.cornerWireframe.visible = !1
             this.cornerWireframe.visible = !1
         }
         }
     }
     }
-    
+    */
     
     
 } 
 } 
 
 
@@ -354,16 +340,16 @@ class Face extends base{
         }
         }
         for (var u = h.getCenter(new THREE.Vector3).normalize(), g = [], p = 0; p < e.length; p++) {
         for (var u = h.getCenter(new THREE.Vector3).normalize(), g = [], p = 0; p < e.length; p++) {
             var m = e[p];
             var m = e[p];
-            g.push(m.clone().add(u))
+            g.push(m.clone()/* .add(u) */)
         }
         }
-        this.highlightMesh = this.createMesh(g) 
+        /*  this.highlightMesh = this.createMesh(g) 
         this.highlightMesh.visible = !1 
         this.highlightMesh.visible = !1 
-        this.highlightMesh.isHighlightMesh = !0 
+        this.highlightMesh.isHighlightMesh = !0  */  
         g.push(g[0]) 
         g.push(g[0]) 
-        this.wireframeMesh = this.createWireframe(g, 1)
+        this.wireframeMesh = this.createWireframe(g, 1)  
     }
     }
      
      
-    highlight() {
+    /* highlight() {
         this.highlightMesh.visible = !0 
         this.highlightMesh.visible = !0 
         this.highlightMesh.material.color.setHex(this.faceHighlightColor) 
         this.highlightMesh.material.color.setHex(this.faceHighlightColor) 
         this.highlightMesh.material.transparent = !0 
         this.highlightMesh.material.transparent = !0 
@@ -374,7 +360,7 @@ class Face extends base{
     cancelHighlight() {
     cancelHighlight() {
         this.highlightMesh.visible = !1 
         this.highlightMesh.visible = !1 
         //this.wireframeMesh.material.color.setHex(this.wireframeDefaultColor)
         //this.wireframeMesh.material.color.setHex(this.wireframeDefaultColor)
-    }
+    } */
      
      
     createTexturedMesh(e) {
     createTexturedMesh(e) {
         for (var t = e.length - 2, i = new Uint32Array(3 * t), n = 0, o = 1; o <= t; o++)
         for (var t = e.length - 2, i = new Uint32Array(3 * t), n = 0, o = 1; o <= t; o++)
@@ -434,7 +420,7 @@ class Face extends base{
         this.mesh.componentId = this.componentId
         this.mesh.componentId = this.componentId
     }
     }
     
     
-    getHighlightMesh() {
+    /* getHighlightMesh() {
         return this.highlightMesh
         return this.highlightMesh
     }
     }
      
      
@@ -453,7 +439,7 @@ class Face extends base{
             t.push(c)
             t.push(c)
         }
         }
         return t
         return t
-    }
+    } */
      
      
 } 
 } 
 
 
@@ -485,7 +471,7 @@ class NavigationCube{
             "5764": "Back",
             "5764": "Back",
             "1375": "Right",
             "1375": "Right",
             "4620": "Left",
             "4620": "Left",
-            3: "RoofSouthEast",
+            /* 3: "RoofSouthEast",
             2: "RoofSouthWest",
             2: "RoofSouthWest",
             7: "RoofNorthEast",
             7: "RoofNorthEast",
             6: "RoofNorthWest",
             6: "RoofNorthWest",
@@ -504,7 +490,7 @@ class NavigationCube{
             13: "SouthEast",
             13: "SouthEast",
             20: "SouthWest",
             20: "SouthWest",
             57: "NorthEast",
             57: "NorthEast",
-            64: "NorthWest"
+            64: "NorthWest" */
         }  
         }  
         this.vertices = [],
         this.vertices = [],
         this.vertexIds = [],
         this.vertexIds = [],
@@ -527,13 +513,13 @@ class NavigationCube{
         for (var t = 0; t < 8; t++)
         for (var t = 0; t < 8; t++)
             this.vertexIds.push(t + ""); 
             this.vertexIds.push(t + ""); 
         //12条边
         //12条边
-        this.edgeIndices.push([0, 1], [1, 3], [3, 2], [2, 0]),
+        /* this.edgeIndices.push([0, 1], [1, 3], [3, 2], [2, 0]),
         this.edgeIndices.push([0, 4], [1, 5], [2, 6], [3, 7]),
         this.edgeIndices.push([0, 4], [1, 5], [2, 6], [3, 7]),
         this.edgeIndices.push([4, 5], [5, 7], [7, 6], [6, 4]);
         this.edgeIndices.push([4, 5], [5, 7], [7, 6], [6, 4]);
         for (t = 0; t < 12; t++) {
         for (t = 0; t < 12; t++) {
             var i = this.edgeIndices[t];
             var i = this.edgeIndices[t];
             this.edgeIds.push(i[0] + "" + i[1])
             this.edgeIds.push(i[0] + "" + i[1])
-        }
+        } */
         
         
         //6个面,每个面2个三角形
         //6个面,每个面2个三角形
         this.faceIndices.push([0, 2, 3, 1]),
         this.faceIndices.push([0, 2, 3, 1]),
@@ -572,11 +558,11 @@ class NavigationCube{
               , r = new THREE.TextureLoader;
               , r = new THREE.TextureLoader;
             r.setCrossOrigin("anonymous"); 
             r.setCrossOrigin("anonymous"); 
             r.load(url, (tex)=> {
             r.load(url, (tex)=> {
-                var face = new Face(e,t[n], this.faceIds[n], tex);
+                var face = new Face(e,t[n], this.faceIds[n], tex); 
                 this.componentList.push(face) 
                 this.componentList.push(face) 
-                let faceMesh = face.getMesh()
+                let faceMesh = face.getMesh() 
                 this.scene.add(faceMesh) 
                 this.scene.add(faceMesh) 
-                this.scene.add(face.getWireframe()) 
+                this.scene.add(face.getWireframe()) //每个面是八边形
                 /* this.scene.add(face.getHighlightMesh())  */
                 /* this.scene.add(face.getHighlightMesh())  */
                 //6 == ++texturesLoaded && a.callback && a.callback()
                 //6 == ++texturesLoaded && a.callback && a.callback()
                 
                 
@@ -613,31 +599,34 @@ class NavigationCube{
            create(s)
            create(s)
         }
         }
     }
     }
-      
+    
+    
+    
+    buildCorners() {
+        for (var e = this.vertices, t = this.vertexIds, i = 0; i < 8; i++) {
+            var n = new Corner(e[i],t[i]);
+            this.componentList.push(n) 
+            this.scene.add(n.getMesh()) //8个三角形 
+            //this.scene.add(n.getWireframe()) 
+            //this.scene.add(n.getCornerFace()) 
+            //this.scene.add(n.getCornerWireframe())
+        }
+    } 
 
 
 
 
 
 
 
 
-    buildEdges() {
+    /* buildEdges() {
         for (var e = this.vertices, t = this.edgeIndices, i = this.edgeIds, n = 0; n < 12; n++) {
         for (var e = this.vertices, t = this.edgeIndices, i = this.edgeIds, n = 0; n < 12; n++) {
             var o = new Edge(e,t[n],i[n]);
             var o = new Edge(e,t[n],i[n]);
-            this.componentList.push(o),
-            this.scene.add(o.getMesh()),
-            this.scene.add(o.getWireframe()),
-            this.scene.add(o.getHighlightWireframeMesh())
+            this.componentList.push(o) 
+            //this.scene.add(o.getMesh()) 
+            //this.scene.add(o.getWireframe())   
+            //this.scene.add(o.getHighlightWireframeMesh())
         }
         }
-    }
+    } */
 
 
-    buildCorners() {
-        for (var e = this.vertices, t = this.vertexIds, i = 0; i < 8; i++) {
-            var n = new Corner(e[i],t[i]);
-            this.componentList.push(n) 
-            this.scene.add(n.getMesh())  
-            this.scene.add(n.getWireframe()),
-            this.scene.add(n.getCornerFace()) 
-            this.scene.add(n.getCornerWireframe())
-        }
-    }
+    
      
      
     getComponent(e) {
     getComponent(e) {
         for (var t = 0; t < this.componentList.length; t++) {
         for (var t = 0; t < this.componentList.length; t++) {
@@ -649,27 +638,6 @@ class NavigationCube{
     }
     }
     
     
     
     
-    /* 
-    getMeshes() {
-        for (var e = [], t = this.scene.children, i = 0; i < t.length; i++) {
-            var n = t[i];
-            "Mesh" === n.type && !0 !== n.isHighlightMesh && e.push(n)
-        }
-        return e
-    }
-    
-    destroy() {
-        this.scene = null,
-        this.vertices = null,
-        this.vertexIds = null,
-        this.edgeIds = null,
-        this.edgeIndices = null,
-        this.faceIds = null,
-        this.faceIndices = null,
-        this.componentList = null,
-        this.enumViewMode = null
-    }
-    , */
     
     
     
     
 }
 }
@@ -740,6 +708,7 @@ class NavCubeViewer extends ViewerBase{
             splitScreen.splitStart(viewportProps)
             splitScreen.splitStart(viewportProps)
         })
         })
         
         
+        //this.addEventListener('resize',(e)=>{console.log('resize',e)})
         
         
     }
     }