|
@@ -763,11 +763,42 @@ window.expandMath = function(math){
|
|
|
let r = ((n - Math.pow(2,k) ) * 2 + 1)/ Math.pow(2,k+1)
|
|
let r = ((n - Math.pow(2,k) ) * 2 + 1)/ Math.pow(2,k+1)
|
|
|
console.log('getSpreadRatio',n,r)
|
|
console.log('getSpreadRatio',n,r)
|
|
|
return r
|
|
return r
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ } ,
|
|
|
|
|
|
|
|
|
|
+ getQuaBetween2Vector:function(oriVec, newVec, upVec){ //获取从oriVec旋转到newVec可以应用的quaternion
|
|
|
|
|
+ var angle = oriVec.angleTo(newVec);
|
|
|
|
|
+ var axis = oriVec.clone().cross( newVec).normalize();//两个up之间
|
|
|
|
|
+ if(axis.length() == 0){//当夹角为180 或 0 度时,得到的axis为(0,0,0),故使用备用的指定upVec
|
|
|
|
|
+ return new THREE.Quaternion().setFromAxisAngle( upVec, angle );
|
|
|
|
|
+ }
|
|
|
|
|
+ return new THREE.Quaternion().setFromAxisAngle( axis, angle );
|
|
|
|
|
+ } ,
|
|
|
|
|
+ getTwoPointsTran(points1, points2, ifScale, up){//在两个系统上获得两个对应的点,得到从1到2的变换矩阵
|
|
|
|
|
+ let vec1 = new THREE.Vector3().subVectors(points1[1], points1[0] )
|
|
|
|
|
+ let vec2 = new THREE.Vector3().subVectors(points2[1], points2[0] )
|
|
|
|
|
+
|
|
|
|
|
+ let matrix = new THREE.Matrix4
|
|
|
|
|
+
|
|
|
|
|
+ matrix.makeTranslation(-points1[0].x, -points1[0].y, -points1[0].z)
|
|
|
|
|
+ let angle = vec1.angleTo(vec2)
|
|
|
|
|
+ let qua = this.getQuaBetween2Vector(vec1, vec2, up)
|
|
|
|
|
+ let rotMatrix = new THREE.Matrix4().makeRotationFromQuaternion(qua)
|
|
|
|
|
+ if(ifScale){
|
|
|
|
|
+ let len1 = vec1.length()
|
|
|
|
|
+ let len2 = vec2.length()
|
|
|
|
|
+ let scale = len2 / len1
|
|
|
|
|
+ let sclMatrix = new THREE.Matrix4().makeScale(scale,scale,scale)
|
|
|
|
|
+ matrix.multiplyMatrices(sclMatrix, matrix )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ matrix.multiplyMatrices(rotMatrix, matrix )
|
|
|
|
|
+ matrix.elements[12]+=points2[0].x
|
|
|
|
|
+ matrix.elements[13]+=points2[0].y
|
|
|
|
|
+ matrix.elements[14]+=points2[0].z
|
|
|
|
|
+ return matrix
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -2942,30 +2973,33 @@ Manage.prototype.switchBgmState = function(state){//按钮的状态完全代表
|
|
|
|
|
|
|
|
var manage = new Manage();
|
|
var manage = new Manage();
|
|
|
|
|
|
|
|
-manage.initMapPanoPos = function(width,height){
|
|
|
|
|
-
|
|
|
|
|
- let data = {}
|
|
|
|
|
-
|
|
|
|
|
- let imgSize = new THREE.Vector2(width,height)
|
|
|
|
|
- let bound2dSize = new THREE.Vector2(player.model.size.x,player.model.size.z)
|
|
|
|
|
-
|
|
|
|
|
|
|
+manage.initMapPanoPos = function( twoPano = [{id:2, px:{x:157,y:240}}, {id:33, px:{x:518,y:921}}] ){
|
|
|
|
|
+ twoPano = [{id:2, px:{x:157,y:240}}, {id:33, px:{x:518,y:921}}]
|
|
|
|
|
+ let pano1 = player.model.panos.index[twoPano[0].id]
|
|
|
|
|
+ let pano2 = player.model.panos.index[twoPano[1].id]
|
|
|
|
|
+ if(!pano1 || !pano2){
|
|
|
|
|
+ return console.error('找不到这两个漫游点', twoPano)
|
|
|
|
|
+ }
|
|
|
|
|
+ let pos1 = new THREE.Vector3().copy(pano1.position).setY(0)
|
|
|
|
|
+ let pos2 = new THREE.Vector3().copy(pano2.position).setY(0)
|
|
|
|
|
+ let pos1PX = new THREE.Vector3(twoPano[0].px.x, 0, twoPano[0].px.y)
|
|
|
|
|
+ let pos2PX = new THREE.Vector3(twoPano[1].px.x, 0, twoPano[1].px.y)
|
|
|
|
|
+ let matrix = math.getTwoPointsTran([pos1, pos2],[pos1PX, pos2PX], true, new THREE.Vector3(0,1,0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ let data = {}
|
|
|
player.model.panos.forEach(pano=>{
|
|
player.model.panos.forEach(pano=>{
|
|
|
- let panoPos = new THREE.Vector2(pano.position.x, pano.position.z);
|
|
|
|
|
- let boundMin = new THREE.Vector2(player.model.boundingBox.min.x, player.model.boundingBox.min.z);
|
|
|
|
|
- let diff = new THREE.Vector2().subVectors(panoPos, boundMin)
|
|
|
|
|
- diff.divide(bound2dSize)
|
|
|
|
|
- diff.y = 1-diff.y, diff.x = 1-diff.x //暂时先这么写,其实应该用旋转角,旋转180度比较适应所有旋转情况
|
|
|
|
|
- diff.multiply(imgSize)
|
|
|
|
|
-
|
|
|
|
|
- data[pano.id] = diff
|
|
|
|
|
|
|
+ let px = pano.position.clone().setY(0).applyMatrix4(matrix)
|
|
|
|
|
+
|
|
|
|
|
+ data[pano.id] = {x:157,y:240} //{x:px.x, y:px.z}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
return data
|
|
return data
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
//处理cursor优先级
|
|
//处理cursor优先级
|
|
|
|
|
|