@itwin/core-frontend 4.1.0-dev.5 → 4.1.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/core-frontend.d.ts +3 -0
- package/lib/cjs/core-frontend.d.ts.map +1 -1
- package/lib/cjs/core-frontend.js +3 -0
- package/lib/cjs/core-frontend.js.map +1 -1
- package/lib/cjs/imdl/ImdlGraphicsCreator.d.ts +19 -0
- package/lib/cjs/imdl/ImdlGraphicsCreator.d.ts.map +1 -0
- package/lib/cjs/imdl/ImdlGraphicsCreator.js +328 -0
- package/lib/cjs/imdl/ImdlGraphicsCreator.js.map +1 -0
- package/lib/cjs/imdl/ImdlModel.d.ts +181 -0
- package/lib/cjs/imdl/ImdlModel.d.ts.map +1 -0
- package/lib/cjs/imdl/ImdlModel.js +10 -0
- package/lib/cjs/imdl/ImdlModel.js.map +1 -0
- package/lib/cjs/imdl/ImdlParser.d.ts +40 -0
- package/lib/cjs/imdl/ImdlParser.d.ts.map +1 -0
- package/lib/cjs/imdl/ImdlParser.js +996 -0
- package/lib/cjs/imdl/ImdlParser.js.map +1 -0
- package/lib/cjs/imdl/ImdlSchema.d.ts +380 -0
- package/lib/cjs/imdl/ImdlSchema.d.ts.map +1 -0
- package/lib/cjs/imdl/ImdlSchema.js +10 -0
- package/lib/cjs/imdl/ImdlSchema.js.map +1 -0
- package/lib/cjs/render/primitives/AuxChannelTable.d.ts +4 -0
- package/lib/cjs/render/primitives/AuxChannelTable.d.ts.map +1 -1
- package/lib/cjs/render/primitives/AuxChannelTable.js +33 -0
- package/lib/cjs/render/primitives/AuxChannelTable.js.map +1 -1
- package/lib/cjs/render/primitives/VertexTable.d.ts +3 -3
- package/lib/cjs/render/primitives/VertexTable.d.ts.map +1 -1
- package/lib/cjs/render/primitives/VertexTable.js.map +1 -1
- package/lib/cjs/render/primitives/VertexTableSplitter.d.ts +5 -1
- package/lib/cjs/render/primitives/VertexTableSplitter.d.ts.map +1 -1
- package/lib/cjs/render/primitives/VertexTableSplitter.js +13 -12
- package/lib/cjs/render/primitives/VertexTableSplitter.js.map +1 -1
- package/lib/cjs/tile/IModelTile.d.ts.map +1 -1
- package/lib/cjs/tile/IModelTile.js +14 -15
- package/lib/cjs/tile/IModelTile.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts +11 -420
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +64 -902
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/cjs/tile/map/MapTile.d.ts +6 -1
- package/lib/cjs/tile/map/MapTile.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTile.js +8 -7
- package/lib/cjs/tile/map/MapTile.js.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.js +8 -2
- package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
- package/lib/esm/core-frontend.d.ts +3 -0
- package/lib/esm/core-frontend.d.ts.map +1 -1
- package/lib/esm/core-frontend.js +3 -0
- package/lib/esm/core-frontend.js.map +1 -1
- package/lib/esm/imdl/ImdlGraphicsCreator.d.ts +19 -0
- package/lib/esm/imdl/ImdlGraphicsCreator.d.ts.map +1 -0
- package/lib/esm/imdl/ImdlGraphicsCreator.js +324 -0
- package/lib/esm/imdl/ImdlGraphicsCreator.js.map +1 -0
- package/lib/esm/imdl/ImdlModel.d.ts +181 -0
- package/lib/esm/imdl/ImdlModel.d.ts.map +1 -0
- package/lib/esm/imdl/ImdlModel.js +9 -0
- package/lib/esm/imdl/ImdlModel.js.map +1 -0
- package/lib/esm/imdl/ImdlParser.d.ts +40 -0
- package/lib/esm/imdl/ImdlParser.d.ts.map +1 -0
- package/lib/esm/imdl/ImdlParser.js +988 -0
- package/lib/esm/imdl/ImdlParser.js.map +1 -0
- package/lib/esm/imdl/ImdlSchema.d.ts +380 -0
- package/lib/esm/imdl/ImdlSchema.d.ts.map +1 -0
- package/lib/esm/imdl/ImdlSchema.js +9 -0
- package/lib/esm/imdl/ImdlSchema.js.map +1 -0
- package/lib/esm/render/primitives/AuxChannelTable.d.ts +4 -0
- package/lib/esm/render/primitives/AuxChannelTable.d.ts.map +1 -1
- package/lib/esm/render/primitives/AuxChannelTable.js +33 -0
- package/lib/esm/render/primitives/AuxChannelTable.js.map +1 -1
- package/lib/esm/render/primitives/VertexTable.d.ts +3 -3
- package/lib/esm/render/primitives/VertexTable.d.ts.map +1 -1
- package/lib/esm/render/primitives/VertexTable.js.map +1 -1
- package/lib/esm/render/primitives/VertexTableSplitter.d.ts +5 -1
- package/lib/esm/render/primitives/VertexTableSplitter.d.ts.map +1 -1
- package/lib/esm/render/primitives/VertexTableSplitter.js +13 -12
- package/lib/esm/render/primitives/VertexTableSplitter.js.map +1 -1
- package/lib/esm/tile/IModelTile.d.ts.map +1 -1
- package/lib/esm/tile/IModelTile.js +14 -15
- package/lib/esm/tile/IModelTile.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts +11 -420
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +67 -903
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/lib/esm/tile/map/MapTile.d.ts +6 -1
- package/lib/esm/tile/map/MapTile.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTile.js +8 -7
- package/lib/esm/tile/map/MapTile.js.map +1 -1
- package/lib/esm/tile/map/MapTileTree.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTileTree.js +8 -2
- package/lib/esm/tile/map/MapTileTree.js.map +1 -1
- package/package.json +18 -18
|
@@ -12,7 +12,6 @@ import { PointStringParams } from "./PointStringParams";
|
|
|
12
12
|
import { PolylineParams } from "./PolylineParams";
|
|
13
13
|
import { calculateEdgeTableParams } from "./EdgeParams";
|
|
14
14
|
import { createSurfaceMaterial } from "./SurfaceParams";
|
|
15
|
-
import { IModelApp } from "../../IModelApp";
|
|
16
15
|
/** Builds up a [[VertexIndices]].
|
|
17
16
|
* Exported strictly for tests.
|
|
18
17
|
*/
|
|
@@ -125,12 +124,13 @@ class ColorTableRemapper {
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
class MaterialAtlasRemapper {
|
|
128
|
-
constructor(_atlasTable) {
|
|
127
|
+
constructor(_atlasTable, createMaterial) {
|
|
129
128
|
this._remappedIndices = new Map();
|
|
130
129
|
this.materials = [];
|
|
131
130
|
this._32 = new Uint32Array(1);
|
|
132
131
|
this._8 = new Uint8Array(this._32.buffer);
|
|
133
132
|
this._atlasTable = _atlasTable;
|
|
133
|
+
this._createMaterial = createMaterial;
|
|
134
134
|
}
|
|
135
135
|
/** Extract the mat index stored in `vertex`, ensure it is present in the remapped atlas table, and return its index in that table. */
|
|
136
136
|
remap(vertex, usesUnquantizedPositions) {
|
|
@@ -177,7 +177,7 @@ class MaterialAtlasRemapper {
|
|
|
177
177
|
exponent: this.unpackFloat(entry[3]),
|
|
178
178
|
},
|
|
179
179
|
};
|
|
180
|
-
const material =
|
|
180
|
+
const material = this._createMaterial(args);
|
|
181
181
|
return createSurfaceMaterial(material);
|
|
182
182
|
}
|
|
183
183
|
/** Construct the finished color table. */
|
|
@@ -190,15 +190,15 @@ class MaterialAtlasRemapper {
|
|
|
190
190
|
/** A node in a split vertex table. Each node corresponds to one or more elements. */
|
|
191
191
|
class Node {
|
|
192
192
|
/** `vertexTable` is the source table containing vertex data for all nodes, from which this node will extract the vertices belong to it. */
|
|
193
|
-
constructor(vertexTable,
|
|
193
|
+
constructor(vertexTable, atlas) {
|
|
194
194
|
this.remappedIndices = new Map();
|
|
195
195
|
this.indices = new IndexBuffer();
|
|
196
196
|
this.vertices = new VertexBuffer(vertexTable);
|
|
197
197
|
if (undefined === vertexTable.uniformColor)
|
|
198
198
|
this.colors = new ColorTableRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + 4 * vertexTable.numVertices * vertexTable.numRgbaPerVertex));
|
|
199
|
-
if (
|
|
200
|
-
const atlasOffset = (vertexTable.numVertices * vertexTable.numRgbaPerVertex +
|
|
201
|
-
this.atlas = new MaterialAtlasRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + atlasOffset));
|
|
199
|
+
if (atlas) {
|
|
200
|
+
const atlasOffset = (vertexTable.numVertices * vertexTable.numRgbaPerVertex + atlas.offset) * 4;
|
|
201
|
+
this.atlas = new MaterialAtlasRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + atlasOffset), atlas.createMaterial);
|
|
202
202
|
}
|
|
203
203
|
this.usesUnquantizedPositions = vertexTable.usesUnquantizedPositions;
|
|
204
204
|
}
|
|
@@ -257,7 +257,7 @@ class VertexTableSplitter {
|
|
|
257
257
|
const nodeId = this._computeNodeId(featureIndex);
|
|
258
258
|
let node = this._nodes.get(nodeId);
|
|
259
259
|
if (undefined === node)
|
|
260
|
-
this._nodes.set(nodeId, node = new Node(this._input.vertices, this._input.
|
|
260
|
+
this._nodes.set(nodeId, node = new Node(this._input.vertices, this._input.atlasInfo));
|
|
261
261
|
curState.node = node;
|
|
262
262
|
}
|
|
263
263
|
// Add the vertex to the appropriate node.
|
|
@@ -438,7 +438,7 @@ function remapIndexedEdges(src, nodes, edges) {
|
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
function splitEdges(source, nodes) {
|
|
441
|
+
function splitEdges(source, nodes, maxDimension) {
|
|
442
442
|
const edges = new Map();
|
|
443
443
|
remapSegmentEdges("segments", source, nodes, edges);
|
|
444
444
|
remapSegmentEdges("silhouettes", source, nodes, edges);
|
|
@@ -455,7 +455,7 @@ function splitEdges(source, nodes) {
|
|
|
455
455
|
if (remappedEdges.indexed) {
|
|
456
456
|
const numSegmentEdges = remappedEdges.indexed.edges.length / 6;
|
|
457
457
|
const numSilhouettes = remappedEdges.indexed.silhouettes.length / 10;
|
|
458
|
-
const { width, height, silhouettePadding, silhouetteStartByteIndex } = calculateEdgeTableParams(numSegmentEdges, numSilhouettes,
|
|
458
|
+
const { width, height, silhouettePadding, silhouetteStartByteIndex } = calculateEdgeTableParams(numSegmentEdges, numSilhouettes, maxDimension);
|
|
459
459
|
const data = new Uint8Array(width * height * 4);
|
|
460
460
|
data.set(remappedEdges.indexed.edges.toTypedArray(), 0);
|
|
461
461
|
if (numSilhouettes > 0)
|
|
@@ -502,13 +502,14 @@ export function splitMeshParams(args) {
|
|
|
502
502
|
const result = new Map();
|
|
503
503
|
const mat = args.params.surface.material;
|
|
504
504
|
const atlasOffset = undefined !== mat && mat.isAtlas ? mat.vertexTableOffset : undefined;
|
|
505
|
+
const atlasInfo = atlasOffset ? { offset: atlasOffset, createMaterial: args.createMaterial } : undefined;
|
|
505
506
|
const nodes = VertexTableSplitter.split({
|
|
506
507
|
indices: args.params.surface.indices,
|
|
507
508
|
vertices: args.params.vertices,
|
|
508
509
|
featureTable: args.featureTable,
|
|
509
|
-
|
|
510
|
+
atlasInfo,
|
|
510
511
|
}, args.computeNodeId);
|
|
511
|
-
const edges = args.params.edges ? splitEdges(args.params.edges, nodes) : undefined;
|
|
512
|
+
const edges = args.params.edges ? splitEdges(args.params.edges, nodes, args.maxDimension) : undefined;
|
|
512
513
|
for (const [id, node] of nodes) {
|
|
513
514
|
const { vertices, indices, material } = node.buildOutput(args.maxDimension);
|
|
514
515
|
const params = new MeshParams(vertices, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VertexTableSplitter.js","sourceRoot":"","sources":["../../../../src/render/primitives/VertexTableSplitter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAsB,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,GAC1D,MAAM,eAAe,CAAC;AACv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AC,oBAAoB,CAAC,YAAY,EAAE;SAC/D,EACD,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,IAAI,CAAC,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;KACxB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { assert, Uint32ArrayBuilder, Uint8ArrayBuilder } from \"@itwin/core-bentley\";\r\nimport { ColorDef, RenderFeatureTable } from \"@itwin/core-common\";\r\nimport {\r\n computeDimensions, MeshParams, VertexIndices, VertexTable, VertexTableProps, VertexTableWithIndices,\r\n} from \"./VertexTable\";\r\nimport { PointStringParams } from \"./PointStringParams\";\r\nimport { PolylineParams, TesselatedPolyline } from \"./PolylineParams\";\r\nimport { calculateEdgeTableParams, EdgeParams, EdgeTable, IndexedEdgeParams } from \"./EdgeParams\";\r\nimport { createSurfaceMaterial, SurfaceMaterial } from \"./SurfaceParams\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { CreateRenderMaterialArgs } from \"../RenderMaterial\";\r\n\r\n/** Builds up a [[VertexIndices]].\r\n * Exported strictly for tests.\r\n */\r\nexport class IndexBuffer {\r\n private readonly _builder: Uint8ArrayBuilder;\r\n private readonly _index32 = new Uint32Array(1);\r\n private readonly _index8 = new Uint8Array(this._index32.buffer, 0, 3);\r\n\r\n public constructor(initialCapacity = 3) {\r\n this._builder = new Uint8ArrayBuilder({ initialCapacity: initialCapacity * 3 });\r\n }\r\n\r\n public get numIndices(): number {\r\n assert((this._builder.length % 3) === 0);\r\n return this._builder.length / 3;\r\n }\r\n\r\n public push(index: number): void {\r\n this._index32[0] = index;\r\n this._builder.append(this._index8);\r\n }\r\n\r\n public toVertexIndices(): VertexIndices {\r\n return new VertexIndices(this._builder.toTypedArray());\r\n }\r\n}\r\n\r\n/** Builds up a [[VertexTable]]. */\r\nclass VertexBuffer {\r\n private readonly _builder: Uint32ArrayBuilder;\r\n private readonly _source: VertexTable;\r\n\r\n /** `source` is the original table containing the vertex data from which individual vertices will be obtained. */\r\n public constructor(source: VertexTable) {\r\n this._source = source;\r\n this._builder = new Uint32ArrayBuilder({ initialCapacity: 3 * source.numRgbaPerVertex });\r\n }\r\n\r\n /** The number of vertices currently in the table. */\r\n public get length(): number {\r\n assert((this._builder.length % this.vertexSize) === 0);\r\n return this._builder.length / this.vertexSize;\r\n }\r\n\r\n /** The number of 32-bit unsigned integers (RGBA values) per vertex. */\r\n public get vertexSize(): number {\r\n return this._source.numRgbaPerVertex;\r\n }\r\n\r\n /** Append a vertex. `vertex` must be of size [[vertexSize]]. */\r\n public push(vertex: Uint32Array): void {\r\n assert(vertex.length === this.vertexSize);\r\n this._builder.append(vertex);\r\n }\r\n\r\n /** Construct the finished vertex table. */\r\n public buildVertexTable(maxDimension: number, colorTable: ColorTable | undefined, materialAtlasTable: MaterialAtlasTable): VertexTable {\r\n const source = this._source;\r\n colorTable = colorTable ?? source.uniformColor;\r\n assert(undefined !== colorTable);\r\n\r\n const colorTableLength = colorTable instanceof Uint32Array ? colorTable.length : 0;\r\n const materialAtlasTableLength = materialAtlasTable instanceof Uint32Array ? materialAtlasTable.length : 0;\r\n const dimensions = computeDimensions(this.length, this.vertexSize, colorTableLength + materialAtlasTableLength, maxDimension);\r\n\r\n let rgbaData = this._builder.toTypedArray();\r\n if (dimensions.width * dimensions.height > rgbaData.length) {\r\n const prevData = rgbaData;\r\n rgbaData = new Uint32Array(dimensions.width * dimensions.height);\r\n rgbaData.set(prevData, 0);\r\n }\r\n\r\n let tableSize = this.vertexSize * this.length;\r\n if (colorTable instanceof Uint32Array) {\r\n rgbaData.set(colorTable, tableSize);\r\n tableSize += colorTable.length;\r\n }\r\n\r\n if (materialAtlasTable instanceof Uint32Array)\r\n rgbaData.set(materialAtlasTable, tableSize);\r\n\r\n const tableProps: VertexTableProps = {\r\n data: new Uint8Array(rgbaData.buffer, rgbaData.byteOffset, rgbaData.byteLength),\r\n usesUnquantizedPositions: source.usesUnquantizedPositions,\r\n qparams: source.qparams,\r\n width: dimensions.width,\r\n height: dimensions.height,\r\n hasTranslucency: source.hasTranslucency,\r\n uniformColor: colorTable instanceof ColorDef ? colorTable : undefined,\r\n featureIndexType: source.featureIndexType,\r\n uniformFeatureID: source.uniformFeatureID,\r\n numVertices: this.length,\r\n numRgbaPerVertex: source.numRgbaPerVertex,\r\n uvParams: source.uvParams,\r\n };\r\n\r\n return new VertexTable(tableProps);\r\n }\r\n}\r\n\r\ntype ColorTable = Uint32Array | ColorDef;\r\n\r\n/** Remaps portions of a source color table into a filtered target color table. */\r\nclass ColorTableRemapper {\r\n private readonly _remappedIndices = new Map<number, number>();\r\n private readonly _colorTable: Uint32Array;\r\n public readonly colors: number[] = [];\r\n private readonly _32 = new Uint32Array(1);\r\n private readonly _16 = new Uint16Array(this._32.buffer);\r\n\r\n public constructor(colorTable: Uint32Array) {\r\n this._colorTable = colorTable;\r\n }\r\n\r\n /** Extract the color index stored in `vertex`, ensure it is present in the remapped color table, and return its index in that table. */\r\n public remap(vertex: Uint32Array, usesUnquantizedPositions: boolean | undefined): void {\r\n const vertIndex = usesUnquantizedPositions ? 4 : 1;\r\n const shortIndex = usesUnquantizedPositions ? 0 : 1;\r\n this._32[0] = vertex[vertIndex];\r\n const oldIndex = this._16[shortIndex];\r\n let newIndex = this._remappedIndices.get(oldIndex);\r\n if (undefined === newIndex) {\r\n newIndex = this.colors.length;\r\n this._remappedIndices.set(oldIndex, newIndex);\r\n const color = this._colorTable[oldIndex];\r\n this.colors.push(color);\r\n }\r\n\r\n this._16[shortIndex] = newIndex;\r\n vertex[vertIndex] = this._32[0];\r\n }\r\n\r\n /** Construct the finished color table. */\r\n public buildColorTable(): ColorTable {\r\n assert(this.colors.length > 0);\r\n return this.colors.length > 1 ? new Uint32Array(this.colors) : ColorDef.fromAbgr(this.colors[0]);\r\n }\r\n}\r\n\r\ntype MaterialAtlasTable = Uint32Array | SurfaceMaterial | undefined;\r\n\r\nclass MaterialAtlasRemapper {\r\n private readonly _remappedIndices = new Map<number, number>();\r\n private readonly _atlasTable: Uint32Array;\r\n public readonly materials: number[] = [];\r\n private readonly _32 = new Uint32Array(1);\r\n private readonly _8 = new Uint8Array(this._32.buffer);\r\n\r\n public constructor(_atlasTable: Uint32Array) {\r\n this._atlasTable = _atlasTable;\r\n }\r\n\r\n /** Extract the mat index stored in `vertex`, ensure it is present in the remapped atlas table, and return its index in that table. */\r\n public remap(vertex: Uint32Array, usesUnquantizedPositions: boolean | undefined): void {\r\n const vertIndex = usesUnquantizedPositions ? 3 : 2;\r\n this._32[0] = vertex[vertIndex];\r\n const oldIndex = this._8[3];\r\n let newIndex = this._remappedIndices.get(oldIndex);\r\n if (undefined === newIndex) {\r\n newIndex = this.materials.length / 4;\r\n this._remappedIndices.set(oldIndex, newIndex);\r\n let index = oldIndex * 4;\r\n this.materials.push(this._atlasTable[index++]);\r\n this.materials.push(this._atlasTable[index++]);\r\n this.materials.push(this._atlasTable[index++]);\r\n this.materials.push(this._atlasTable[index]);\r\n }\r\n\r\n this._8[3] = newIndex;\r\n vertex[vertIndex] = this._32[0];\r\n }\r\n\r\n private unpackFloat(value: number): number {\r\n this._32[0] = value;\r\n const valUint32 = this._32[0];\r\n const bias = 38.0;\r\n const temp = (valUint32 >>> 24) / 2.0;\r\n let exponent = Math.floor(temp);\r\n let sign = (temp - exponent) * 2.0;\r\n sign = -(sign * 2.0 - 1.0);\r\n const base = sign * (valUint32 & 0xffffff) / 16777216.0;\r\n exponent = exponent - bias;\r\n return base * Math.pow(10.0, exponent);\r\n }\r\n\r\n private materialFromAtlasEntry(entry: Uint32Array): SurfaceMaterial | undefined {\r\n const rgbOverridden = (entry[1] & 0x1000000) !== 0;\r\n const alphaOverridden = (entry[1] & 0x2000000) !== 0;\r\n const args: CreateRenderMaterialArgs = {\r\n alpha: alphaOverridden ? (entry[0] >>> 24) / 255.0 : undefined,\r\n diffuse: {\r\n color: rgbOverridden ? ColorDef.fromTbgr(entry[0] & 0xffffff) : undefined,\r\n weight: (entry[1] >>> 8) / 255.0,\r\n },\r\n specular: {\r\n color: ColorDef.fromTbgr(entry[2]),\r\n weight: ((entry[1] >>> 16) & 0xff) / 255.0,\r\n exponent: this.unpackFloat(entry[3]),\r\n },\r\n };\r\n const material = IModelApp.renderSystem.createRenderMaterial(args);\r\n return createSurfaceMaterial(material);\r\n }\r\n\r\n /** Construct the finished color table. */\r\n public buildAtlasTable(): MaterialAtlasTable {\r\n assert(this.materials.length > 0);\r\n const m = new Uint32Array(this.materials);\r\n return this.materials.length > 4 ? m : this.materialFromAtlasEntry(m);\r\n }\r\n}\r\n\r\n/** A node in a split vertex table. Each node corresponds to one or more elements. */\r\nclass Node {\r\n public readonly vertices: VertexBuffer;\r\n public readonly remappedIndices = new Map<number, number>();\r\n public readonly indices = new IndexBuffer();\r\n public readonly colors?: ColorTableRemapper;\r\n public readonly atlas?: MaterialAtlasRemapper;\r\n public readonly usesUnquantizedPositions?: boolean;\r\n\r\n /** `vertexTable` is the source table containing vertex data for all nodes, from which this node will extract the vertices belong to it. */\r\n public constructor(vertexTable: VertexTable, numColorsPrecedingAtlas: number | undefined) {\r\n this.vertices = new VertexBuffer(vertexTable);\r\n if (undefined === vertexTable.uniformColor)\r\n this.colors = new ColorTableRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + 4 * vertexTable.numVertices * vertexTable.numRgbaPerVertex));\r\n\r\n if (undefined !== numColorsPrecedingAtlas) {\r\n const atlasOffset = (vertexTable.numVertices * vertexTable.numRgbaPerVertex + numColorsPrecedingAtlas) * 4;\r\n this.atlas = new MaterialAtlasRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + atlasOffset));\r\n }\r\n\r\n this.usesUnquantizedPositions = vertexTable.usesUnquantizedPositions;\r\n }\r\n\r\n public addVertex(originalIndex: number, vertex: Uint32Array): void {\r\n let newIndex = this.remappedIndices.get(originalIndex);\r\n if (undefined === newIndex) {\r\n newIndex = this.vertices.length;\r\n this.remappedIndices.set(originalIndex, newIndex);\r\n\r\n this.colors?.remap(vertex, this.usesUnquantizedPositions);\r\n this.atlas?.remap(vertex, this.usesUnquantizedPositions);\r\n this.vertices.push(vertex);\r\n }\r\n\r\n this.indices.push(newIndex);\r\n }\r\n\r\n public buildOutput(maxDimension: number): VertexTableWithIndices {\r\n const materialAtlas = this.atlas?.buildAtlasTable();\r\n const material: SurfaceMaterial | undefined = (materialAtlas instanceof Uint32Array) ? undefined : materialAtlas;\r\n return {\r\n indices: this.indices.toVertexIndices(),\r\n vertices: this.vertices.buildVertexTable(maxDimension, this.colors?.buildColorTable(), materialAtlas),\r\n material,\r\n };\r\n }\r\n}\r\n\r\ninterface VertexTableSplitArgs extends VertexTableWithIndices {\r\n featureTable: RenderFeatureTable;\r\n atlasOffset?: number;\r\n}\r\n\r\nexport type ComputeAnimationNodeId = (featureIndex: number) => number;\r\n\r\nclass VertexTableSplitter {\r\n private readonly _input: VertexTableSplitArgs;\r\n private readonly _computeNodeId: ComputeAnimationNodeId;\r\n private readonly _nodes = new Map<number, Node>();\r\n\r\n private constructor(input: VertexTableSplitArgs, computeNodeId: ComputeAnimationNodeId) {\r\n this._input = input;\r\n this._computeNodeId = computeNodeId;\r\n }\r\n\r\n /** Split the source into one or more output nodes, returning a mapping of integer node Id to node. */\r\n public static split(source: VertexTableSplitArgs, computeNodeId: ComputeAnimationNodeId): Map<number, Node> {\r\n const splitter = new VertexTableSplitter(source, computeNodeId);\r\n splitter.split();\r\n return splitter._nodes;\r\n }\r\n\r\n private split(): void {\r\n // Track the most recent feature and corresponding node to avoid repeated lookups - vertices for\r\n // individual features are largely contiguous.\r\n const curState = {\r\n featureIndex: -1,\r\n node: undefined as unknown as Node,\r\n };\r\n\r\n const vertSize = this._input.vertices.numRgbaPerVertex;\r\n const vertex = new Uint32Array(vertSize);\r\n const vertexTable = new Uint32Array(this._input.vertices.data.buffer, this._input.vertices.data.byteOffset, this._input.vertices.numVertices * vertSize);\r\n\r\n for (const index of this._input.indices) {\r\n // Extract the data for this vertex without allocating new typed arrays.\r\n const vertexOffset = index * vertSize;\r\n for (let i = 0; i < vertex.length; i++)\r\n vertex[i] = vertexTable[vertexOffset + i];\r\n\r\n // Determine to which element the vertex belongs and find the corresponding Node.\r\n const featureIndex = vertex[2] & 0x00ffffff;\r\n if (curState.featureIndex !== featureIndex) {\r\n curState.featureIndex = featureIndex;\r\n const nodeId = this._computeNodeId(featureIndex);\r\n let node = this._nodes.get(nodeId);\r\n if (undefined === node)\r\n this._nodes.set(nodeId, node = new Node(this._input.vertices, this._input.atlasOffset));\r\n\r\n curState.node = node;\r\n }\r\n\r\n // Add the vertex to the appropriate node.\r\n curState.node.addVertex(index, vertex);\r\n }\r\n }\r\n}\r\n\r\nexport interface SplitVertexTableArgs {\r\n featureTable: RenderFeatureTable;\r\n maxDimension: number;\r\n computeNodeId: ComputeAnimationNodeId;\r\n}\r\n\r\nexport interface SplitPointStringArgs extends SplitVertexTableArgs {\r\n params: PointStringParams;\r\n}\r\n\r\n/** Given a PointStringParams and a function that can associate a node Id with an element Id, produce a mapping of nodes to PointStringParams, splitting up\r\n * the input params as needed.\r\n * @internal\r\n */\r\nexport function splitPointStringParams(args: SplitPointStringArgs): Map<number, PointStringParams> {\r\n const nodes = VertexTableSplitter.split({\r\n indices: args.params.indices,\r\n vertices: args.params.vertices,\r\n featureTable: args.featureTable,\r\n }, args.computeNodeId);\r\n\r\n const result = new Map<number, PointStringParams>();\r\n for (const [id, node] of nodes) {\r\n const { vertices, indices } = node.buildOutput(args.maxDimension);\r\n result.set(id, new PointStringParams(vertices, indices, args.params.weight));\r\n }\r\n\r\n return result;\r\n}\r\n\r\ninterface RemappedSegmentEdges {\r\n indices: IndexBuffer;\r\n endPointAndQuadIndices: Uint32ArrayBuilder;\r\n}\r\n\r\ninterface RemappedSilhouetteEdges extends RemappedSegmentEdges {\r\n normalPairs: Uint32ArrayBuilder;\r\n}\r\n\r\nclass RemappedPolylineEdges {\r\n public readonly indices = new IndexBuffer();\r\n public readonly prevIndices = new IndexBuffer();\r\n public readonly nextIndicesAndParams = new Uint32ArrayBuilder();\r\n}\r\n\r\ninterface RemappedIndexEdges {\r\n edges: Uint8ArrayBuilder;\r\n silhouettes: Uint8ArrayBuilder;\r\n}\r\n\r\ninterface RemappedEdges {\r\n segments?: RemappedSegmentEdges;\r\n silhouettes?: RemappedSilhouetteEdges;\r\n polylines?: RemappedPolylineEdges;\r\n indexed?: RemappedIndexEdges;\r\n}\r\n\r\ninterface RemappedIndex {\r\n node: Node;\r\n id: number;\r\n index: number;\r\n}\r\n\r\nfunction remapIndex(out: RemappedIndex, srcIndex: number, nodes: Map<number, Node>): boolean {\r\n for (const [id, node] of nodes) {\r\n const index = node.remappedIndices.get(srcIndex);\r\n if (undefined !== index) {\r\n out.index = index;\r\n out.node = node;\r\n out.id = id;\r\n return true;\r\n }\r\n }\r\n\r\n assert(false);\r\n return false;\r\n}\r\n\r\nfunction remapSegmentEdges(type: \"segments\" | \"silhouettes\", source: EdgeParams, nodes: Map<number, Node>, edges: Map<number, RemappedEdges>): void {\r\n const src = source[type];\r\n if (!src)\r\n return;\r\n\r\n const srcEndPts = new Uint32Array(src.endPointAndQuadIndices.buffer, src.endPointAndQuadIndices.byteOffset, src.endPointAndQuadIndices.length / 4);\r\n let srcNormalPairs;\r\n if (type === \"silhouettes\") {\r\n assert(undefined !== source.silhouettes);\r\n srcNormalPairs = new Uint32Array(source.silhouettes.normalPairs.buffer, source.silhouettes.normalPairs.byteOffset, source.silhouettes.normalPairs.length / 4);\r\n }\r\n\r\n let curIndexIndex = 0;\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n for (const srcIndex of src.indices) {\r\n if (remapIndex(remappedIndex, srcIndex, nodes)) {\r\n let endPointAndQuad = srcEndPts[curIndexIndex];\r\n const otherIndex = (endPointAndQuad & 0x00ffffff) >>> 0;\r\n const newOtherIndex = remappedIndex.node.remappedIndices.get(otherIndex);\r\n assert(undefined !== newOtherIndex);\r\n endPointAndQuad = (endPointAndQuad & 0xff000000) | newOtherIndex;\r\n\r\n let entry = edges.get(remappedIndex.id);\r\n if (!entry)\r\n edges.set(remappedIndex.id, entry = { });\r\n\r\n if (srcNormalPairs) {\r\n if (!entry.silhouettes)\r\n entry.silhouettes = { indices: new IndexBuffer(), endPointAndQuadIndices: new Uint32ArrayBuilder(), normalPairs: new Uint32ArrayBuilder() };\r\n\r\n entry.silhouettes.normalPairs.push(srcNormalPairs[curIndexIndex]);\r\n } else if (!entry.segments) {\r\n entry.segments = { indices: new IndexBuffer(), endPointAndQuadIndices: new Uint32ArrayBuilder() };\r\n }\r\n\r\n const segments = entry[type];\r\n assert(undefined !== segments);\r\n\r\n segments.indices.push(remappedIndex.index);\r\n segments.endPointAndQuadIndices.push(endPointAndQuad);\r\n }\r\n\r\n ++curIndexIndex;\r\n }\r\n}\r\n\r\nfunction remapPolylineEdges(src: TesselatedPolyline, nodes: Map<number, Node>, edges: Map<number, RemappedEdges>): void {\r\n const srcNextAndParam = new Uint32Array(src.nextIndicesAndParams.buffer, src.nextIndicesAndParams.byteOffset, src.nextIndicesAndParams.length / 4);\r\n const prevIter = src.prevIndices[Symbol.iterator]();\r\n let curIndexIndex = 0;\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n for (const srcIndex of src.indices) {\r\n if (remapIndex(remappedIndex, srcIndex, nodes)) {\r\n const prevIndex = prevIter.next().value;\r\n assert(undefined !== prevIndex);\r\n const newPrevIndex = remappedIndex.node.remappedIndices.get(prevIndex);\r\n assert(undefined !== newPrevIndex);\r\n\r\n let nextAndParam = srcNextAndParam[curIndexIndex];\r\n const nextIndex = (nextAndParam & 0x00ffffff) >>> 0;\r\n const newNextIndex = remappedIndex.node.remappedIndices.get(nextIndex);\r\n assert(undefined !== newNextIndex);\r\n nextAndParam = (nextAndParam & 0xff000000) | newNextIndex;\r\n\r\n let entry = edges.get(remappedIndex.id);\r\n if (!entry)\r\n edges.set(remappedIndex.id, entry = { });\r\n\r\n if (!entry.polylines)\r\n entry.polylines = new RemappedPolylineEdges();\r\n\r\n entry.polylines.indices.push(remappedIndex.index);\r\n entry.polylines.prevIndices.push(newPrevIndex);\r\n entry.polylines.nextIndicesAndParams.push(nextAndParam);\r\n }\r\n\r\n ++curIndexIndex;\r\n }\r\n}\r\n\r\nfunction remapIndexedEdges(src: IndexedEdgeParams, nodes: Map<number, Node>, edges: Map<number, RemappedEdges>): void {\r\n const srcEdgeData = src.edges.data;\r\n const numSegments = src.edges.numSegments;\r\n const silhouetteStartByteIndex = numSegments * 6 + src.edges.silhouettePadding;\r\n\r\n function getUint24EdgePair(byteIndex: number): [number, number] {\r\n return [srcEdgeData[byteIndex + 0] | (srcEdgeData[byteIndex + 1] << 8) | srcEdgeData[byteIndex + 2] << 16,\r\n srcEdgeData[byteIndex + 3] | (srcEdgeData[byteIndex + 4] << 8) | srcEdgeData[byteIndex + 5] << 16];\r\n }\r\n\r\n function setUint24EdgePair(indEdges: RemappedIndexEdges, value1: number, value2: number): void {\r\n indEdges.edges.push(value1 & 0x0000ff);\r\n indEdges.edges.push((value1 & 0x00ff00) >>> 8);\r\n indEdges.edges.push((value1 & 0xff0000) >>> 16);\r\n indEdges.edges.push(value2 & 0x0000ff);\r\n indEdges.edges.push((value2 & 0x00ff00) >>> 8);\r\n indEdges.edges.push((value2 & 0xff0000) >>> 16);\r\n }\r\n\r\n function getUint24SilPair(byteIndex: number): [number, number, number, number] {\r\n return [srcEdgeData[byteIndex + 0] | (srcEdgeData[byteIndex + 1] << 8) | srcEdgeData[byteIndex + 2] << 16,\r\n srcEdgeData[byteIndex + 3] | (srcEdgeData[byteIndex + 4] << 8) | srcEdgeData[byteIndex + 5] << 16,\r\n srcEdgeData[byteIndex + 6] | (srcEdgeData[byteIndex + 7] << 8), srcEdgeData[byteIndex + 8] | (srcEdgeData[byteIndex + 9] << 8)];\r\n }\r\n\r\n function setUint24SilPair(indSil: RemappedIndexEdges, value1: number, value2: number, norm1: number, norm2: number): void {\r\n indSil.silhouettes.push(value1 & 0x0000ff);\r\n indSil.silhouettes.push((value1 & 0x00ff00) >>> 8);\r\n indSil.silhouettes.push((value1 & 0xff0000) >>> 16);\r\n indSil.silhouettes.push(value2 & 0x0000ff);\r\n indSil.silhouettes.push((value2 & 0x00ff00) >>> 8);\r\n indSil.silhouettes.push((value2 & 0xff0000) >>> 16);\r\n indSil.silhouettes.push(norm1 & 0x0000ff);\r\n indSil.silhouettes.push((norm1 & 0x00ff00) >>> 8);\r\n indSil.silhouettes.push(norm2 & 0x0000ff);\r\n indSil.silhouettes.push((norm2 & 0x00ff00) >>> 8);\r\n }\r\n\r\n let maxIndex = 0;\r\n for (const srcIndex of src.indices)\r\n maxIndex = Math.max (srcIndex, maxIndex);\r\n\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n let es1Index = 0, es2Index = 0, n1 = 0, n2 = 0;\r\n for (let curSegment = 0, byteIndex = 0; curSegment <= maxIndex; ++curSegment) {\r\n if (curSegment < numSegments) { // edges\r\n [es1Index, es2Index] = getUint24EdgePair(byteIndex);\r\n byteIndex += 6;\r\n } else { // silhouettes\r\n byteIndex = silhouetteStartByteIndex + (curSegment - numSegments) * 10;\r\n [es1Index, es2Index, n1, n2] = getUint24SilPair(byteIndex);\r\n }\r\n\r\n if (remapIndex(remappedIndex, es1Index, nodes)) {\r\n let entry = edges.get(remappedIndex.id);\r\n if (!entry)\r\n edges.set(remappedIndex.id, entry = { });\r\n\r\n if (!entry.indexed)\r\n entry.indexed = { edges: new Uint8ArrayBuilder(), silhouettes: new Uint8ArrayBuilder() };\r\n\r\n if (curSegment < numSegments) { // edges\r\n const newE1Index = remappedIndex.node.remappedIndices.get(es1Index);\r\n assert(undefined !== newE1Index);\r\n const newE2Index = remappedIndex.node.remappedIndices.get(es2Index);\r\n assert(undefined !== newE2Index);\r\n setUint24EdgePair(entry.indexed, newE1Index, newE2Index);\r\n } else { // silhouettes\r\n const newS1Index = remappedIndex.node.remappedIndices.get(es1Index);\r\n assert(undefined !== newS1Index);\r\n const newS2Index = remappedIndex.node.remappedIndices.get(es2Index);\r\n assert(undefined !== newS2Index);\r\n setUint24SilPair(entry.indexed, newS1Index, newS2Index, n1, n2);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction splitEdges(source: EdgeParams, nodes: Map<number, Node>): Map<number, EdgeParams> {\r\n const edges = new Map<number, RemappedEdges>();\r\n remapSegmentEdges(\"segments\", source, nodes, edges);\r\n remapSegmentEdges(\"silhouettes\", source, nodes, edges);\r\n\r\n if (source.polylines)\r\n remapPolylineEdges(source.polylines, nodes, edges);\r\n\r\n if (source.indexed)\r\n remapIndexedEdges(source.indexed, nodes, edges);\r\n\r\n const result = new Map<number, EdgeParams>();\r\n for (const [id, remappedEdges] of edges) {\r\n if (!remappedEdges.segments && !remappedEdges.silhouettes && !remappedEdges.indexed)\r\n continue;\r\n\r\n let edgeTable = { } as unknown as EdgeTable;\r\n let edgeIndices = { } as unknown as VertexIndices;\r\n if (remappedEdges.indexed) {\r\n const numSegmentEdges = remappedEdges.indexed.edges.length / 6;\r\n const numSilhouettes = remappedEdges.indexed.silhouettes.length / 10;\r\n const { width, height, silhouettePadding, silhouetteStartByteIndex } = calculateEdgeTableParams(numSegmentEdges, numSilhouettes, IModelApp.renderSystem.maxTextureSize);\r\n const data = new Uint8Array(width * height * 4);\r\n data.set(remappedEdges.indexed.edges.toTypedArray(), 0);\r\n if (numSilhouettes > 0)\r\n data.set(remappedEdges.indexed.silhouettes.toTypedArray(), silhouetteStartByteIndex + silhouettePadding);\r\n\r\n const numTotalEdges = numSegmentEdges + numSilhouettes;\r\n edgeIndices = new VertexIndices(new Uint8Array(numTotalEdges * 6 * 3));\r\n for (let i = 0; i < numTotalEdges; i++)\r\n for (let j = 0; j < 6; j++)\r\n edgeIndices.setNthIndex(i * 6 + j, i);\r\n\r\n edgeTable = {\r\n data,\r\n width,\r\n height,\r\n numSegments: numSegmentEdges,\r\n silhouettePadding,\r\n };\r\n }\r\n\r\n result.set(id, {\r\n weight: source.weight,\r\n linePixels: source.linePixels,\r\n segments: remappedEdges.segments ? {\r\n indices: remappedEdges.segments.indices.toVertexIndices(),\r\n endPointAndQuadIndices: remappedEdges.segments.endPointAndQuadIndices.toUint8Array(),\r\n } : undefined,\r\n silhouettes: remappedEdges.silhouettes ? {\r\n indices: remappedEdges.silhouettes.indices.toVertexIndices(),\r\n endPointAndQuadIndices: remappedEdges.silhouettes.endPointAndQuadIndices.toUint8Array(),\r\n normalPairs: remappedEdges.silhouettes.normalPairs.toUint8Array(),\r\n } : undefined,\r\n polylines: remappedEdges.polylines ? {\r\n indices: remappedEdges.polylines.indices.toVertexIndices(),\r\n prevIndices: remappedEdges.polylines.prevIndices.toVertexIndices(),\r\n nextIndicesAndParams: remappedEdges.polylines.nextIndicesAndParams.toUint8Array(),\r\n } : undefined,\r\n indexed: remappedEdges.indexed ? {\r\n indices: edgeIndices,\r\n edges: edgeTable,\r\n } : undefined,\r\n });\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport interface SplitMeshArgs extends SplitVertexTableArgs {\r\n params: MeshParams;\r\n}\r\n\r\nexport function splitMeshParams(args: SplitMeshArgs): Map<number, MeshParams> {\r\n const result = new Map<number, MeshParams>();\r\n\r\n const mat = args.params.surface.material;\r\n const atlasOffset = undefined !== mat && mat.isAtlas ? mat.vertexTableOffset : undefined;\r\n\r\n const nodes = VertexTableSplitter.split({\r\n indices: args.params.surface.indices,\r\n vertices: args.params.vertices,\r\n featureTable: args.featureTable,\r\n atlasOffset,\r\n }, args.computeNodeId);\r\n\r\n const edges = args.params.edges ? splitEdges(args.params.edges, nodes) : undefined;\r\n\r\n for (const [id, node] of nodes) {\r\n const { vertices, indices, material } = node.buildOutput(args.maxDimension);\r\n const params = new MeshParams(\r\n vertices, {\r\n type: args.params.surface.type,\r\n indices,\r\n fillFlags: args.params.surface.fillFlags,\r\n hasBakedLighting: args.params.surface.hasBakedLighting,\r\n textureMapping: args.params.surface.textureMapping,\r\n material: material !== undefined ? material : args.params.surface.material,\r\n },\r\n edges?.get(id),\r\n args.params.isPlanar,\r\n // ###TODO handle aux channels.......\r\n args.params.auxChannels,\r\n );\r\n\r\n result.set(id, params);\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport interface SplitPolylineArgs extends SplitVertexTableArgs {\r\n params: PolylineParams;\r\n}\r\n\r\ninterface PolylineNode extends Node {\r\n prevIndices?: IndexBuffer;\r\n nextIndicesAndParams?: Uint32ArrayBuilder;\r\n}\r\n\r\nexport function splitPolylineParams(args: SplitPolylineArgs): Map<number, PolylineParams> {\r\n const nodes = VertexTableSplitter.split({\r\n indices: args.params.polyline.indices,\r\n vertices: args.params.vertices,\r\n featureTable: args.featureTable,\r\n }, args.computeNodeId) as Map<number, PolylineNode>;\r\n\r\n const src = args.params.polyline;\r\n const srcNextAndParam = new Uint32Array(src.nextIndicesAndParams.buffer, src.nextIndicesAndParams.byteOffset, src.nextIndicesAndParams.length / 4);\r\n let curIndexIndex = 0;\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n for (const prevIndex of src.prevIndices) {\r\n if (remapIndex(remappedIndex, prevIndex, nodes)) {\r\n const node = remappedIndex.node as PolylineNode;\r\n if (!node.prevIndices) {\r\n assert(undefined === node.nextIndicesAndParams);\r\n node.prevIndices = new IndexBuffer(node.indices.numIndices);\r\n node.nextIndicesAndParams = new Uint32ArrayBuilder({ initialCapacity: node.indices.numIndices });\r\n } else {\r\n assert(undefined !== node.nextIndicesAndParams);\r\n }\r\n\r\n node.prevIndices.push(remappedIndex.index);\r\n\r\n let nextAndParam = srcNextAndParam[curIndexIndex];\r\n const nextIndex = (nextAndParam & 0x00ffffff) >>> 0;\r\n const newNextIndex = remappedIndex.node.remappedIndices.get(nextIndex);\r\n assert(undefined !== newNextIndex);\r\n nextAndParam = (nextAndParam & 0xff000000) | newNextIndex;\r\n node.nextIndicesAndParams.push(nextAndParam);\r\n }\r\n\r\n ++curIndexIndex;\r\n }\r\n\r\n const result = new Map<number, PolylineParams>();\r\n for (const [id, node] of nodes) {\r\n assert(undefined !== node.prevIndices && undefined !== node.nextIndicesAndParams);\r\n const { vertices, indices } = node.buildOutput(args.maxDimension);\r\n const params = new PolylineParams(\r\n vertices, {\r\n indices,\r\n prevIndices: node.prevIndices.toVertexIndices(),\r\n nextIndicesAndParams: node.nextIndicesAndParams.toUint8Array(),\r\n },\r\n args.params.weight,\r\n args.params.linePixels,\r\n args.params.isPlanar,\r\n args.params.type);\r\n\r\n result.set(id, params);\r\n }\r\n\r\n return result;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"VertexTableSplitter.js","sourceRoot":"","sources":["../../../../src/render/primitives/VertexTableSplitter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAsC,MAAM,oBAAoB,CAAC;AAClF,OAAO,EACL,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,GAC1D,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAA4C,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,qBAAqB,EAAmB,MAAM,iBAAiB,CAAC;AAGzE;;GAEG;AACH,MAAM,OAAO,WAAW;IAKtB,YAAmB,eAAe,GAAG,CAAC;QAHrB,aAAQ,GAAG,IAA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AAC,QAAQ,EACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;KACxB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { assert, Uint32ArrayBuilder, Uint8ArrayBuilder } from \"@itwin/core-bentley\";\r\nimport { ColorDef, RenderFeatureTable, RenderMaterial } from \"@itwin/core-common\";\r\nimport {\r\n computeDimensions, MeshParams, VertexIndices, VertexTable, VertexTableParams, VertexTableWithIndices,\r\n} from \"./VertexTable\";\r\nimport { PointStringParams } from \"./PointStringParams\";\r\nimport { PolylineParams, TesselatedPolyline } from \"./PolylineParams\";\r\nimport { calculateEdgeTableParams, EdgeParams, EdgeTable, IndexedEdgeParams } from \"./EdgeParams\";\r\nimport { createSurfaceMaterial, SurfaceMaterial } from \"./SurfaceParams\";\r\nimport { CreateRenderMaterialArgs } from \"../RenderMaterial\";\r\n\r\n/** Builds up a [[VertexIndices]].\r\n * Exported strictly for tests.\r\n */\r\nexport class IndexBuffer {\r\n private readonly _builder: Uint8ArrayBuilder;\r\n private readonly _index32 = new Uint32Array(1);\r\n private readonly _index8 = new Uint8Array(this._index32.buffer, 0, 3);\r\n\r\n public constructor(initialCapacity = 3) {\r\n this._builder = new Uint8ArrayBuilder({ initialCapacity: initialCapacity * 3 });\r\n }\r\n\r\n public get numIndices(): number {\r\n assert((this._builder.length % 3) === 0);\r\n return this._builder.length / 3;\r\n }\r\n\r\n public push(index: number): void {\r\n this._index32[0] = index;\r\n this._builder.append(this._index8);\r\n }\r\n\r\n public toVertexIndices(): VertexIndices {\r\n return new VertexIndices(this._builder.toTypedArray());\r\n }\r\n}\r\n\r\n/** Builds up a [[VertexTable]]. */\r\nclass VertexBuffer {\r\n private readonly _builder: Uint32ArrayBuilder;\r\n private readonly _source: VertexTable;\r\n\r\n /** `source` is the original table containing the vertex data from which individual vertices will be obtained. */\r\n public constructor(source: VertexTable) {\r\n this._source = source;\r\n this._builder = new Uint32ArrayBuilder({ initialCapacity: 3 * source.numRgbaPerVertex });\r\n }\r\n\r\n /** The number of vertices currently in the table. */\r\n public get length(): number {\r\n assert((this._builder.length % this.vertexSize) === 0);\r\n return this._builder.length / this.vertexSize;\r\n }\r\n\r\n /** The number of 32-bit unsigned integers (RGBA values) per vertex. */\r\n public get vertexSize(): number {\r\n return this._source.numRgbaPerVertex;\r\n }\r\n\r\n /** Append a vertex. `vertex` must be of size [[vertexSize]]. */\r\n public push(vertex: Uint32Array): void {\r\n assert(vertex.length === this.vertexSize);\r\n this._builder.append(vertex);\r\n }\r\n\r\n /** Construct the finished vertex table. */\r\n public buildVertexTable(maxDimension: number, colorTable: ColorTable | undefined, materialAtlasTable: MaterialAtlasTable): VertexTable {\r\n const source = this._source;\r\n colorTable = colorTable ?? source.uniformColor;\r\n assert(undefined !== colorTable);\r\n\r\n const colorTableLength = colorTable instanceof Uint32Array ? colorTable.length : 0;\r\n const materialAtlasTableLength = materialAtlasTable instanceof Uint32Array ? materialAtlasTable.length : 0;\r\n const dimensions = computeDimensions(this.length, this.vertexSize, colorTableLength + materialAtlasTableLength, maxDimension);\r\n\r\n let rgbaData = this._builder.toTypedArray();\r\n if (dimensions.width * dimensions.height > rgbaData.length) {\r\n const prevData = rgbaData;\r\n rgbaData = new Uint32Array(dimensions.width * dimensions.height);\r\n rgbaData.set(prevData, 0);\r\n }\r\n\r\n let tableSize = this.vertexSize * this.length;\r\n if (colorTable instanceof Uint32Array) {\r\n rgbaData.set(colorTable, tableSize);\r\n tableSize += colorTable.length;\r\n }\r\n\r\n if (materialAtlasTable instanceof Uint32Array)\r\n rgbaData.set(materialAtlasTable, tableSize);\r\n\r\n const tableProps: VertexTableParams = {\r\n data: new Uint8Array(rgbaData.buffer, rgbaData.byteOffset, rgbaData.byteLength),\r\n usesUnquantizedPositions: source.usesUnquantizedPositions,\r\n qparams: source.qparams,\r\n width: dimensions.width,\r\n height: dimensions.height,\r\n hasTranslucency: source.hasTranslucency,\r\n uniformColor: colorTable instanceof ColorDef ? colorTable : undefined,\r\n featureIndexType: source.featureIndexType,\r\n uniformFeatureID: source.uniformFeatureID,\r\n numVertices: this.length,\r\n numRgbaPerVertex: source.numRgbaPerVertex,\r\n uvParams: source.uvParams,\r\n };\r\n\r\n return new VertexTable(tableProps);\r\n }\r\n}\r\n\r\ntype ColorTable = Uint32Array | ColorDef;\r\n\r\n/** Remaps portions of a source color table into a filtered target color table. */\r\nclass ColorTableRemapper {\r\n private readonly _remappedIndices = new Map<number, number>();\r\n private readonly _colorTable: Uint32Array;\r\n public readonly colors: number[] = [];\r\n private readonly _32 = new Uint32Array(1);\r\n private readonly _16 = new Uint16Array(this._32.buffer);\r\n\r\n public constructor(colorTable: Uint32Array) {\r\n this._colorTable = colorTable;\r\n }\r\n\r\n /** Extract the color index stored in `vertex`, ensure it is present in the remapped color table, and return its index in that table. */\r\n public remap(vertex: Uint32Array, usesUnquantizedPositions: boolean | undefined): void {\r\n const vertIndex = usesUnquantizedPositions ? 4 : 1;\r\n const shortIndex = usesUnquantizedPositions ? 0 : 1;\r\n this._32[0] = vertex[vertIndex];\r\n const oldIndex = this._16[shortIndex];\r\n let newIndex = this._remappedIndices.get(oldIndex);\r\n if (undefined === newIndex) {\r\n newIndex = this.colors.length;\r\n this._remappedIndices.set(oldIndex, newIndex);\r\n const color = this._colorTable[oldIndex];\r\n this.colors.push(color);\r\n }\r\n\r\n this._16[shortIndex] = newIndex;\r\n vertex[vertIndex] = this._32[0];\r\n }\r\n\r\n /** Construct the finished color table. */\r\n public buildColorTable(): ColorTable {\r\n assert(this.colors.length > 0);\r\n return this.colors.length > 1 ? new Uint32Array(this.colors) : ColorDef.fromAbgr(this.colors[0]);\r\n }\r\n}\r\n\r\ntype MaterialAtlasTable = Uint32Array | SurfaceMaterial | undefined;\r\n\r\ntype CreateRenderMaterial = (args: CreateRenderMaterialArgs) => RenderMaterial | undefined;\r\n\r\nclass MaterialAtlasRemapper {\r\n private readonly _remappedIndices = new Map<number, number>();\r\n private readonly _atlasTable: Uint32Array;\r\n private readonly _createMaterial: CreateRenderMaterial;\r\n public readonly materials: number[] = [];\r\n private readonly _32 = new Uint32Array(1);\r\n private readonly _8 = new Uint8Array(this._32.buffer);\r\n\r\n public constructor(_atlasTable: Uint32Array, createMaterial: CreateRenderMaterial) {\r\n this._atlasTable = _atlasTable;\r\n this._createMaterial = createMaterial;\r\n }\r\n\r\n /** Extract the mat index stored in `vertex`, ensure it is present in the remapped atlas table, and return its index in that table. */\r\n public remap(vertex: Uint32Array, usesUnquantizedPositions: boolean | undefined): void {\r\n const vertIndex = usesUnquantizedPositions ? 3 : 2;\r\n this._32[0] = vertex[vertIndex];\r\n const oldIndex = this._8[3];\r\n let newIndex = this._remappedIndices.get(oldIndex);\r\n if (undefined === newIndex) {\r\n newIndex = this.materials.length / 4;\r\n this._remappedIndices.set(oldIndex, newIndex);\r\n let index = oldIndex * 4;\r\n this.materials.push(this._atlasTable[index++]);\r\n this.materials.push(this._atlasTable[index++]);\r\n this.materials.push(this._atlasTable[index++]);\r\n this.materials.push(this._atlasTable[index]);\r\n }\r\n\r\n this._8[3] = newIndex;\r\n vertex[vertIndex] = this._32[0];\r\n }\r\n\r\n private unpackFloat(value: number): number {\r\n this._32[0] = value;\r\n const valUint32 = this._32[0];\r\n const bias = 38.0;\r\n const temp = (valUint32 >>> 24) / 2.0;\r\n let exponent = Math.floor(temp);\r\n let sign = (temp - exponent) * 2.0;\r\n sign = -(sign * 2.0 - 1.0);\r\n const base = sign * (valUint32 & 0xffffff) / 16777216.0;\r\n exponent = exponent - bias;\r\n return base * Math.pow(10.0, exponent);\r\n }\r\n\r\n private materialFromAtlasEntry(entry: Uint32Array): SurfaceMaterial | undefined {\r\n const rgbOverridden = (entry[1] & 0x1000000) !== 0;\r\n const alphaOverridden = (entry[1] & 0x2000000) !== 0;\r\n const args: CreateRenderMaterialArgs = {\r\n alpha: alphaOverridden ? (entry[0] >>> 24) / 255.0 : undefined,\r\n diffuse: {\r\n color: rgbOverridden ? ColorDef.fromTbgr(entry[0] & 0xffffff) : undefined,\r\n weight: (entry[1] >>> 8) / 255.0,\r\n },\r\n specular: {\r\n color: ColorDef.fromTbgr(entry[2]),\r\n weight: ((entry[1] >>> 16) & 0xff) / 255.0,\r\n exponent: this.unpackFloat(entry[3]),\r\n },\r\n };\r\n\r\n const material = this._createMaterial(args);\r\n return createSurfaceMaterial(material);\r\n }\r\n\r\n /** Construct the finished color table. */\r\n public buildAtlasTable(): MaterialAtlasTable {\r\n assert(this.materials.length > 0);\r\n const m = new Uint32Array(this.materials);\r\n return this.materials.length > 4 ? m : this.materialFromAtlasEntry(m);\r\n }\r\n}\r\n\r\n/** A node in a split vertex table. Each node corresponds to one or more elements. */\r\nclass Node {\r\n public readonly vertices: VertexBuffer;\r\n public readonly remappedIndices = new Map<number, number>();\r\n public readonly indices = new IndexBuffer();\r\n public readonly colors?: ColorTableRemapper;\r\n public readonly atlas?: MaterialAtlasRemapper;\r\n public readonly usesUnquantizedPositions?: boolean;\r\n\r\n /** `vertexTable` is the source table containing vertex data for all nodes, from which this node will extract the vertices belong to it. */\r\n public constructor(vertexTable: VertexTable, atlas?: AtlasInfo) {\r\n this.vertices = new VertexBuffer(vertexTable);\r\n if (undefined === vertexTable.uniformColor)\r\n this.colors = new ColorTableRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + 4 * vertexTable.numVertices * vertexTable.numRgbaPerVertex));\r\n\r\n if (atlas) {\r\n const atlasOffset = (vertexTable.numVertices * vertexTable.numRgbaPerVertex + atlas.offset) * 4;\r\n this.atlas = new MaterialAtlasRemapper(new Uint32Array(vertexTable.data.buffer, vertexTable.data.byteOffset + atlasOffset), atlas.createMaterial);\r\n }\r\n\r\n this.usesUnquantizedPositions = vertexTable.usesUnquantizedPositions;\r\n }\r\n\r\n public addVertex(originalIndex: number, vertex: Uint32Array): void {\r\n let newIndex = this.remappedIndices.get(originalIndex);\r\n if (undefined === newIndex) {\r\n newIndex = this.vertices.length;\r\n this.remappedIndices.set(originalIndex, newIndex);\r\n\r\n this.colors?.remap(vertex, this.usesUnquantizedPositions);\r\n this.atlas?.remap(vertex, this.usesUnquantizedPositions);\r\n this.vertices.push(vertex);\r\n }\r\n\r\n this.indices.push(newIndex);\r\n }\r\n\r\n public buildOutput(maxDimension: number): VertexTableWithIndices {\r\n const materialAtlas = this.atlas?.buildAtlasTable();\r\n const material: SurfaceMaterial | undefined = (materialAtlas instanceof Uint32Array) ? undefined : materialAtlas;\r\n return {\r\n indices: this.indices.toVertexIndices(),\r\n vertices: this.vertices.buildVertexTable(maxDimension, this.colors?.buildColorTable(), materialAtlas),\r\n material,\r\n };\r\n }\r\n}\r\n\r\ninterface AtlasInfo {\r\n offset: number;\r\n createMaterial: CreateRenderMaterial;\r\n}\r\n\r\ninterface VertexTableSplitArgs extends VertexTableWithIndices {\r\n featureTable: RenderFeatureTable;\r\n atlasInfo?: AtlasInfo;\r\n}\r\n\r\nexport type ComputeAnimationNodeId = (featureIndex: number) => number;\r\n\r\nclass VertexTableSplitter {\r\n private readonly _input: VertexTableSplitArgs;\r\n private readonly _computeNodeId: ComputeAnimationNodeId;\r\n private readonly _nodes = new Map<number, Node>();\r\n\r\n private constructor(input: VertexTableSplitArgs, computeNodeId: ComputeAnimationNodeId) {\r\n this._input = input;\r\n this._computeNodeId = computeNodeId;\r\n }\r\n\r\n /** Split the source into one or more output nodes, returning a mapping of integer node Id to node. */\r\n public static split(source: VertexTableSplitArgs, computeNodeId: ComputeAnimationNodeId): Map<number, Node> {\r\n const splitter = new VertexTableSplitter(source, computeNodeId);\r\n splitter.split();\r\n return splitter._nodes;\r\n }\r\n\r\n private split(): void {\r\n // Track the most recent feature and corresponding node to avoid repeated lookups - vertices for\r\n // individual features are largely contiguous.\r\n const curState = {\r\n featureIndex: -1,\r\n node: undefined as unknown as Node,\r\n };\r\n\r\n const vertSize = this._input.vertices.numRgbaPerVertex;\r\n const vertex = new Uint32Array(vertSize);\r\n const vertexTable = new Uint32Array(this._input.vertices.data.buffer, this._input.vertices.data.byteOffset, this._input.vertices.numVertices * vertSize);\r\n\r\n for (const index of this._input.indices) {\r\n // Extract the data for this vertex without allocating new typed arrays.\r\n const vertexOffset = index * vertSize;\r\n for (let i = 0; i < vertex.length; i++)\r\n vertex[i] = vertexTable[vertexOffset + i];\r\n\r\n // Determine to which element the vertex belongs and find the corresponding Node.\r\n const featureIndex = vertex[2] & 0x00ffffff;\r\n if (curState.featureIndex !== featureIndex) {\r\n curState.featureIndex = featureIndex;\r\n const nodeId = this._computeNodeId(featureIndex);\r\n let node = this._nodes.get(nodeId);\r\n if (undefined === node)\r\n this._nodes.set(nodeId, node = new Node(this._input.vertices, this._input.atlasInfo));\r\n\r\n curState.node = node;\r\n }\r\n\r\n // Add the vertex to the appropriate node.\r\n curState.node.addVertex(index, vertex);\r\n }\r\n }\r\n}\r\n\r\nexport interface SplitVertexTableArgs {\r\n featureTable: RenderFeatureTable;\r\n maxDimension: number;\r\n computeNodeId: ComputeAnimationNodeId;\r\n}\r\n\r\nexport interface SplitPointStringArgs extends SplitVertexTableArgs {\r\n params: PointStringParams;\r\n}\r\n\r\n/** Given a PointStringParams and a function that can associate a node Id with an element Id, produce a mapping of nodes to PointStringParams, splitting up\r\n * the input params as needed.\r\n * @internal\r\n */\r\nexport function splitPointStringParams(args: SplitPointStringArgs): Map<number, PointStringParams> {\r\n const nodes = VertexTableSplitter.split({\r\n indices: args.params.indices,\r\n vertices: args.params.vertices,\r\n featureTable: args.featureTable,\r\n }, args.computeNodeId);\r\n\r\n const result = new Map<number, PointStringParams>();\r\n for (const [id, node] of nodes) {\r\n const { vertices, indices } = node.buildOutput(args.maxDimension);\r\n result.set(id, new PointStringParams(vertices, indices, args.params.weight));\r\n }\r\n\r\n return result;\r\n}\r\n\r\ninterface RemappedSegmentEdges {\r\n indices: IndexBuffer;\r\n endPointAndQuadIndices: Uint32ArrayBuilder;\r\n}\r\n\r\ninterface RemappedSilhouetteEdges extends RemappedSegmentEdges {\r\n normalPairs: Uint32ArrayBuilder;\r\n}\r\n\r\nclass RemappedPolylineEdges {\r\n public readonly indices = new IndexBuffer();\r\n public readonly prevIndices = new IndexBuffer();\r\n public readonly nextIndicesAndParams = new Uint32ArrayBuilder();\r\n}\r\n\r\ninterface RemappedIndexEdges {\r\n edges: Uint8ArrayBuilder;\r\n silhouettes: Uint8ArrayBuilder;\r\n}\r\n\r\ninterface RemappedEdges {\r\n segments?: RemappedSegmentEdges;\r\n silhouettes?: RemappedSilhouetteEdges;\r\n polylines?: RemappedPolylineEdges;\r\n indexed?: RemappedIndexEdges;\r\n}\r\n\r\ninterface RemappedIndex {\r\n node: Node;\r\n id: number;\r\n index: number;\r\n}\r\n\r\nfunction remapIndex(out: RemappedIndex, srcIndex: number, nodes: Map<number, Node>): boolean {\r\n for (const [id, node] of nodes) {\r\n const index = node.remappedIndices.get(srcIndex);\r\n if (undefined !== index) {\r\n out.index = index;\r\n out.node = node;\r\n out.id = id;\r\n return true;\r\n }\r\n }\r\n\r\n assert(false);\r\n return false;\r\n}\r\n\r\nfunction remapSegmentEdges(type: \"segments\" | \"silhouettes\", source: EdgeParams, nodes: Map<number, Node>, edges: Map<number, RemappedEdges>): void {\r\n const src = source[type];\r\n if (!src)\r\n return;\r\n\r\n const srcEndPts = new Uint32Array(src.endPointAndQuadIndices.buffer, src.endPointAndQuadIndices.byteOffset, src.endPointAndQuadIndices.length / 4);\r\n let srcNormalPairs;\r\n if (type === \"silhouettes\") {\r\n assert(undefined !== source.silhouettes);\r\n srcNormalPairs = new Uint32Array(source.silhouettes.normalPairs.buffer, source.silhouettes.normalPairs.byteOffset, source.silhouettes.normalPairs.length / 4);\r\n }\r\n\r\n let curIndexIndex = 0;\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n for (const srcIndex of src.indices) {\r\n if (remapIndex(remappedIndex, srcIndex, nodes)) {\r\n let endPointAndQuad = srcEndPts[curIndexIndex];\r\n const otherIndex = (endPointAndQuad & 0x00ffffff) >>> 0;\r\n const newOtherIndex = remappedIndex.node.remappedIndices.get(otherIndex);\r\n assert(undefined !== newOtherIndex);\r\n endPointAndQuad = (endPointAndQuad & 0xff000000) | newOtherIndex;\r\n\r\n let entry = edges.get(remappedIndex.id);\r\n if (!entry)\r\n edges.set(remappedIndex.id, entry = { });\r\n\r\n if (srcNormalPairs) {\r\n if (!entry.silhouettes)\r\n entry.silhouettes = { indices: new IndexBuffer(), endPointAndQuadIndices: new Uint32ArrayBuilder(), normalPairs: new Uint32ArrayBuilder() };\r\n\r\n entry.silhouettes.normalPairs.push(srcNormalPairs[curIndexIndex]);\r\n } else if (!entry.segments) {\r\n entry.segments = { indices: new IndexBuffer(), endPointAndQuadIndices: new Uint32ArrayBuilder() };\r\n }\r\n\r\n const segments = entry[type];\r\n assert(undefined !== segments);\r\n\r\n segments.indices.push(remappedIndex.index);\r\n segments.endPointAndQuadIndices.push(endPointAndQuad);\r\n }\r\n\r\n ++curIndexIndex;\r\n }\r\n}\r\n\r\nfunction remapPolylineEdges(src: TesselatedPolyline, nodes: Map<number, Node>, edges: Map<number, RemappedEdges>): void {\r\n const srcNextAndParam = new Uint32Array(src.nextIndicesAndParams.buffer, src.nextIndicesAndParams.byteOffset, src.nextIndicesAndParams.length / 4);\r\n const prevIter = src.prevIndices[Symbol.iterator]();\r\n let curIndexIndex = 0;\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n for (const srcIndex of src.indices) {\r\n if (remapIndex(remappedIndex, srcIndex, nodes)) {\r\n const prevIndex = prevIter.next().value;\r\n assert(undefined !== prevIndex);\r\n const newPrevIndex = remappedIndex.node.remappedIndices.get(prevIndex);\r\n assert(undefined !== newPrevIndex);\r\n\r\n let nextAndParam = srcNextAndParam[curIndexIndex];\r\n const nextIndex = (nextAndParam & 0x00ffffff) >>> 0;\r\n const newNextIndex = remappedIndex.node.remappedIndices.get(nextIndex);\r\n assert(undefined !== newNextIndex);\r\n nextAndParam = (nextAndParam & 0xff000000) | newNextIndex;\r\n\r\n let entry = edges.get(remappedIndex.id);\r\n if (!entry)\r\n edges.set(remappedIndex.id, entry = { });\r\n\r\n if (!entry.polylines)\r\n entry.polylines = new RemappedPolylineEdges();\r\n\r\n entry.polylines.indices.push(remappedIndex.index);\r\n entry.polylines.prevIndices.push(newPrevIndex);\r\n entry.polylines.nextIndicesAndParams.push(nextAndParam);\r\n }\r\n\r\n ++curIndexIndex;\r\n }\r\n}\r\n\r\nfunction remapIndexedEdges(src: IndexedEdgeParams, nodes: Map<number, Node>, edges: Map<number, RemappedEdges>): void {\r\n const srcEdgeData = src.edges.data;\r\n const numSegments = src.edges.numSegments;\r\n const silhouetteStartByteIndex = numSegments * 6 + src.edges.silhouettePadding;\r\n\r\n function getUint24EdgePair(byteIndex: number): [number, number] {\r\n return [srcEdgeData[byteIndex + 0] | (srcEdgeData[byteIndex + 1] << 8) | srcEdgeData[byteIndex + 2] << 16,\r\n srcEdgeData[byteIndex + 3] | (srcEdgeData[byteIndex + 4] << 8) | srcEdgeData[byteIndex + 5] << 16];\r\n }\r\n\r\n function setUint24EdgePair(indEdges: RemappedIndexEdges, value1: number, value2: number): void {\r\n indEdges.edges.push(value1 & 0x0000ff);\r\n indEdges.edges.push((value1 & 0x00ff00) >>> 8);\r\n indEdges.edges.push((value1 & 0xff0000) >>> 16);\r\n indEdges.edges.push(value2 & 0x0000ff);\r\n indEdges.edges.push((value2 & 0x00ff00) >>> 8);\r\n indEdges.edges.push((value2 & 0xff0000) >>> 16);\r\n }\r\n\r\n function getUint24SilPair(byteIndex: number): [number, number, number, number] {\r\n return [srcEdgeData[byteIndex + 0] | (srcEdgeData[byteIndex + 1] << 8) | srcEdgeData[byteIndex + 2] << 16,\r\n srcEdgeData[byteIndex + 3] | (srcEdgeData[byteIndex + 4] << 8) | srcEdgeData[byteIndex + 5] << 16,\r\n srcEdgeData[byteIndex + 6] | (srcEdgeData[byteIndex + 7] << 8), srcEdgeData[byteIndex + 8] | (srcEdgeData[byteIndex + 9] << 8)];\r\n }\r\n\r\n function setUint24SilPair(indSil: RemappedIndexEdges, value1: number, value2: number, norm1: number, norm2: number): void {\r\n indSil.silhouettes.push(value1 & 0x0000ff);\r\n indSil.silhouettes.push((value1 & 0x00ff00) >>> 8);\r\n indSil.silhouettes.push((value1 & 0xff0000) >>> 16);\r\n indSil.silhouettes.push(value2 & 0x0000ff);\r\n indSil.silhouettes.push((value2 & 0x00ff00) >>> 8);\r\n indSil.silhouettes.push((value2 & 0xff0000) >>> 16);\r\n indSil.silhouettes.push(norm1 & 0x0000ff);\r\n indSil.silhouettes.push((norm1 & 0x00ff00) >>> 8);\r\n indSil.silhouettes.push(norm2 & 0x0000ff);\r\n indSil.silhouettes.push((norm2 & 0x00ff00) >>> 8);\r\n }\r\n\r\n let maxIndex = 0;\r\n for (const srcIndex of src.indices)\r\n maxIndex = Math.max (srcIndex, maxIndex);\r\n\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n let es1Index = 0, es2Index = 0, n1 = 0, n2 = 0;\r\n for (let curSegment = 0, byteIndex = 0; curSegment <= maxIndex; ++curSegment) {\r\n if (curSegment < numSegments) { // edges\r\n [es1Index, es2Index] = getUint24EdgePair(byteIndex);\r\n byteIndex += 6;\r\n } else { // silhouettes\r\n byteIndex = silhouetteStartByteIndex + (curSegment - numSegments) * 10;\r\n [es1Index, es2Index, n1, n2] = getUint24SilPair(byteIndex);\r\n }\r\n\r\n if (remapIndex(remappedIndex, es1Index, nodes)) {\r\n let entry = edges.get(remappedIndex.id);\r\n if (!entry)\r\n edges.set(remappedIndex.id, entry = { });\r\n\r\n if (!entry.indexed)\r\n entry.indexed = { edges: new Uint8ArrayBuilder(), silhouettes: new Uint8ArrayBuilder() };\r\n\r\n if (curSegment < numSegments) { // edges\r\n const newE1Index = remappedIndex.node.remappedIndices.get(es1Index);\r\n assert(undefined !== newE1Index);\r\n const newE2Index = remappedIndex.node.remappedIndices.get(es2Index);\r\n assert(undefined !== newE2Index);\r\n setUint24EdgePair(entry.indexed, newE1Index, newE2Index);\r\n } else { // silhouettes\r\n const newS1Index = remappedIndex.node.remappedIndices.get(es1Index);\r\n assert(undefined !== newS1Index);\r\n const newS2Index = remappedIndex.node.remappedIndices.get(es2Index);\r\n assert(undefined !== newS2Index);\r\n setUint24SilPair(entry.indexed, newS1Index, newS2Index, n1, n2);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction splitEdges(source: EdgeParams, nodes: Map<number, Node>, maxDimension: number): Map<number, EdgeParams> {\r\n const edges = new Map<number, RemappedEdges>();\r\n remapSegmentEdges(\"segments\", source, nodes, edges);\r\n remapSegmentEdges(\"silhouettes\", source, nodes, edges);\r\n\r\n if (source.polylines)\r\n remapPolylineEdges(source.polylines, nodes, edges);\r\n\r\n if (source.indexed)\r\n remapIndexedEdges(source.indexed, nodes, edges);\r\n\r\n const result = new Map<number, EdgeParams>();\r\n for (const [id, remappedEdges] of edges) {\r\n if (!remappedEdges.segments && !remappedEdges.silhouettes && !remappedEdges.indexed)\r\n continue;\r\n\r\n let edgeTable = { } as unknown as EdgeTable;\r\n let edgeIndices = { } as unknown as VertexIndices;\r\n if (remappedEdges.indexed) {\r\n const numSegmentEdges = remappedEdges.indexed.edges.length / 6;\r\n const numSilhouettes = remappedEdges.indexed.silhouettes.length / 10;\r\n const { width, height, silhouettePadding, silhouetteStartByteIndex } = calculateEdgeTableParams(numSegmentEdges, numSilhouettes, maxDimension);\r\n const data = new Uint8Array(width * height * 4);\r\n data.set(remappedEdges.indexed.edges.toTypedArray(), 0);\r\n if (numSilhouettes > 0)\r\n data.set(remappedEdges.indexed.silhouettes.toTypedArray(), silhouetteStartByteIndex + silhouettePadding);\r\n\r\n const numTotalEdges = numSegmentEdges + numSilhouettes;\r\n edgeIndices = new VertexIndices(new Uint8Array(numTotalEdges * 6 * 3));\r\n for (let i = 0; i < numTotalEdges; i++)\r\n for (let j = 0; j < 6; j++)\r\n edgeIndices.setNthIndex(i * 6 + j, i);\r\n\r\n edgeTable = {\r\n data,\r\n width,\r\n height,\r\n numSegments: numSegmentEdges,\r\n silhouettePadding,\r\n };\r\n }\r\n\r\n result.set(id, {\r\n weight: source.weight,\r\n linePixels: source.linePixels,\r\n segments: remappedEdges.segments ? {\r\n indices: remappedEdges.segments.indices.toVertexIndices(),\r\n endPointAndQuadIndices: remappedEdges.segments.endPointAndQuadIndices.toUint8Array(),\r\n } : undefined,\r\n silhouettes: remappedEdges.silhouettes ? {\r\n indices: remappedEdges.silhouettes.indices.toVertexIndices(),\r\n endPointAndQuadIndices: remappedEdges.silhouettes.endPointAndQuadIndices.toUint8Array(),\r\n normalPairs: remappedEdges.silhouettes.normalPairs.toUint8Array(),\r\n } : undefined,\r\n polylines: remappedEdges.polylines ? {\r\n indices: remappedEdges.polylines.indices.toVertexIndices(),\r\n prevIndices: remappedEdges.polylines.prevIndices.toVertexIndices(),\r\n nextIndicesAndParams: remappedEdges.polylines.nextIndicesAndParams.toUint8Array(),\r\n } : undefined,\r\n indexed: remappedEdges.indexed ? {\r\n indices: edgeIndices,\r\n edges: edgeTable,\r\n } : undefined,\r\n });\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport interface SplitMeshArgs extends SplitVertexTableArgs {\r\n params: MeshParams;\r\n createMaterial: CreateRenderMaterial;\r\n}\r\n\r\nexport function splitMeshParams(args: SplitMeshArgs): Map<number, MeshParams> {\r\n const result = new Map<number, MeshParams>();\r\n\r\n const mat = args.params.surface.material;\r\n const atlasOffset = undefined !== mat && mat.isAtlas ? mat.vertexTableOffset : undefined;\r\n const atlasInfo = atlasOffset ? { offset: atlasOffset, createMaterial: args.createMaterial } : undefined;\r\n\r\n const nodes = VertexTableSplitter.split({\r\n indices: args.params.surface.indices,\r\n vertices: args.params.vertices,\r\n featureTable: args.featureTable,\r\n atlasInfo,\r\n }, args.computeNodeId);\r\n\r\n const edges = args.params.edges ? splitEdges(args.params.edges, nodes, args.maxDimension) : undefined;\r\n\r\n for (const [id, node] of nodes) {\r\n const { vertices, indices, material } = node.buildOutput(args.maxDimension);\r\n const params = new MeshParams(\r\n vertices, {\r\n type: args.params.surface.type,\r\n indices,\r\n fillFlags: args.params.surface.fillFlags,\r\n hasBakedLighting: args.params.surface.hasBakedLighting,\r\n textureMapping: args.params.surface.textureMapping,\r\n material: material !== undefined ? material : args.params.surface.material,\r\n },\r\n edges?.get(id),\r\n args.params.isPlanar,\r\n // ###TODO handle aux channels.......\r\n args.params.auxChannels,\r\n );\r\n\r\n result.set(id, params);\r\n }\r\n\r\n return result;\r\n}\r\n\r\nexport interface SplitPolylineArgs extends SplitVertexTableArgs {\r\n params: PolylineParams;\r\n}\r\n\r\ninterface PolylineNode extends Node {\r\n prevIndices?: IndexBuffer;\r\n nextIndicesAndParams?: Uint32ArrayBuilder;\r\n}\r\n\r\nexport function splitPolylineParams(args: SplitPolylineArgs): Map<number, PolylineParams> {\r\n const nodes = VertexTableSplitter.split({\r\n indices: args.params.polyline.indices,\r\n vertices: args.params.vertices,\r\n featureTable: args.featureTable,\r\n }, args.computeNodeId) as Map<number, PolylineNode>;\r\n\r\n const src = args.params.polyline;\r\n const srcNextAndParam = new Uint32Array(src.nextIndicesAndParams.buffer, src.nextIndicesAndParams.byteOffset, src.nextIndicesAndParams.length / 4);\r\n let curIndexIndex = 0;\r\n const remappedIndex = { } as unknown as RemappedIndex;\r\n for (const prevIndex of src.prevIndices) {\r\n if (remapIndex(remappedIndex, prevIndex, nodes)) {\r\n const node = remappedIndex.node as PolylineNode;\r\n if (!node.prevIndices) {\r\n assert(undefined === node.nextIndicesAndParams);\r\n node.prevIndices = new IndexBuffer(node.indices.numIndices);\r\n node.nextIndicesAndParams = new Uint32ArrayBuilder({ initialCapacity: node.indices.numIndices });\r\n } else {\r\n assert(undefined !== node.nextIndicesAndParams);\r\n }\r\n\r\n node.prevIndices.push(remappedIndex.index);\r\n\r\n let nextAndParam = srcNextAndParam[curIndexIndex];\r\n const nextIndex = (nextAndParam & 0x00ffffff) >>> 0;\r\n const newNextIndex = remappedIndex.node.remappedIndices.get(nextIndex);\r\n assert(undefined !== newNextIndex);\r\n nextAndParam = (nextAndParam & 0xff000000) | newNextIndex;\r\n node.nextIndicesAndParams.push(nextAndParam);\r\n }\r\n\r\n ++curIndexIndex;\r\n }\r\n\r\n const result = new Map<number, PolylineParams>();\r\n for (const [id, node] of nodes) {\r\n assert(undefined !== node.prevIndices && undefined !== node.nextIndicesAndParams);\r\n const { vertices, indices } = node.buildOutput(args.maxDimension);\r\n const params = new PolylineParams(\r\n vertices, {\r\n indices,\r\n prevIndices: node.prevIndices.toVertexIndices(),\r\n nextIndicesAndParams: node.nextIndicesAndParams.toUint8Array(),\r\n },\r\n args.params.weight,\r\n args.params.linePixels,\r\n args.params.isPlanar,\r\n args.params.type);\r\n\r\n result.set(id, params);\r\n }\r\n\r\n return result;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTile.d.ts","sourceRoot":"","sources":["../../../src/tile/IModelTile.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAwB,WAAW,EAAc,MAAM,qBAAqB,CAAC;AAEpF,OAAO,EACL,QAAQ,EAAyH,SAAS,EAC3I,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACwB,cAAc,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAkB,UAAU,EAAE,WAAW,EACxI,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,cAAc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AI,MAAM,CAExC;IAED,IAAW,OAAO,IAAI,kBAAkB,CAEvC;IAEY,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;IAI/C,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAsCtH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAoB5D,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAkBlG,cAAuB,iBAAiB,IAAI,QAAQ,CAEnD;cAEkB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAgBnF,aAAa,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;IAc3C,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY;CAkI3F"}
|
|
@@ -71,21 +71,20 @@ export class IModelTile extends Tile {
|
|
|
71
71
|
const tree = this.iModelTree;
|
|
72
72
|
const sizeMultiplier = this.hasSizeMultiplier ? this.sizeMultiplier : undefined;
|
|
73
73
|
const { iModel, modelId, is3d, containsTransformNodes } = tree;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
74
|
+
try {
|
|
75
|
+
const reader = ImdlReader.create({
|
|
76
|
+
stream: streamBuffer,
|
|
77
|
+
type: tree.batchType,
|
|
78
|
+
loadEdges: false !== tree.edgeOptions,
|
|
79
|
+
options: { tileId: this.contentId },
|
|
80
|
+
timeline: tree.timeline,
|
|
81
|
+
iModel, modelId, is3d, system, isCanceled, sizeMultiplier, containsTransformNodes,
|
|
82
|
+
});
|
|
83
|
+
content = await reader.read();
|
|
84
|
+
return content;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
//
|
|
89
88
|
}
|
|
90
89
|
return content;
|
|
91
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTile.js","sourceRoot":"","sources":["../../../src/tile/IModelTile.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAe,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACL,QAAQ,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,yBAAyB,EAAuB,UAAU,EAAE,UAAU,GAChI,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACL,eAAe,EAAE,UAAU,EAAkB,IAAI,EAAE,iBAAiB,EAA6B,cAAc,EAC3F,kBAAkB,EAAE,cAAc,GACvD,MAAM,YAAY,CAAC;AASpB,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,KAAgB,EAAE,MAA8B;IACvF,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IACjE,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,YAAY,CAAC;IACjB,IAAI,SAAS,KAAK,KAAK,CAAC,YAAY;QAClC,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAsB,KAAK,CAAC,YAAY,CAAC,CAAC;IAE3E,OAAO,EAAE,SAAS,EAAE,KAAK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C,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC;IACvE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, BentleyError, BeTimePoint, ByteStream } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n ColorDef, computeChildTileProps, computeChildTileRanges, computeTileChordTolerance, ElementAlignedBox3d, LinePixels, TileFormat, TileProps,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBuilder } from \"../render/GraphicBuilder\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport {\r\n addRangeGraphic, ImdlReader, IModelTileTree, Tile, TileBoundingBoxes, TileContent, TileDrawArgs, TileLoadStatus, TileParams, TileRequest,\r\n TileRequestChannel, TileTreeLoadStatus, TileVisibility,\r\n} from \"./internal\";\r\n\r\n/** Parameters used to construct an [[IModelTile]].\r\n * @internal\r\n */\r\nexport interface IModelTileParams extends TileParams {\r\n sizeMultiplier?: number;\r\n}\r\n\r\n/** @internal */\r\nexport function iModelTileParamsFromJSON(props: TileProps, parent: IModelTile | undefined): IModelTileParams {\r\n const { contentId, maximumSize, isLeaf, sizeMultiplier } = props;\r\n const range = Range3d.fromJSON(props.range);\r\n\r\n let contentRange;\r\n if (undefined !== props.contentRange)\r\n contentRange = Range3d.fromJSON<ElementAlignedBox3d>(props.contentRange);\r\n\r\n return { contentId, range, maximumSize, isLeaf, parent, contentRange, sizeMultiplier };\r\n}\r\n\r\n/**\r\n * Indicates whether a parent tile should be drawn in place of a child tile.\r\n * @internal\r\n */\r\nexport enum SelectParent {\r\n No,\r\n Yes,\r\n}\r\n\r\n/** @internal */\r\nexport interface IModelTileContent extends TileContent {\r\n /** If this tile was produced by refinement, the multiplier applied to its screen size. */\r\n sizeMultiplier?: number;\r\n /** A bitfield describing empty sub-volumes of this tile's volume. */\r\n emptySubRangeMask?: number;\r\n}\r\n\r\n/** A tile belonging to an [[IModelTileTree].\r\n * @internal\r\n */\r\nexport class IModelTile extends Tile {\r\n private _sizeMultiplier?: number;\r\n private _emptySubRangeMask?: number;\r\n /** If an initial attempt to obtain this tile's content (e.g., from cloud storage cache) failed,\r\n * the next channel to try.\r\n */\r\n public requestChannel?: TileRequestChannel;\r\n\r\n public constructor(params: IModelTileParams, tree: IModelTileTree) {\r\n super(params, tree);\r\n this._sizeMultiplier = params.sizeMultiplier;\r\n\r\n if (!this.isLeaf && this.tree.is3d && !this.isReady) { // ###TODO: Want to know specifically if tree is *spatial*.\r\n // Do not sub-divide such that chord tolerance would be below specified minimum, if minimum defined.\r\n const minTolerance = IModelApp.tileAdmin.minimumSpatialTolerance;\r\n if (minTolerance > 0 && computeTileChordTolerance(this, this.tree.is3d, this.iModelTree.tileScreenSize) <= minTolerance)\r\n this.setLeaf();\r\n }\r\n }\r\n\r\n public get iModelTree(): IModelTileTree { return this.tree as IModelTileTree; }\r\n public get iModelChildren(): IModelTile[] | undefined { return this.children as IModelTile[] | undefined; }\r\n public get emptySubRangeMask(): number { return this._emptySubRangeMask ?? 0; }\r\n\r\n public get sizeMultiplier(): number | undefined { return this._sizeMultiplier; }\r\n public get hasSizeMultiplier() { return undefined !== this.sizeMultiplier; }\r\n public override get maximumSize(): number {\r\n return super.maximumSize * (this.sizeMultiplier ?? 1.0);\r\n }\r\n\r\n public get channel(): TileRequestChannel {\r\n return IModelApp.tileAdmin.channels.getIModelTileChannel(this);\r\n }\r\n\r\n public async requestContent(): Promise<TileRequest.Response> {\r\n return IModelApp.tileAdmin.generateTileContent(this);\r\n }\r\n\r\n public async readContent(data: TileRequest.ResponseData, system: RenderSystem, isCanceled?: () => boolean): Promise<IModelTileContent> {\r\n if (undefined === isCanceled)\r\n isCanceled = () => !this.isLoading;\r\n\r\n assert(data instanceof Uint8Array);\r\n const streamBuffer = ByteStream.fromUint8Array(data);\r\n\r\n const position = streamBuffer.curPos;\r\n const format = streamBuffer.readUint32();\r\n streamBuffer.curPos = position;\r\n\r\n let content: IModelTileContent = { isLeaf: true };\r\n assert(TileFormat.IModel === format);\r\n if (format !== TileFormat.IModel)\r\n return content;\r\n\r\n const tree = this.iModelTree;\r\n const sizeMultiplier = this.hasSizeMultiplier ? this.sizeMultiplier : undefined;\r\n const { iModel, modelId, is3d, containsTransformNodes } = tree;\r\n const reader = ImdlReader.create({\r\n stream: streamBuffer,\r\n type: tree.batchType,\r\n loadEdges: false !== tree.edgeOptions,\r\n options: { tileId: this.contentId },\r\n timeline: tree.timeline,\r\n iModel, modelId, is3d, system, isCanceled, sizeMultiplier, containsTransformNodes,\r\n });\r\n\r\n if (undefined !== reader) {\r\n try {\r\n content = await reader.read();\r\n } catch {\r\n //\r\n }\r\n }\r\n\r\n return content;\r\n }\r\n\r\n public override setContent(content: IModelTileContent): void {\r\n super.setContent(content);\r\n\r\n this._emptySubRangeMask = content.emptySubRangeMask;\r\n\r\n // NB: If this tile has no graphics, it may or may not have children - but we don't want to load the children until\r\n // this tile is too coarse for view based on its size in pixels.\r\n // That is different than an \"undisplayable\" tile (maximumSize=0) whose children should be loaded immediately.\r\n if (undefined !== content.graphic && 0 === this.maximumSize)\r\n this._maximumSize = this.iModelTree.tileScreenSize;\r\n\r\n const sizeMult = content.sizeMultiplier;\r\n if (undefined !== sizeMult && (undefined === this._sizeMultiplier || sizeMult > this._sizeMultiplier)) {\r\n this._sizeMultiplier = sizeMult;\r\n this._contentId = this.iModelTree.contentIdProvider.idFromParentAndMultiplier(this.contentId, sizeMult);\r\n if (undefined !== this.children && this.children.length > 1)\r\n this.disposeChildren();\r\n }\r\n }\r\n\r\n protected _loadChildren(resolve: (children: Tile[]) => void, reject: (error: Error) => void): void {\r\n try {\r\n const tree = this.iModelTree;\r\n const kids = computeChildTileProps(this, tree.contentIdProvider, tree);\r\n IModelApp.tileAdmin.onTilesElided(kids.numEmpty);\r\n\r\n const children: IModelTile[] = [];\r\n for (const props of kids.children) {\r\n const child = new IModelTile(iModelTileParamsFromJSON(props, this), tree);\r\n children.push(child);\r\n }\r\n\r\n resolve(children);\r\n } catch (err) {\r\n reject(err instanceof Error ? err : new Error(BentleyError.getErrorMessage(err)));\r\n }\r\n }\r\n\r\n protected override get rangeGraphicColor(): ColorDef {\r\n return this.hasSizeMultiplier ? ColorDef.red : super.rangeGraphicColor;\r\n }\r\n\r\n protected override addRangeGraphic(builder: GraphicBuilder, type: TileBoundingBoxes): void {\r\n if (TileBoundingBoxes.ChildVolumes !== type) {\r\n super.addRangeGraphic(builder, type);\r\n return;\r\n }\r\n\r\n const ranges = computeChildTileRanges(this, this.iModelTree);\r\n for (const range of ranges) {\r\n const color = range.isEmpty ? ColorDef.blue : ColorDef.green;\r\n const pixels = !range.isEmpty ? LinePixels.HiddenLine : LinePixels.Solid;\r\n const width = !range.isEmpty ? 2 : 1;\r\n builder.setSymbology(color, color, width, pixels);\r\n addRangeGraphic(builder, range.range, this.tree.is2d);\r\n }\r\n }\r\n\r\n public pruneChildren(olderThan: BeTimePoint): void {\r\n // A tile's usage marker indicates its the most recent time its *children* were used.\r\n if (this.usageMarker.isExpired(olderThan)) {\r\n this.disposeChildren();\r\n return;\r\n }\r\n\r\n // this node has been used recently. Keep it, but potentially unload its grandchildren.\r\n const children = this.iModelChildren;\r\n if (undefined !== children)\r\n for (const child of children)\r\n child.pruneChildren(olderThan);\r\n }\r\n\r\n public selectTiles(selected: Tile[], args: TileDrawArgs, numSkipped: number): SelectParent {\r\n let vis = this.computeVisibility(args);\r\n if (TileVisibility.OutsideFrustum === vis)\r\n return SelectParent.No;\r\n\r\n const maxDepth = this.iModelTree.debugMaxDepth;\r\n if (undefined !== maxDepth && this.depth >= maxDepth)\r\n vis = TileVisibility.Visible;\r\n\r\n if (TileVisibility.Visible === vis) {\r\n // This tile is of appropriate resolution to draw. If need loading or refinement, enqueue.\r\n if (!this.isReady)\r\n args.insertMissing(this);\r\n\r\n if (this.hasGraphics) {\r\n // It can be drawn - select it\r\n args.markReady(this);\r\n selected.push(this);\r\n } else if (!this.isReady) {\r\n // It can't be drawn. Try to draw children in its place; otherwise draw the parent.\r\n // Do not load/request the children for this purpose.\r\n const initialSize = selected.length;\r\n const kids = this.iModelChildren;\r\n if (undefined === kids)\r\n return SelectParent.Yes;\r\n\r\n // Find any descendant to draw, until we exceed max initial tiles to skip.\r\n if (this.depth < this.iModelTree.maxInitialTilesToSkip) {\r\n for (const kid of kids) {\r\n if (SelectParent.Yes === kid.selectTiles(selected, args, numSkipped)) {\r\n selected.length = initialSize;\r\n return SelectParent.Yes;\r\n }\r\n\r\n return SelectParent.No;\r\n }\r\n }\r\n\r\n // If all visible direct children can be drawn, draw them.\r\n for (const kid of kids) {\r\n if (TileVisibility.OutsideFrustum !== kid.computeVisibility(args)) {\r\n if (!kid.hasGraphics) {\r\n selected.length = initialSize;\r\n return SelectParent.Yes;\r\n } else {\r\n selected.push(kid);\r\n }\r\n }\r\n }\r\n\r\n args.markUsed(this);\r\n }\r\n\r\n // We're drawing either this tile, or its direct children.\r\n return SelectParent.No;\r\n }\r\n\r\n // This tile is too coarse to draw. Try to draw something more appropriate.\r\n // If it is not ready to draw, we may want to skip loading in favor of loading its descendants.\r\n // If we previously loaded and later unloaded content for this tile to free memory, don't force it to reload its content - proceed to children.\r\n let canSkipThisTile = (this._hadGraphics && !this.hasGraphics) || this.depth < this.iModelTree.maxInitialTilesToSkip;\r\n if (canSkipThisTile) {\r\n numSkipped = 1;\r\n } else {\r\n canSkipThisTile = this.isReady || this.isParentDisplayable || this.depth < this.iModelTree.maxInitialTilesToSkip;\r\n if (canSkipThisTile && this.isDisplayable) { // skipping an undisplayable tile doesn't count toward the maximum\r\n // Some tiles do not sub-divide - they only facet the same geometry to a higher resolution. We can skip directly to the correct resolution.\r\n const isNotReady = !this.isReady && !this.hasGraphics && !this.hasSizeMultiplier;\r\n if (isNotReady) {\r\n if (numSkipped >= this.iModelTree.maxTilesToSkip)\r\n canSkipThisTile = false;\r\n else\r\n numSkipped += 1;\r\n }\r\n }\r\n }\r\n\r\n const childrenLoadStatus = this.loadChildren(); // NB: asynchronous\r\n const children = canSkipThisTile ? this.iModelChildren : undefined;\r\n if (canSkipThisTile && TileTreeLoadStatus.Loading === childrenLoadStatus) {\r\n args.markChildrenLoading();\r\n args.markUsed(this);\r\n }\r\n\r\n if (undefined !== children) {\r\n // If we are the root tile and we are not displayable, then we want to draw *any* currently available children in our place, or else we would draw nothing.\r\n // Otherwise, if we want to draw children in our place, we should wait for *all* of them to load, or else we would show missing chunks where not-yet-loaded children belong.\r\n const isUndisplayableRootTile = this.isUndisplayableRootTile;\r\n args.markUsed(this);\r\n let drawChildren = true;\r\n const initialSize = selected.length;\r\n for (const child of children) {\r\n // NB: We must continue iterating children so that they can be requested if missing.\r\n if (SelectParent.Yes === child.selectTiles(selected, args, numSkipped)) {\r\n if (child.loadStatus === TileLoadStatus.NotFound) {\r\n // At least one child we want to draw failed to load. e.g., we reached max depth of map tile tree. Draw parent instead.\r\n drawChildren = canSkipThisTile = false;\r\n } else {\r\n // At least one child we want to draw is not yet loaded. Wait for it to load before drawing it and its siblings, unless we have nothing to draw in their place.\r\n drawChildren = isUndisplayableRootTile;\r\n }\r\n }\r\n }\r\n\r\n if (drawChildren)\r\n return SelectParent.No;\r\n\r\n // Some types of tiles (like maps) allow the ready children to be drawn on top of the parent while other children are not yet loaded.\r\n if (args.parentsAndChildrenExclusive)\r\n selected.length = initialSize;\r\n }\r\n\r\n if (this.isReady) {\r\n if (this.hasGraphics) {\r\n selected.push(this);\r\n if (!canSkipThisTile) {\r\n // This tile is too coarse, but we require loading it before we can start loading higher-res children.\r\n args.markReady(this);\r\n }\r\n }\r\n\r\n return SelectParent.No;\r\n }\r\n\r\n // This tile is not ready to be drawn. Request it *only* if we cannot skip it.\r\n if (!canSkipThisTile)\r\n args.insertMissing(this);\r\n\r\n return this.isParentDisplayable ? SelectParent.Yes : SelectParent.No;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IModelTile.js","sourceRoot":"","sources":["../../../src/tile/IModelTile.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAe,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACL,QAAQ,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,yBAAyB,EAAuB,UAAU,EAAE,UAAU,GAChI,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACL,eAAe,EAAE,UAAU,EAAkB,IAAI,EAAE,iBAAiB,EAA6B,cAAc,EAC3F,kBAAkB,EAAE,cAAc,GACvD,MAAM,YAAY,CAAC;AASpB,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,KAAgB,EAAE,MAA8B;IACvF,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IACjE,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,YAAY,CAAC;IACjB,IAAI,SAAS,KAAK,KAAK,CAAC,YAAY;QAClC,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAsB,KAAK,CAAC,YAAY,CAAC,CAAC;IAE3E,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AACzF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2CAAE,CAAA;IACF,6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AC7D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACpB,IAAI,YAAY,GAAG,IAAI,CAAC;YACxB,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC;YACpC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;gBAC5B,oFAAoF;gBACpF,IAAI,YAAY,CAAC,GAAG,KAAK,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE;oBACtE,IAAI,KAAK,CAAC,UAAU,KAAK,cAAc,CAAC,QAAQ,EAAE;wBAChD,uHAAuH;wBACvH,YAAY,GAAG,eAAe,GAAG,KAAK,CAAC;qBACxC;yBAAM;wBACL,+JAA+J;wBAC/J,YAAY,GAAG,uBAAuB,CAAC;qBACxC;iBACF;aACF;YAED,IAAI,YAAY;gBACd,OAAO,YAAY,CAAC,EAAE,CAAC;YAEzB,qIAAqI;YACrI,IAAI,IAAI,CAAC,2BAA2B;gBAClC,QAAQ,CAAC,MAAM,GAAG,WAAW,CAAC;SACjC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpB,IAAI,CAAC,eAAe,EAAE;oBACpB,sGAAsG;oBACtG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;iBACtB;aACF;YAED,OAAO,YAAY,CAAC,EAAE,CAAC;SACxB;QAED,8EAA8E;QAC9E,IAAI,CAAC,eAAe;YAClB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC;IACvE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, BentleyError, BeTimePoint, ByteStream } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n ColorDef, computeChildTileProps, computeChildTileRanges, computeTileChordTolerance, ElementAlignedBox3d, LinePixels, TileFormat, TileProps,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBuilder } from \"../render/GraphicBuilder\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport {\r\n addRangeGraphic, ImdlReader, IModelTileTree, Tile, TileBoundingBoxes, TileContent, TileDrawArgs, TileLoadStatus, TileParams, TileRequest,\r\n TileRequestChannel, TileTreeLoadStatus, TileVisibility,\r\n} from \"./internal\";\r\n\r\n/** Parameters used to construct an [[IModelTile]].\r\n * @internal\r\n */\r\nexport interface IModelTileParams extends TileParams {\r\n sizeMultiplier?: number;\r\n}\r\n\r\n/** @internal */\r\nexport function iModelTileParamsFromJSON(props: TileProps, parent: IModelTile | undefined): IModelTileParams {\r\n const { contentId, maximumSize, isLeaf, sizeMultiplier } = props;\r\n const range = Range3d.fromJSON(props.range);\r\n\r\n let contentRange;\r\n if (undefined !== props.contentRange)\r\n contentRange = Range3d.fromJSON<ElementAlignedBox3d>(props.contentRange);\r\n\r\n return { contentId, range, maximumSize, isLeaf, parent, contentRange, sizeMultiplier };\r\n}\r\n\r\n/**\r\n * Indicates whether a parent tile should be drawn in place of a child tile.\r\n * @internal\r\n */\r\nexport enum SelectParent {\r\n No,\r\n Yes,\r\n}\r\n\r\n/** @internal */\r\nexport interface IModelTileContent extends TileContent {\r\n /** If this tile was produced by refinement, the multiplier applied to its screen size. */\r\n sizeMultiplier?: number;\r\n /** A bitfield describing empty sub-volumes of this tile's volume. */\r\n emptySubRangeMask?: number;\r\n}\r\n\r\n/** A tile belonging to an [[IModelTileTree].\r\n * @internal\r\n */\r\nexport class IModelTile extends Tile {\r\n private _sizeMultiplier?: number;\r\n private _emptySubRangeMask?: number;\r\n /** If an initial attempt to obtain this tile's content (e.g., from cloud storage cache) failed,\r\n * the next channel to try.\r\n */\r\n public requestChannel?: TileRequestChannel;\r\n\r\n public constructor(params: IModelTileParams, tree: IModelTileTree) {\r\n super(params, tree);\r\n this._sizeMultiplier = params.sizeMultiplier;\r\n\r\n if (!this.isLeaf && this.tree.is3d && !this.isReady) { // ###TODO: Want to know specifically if tree is *spatial*.\r\n // Do not sub-divide such that chord tolerance would be below specified minimum, if minimum defined.\r\n const minTolerance = IModelApp.tileAdmin.minimumSpatialTolerance;\r\n if (minTolerance > 0 && computeTileChordTolerance(this, this.tree.is3d, this.iModelTree.tileScreenSize) <= minTolerance)\r\n this.setLeaf();\r\n }\r\n }\r\n\r\n public get iModelTree(): IModelTileTree { return this.tree as IModelTileTree; }\r\n public get iModelChildren(): IModelTile[] | undefined { return this.children as IModelTile[] | undefined; }\r\n public get emptySubRangeMask(): number { return this._emptySubRangeMask ?? 0; }\r\n\r\n public get sizeMultiplier(): number | undefined { return this._sizeMultiplier; }\r\n public get hasSizeMultiplier() { return undefined !== this.sizeMultiplier; }\r\n public override get maximumSize(): number {\r\n return super.maximumSize * (this.sizeMultiplier ?? 1.0);\r\n }\r\n\r\n public get channel(): TileRequestChannel {\r\n return IModelApp.tileAdmin.channels.getIModelTileChannel(this);\r\n }\r\n\r\n public async requestContent(): Promise<TileRequest.Response> {\r\n return IModelApp.tileAdmin.generateTileContent(this);\r\n }\r\n\r\n public async readContent(data: TileRequest.ResponseData, system: RenderSystem, isCanceled?: () => boolean): Promise<IModelTileContent> {\r\n if (undefined === isCanceled)\r\n isCanceled = () => !this.isLoading;\r\n\r\n assert(data instanceof Uint8Array);\r\n const streamBuffer = ByteStream.fromUint8Array(data);\r\n\r\n const position = streamBuffer.curPos;\r\n const format = streamBuffer.readUint32();\r\n streamBuffer.curPos = position;\r\n\r\n let content: IModelTileContent = { isLeaf: true };\r\n assert(TileFormat.IModel === format);\r\n if (format !== TileFormat.IModel)\r\n return content;\r\n\r\n const tree = this.iModelTree;\r\n const sizeMultiplier = this.hasSizeMultiplier ? this.sizeMultiplier : undefined;\r\n const { iModel, modelId, is3d, containsTransformNodes } = tree;\r\n try {\r\n const reader = ImdlReader.create({\r\n stream: streamBuffer,\r\n type: tree.batchType,\r\n loadEdges: false !== tree.edgeOptions,\r\n options: { tileId: this.contentId },\r\n timeline: tree.timeline,\r\n iModel, modelId, is3d, system, isCanceled, sizeMultiplier, containsTransformNodes,\r\n });\r\n\r\n content = await reader.read();\r\n return content;\r\n } catch {\r\n //\r\n }\r\n\r\n return content;\r\n }\r\n\r\n public override setContent(content: IModelTileContent): void {\r\n super.setContent(content);\r\n\r\n this._emptySubRangeMask = content.emptySubRangeMask;\r\n\r\n // NB: If this tile has no graphics, it may or may not have children - but we don't want to load the children until\r\n // this tile is too coarse for view based on its size in pixels.\r\n // That is different than an \"undisplayable\" tile (maximumSize=0) whose children should be loaded immediately.\r\n if (undefined !== content.graphic && 0 === this.maximumSize)\r\n this._maximumSize = this.iModelTree.tileScreenSize;\r\n\r\n const sizeMult = content.sizeMultiplier;\r\n if (undefined !== sizeMult && (undefined === this._sizeMultiplier || sizeMult > this._sizeMultiplier)) {\r\n this._sizeMultiplier = sizeMult;\r\n this._contentId = this.iModelTree.contentIdProvider.idFromParentAndMultiplier(this.contentId, sizeMult);\r\n if (undefined !== this.children && this.children.length > 1)\r\n this.disposeChildren();\r\n }\r\n }\r\n\r\n protected _loadChildren(resolve: (children: Tile[]) => void, reject: (error: Error) => void): void {\r\n try {\r\n const tree = this.iModelTree;\r\n const kids = computeChildTileProps(this, tree.contentIdProvider, tree);\r\n IModelApp.tileAdmin.onTilesElided(kids.numEmpty);\r\n\r\n const children: IModelTile[] = [];\r\n for (const props of kids.children) {\r\n const child = new IModelTile(iModelTileParamsFromJSON(props, this), tree);\r\n children.push(child);\r\n }\r\n\r\n resolve(children);\r\n } catch (err) {\r\n reject(err instanceof Error ? err : new Error(BentleyError.getErrorMessage(err)));\r\n }\r\n }\r\n\r\n protected override get rangeGraphicColor(): ColorDef {\r\n return this.hasSizeMultiplier ? ColorDef.red : super.rangeGraphicColor;\r\n }\r\n\r\n protected override addRangeGraphic(builder: GraphicBuilder, type: TileBoundingBoxes): void {\r\n if (TileBoundingBoxes.ChildVolumes !== type) {\r\n super.addRangeGraphic(builder, type);\r\n return;\r\n }\r\n\r\n const ranges = computeChildTileRanges(this, this.iModelTree);\r\n for (const range of ranges) {\r\n const color = range.isEmpty ? ColorDef.blue : ColorDef.green;\r\n const pixels = !range.isEmpty ? LinePixels.HiddenLine : LinePixels.Solid;\r\n const width = !range.isEmpty ? 2 : 1;\r\n builder.setSymbology(color, color, width, pixels);\r\n addRangeGraphic(builder, range.range, this.tree.is2d);\r\n }\r\n }\r\n\r\n public pruneChildren(olderThan: BeTimePoint): void {\r\n // A tile's usage marker indicates its the most recent time its *children* were used.\r\n if (this.usageMarker.isExpired(olderThan)) {\r\n this.disposeChildren();\r\n return;\r\n }\r\n\r\n // this node has been used recently. Keep it, but potentially unload its grandchildren.\r\n const children = this.iModelChildren;\r\n if (undefined !== children)\r\n for (const child of children)\r\n child.pruneChildren(olderThan);\r\n }\r\n\r\n public selectTiles(selected: Tile[], args: TileDrawArgs, numSkipped: number): SelectParent {\r\n let vis = this.computeVisibility(args);\r\n if (TileVisibility.OutsideFrustum === vis)\r\n return SelectParent.No;\r\n\r\n const maxDepth = this.iModelTree.debugMaxDepth;\r\n if (undefined !== maxDepth && this.depth >= maxDepth)\r\n vis = TileVisibility.Visible;\r\n\r\n if (TileVisibility.Visible === vis) {\r\n // This tile is of appropriate resolution to draw. If need loading or refinement, enqueue.\r\n if (!this.isReady)\r\n args.insertMissing(this);\r\n\r\n if (this.hasGraphics) {\r\n // It can be drawn - select it\r\n args.markReady(this);\r\n selected.push(this);\r\n } else if (!this.isReady) {\r\n // It can't be drawn. Try to draw children in its place; otherwise draw the parent.\r\n // Do not load/request the children for this purpose.\r\n const initialSize = selected.length;\r\n const kids = this.iModelChildren;\r\n if (undefined === kids)\r\n return SelectParent.Yes;\r\n\r\n // Find any descendant to draw, until we exceed max initial tiles to skip.\r\n if (this.depth < this.iModelTree.maxInitialTilesToSkip) {\r\n for (const kid of kids) {\r\n if (SelectParent.Yes === kid.selectTiles(selected, args, numSkipped)) {\r\n selected.length = initialSize;\r\n return SelectParent.Yes;\r\n }\r\n\r\n return SelectParent.No;\r\n }\r\n }\r\n\r\n // If all visible direct children can be drawn, draw them.\r\n for (const kid of kids) {\r\n if (TileVisibility.OutsideFrustum !== kid.computeVisibility(args)) {\r\n if (!kid.hasGraphics) {\r\n selected.length = initialSize;\r\n return SelectParent.Yes;\r\n } else {\r\n selected.push(kid);\r\n }\r\n }\r\n }\r\n\r\n args.markUsed(this);\r\n }\r\n\r\n // We're drawing either this tile, or its direct children.\r\n return SelectParent.No;\r\n }\r\n\r\n // This tile is too coarse to draw. Try to draw something more appropriate.\r\n // If it is not ready to draw, we may want to skip loading in favor of loading its descendants.\r\n // If we previously loaded and later unloaded content for this tile to free memory, don't force it to reload its content - proceed to children.\r\n let canSkipThisTile = (this._hadGraphics && !this.hasGraphics) || this.depth < this.iModelTree.maxInitialTilesToSkip;\r\n if (canSkipThisTile) {\r\n numSkipped = 1;\r\n } else {\r\n canSkipThisTile = this.isReady || this.isParentDisplayable || this.depth < this.iModelTree.maxInitialTilesToSkip;\r\n if (canSkipThisTile && this.isDisplayable) { // skipping an undisplayable tile doesn't count toward the maximum\r\n // Some tiles do not sub-divide - they only facet the same geometry to a higher resolution. We can skip directly to the correct resolution.\r\n const isNotReady = !this.isReady && !this.hasGraphics && !this.hasSizeMultiplier;\r\n if (isNotReady) {\r\n if (numSkipped >= this.iModelTree.maxTilesToSkip)\r\n canSkipThisTile = false;\r\n else\r\n numSkipped += 1;\r\n }\r\n }\r\n }\r\n\r\n const childrenLoadStatus = this.loadChildren(); // NB: asynchronous\r\n const children = canSkipThisTile ? this.iModelChildren : undefined;\r\n if (canSkipThisTile && TileTreeLoadStatus.Loading === childrenLoadStatus) {\r\n args.markChildrenLoading();\r\n args.markUsed(this);\r\n }\r\n\r\n if (undefined !== children) {\r\n // If we are the root tile and we are not displayable, then we want to draw *any* currently available children in our place, or else we would draw nothing.\r\n // Otherwise, if we want to draw children in our place, we should wait for *all* of them to load, or else we would show missing chunks where not-yet-loaded children belong.\r\n const isUndisplayableRootTile = this.isUndisplayableRootTile;\r\n args.markUsed(this);\r\n let drawChildren = true;\r\n const initialSize = selected.length;\r\n for (const child of children) {\r\n // NB: We must continue iterating children so that they can be requested if missing.\r\n if (SelectParent.Yes === child.selectTiles(selected, args, numSkipped)) {\r\n if (child.loadStatus === TileLoadStatus.NotFound) {\r\n // At least one child we want to draw failed to load. e.g., we reached max depth of map tile tree. Draw parent instead.\r\n drawChildren = canSkipThisTile = false;\r\n } else {\r\n // At least one child we want to draw is not yet loaded. Wait for it to load before drawing it and its siblings, unless we have nothing to draw in their place.\r\n drawChildren = isUndisplayableRootTile;\r\n }\r\n }\r\n }\r\n\r\n if (drawChildren)\r\n return SelectParent.No;\r\n\r\n // Some types of tiles (like maps) allow the ready children to be drawn on top of the parent while other children are not yet loaded.\r\n if (args.parentsAndChildrenExclusive)\r\n selected.length = initialSize;\r\n }\r\n\r\n if (this.isReady) {\r\n if (this.hasGraphics) {\r\n selected.push(this);\r\n if (!canSkipThisTile) {\r\n // This tile is too coarse, but we require loading it before we can start loading higher-res children.\r\n args.markReady(this);\r\n }\r\n }\r\n\r\n return SelectParent.No;\r\n }\r\n\r\n // This tile is not ready to be drawn. Request it *only* if we cannot skip it.\r\n if (!canSkipThisTile)\r\n args.insertMissing(this);\r\n\r\n return this.isParentDisplayable ? SelectParent.Yes : SelectParent.No;\r\n }\r\n}\r\n"]}
|