瀏覽代碼

transformControls在scale为负数时translate反向问题

xzw 4 月之前
父節點
當前提交
7edd8c137f
共有 5 個文件被更改,包括 89 次插入37 次删除
  1. 28 1
      js/Hot.js
  2. 4 7
      js/TransformControls.js
  3. 8 6
      js/main_2020_edit.js
  4. 34 20
      js/main_2020_show.js
  5. 15 3
      js/manage.js

+ 28 - 1
js/Hot.js

@@ -1014,6 +1014,23 @@ window.ctlBtn = ctlBtn
             //return true
             if(window.isEdit)return true // 太容易move了
              
+             
+             
+            /* if(overlay.plane.material.side!=2){ //side为0
+                let dir = overlay.plane.getWorldDirection(new THREE.Vector3) 
+                if(dir.dot(camDir)>0 ){
+                    console.log('dir.dot(camDir)',dir.dot(camDir))
+                    return false
+                }
+                //可能看到背面。若能看到正面,视线方向和plane朝向必定为钝角
+            }  */
+             
+             
+             
+             
+             
+             
+             
             if(player.mode == 'panorama' && player.currentPano){
                 if(!player.camera) return
                   
@@ -1061,6 +1078,7 @@ window.ctlBtn = ctlBtn
                  
             }else{//飞出 只判断在不在画面内
                 //return playVideoWhenFlyOut//true 
+                
                 let frustumMatrix = new THREE.Matrix4
                 frustumMatrix.multiplyMatrices(player.camera.projectionMatrix, player.camera.matrixWorldInverse)
          
@@ -1069,7 +1087,16 @@ window.ctlBtn = ctlBtn
                 
                 let bound = this.getBoundOri() 
                 bound.applyMatrix4(this.matrixWorld)
-                return frustum.intersectsBox(bound)  
+                let insight = frustum.intersectsBox(bound)  
+                if(!insight)return false
+                
+                const min = 0.15//最小可播放尺寸(屏幕宽高都是2)
+                bound.applyMatrix4(frustumMatrix); //project on screen
+                let boundSize = bound.size(new THREE.Vector3)
+                if(boundSize.x < min && boundSize.y < min){ 
+                    return false
+                } 
+                return true 
             }
                 
                 

+ 4 - 7
js/TransformControls.js

