|
@@ -63738,7 +63738,7 @@ void main() {
|
|
|
pointcloud.rotateMatrix = new THREE.Matrix4().makeRotationFromEuler(pointcloud.rotation);
|
|
|
pointcloud.rotateInvMatrix.copy(pointcloud.rotateMatrix).invert()
|
|
|
pointcloud.panos.forEach(e=>e.transformByPointcloud()) */
|
|
|
- pointcloud.updateBound();
|
|
|
+ //pointcloud.updateBound()
|
|
|
//pointcloud.getPanosBound()
|
|
|
viewer.updateModelBound();
|
|
|
};
|
|
@@ -63756,14 +63756,15 @@ void main() {
|
|
|
|
|
|
//过后改为根据intersect的点来设置底部高度;这样的话,需要发送高度
|
|
|
|
|
|
- let pos = new Vector3(x,y, planeZ );
|
|
|
- modelEditing.updateMatrixWorld();
|
|
|
- let boundCenter = modelEditing.boundingBox.getCenter(new Vector3).applyMatrix4(modelEditing.matrixWorld);
|
|
|
- let diff = new Vector3().subVectors(pos, boundCenter);
|
|
|
- modelEditing.position.add(diff); //使模型中心在鼠标所在位置
|
|
|
+ /*let pos = new THREE.Vector3(x,y, planeZ )
|
|
|
+ modelEditing.updateMatrixWorld()
|
|
|
+ let boundCenter = modelEditing.boundingBox.getCenter(new THREE.Vector3).applyMatrix4(modelEditing.matrixWorld);
|
|
|
+ */
|
|
|
+ MergeEditor.moveBoundCenterTo(new Vector2$1(x,y)); //使模型中心在鼠标所在位置
|
|
|
+
|
|
|
+
|
|
|
+ model.dispatchEvent("position_changed");
|
|
|
|
|
|
-
|
|
|
- modelEditing.dispatchEvent("position_changed");
|
|
|
|
|
|
};
|
|
|
let cancelMove = ()=>{
|
|
@@ -63784,6 +63785,8 @@ void main() {
|
|
|
let isFirstLoad = !prop.position; //在编辑时用户添加的
|
|
|
|
|
|
let loadDone = (model)=>{
|
|
|
+ model.dataset_id = prop.id;
|
|
|
+
|
|
|
if(isFirstLoad){
|
|
|
modelEditing = model;
|
|
|
MergeEditor.setModelBtmHeight(model, 0); //默认离地高度为0
|
|
@@ -63793,12 +63796,31 @@ void main() {
|
|
|
MergeEditor.setModelBtmHeight(model, prop.btmHeight || 0); //默认离地高度为0
|
|
|
modelEditing = null;
|
|
|
}
|
|
|
+ {//transform
|
|
|
+ let updateBound = ()=>{
|
|
|
+ model.updateMatrixWorld();
|
|
|
+ viewer.updateModelBound();
|
|
|
+ model.dispatchEvent('transformChanged');
|
|
|
+ };
|
|
|
+ let maintainBtmZAndCenter = ()=>{
|
|
|
+ MergeEditor.maintainBoundXY(model);
|
|
|
+ MergeEditor.setModelBtmHeight(model);
|
|
|
+ updateBound();
|
|
|
+ };
|
|
|
+ model.addEventListener('position_changed', ()=>{
|
|
|
+ MergeEditor.getBoundCenterXY(model);//更新boundcenter
|
|
|
+ updateBound();
|
|
|
+ });
|
|
|
+ model.addEventListener("orientation_changed", maintainBtmZAndCenter );
|
|
|
+ model.addEventListener("scale_changed", maintainBtmZAndCenter );
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
model.updateMatrixWorld();
|
|
|
viewer.updateModelBound();
|
|
|
|
|
|
+ MergeEditor.getBoundCenterXY(model); //初始化
|
|
|
|
|
|
- model.boundCenter = model.boundingBox.getCenter(new Vector3);
|
|
|
- model.dataset_id = prop.id;
|
|
|
done(model);
|
|
|
};
|
|
|
|
|
@@ -63809,17 +63831,17 @@ void main() {
|
|
|
|
|
|
pointcloud.pos1MatrixInvert = new Matrix4().setPosition(pointcloud.initialPosition).invert();
|
|
|
|
|
|
- let maintainBtmZ = ()=>{
|
|
|
- MergeEditor.setModelBtmHeight(pointcloud);
|
|
|
- updateMatrix();
|
|
|
- };
|
|
|
+ /* let maintainBtmZ = ()=>{
|
|
|
+ MergeEditor.setModelBtmHeight(pointcloud)
|
|
|
+ updateMatrix()
|
|
|
+ }
|
|
|
let updateMatrix = ()=>{
|
|
|
- setMatrix(pointcloud);
|
|
|
- pointcloud.dispatchEvent('transformChanged');
|
|
|
- };
|
|
|
- pointcloud.addEventListener('position_changed', updateMatrix );
|
|
|
- pointcloud.addEventListener("orientation_changed", maintainBtmZ );
|
|
|
- pointcloud.addEventListener("scale_changed", maintainBtmZ );
|
|
|
+ setMatrix(pointcloud)
|
|
|
+ pointcloud.dispatchEvent('transformChanged')
|
|
|
+ }
|
|
|
+ pointcloud.addEventListener('position_changed', updateMatrix )
|
|
|
+ pointcloud.addEventListener("orientation_changed", maintainBtmZ )
|
|
|
+ pointcloud.addEventListener("scale_changed", maintainBtmZ ) */
|
|
|
|
|
|
loadDone(pointcloud);
|
|
|
/* pointcloud.addEventListener('select',(e)=>{
|
|
@@ -63862,19 +63884,19 @@ void main() {
|
|
|
object.addEventListener('click',(e)=>{
|
|
|
//只是为了能得到hoverElement识别才加这个侦听
|
|
|
});
|
|
|
- let updateBound = ()=>{
|
|
|
- object.updateMatrixWorld();
|
|
|
- viewer.updateModelBound();
|
|
|
- object.dispatchEvent('transformChanged');
|
|
|
+ /* let updateBound = ()=>{
|
|
|
+ object.updateMatrixWorld()
|
|
|
+ viewer.updateModelBound()
|
|
|
+ object.dispatchEvent('transformChanged')
|
|
|
|
|
|
- };
|
|
|
+ }
|
|
|
let maintainBtmZ = ()=>{
|
|
|
- MergeEditor.setModelBtmHeight(object);
|
|
|
- updateBound();
|
|
|
- };
|
|
|
- object.addEventListener('position_changed', updateBound );
|
|
|
- object.addEventListener("orientation_changed", maintainBtmZ );
|
|
|
- object.addEventListener("scale_changed", maintainBtmZ );
|
|
|
+ MergeEditor.setModelBtmHeight(object)
|
|
|
+ updateBound()
|
|
|
+ }
|
|
|
+ object.addEventListener('position_changed', updateBound )
|
|
|
+ object.addEventListener("orientation_changed", maintainBtmZ )
|
|
|
+ object.addEventListener("scale_changed", maintainBtmZ ) */
|
|
|
loadDone(object);
|
|
|
};
|
|
|
|
|
@@ -63883,8 +63905,8 @@ void main() {
|
|
|
name: 'glb',
|
|
|
glburl: prop.url, //0.3s
|
|
|
transform : {
|
|
|
- rotation : prop.rotation,
|
|
|
position : prop.position,
|
|
|
+ rotation : new Euler().setFromVector3(prop.rotation),
|
|
|
scale: new Vector3(prop.scale,prop.scale,prop.scale),
|
|
|
}
|
|
|
|
|
@@ -112536,10 +112558,10 @@ ENDSEC
|
|
|
pointcloud.spriteNodeRoot.matrixWorld.copy(pointcloud.matrixWorld);//.multiplyMatrices(pointcloud.matrixWorld, pointcloud.matrixWorld);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- pointcloud.updateBound();
|
|
|
- pointcloud.getPanosBound();
|
|
|
viewer.updateModelBound();
|
|
|
+ //pointcloud.updateBound()
|
|
|
+ pointcloud.getPanosBound();
|
|
|
+
|
|
|
|
|
|
},
|
|
|
|
|
@@ -114981,6 +115003,13 @@ ENDSEC
|
|
|
getAllObjects(){
|
|
|
return viewer.objs.children.concat(viewer.scene.pointclouds)
|
|
|
},
|
|
|
+
|
|
|
+ getModel(id){
|
|
|
+ let models = this.getAllObjects();
|
|
|
+ return models.find(e=>e.dataset_id == id)
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
selectModel(model, state=true, by2d){
|
|
|
if(!model) {
|
|
|
model = this.selected;
|
|
@@ -115040,18 +115069,47 @@ ENDSEC
|
|
|
},
|
|
|
|
|
|
|
|
|
- setModelBtmHeight(model, z ){
|
|
|
+ setModelBtmHeight(model, z ){
|
|
|
+
|
|
|
//无论模型怎么缩放、旋转,都使最低点为z
|
|
|
- if(z == void 0) z = model.btmHeight; //离地高度
|
|
|
+ if(z == void 0) z = model.btmHeight; //维持离地高度
|
|
|
else model.btmHeight = z;
|
|
|
|
|
|
model.updateMatrixWorld();
|
|
|
let boundingBox2 = model.boundingBox.clone().applyMatrix4(model.matrixWorld);
|
|
|
let size = boundingBox2.getSize(new Vector3);
|
|
|
let center = boundingBox2.getCenter(new Vector3);
|
|
|
-
|
|
|
- model.position.z = z + size.z / 2 - center.z;
|
|
|
+ let hopeZ = z + size.z / 2;
|
|
|
+ //model.position.z = z + size.z / 2 - center.z
|
|
|
+ model.position.z += (hopeZ - center.z);
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ maintainBoundXY(model){ //在旋转和缩放后,立即执行这个函数,使boundCenter保持原位
|
|
|
+
|
|
|
+ model.updateMatrixWorld();
|
|
|
+ let center1 = model.boundCenterXY.clone();//还未更新的
|
|
|
+ this.getBoundCenterXY(model);//更新
|
|
|
+ let center2 = model.boundCenterXY.clone();
|
|
|
+ let diff = new Vector2$1().subVectors(center1,center2);
|
|
|
+ model.position.x += diff.x;
|
|
|
+ model.position.y += diff.y;
|
|
|
+ /* model.updateMatrixWorld()
|
|
|
+ this.getBoundCenterXY(model)//再次更新,它需要和center1相同 */
|
|
|
+ model.boundCenterXY = center1;
|
|
|
+ },
|
|
|
+
|
|
|
+ moveBoundCenterTo(model,pos){ //水平移动,使boundCenter在所要的位置
|
|
|
+ let diff = new Vector2$1().subVectors(pos, model.boundCenterXY);
|
|
|
+ model.position.x += diff.x;
|
|
|
+ model.position.y += diff.y;
|
|
|
+ },
|
|
|
+
|
|
|
+ getBoundCenterXY(model){
|
|
|
+ let boundCenter = model.boundingBox.getCenter(new Vector3).applyMatrix4(model.matrixWorld);
|
|
|
+ model.boundCenterXY = new Vector2$1().copy(boundCenter);
|
|
|
}
|
|
|
+
|
|
|
};
|
|
|
|
|
|
const texLoader$8 = new TextureLoader();
|
|
@@ -127163,7 +127221,7 @@ ENDSEC
|
|
|
if(!value)return
|
|
|
if(value instanceof Array){
|
|
|
object[name].fromArray(value);
|
|
|
- }else {
|
|
|
+ }else {
|
|
|
object[name].copy(value);
|
|
|
}
|
|
|
};
|