|
|
@@ -1193,72 +1193,90 @@ export function mergeEditStart(dom, mapDom, {queryCloudLonLatUrl}={}){
|
|
|
model.renderOrder = Potree.config.renderOrders.model; //same as glb
|
|
|
}
|
|
|
|
|
|
- if(Potree.settings.maintainBtmZ)
|
|
|
- {//transform --------维持离地高度和中心点的版本(local ver)
|
|
|
- let updateBound = ()=>{
|
|
|
- model.updateMatrixWorld()
|
|
|
- viewer.updateModelBound()
|
|
|
- }
|
|
|
- let maintainBtmZAndCenter = ()=>{
|
|
|
- MergeEditor.maintainBoundXY(model)
|
|
|
- MergeEditor.setModelBtmHeight(model)
|
|
|
- updateBound()
|
|
|
- model.dispatchEvent('transformChanged')
|
|
|
- }
|
|
|
- model.addEventListener('position_changed', ()=>{
|
|
|
- updateBound()
|
|
|
- MergeEditor.getBoundCenter(model);//更新boundcenter
|
|
|
- MergeEditor.computeBtmHeight(model)
|
|
|
- if(prop.bottomRange && (model.btmHeight > prop.bottomRange.max || model.btmHeight < prop.bottomRange.min)){
|
|
|
- model.btmHeight = THREE.Math.clamp(model.btmHeight, prop.bottomRange.min, prop.bottomRange.max)
|
|
|
- MergeEditor.setModelBtmHeight(model)
|
|
|
- updateBound()
|
|
|
- }
|
|
|
- model.dispatchEvent('transformChanged')
|
|
|
- })
|
|
|
- model.addEventListener("rotation_changed", maintainBtmZAndCenter )
|
|
|
- model.addEventListener("scale_changed", maintainBtmZAndCenter )
|
|
|
- model.addEventListener('transformChanged', ()=>{
|
|
|
- MergeEditor.modelTransformCallback(model)
|
|
|
- })
|
|
|
- //离地高度只是boundingbox在transform后的最低点的高度,而非模型transform后的最低点的高度,所以旋转过后看起来不太准确
|
|
|
- } else
|
|
|
+ let initModel = (model)=>{
|
|
|
+ model.updateMatrixWorld()
|
|
|
+ viewer.updateModelBound()
|
|
|
|
|
|
- {//transform --------维持中心点的版本
|
|
|
- let updateBound = ()=>{
|
|
|
- model.updateMatrixWorld()
|
|
|
- viewer.updateModelBound()
|
|
|
- }
|
|
|
- let maintainCenter = (e)=>{
|
|
|
- //MergeEditor.maintainBoundXY(model)
|
|
|
- e.by2d || model.atPath || MergeEditor.maintainBoundCenter(model)
|
|
|
- updateBound()
|
|
|
- model.dispatchEvent({type:'transformChanged', byControl:e.byControl})
|
|
|
+ if(Potree.settings.maintainBtmZ)
|
|
|
+ {//transform --------维持离地高度和中心点的版本(local ver)
|
|
|
+ let updateBound = ()=>{
|
|
|
+ model.updateMatrixWorld()
|
|
|
+ viewer.updateModelBound()
|
|
|
+ }
|
|
|
+ let maintainBtmZAndCenter = ()=>{
|
|
|
+ MergeEditor.maintainBoundXY(model)
|
|
|
+ MergeEditor.setModelBtmHeight(model)
|
|
|
+ updateBound()
|
|
|
+ model.dispatchEvent('transformChanged')
|
|
|
+ }
|
|
|
+ model.addEventListener('position_changed', ()=>{
|
|
|
+ updateBound()
|
|
|
+ MergeEditor.getBoundCenter(model);//更新boundcenter
|
|
|
+ MergeEditor.computeBtmHeight(model)
|
|
|
+ if(prop.bottomRange && (model.btmHeight > prop.bottomRange.max || model.btmHeight < prop.bottomRange.min)){
|
|
|
+ model.btmHeight = THREE.Math.clamp(model.btmHeight, prop.bottomRange.min, prop.bottomRange.max)
|
|
|
+ MergeEditor.setModelBtmHeight(model)
|
|
|
+ updateBound()
|
|
|
+ }
|
|
|
+ model.dispatchEvent('transformChanged')
|
|
|
+ })
|
|
|
+ model.addEventListener("rotation_changed", maintainBtmZAndCenter )
|
|
|
+ model.addEventListener("scale_changed", maintainBtmZAndCenter )
|
|
|
+ model.addEventListener('transformChanged', ()=>{
|
|
|
+ MergeEditor.modelTransformCallback(model)
|
|
|
+ })
|
|
|
+ //离地高度只是boundingbox在transform后的最低点的高度,而非模型transform后的最低点的高度,所以旋转过后看起来不太准确
|
|
|
+ } else
|
|
|
+
|
|
|
+ {//transform --------维持中心点的版本
|
|
|
+ let updateBound = ()=>{
|
|
|
+ model.updateMatrixWorld()
|
|
|
+ viewer.updateModelBound()
|
|
|
+ }
|
|
|
+ let maintainCenter = (e)=>{
|
|
|
+ //MergeEditor.maintainBoundXY(model)
|
|
|
+ e.by2d || model.atPath || MergeEditor.maintainBoundCenter(model)
|
|
|
+ updateBound()
|
|
|
+ model.dispatchEvent({type:'transformChanged', byControl:e.byControl})
|
|
|
+ }
|
|
|
+ model.addEventListener('position_changed', (e)=>{//要先发送position_changed再其他
|
|
|
+ updateBound()
|
|
|
+ MergeEditor.getBoundCenter(model);//更新boundcenter
|
|
|
+
|
|
|
+ model.dispatchEvent({type:'transformChanged', byControl:e.byControl})
|
|
|
+ })
|
|
|
+ model.addEventListener("rotation_changed", maintainCenter )
|
|
|
+ model.addEventListener("scale_changed", maintainCenter )
|
|
|
+ model.addEventListener('transformChanged', ()=>{
|
|
|
+ MergeEditor.modelTransformCallback(model)
|
|
|
+ })
|
|
|
}
|
|
|
- model.addEventListener('position_changed', (e)=>{//要先发送position_changed再其他
|
|
|
- updateBound()
|
|
|
- MergeEditor.getBoundCenter(model);//更新boundcenter
|
|
|
-
|
|
|
- model.dispatchEvent({type:'transformChanged', byControl:e.byControl})
|
|
|
- })
|
|
|
- model.addEventListener("rotation_changed", maintainCenter )
|
|
|
- model.addEventListener("scale_changed", maintainCenter )
|
|
|
- model.addEventListener('transformChanged', ()=>{
|
|
|
- MergeEditor.modelTransformCallback(model)
|
|
|
- })
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ MergeEditor.getBoundCenter(model) //初始化
|
|
|
+ //model.lastMatrixWorld = model.matrixWorld.clone()
|
|
|
+ model.lastMatrixWorld = new THREE.Matrix4
|
|
|
+ MergeEditor.modelTransformCallback(model, true)
|
|
|
}
|
|
|
+ initModel(model)
|
|
|
|
|
|
- model.updateMatrixWorld()
|
|
|
- viewer.updateModelBound()
|
|
|
|
|
|
- MergeEditor.getBoundCenter(model) //初始化
|
|
|
- //model.lastMatrixWorld = model.matrixWorld.clone()
|
|
|
- model.lastMatrixWorld = new THREE.Matrix4
|
|
|
- MergeEditor.modelTransformCallback(model, true)
|
|
|
prop.scale != void 0 && model.isPointcloud && model.changePointSize() //有的被缩放的很小导致testMaxNodeLevel时距离较远时被return 但点云过大急需changesize
|
|
|
|
|
|
|
|
|
+ {
|
|
|
+ let oldClone = model.clone
|
|
|
+ model.clone = ()=>{//SkinnedMesh的模型复制了有问题,不能移动
|
|
|
+ let copyObj = oldClone.apply(model)
|
|
|
+ copyObj.boundingBox = model.boundingBox.clone()
|
|
|
+ copyObj.updateMatrixWorld()
|
|
|
+ copyObj.gltf = model.gltf
|
|
|
+ viewer.gltfAddAnimation(copyObj)
|
|
|
+ initModel(copyObj)
|
|
|
+ return copyObj
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
done && done(model) // 先发送成功,因为2d界面会随机执行changePosition等初始化,然后这边再将模型移到中心地面上
|
|
|
|