|
@@ -245,7 +245,7 @@ export class Viewer extends ViewerBase{
|
|
|
//add
|
|
|
{
|
|
|
$(domElement).append($("<div id='potree_labels'></div>"));
|
|
|
- if(!mapArea && Potree.settings.editType != 'merge'){
|
|
|
+ if(!mapArea && (Potree.settings.editType != 'merge' /* || Potree.settings.showObjectsOnMap */)){
|
|
|
mapArea = $("<div id='mapGaode'></div>");
|
|
|
$(domElement).append(mapArea);
|
|
|
mapArea = mapArea[0];
|
|
@@ -473,7 +473,7 @@ export class Viewer extends ViewerBase{
|
|
|
this.scene.scene.add(this.reticule)
|
|
|
|
|
|
|
|
|
- if(Potree.settings.editType != "pano" && Potree.settings.editType != 'merge'){
|
|
|
+ if(Potree.settings.editType != "pano" && (Potree.settings.editType != 'merge' /* || Potree.settings.showObjectsOnMap */)){
|
|
|
this.mapViewer = new MapViewer(mapArea/* $('#mapGaode')[0] */)
|
|
|
}
|
|
|
|
|
@@ -2359,7 +2359,7 @@ export class Viewer extends ViewerBase{
|
|
|
}
|
|
|
|
|
|
loadGUI(callback){
|
|
|
-
|
|
|
+
|
|
|
if(callback){
|
|
|
this.onGUILoaded(callback);
|
|
|
}
|
|
@@ -2872,10 +2872,10 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
if(Potree.settings.editType != 'pano' && Potree.settings.editType != 'merge'){
|
|
|
- this.modules.ParticleEditor.update(delta)
|
|
|
- this.mapViewer.update(delta) //地图更新
|
|
|
+ this.modules.ParticleEditor.update(delta)
|
|
|
}
|
|
|
-
|
|
|
+ this.mapViewer && this.mapViewer.update(delta) //地图更新
|
|
|
+
|
|
|
this.dispatchEvent({ type: 'update', delta: delta, timestamp: timestamp}); //在有sidebar时耗高cpu,占本update函数80%
|
|
|
|
|
|
|
|
@@ -4871,11 +4871,17 @@ export class Viewer extends ViewerBase{
|
|
|
this.update(deltaTime, timestamp);
|
|
|
this.magnifier.render();
|
|
|
this.render();
|
|
|
-
|
|
|
+
|
|
|
|
|
|
this.objs.children.forEach(e=>{
|
|
|
if(e.fileType == '3dTiles'){
|
|
|
- e.runtime.update(deltaTime, this.renderer, this.mainViewport.camera)
|
|
|
+ e.traverse(child=>{
|
|
|
+ if(child.runtime){
|
|
|
+ child.runtime.update(deltaTime, this.renderer, this.mainViewport.camera)
|
|
|
+ return {stopContinue:true}
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -5161,7 +5167,7 @@ export class Viewer extends ViewerBase{
|
|
|
fileInfo_.parentInfo.loadedCount ++
|
|
|
fileInfo_.parentInfo.modelGroup.add(object)
|
|
|
if(fileInfo_.parentInfo.loadedCount == fileInfo_.parentInfo.url.length){
|
|
|
- return loadDone(fileInfo_.parentInfo.modelGroup, fileInfo_.parentInfo)
|
|
|
+ return this.modelLoaded(fileInfo_.parentInfo.modelGroup, fileInfo_.parentInfo, done)
|
|
|
}else{
|
|
|
return
|
|
|
}
|
|
@@ -5183,57 +5189,73 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
if(fileInfo_.fileType == '3dTiles'){
|
|
|
- let tileset = object.runtime.getTileset()
|
|
|
-
|
|
|
- //TileHeader: tileset.root
|
|
|
- //参见另一个工程 TileRenderer.js preprocessNode //这个坐标位置几万…… let data = boundingVolume.halfAxes //但这个似乎是premultiply( transform );过后的,可能需还原下
|
|
|
+ let children = object.runtime ? [object] : object.children
|
|
|
|
|
|
- let json = tileset.tileset
|
|
|
- let box = json.root.boundingVolume.box
|
|
|
-
|
|
|
- if(box){
|
|
|
- let center = new THREE.Vector3(box[0],box[1],box[2])
|
|
|
- let boundSize = new THREE.Vector3( )
|
|
|
-
|
|
|
- // get the extents of the bounds in each axis
|
|
|
- let vecX = new THREE.Vector3( box[ 3 ], box[ 4 ], box[ 5 ] )
|
|
|
- let vecY = new THREE.Vector3( box[ 6 ], box[ 7 ], box[ 8 ] );
|
|
|
- let vecZ = new THREE.Vector3( box[ 9 ], box[ 10 ], box[ 11 ] );
|
|
|
-
|
|
|
- const scaleX = vecX.length();
|
|
|
- const scaleY = vecY.length();
|
|
|
- const scaleZ = vecZ.length();
|
|
|
- /* boundingBox.expandByPoint(center);
|
|
|
- boundingBox.expandByVector(new THREE.Vector3(scaleX,scaleY,scaleZ)) */
|
|
|
-
|
|
|
+
|
|
|
+ children.forEach(object =>{
|
|
|
+ let boundingBox_ = new THREE.Box3()
|
|
|
+
|
|
|
|
|
|
- boundingBox.min.set( - scaleX, - scaleY, - scaleZ );
|
|
|
- boundingBox.max.set( scaleX, scaleY, scaleZ );
|
|
|
+ let tileset = object.runtime.getTileset()
|
|
|
+
|
|
|
+ //TileHeader: tileset.root
|
|
|
+ //参见另一个工程 TileRenderer.js preprocessNode //这个坐标位置几万…… let data = boundingVolume.halfAxes //但这个似乎是premultiply( transform );过后的,可能需还原下
|
|
|
|
|
|
- }else if(json.root.boundingVolume.sphere){
|
|
|
- let sphereData = json.root.boundingVolume.sphere
|
|
|
- let center = new THREE.Vector3(...sphereData)
|
|
|
- let radius = sphereData[3] / 2
|
|
|
- /* let sphere = new THREE.Sphere(center, radius)
|
|
|
- let box = sphere.getBoundingBox()
|
|
|
- boundingBox.copy(box) */
|
|
|
+ let json = tileset.tileset
|
|
|
+ let box = json.root.boundingVolume.box
|
|
|
|
|
|
- boundingBox.min.set( - radius, - radius, - radius );
|
|
|
- boundingBox.max.set( radius, radius, radius );
|
|
|
+ if(box){
|
|
|
+ let center = new THREE.Vector3(box[0],box[1],box[2])
|
|
|
+ let boundSize = new THREE.Vector3( )
|
|
|
+
|
|
|
+ // get the extents of the bounds in each axis
|
|
|
+ let vecX = new THREE.Vector3( box[ 3 ], box[ 4 ], box[ 5 ] )
|
|
|
+ let vecY = new THREE.Vector3( box[ 6 ], box[ 7 ], box[ 8 ] );
|
|
|
+ let vecZ = new THREE.Vector3( box[ 9 ], box[ 10 ], box[ 11 ] );
|
|
|
+
|
|
|
+ const scaleX = vecX.length();
|
|
|
+ const scaleY = vecY.length();
|
|
|
+ const scaleZ = vecZ.length();
|
|
|
+ /* boundingBox.expandByPoint(center);
|
|
|
+ boundingBox.expandByVector(new THREE.Vector3(scaleX,scaleY,scaleZ)) */
|
|
|
+
|
|
|
+
|
|
|
+ boundingBox_.min.set( - scaleX, - scaleY, - scaleZ );
|
|
|
+ boundingBox_.max.set( scaleX, scaleY, scaleZ );
|
|
|
+
|
|
|
+ }else if(json.root.boundingVolume.sphere){
|
|
|
+ let sphereData = json.root.boundingVolume.sphere
|
|
|
+ let center = new THREE.Vector3(...sphereData)
|
|
|
+ let radius = sphereData[3] / 2
|
|
|
+ /* let sphere = new THREE.Sphere(center, radius)
|
|
|
+ let box = sphere.getBoundingBox()
|
|
|
+ boundingBox.copy(box) */
|
|
|
+
|
|
|
+ boundingBox_.min.set( - radius, - radius, - radius );
|
|
|
+ boundingBox_.max.set( radius, radius, radius );
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ return console.error('json boundingVolume 缺少信息')
|
|
|
+ }
|
|
|
|
|
|
+ //中心点居然没用。可能是漏用了什么信息,也许这和LVBADUI_qp是散的有关。
|
|
|
+ console.log('3d tiles json',json)
|
|
|
|
|
|
+ json.root.refine = 'ADD';
|
|
|
+ json.refine = 'ADD';
|
|
|
+
|
|
|
|
|
|
- }else{
|
|
|
- return console.error('json boundingVolume 缺少信息')
|
|
|
- }
|
|
|
+ boundingBox.union(boundingBox_)
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- //中心点居然没用。可能是漏用了什么信息,也许这和LVBADUI_qp是散的有关。
|
|
|
- console.log('3d tiles json',json)
|
|
|
|
|
|
- json.root.refine = 'ADD';
|
|
|
- json.refine = 'ADD';
|
|
|
}else {
|
|
|
- Potree.Utils.setObjectLayers(object,'model')
|
|
|
+ Potree.Utils.setObjectLayers(object, Potree.settings.showObjectsOnMap ? 'bothMapAndScene' : 'model')
|
|
|
|
|
|
|
|
|
object.traverse( ( child )=>{
|
|
@@ -5418,7 +5440,7 @@ export class Viewer extends ViewerBase{
|
|
|
}
|
|
|
});
|
|
|
tileset.addEventListener('tileLoaded',(e)=>{ //每一个tile加载完要更改透明度
|
|
|
- let opacity = result.model.opacity
|
|
|
+ let opacity = result.model.parent ? result.model.parent.opacity : result.model.opacity //最多两层
|
|
|
MergeEditor.changeOpacity(e.tileContent,opacity)
|
|
|
//set Layers ?
|
|
|
})
|