|
@@ -1,4 +1,4 @@
|
|
|
-import { CanvasTexture, LinearFilter, RepeatWrapping, Vector2 as Vector2$1, Frustum, Matrix4 as Matrix4$1, Group, PlaneGeometry, Vector3 as Vector3$1, MeshBasicMaterial, DoubleSide, Mesh, ArrowHelper, Color, BoxGeometry, EdgesGeometry, LineSegments, LineBasicMaterial, ShaderMaterial, Euler, BufferGeometry, Float32BufferAttribute, Uint8BufferAttribute, BufferAttribute, Points } from '../build/three.module.js';
|
|
|
+import { EventDispatcher, CanvasTexture, LinearFilter, RepeatWrapping, Vector2 as Vector2$1, Frustum, Matrix4 as Matrix4$1, Group, PlaneGeometry, Vector3 as Vector3$1, MeshBasicMaterial, DoubleSide, Mesh, ArrowHelper, Color, BoxGeometry, EdgesGeometry, LineSegments, LineBasicMaterial, ShaderMaterial, Euler, BufferGeometry, Float32BufferAttribute, Uint8BufferAttribute, BufferAttribute, Points } from '../build/three.module.js';
|
|
|
import { GLTFLoader as GLTFLoader$1 } from '../loaders/GLTFLoader.js';
|
|
|
import { DRACOLoader } from '../loaders/DRACOLoader.js';
|
|
|
import { KTX2Loader } from '../loaders/KTX2Loader.js';
|
|
@@ -8552,6 +8552,13 @@ function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {
|
|
|
} = tileset.options;
|
|
|
let error = lodMetricValue * height * (viewDistanceScale || 1.0) / (distance * sseDenominator);
|
|
|
error -= getDynamicScreenSpaceError(tileset, distance);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return error;
|
|
|
}
|
|
|
|
|
@@ -8801,7 +8808,7 @@ class TilesetTraverser {
|
|
|
this._emptyTraversalStack.reset();
|
|
|
}
|
|
|
|
|
|
- executeTraversal(root, frameState) {
|
|
|
+ executeTraversal(root, frameState) {// 遍历root
|
|
|
const stack = this._traversalStack;
|
|
|
root._selectionDepth = 1;
|
|
|
stack.push(root);
|
|
@@ -8810,7 +8817,9 @@ class TilesetTraverser {
|
|
|
const tile = stack.pop();
|
|
|
let shouldRefine = false;
|
|
|
|
|
|
- if (this.canTraverse(tile, frameState)) {
|
|
|
+
|
|
|
+ // !zeg改 循环遍历子tile, maxDepth用来限制可加载的最大深度
|
|
|
+ if (this.canTraverse(tile, frameState) && tile.depth < this.options.maxDepth) {//add maxDepth
|
|
|
this.updateChildTiles(tile, frameState);
|
|
|
shouldRefine = this.updateAndPushChildren(tile, frameState, stack, tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth);
|
|
|
}
|
|
@@ -9316,6 +9325,12 @@ class TileHeader {
|
|
|
};
|
|
|
this.content = await load(contentUrl, loader, options);
|
|
|
|
|
|
+ // !zeg改
|
|
|
+ if (this.tileset.options.maxDepth < this.depth) {
|
|
|
+ this.unloadContent()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
if (this.tileset.options.contentLoader) {
|
|
|
await this.tileset.options.contentLoader(this);
|
|
|
}
|
|
@@ -9762,8 +9777,9 @@ const TILES_UNLOADED = 'Tiles Unloaded';
|
|
|
const TILES_LOAD_FAILED = 'Failed Tile Loads';
|
|
|
const POINTS_COUNT = 'Points';
|
|
|
const TILES_GPU_MEMORY = 'Tile Memory Use';
|
|
|
-class Tileset3D {
|
|
|
+class Tileset3D extends EventDispatcher{//xzw add EventDispatcher
|
|
|
constructor(json, options) {
|
|
|
+ super()
|
|
|
_defineProperty(this, "options", void 0);
|
|
|
|
|
|
_defineProperty(this, "loadOptions", void 0);
|
|
@@ -10181,11 +10197,14 @@ class Tileset3D {
|
|
|
this.stats.get(TILES_TOTAL).incrementCount();
|
|
|
const children = tile.header.children || [];
|
|
|
|
|
|
- for (const childHeader of children) {
|
|
|
- const childTile = new TileHeader(this, childHeader, tile);
|
|
|
- tile.children.push(childTile);
|
|
|
- childTile.depth = tile.depth + 1;
|
|
|
- stack.push(childTile);
|
|
|
+ // !zeg改
|
|
|
+ if(tile.depth < this.options.maxDepth){
|
|
|
+ for (const childHeader of children) {
|
|
|
+ const childTile = new TileHeader(this, childHeader, tile);
|
|
|
+ tile.children.push(childTile);
|
|
|
+ childTile.depth = tile.depth + 1;
|
|
|
+ stack.push(childTile);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -10230,7 +10249,7 @@ class Tileset3D {
|
|
|
} catch (error) {
|
|
|
this._onTileLoadError(tile, error);
|
|
|
} finally {
|
|
|
- this._onEndTileLoading();
|
|
|
+ this._onEndTileLoading(tile);//
|
|
|
|
|
|
this._onTileLoad(tile, loaded);
|
|
|
}
|
|
@@ -10263,9 +10282,10 @@ class Tileset3D {
|
|
|
this.stats.get(TILES_LOADING).incrementCount();
|
|
|
}
|
|
|
|
|
|
- _onEndTileLoading() {
|
|
|
+ _onEndTileLoading(tile) {
|
|
|
this._pendingCount--;
|
|
|
this.stats.get(TILES_LOADING).decrementCount();
|
|
|
+ this.dispatchEvent({type:'endTileLoading', tile, loadingCount: this._pendingCount }) // !zeg改
|
|
|
}
|
|
|
|
|
|
_addTileToCache(tile) {
|
|
@@ -16207,6 +16227,7 @@ async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, cont
|
|
|
return byteOffset;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
async function parseGltf3DTile(tile, arrayBuffer, options, context) {
|
|
|
tile.rotateYtoZ = true;
|
|
|
tile.gltfUpAxis = options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis ? options['3d-tiles'].assetGltfUpAxis : 'Y';
|
|
@@ -17266,7 +17287,7 @@ class Loader3DTiles {
|
|
|
});
|
|
|
let cameraReference = null;
|
|
|
let rendererReference = null;
|
|
|
- const gltfLoader = new GLTFLoader$1();
|
|
|
+ const gltfLoader = props.gltfLoader || new GLTFLoader$1(); //xzw改
|
|
|
let ktx2Loader = undefined;
|
|
|
let dracoLoader = undefined;
|
|
|
if (options.basisTranscoderPath) {
|
|
@@ -17291,6 +17312,7 @@ class Loader3DTiles {
|
|
|
updateTransforms: options.updateTransforms,
|
|
|
throttleRequests: options.throttleRequests,
|
|
|
maxRequests: options.maxRequests,
|
|
|
+ maxDepth: options.maxDepth || 50, // !zeg改
|
|
|
contentLoader: (tile) => __awaiter(this, void 0, void 0, function* () {
|
|
|
let tileContent = null;
|
|
|
switch (tile.type) {
|
|
@@ -17419,9 +17441,10 @@ class Loader3DTiles {
|
|
|
tileset.modelMatrix = new Matrix4(threeMat.toArray());
|
|
|
}
|
|
|
}
|
|
|
+ // 更新瓦片显隐和瓦片迭代更新
|
|
|
function tilesetUpdate(tileset, renderMap, renderer, camera) {
|
|
|
- if (disposeFlag) {
|
|
|
- return;
|
|
|
+ if (disposeFlag || options.pauseTilesetUpdate) {// !zeg改 pauseTilesetUpdate
|
|
|
+ return
|
|
|
}
|
|
|
// Assumes camera fov, near and far are not changing
|
|
|
if (!sseDenominator || camera.aspect != lastCameraAspect) {
|
|
@@ -17444,6 +17467,9 @@ class Loader3DTiles {
|
|
|
renderer.getSize(rendererSize);
|
|
|
const frameState = {
|
|
|
camera: {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
position: lastCameraPosition.toArray(),
|
|
|
},
|
|
|
height: rendererSize.y,
|
|
@@ -17456,6 +17482,7 @@ class Loader3DTiles {
|
|
|
};
|
|
|
tileset._cache.reset();
|
|
|
tileset._traverser.traverse(tileset.root, frameState, tileset.options);
|
|
|
+
|
|
|
for (const tile of tileset.tiles) {
|
|
|
if (tile.selected) {
|
|
|
if (!renderMap[tile.id]) {
|
|
@@ -17472,6 +17499,7 @@ class Loader3DTiles {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
while (unloadQueue.length > 0) {
|
|
|
const tile = unloadQueue.pop();
|
|
|
if (renderMap[tile.id] && tile.contentState == TILE_CONTENT_STATE.UNLOADED) {
|
|
@@ -17630,7 +17658,28 @@ class Loader3DTiles {
|
|
|
dracoLoader.dispose();
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
});
|
|
|
}
|
|
@@ -17649,9 +17698,17 @@ function createGLTFNodes(gltfLoader, tile, unlitMaterial, options, rootTransform
|
|
|
gltfLoader.parse(tile.content.gltfArrayBuffer, tile.contentUrl ? tile.contentUrl.substr(0, tile.contentUrl.lastIndexOf('/') + 1) : '', (gltf) => {
|
|
|
const tileContent = gltf.scenes[0];
|
|
|
tileContent.applyMatrix4(contentTransform);
|
|
|
+
|
|
|
+
|
|
|
+ // !zeg改
|
|
|
+
|
|
|
+ tileContent.position.set(tile.header.boundingVolume.box[0], tile.header.boundingVolume.box[1], tile.header.boundingVolume.box[2])//add
|
|
|
+ //这个链接需要加上这句https://testgis.4dage.com/LVBADUI_qp/tileset.json
|
|
|
+
|
|
|
tileContent.traverse((object) => {
|
|
|
if (object.type == "Mesh") {
|
|
|
const mesh = object;
|
|
|
+ //mesh.tileId = tile.id//add
|
|
|
const originalMaterial = mesh.material;
|
|
|
const originalMap = originalMaterial.map;
|
|
|
if (options.material) {
|