@@ -388,14 +388,11 @@ var TransformControls = function ( camera, domElement, options ) {
 			if ( axis.indexOf( 'Z' ) === - 1 ) offset.z = 0;
 
 			if ( space === 'local' && axis !== 'XYZ' ) {
-                //xzw 加,否则会反向---------------
-                object.scale.x < 0 && (offset.x *= -1)
-                object.scale.y < 0 && (offset.y *= -1)
-                object.scale.z < 0 && (offset.z *= -1)
-                //---------------------------------
+                //xzw 加,否则会反向-----three官网也有问题----2025.4又改了一下(之前改完没测试吗=,=),经测试没问题---
+                //object.scale.x < 0 && (offset.x *= -1) 
+                object.scale.y < 0 && (offset.x *= -1, offset.y *= -1)
+                object.scale.z < 0 && (offset.x *= -1, offset.z *= -1)   
 				offset.applyQuaternion( quaternionStart ).divide( parentScale );
-                
-                 
 			} else {
 
 				offset.applyQuaternion( parentQuaternionInv ).divide( parentScale );

+ 8 - 6
js/main_2020_edit.js

@@ -19967,12 +19967,17 @@ function o(a, s, l) {
                 t || (t = D.warp.teleportTime) 
                 //add
                 player.model.hotGroup.visible = false
+                let oldPano = this.player.currentPano
+                let toPano =  this.player.model.panos.get(this.warpDestHeroLoc.panoId)
+                this.player.emit("pano.chosen", oldPano, toPano)
+                
+                
                 var done = ()=>{   
                     this.player.transitionPos({type:"beforeFlytopano", pano:this.player.currentPano, dur:0, callback:()=>{
                         player.model.hotGroup.visible = true
                         Hot.updateVisibles([this.player.currentPano]) //更新热点显示 
                     }}) 
-                   
+                    this.player.emit("flying.ended",toPano.position, oldPano.position,toPano, oldPano) 
                 }
                 if(window.DATA.momentTourBlackNewType){
                     player.sceneRenderer.effects.fastTranMaskPass.start(player.sceneRenderer)
@@ -22111,9 +22116,7 @@ function o(a, s, l) {
                 
                 if (this.checkAndWaitForPanoLoad(pano, "high", "low", this.basePanoSize, retry))
                     return void (this.waitingToWarp = !0)
-                
-                this.emit("pano.chosen", oldPano, pano)
-            
+                 
                     
                 console.log('blackToPano')
                 this.flying = true
@@ -22129,8 +22132,7 @@ function o(a, s, l) {
                 this.path.warpTravel_BLACK(null, 1500,1, ()=>{ 
                     pano != this.currentPano && this.currentPano.exit() 
                     pano.enter() 
-                    this.currentPano = pano
-                    this.emit("flying.ended", pano.position, oldPos, pano, oldPano) 
+                    this.currentPano = pano 
                     this.flying = false
                     this.nextPano = null 
                     this.updateMarkerVisi();//add

+ 34 - 20
js/main_2020_show.js

@@ -4969,20 +4969,25 @@ window.Modernizr = function(n, e, t) {
                         var pano = this.model.panos.index[location.panoId];
                         var dis = pano.position.distanceTo(this.player.currentPano.position)
                         if(dis<result.dis){
-                            result.item = item, result.dis = dis
-                        }else if(dis == result.dis){//如果两个位置相同,优先播放在导览条上离激活的最近的那段导览 
-                            
-                            /* if(this.itemCompare(item,  this.currentItem, 'equal')){//优先用当前的
-                                result.item = item, result.dis = dis
-                            }else if(this.currentItem && Math.abs(item[0]-this.currentItem[0]) < Math.abs(result.item[0]-this.currentItem[0])){
-                                result.item = item, result.dis = dis
-                            } */ 
-                            if(this.currentItem){
+                            result.item = item, result.dis = dis, result.location = location, result.angle = null
+                        }else if(dis == result.dis){
+                             
+                            if(this.currentItem){ 
+                                if(result.angle == void 0){
+                                    result.angle = result.location.quaternion.angleTo(player.quaternion)
+                                }//用角度最接近的那一个
+                                
+                                let angle = location.quaternion.angleTo(player.quaternion)
+                                if(angle < result.angle){
+                                    result.item = item, result.dis = dis, result.location = location, result.angle = angle                             
+                                }
+                                 
+                                /* //如果两个位置相同,优先播放在导览条上离激活的最近的那段导览 
                                 let dis1 = [Math.abs(item[0] - this.currentItem[0]), Math.abs(item[1] - this.currentItem[1])] //当前差距
                                 let dis2 = [Math.abs(result.item[0] - this.currentItem[0]), Math.abs(result.item[1] - this.currentItem[1])]
                                 if( this.itemCompare(dis1, dis2, 'less')){ 
                                     result.item = item, result.dis = dis
-                                }
+                                } */
                             }
                         }
                     } 
@@ -9133,9 +9138,9 @@ window.Modernizr = function(n, e, t) {
                 w.addEventListener(e, u.bind(this, !0), !0),
                 E.addEventListener(e, stopTour2, !0) 
                                
-                S.forEach(function(t) {//会触发导览停止  
+                /* S.forEach(function(t) {//会触发导览停止  
                     t.addEventListener(e, stopTour, !0)
-                }) 
+                })  */
                 $("#drawer img").on(e, stopTour)
             }) 
             document.addEventListener("keydown", u.bind(this, !1), !0) 
@@ -21551,12 +21556,16 @@ window.Modernizr = function(n, e, t) {
                 void 0 !== t && null !== t || (t = c.warp.teleportTime)
                 //add
                 player.model.hotGroup.visible = false
+                let oldPano = this.player.currentPano
+                let toPano =  this.player.model.panos.get(this.warpDestHeroLoc.panoId)
+                this.player.emit("pano.chosen", oldPano, toPano)
+                
                 var done = ()=>{   
                     this.player.transitionPos({type:"beforeFlytopano", pano:this.player.currentPano, dur:0, callback:()=>{
                         player.model.hotGroup.visible = true
                         Hot.updateVisibles([this.player.currentPano]) //更新热点显示 
                     }}) 
-                   
+                    this.player.emit("flying.ended",toPano.position, oldPano.position,toPano, oldPano) 
                 }
                 
                 if(window.DATA.momentTourBlackNewType){
@@ -21782,6 +21791,7 @@ window.Modernizr = function(n, e, t) {
             ,
             n.prototype.endWarpState = function() {
                 this.warping = !1
+                this.director.emit('warp.end')//xzw add
             }
             ,
             n.prototype.warpToPano = function(e, t, i, n) {
@@ -23719,7 +23729,7 @@ window.Modernizr = function(n, e, t) {
             n.prototype.warpToPano = function(o={}) {
                 
             }
-            n.prototype.blackToPano = function(o={}) {//add 瞬间过渡
+            n.prototype.blackToPano = function(o={},callback) {//add 瞬间过渡
                 //o.panoId = "8bc9156b288d48459e4e0f74d7051ef1"
                 if(this.flying || this.isWarping() )return;
                 let pano = o.pano || this.model.panos.index[o.panoId] 
@@ -23731,7 +23741,7 @@ window.Modernizr = function(n, e, t) {
                         pano ,
                         duration: o.duration,
                         quaternion: o.quaternion ,
-                        //callback: t
+                        callback
                     })
                 }
                
@@ -23748,18 +23758,18 @@ window.Modernizr = function(n, e, t) {
  
                 var retry = ()=>{
                     this.waitingToWarp = !1,
-                    this.blackToPano(o)
+                    this.blackToPano(o,callback)
                 }
                 
                 if (this.checkAndWaitForPanoLoad(pano, "high", "low", this.basePanoSize, retry))
                     return void (this.waitingToWarp = !0)
                 
-                this.emit("pano.chosen", oldPano, pano)
+                
                 
                 this.flying = true
                 this.nextPano = pano //提前加载高清图片
                 this.path.warpDestHeroLoc = {  
-                    panoId : o.panoId,
+                    panoId : pano.id,
                     position: pano.position,
                     quaternion: o.quaternion || this.quaternion.clone()
                    
@@ -23769,11 +23779,11 @@ window.Modernizr = function(n, e, t) {
                 this.path.warpTravel_BLACK(null, 1500,1, ()=>{ 
                     pano != this.currentPano && this.currentPano.exit() 
                     pano.enter() 
-                    this.currentPano = pano
-                    this.emit("flying.ended", pano.position, oldPos, pano, oldPano) 
+                    this.currentPano = pano 
                     this.flying = false
                     this.nextPano = null 
                     this.updateMarkerVisi();//add
+                    callback && callback()
                 } )
                 
             }
@@ -60995,6 +61005,10 @@ var addMagnifier = function(){
  
     一些后缀
     &panoLabel 加pano标签
+    
+    director.on("tour.end") //导览结束  是否在导览播放中:player.director.tourInProgress() 不包括点击item
+    player.isWarping() //是否在导览中,包括点击item的fly
+            我加了个 director.on("warp.end") 
  
  */
  

+ 15 - 3
js/manage.js

@@ -1506,11 +1506,15 @@ function initByTHREE(THREE){
  
          
     Object.assign(Manage.prototype, THREE.EventDispatcher.prototype)
+ 
 
+    THREE.Quaternion.prototype.angleTo = function(q){
+		return 2 * Math.acos( Math.abs( THREE.Math.clamp( this.dot( q ), - 1, 1 ) ) );
+	}
 
-    let labels = []
 
 
+    let labels = []
 
 
     class Label2D  extends THREE.EventDispatcher{
@@ -2563,7 +2567,15 @@ function initByTHREE(THREE){
                 
                 player.currentPano && setCurBgm(player.currentPano)
                 
-                 
+                /*player.on("view.changed",(e)=>{//位移和旋转时都要判断最近item
+                    if(!player.director.highlightItem && e.cameraWorldMatrixChanged && !player.flying && !player.isWarping()  ){
+                        common.intervalTool.isWaiting('tourUpdateCurItem',()=>{
+                            console.log('setCurrentItem')
+                            player.director.setCurrentItem( player.director.findNearestItem(true,true) )
+                             
+                        }, 521)
+                    }                        
+                })     */ 
             }
         } 
         
@@ -2823,7 +2835,7 @@ Manage.prototype.loadAudio = function() { //相关:g_tourAudio \  g_playAudio
     })  
     SoundManager.createAudio({
         name:'tour',
-        level:0, 
+        level:1, 
         src:'',
         loop:false,
         canplay:(audio)=>{