@itwin/core-frontend 4.0.0-dev.44 → 4.0.0-dev.46

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.
Files changed (71) hide show
  1. package/lib/cjs/core-frontend.d.ts +1 -0
  2. package/lib/cjs/core-frontend.d.ts.map +1 -1
  3. package/lib/cjs/core-frontend.js +1 -0
  4. package/lib/cjs/core-frontend.js.map +1 -1
  5. package/lib/cjs/gltf/GltfModel.d.ts +91 -0
  6. package/lib/cjs/gltf/GltfModel.d.ts.map +1 -0
  7. package/lib/cjs/gltf/GltfModel.js +10 -0
  8. package/lib/cjs/gltf/GltfModel.js.map +1 -0
  9. package/lib/cjs/gltf/GltfParser.d.ts +26 -0
  10. package/lib/cjs/gltf/GltfParser.d.ts.map +1 -0
  11. package/lib/cjs/gltf/GltfParser.js +352 -0
  12. package/lib/cjs/gltf/GltfParser.js.map +1 -0
  13. package/lib/cjs/gltf/GltfSchema.d.ts +557 -0
  14. package/lib/cjs/gltf/GltfSchema.d.ts.map +1 -0
  15. package/lib/cjs/gltf/GltfSchema.js +138 -0
  16. package/lib/cjs/gltf/GltfSchema.js.map +1 -0
  17. package/lib/cjs/render/GraphicBuilder.d.ts +5 -2
  18. package/lib/cjs/render/GraphicBuilder.d.ts.map +1 -1
  19. package/lib/cjs/render/GraphicBuilder.js +12 -3
  20. package/lib/cjs/render/GraphicBuilder.js.map +1 -1
  21. package/lib/cjs/tile/B3dmReader.d.ts +2 -1
  22. package/lib/cjs/tile/B3dmReader.d.ts.map +1 -1
  23. package/lib/cjs/tile/B3dmReader.js +2 -1
  24. package/lib/cjs/tile/B3dmReader.js.map +1 -1
  25. package/lib/cjs/tile/GltfReader.d.ts +13 -420
  26. package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
  27. package/lib/cjs/tile/GltfReader.js +118 -192
  28. package/lib/cjs/tile/GltfReader.js.map +1 -1
  29. package/lib/cjs/tile/RealityTileLoader.d.ts.map +1 -1
  30. package/lib/cjs/tile/RealityTileLoader.js +14 -2
  31. package/lib/cjs/tile/RealityTileLoader.js.map +1 -1
  32. package/lib/cjs/tile/Tile.d.ts +10 -1
  33. package/lib/cjs/tile/Tile.d.ts.map +1 -1
  34. package/lib/cjs/tile/Tile.js +22 -2
  35. package/lib/cjs/tile/Tile.js.map +1 -1
  36. package/lib/esm/core-frontend.d.ts +1 -0
  37. package/lib/esm/core-frontend.d.ts.map +1 -1
  38. package/lib/esm/core-frontend.js +1 -0
  39. package/lib/esm/core-frontend.js.map +1 -1
  40. package/lib/esm/gltf/GltfModel.d.ts +91 -0
  41. package/lib/esm/gltf/GltfModel.d.ts.map +1 -0
  42. package/lib/esm/gltf/GltfModel.js +9 -0
  43. package/lib/esm/gltf/GltfModel.js.map +1 -0
  44. package/lib/esm/gltf/GltfParser.d.ts +26 -0
  45. package/lib/esm/gltf/GltfParser.d.ts.map +1 -0
  46. package/lib/esm/gltf/GltfParser.js +329 -0
  47. package/lib/esm/gltf/GltfParser.js.map +1 -0
  48. package/lib/esm/gltf/GltfSchema.d.ts +557 -0
  49. package/lib/esm/gltf/GltfSchema.d.ts.map +1 -0
  50. package/lib/esm/gltf/GltfSchema.js +131 -0
  51. package/lib/esm/gltf/GltfSchema.js.map +1 -0
  52. package/lib/esm/render/GraphicBuilder.d.ts +5 -2
  53. package/lib/esm/render/GraphicBuilder.d.ts.map +1 -1
  54. package/lib/esm/render/GraphicBuilder.js +13 -4
  55. package/lib/esm/render/GraphicBuilder.js.map +1 -1
  56. package/lib/esm/tile/B3dmReader.d.ts +2 -1
  57. package/lib/esm/tile/B3dmReader.d.ts.map +1 -1
  58. package/lib/esm/tile/B3dmReader.js +2 -1
  59. package/lib/esm/tile/B3dmReader.js.map +1 -1
  60. package/lib/esm/tile/GltfReader.d.ts +13 -420
  61. package/lib/esm/tile/GltfReader.d.ts.map +1 -1
  62. package/lib/esm/tile/GltfReader.js +75 -149
  63. package/lib/esm/tile/GltfReader.js.map +1 -1
  64. package/lib/esm/tile/RealityTileLoader.d.ts.map +1 -1
  65. package/lib/esm/tile/RealityTileLoader.js +14 -2
  66. package/lib/esm/tile/RealityTileLoader.js.map +1 -1
  67. package/lib/esm/tile/Tile.d.ts +10 -1
  68. package/lib/esm/tile/Tile.d.ts.map +1 -1
  69. package/lib/esm/tile/Tile.js +22 -2
  70. package/lib/esm/tile/Tile.js.map +1 -1
  71. package/package.json +22 -22
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Rendering
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.isGltf1Material = exports.GltfTechniqueState = exports.traverseGltfNodes = exports.getGltfNodeMeshIds = exports.gltfDictionaryIterator = exports.GltfBufferTarget = exports.GltfWrapMode = exports.GltfMinFilter = exports.GltfMagFilter = exports.GltfDataType = exports.GltfMeshMode = void 0;
11
+ /** Enumerates the types of [[GltfMeshPrimitive]] topologies.
12
+ * @internal
13
+ */
14
+ var GltfMeshMode;
15
+ (function (GltfMeshMode) {
16
+ GltfMeshMode[GltfMeshMode["Points"] = 0] = "Points";
17
+ GltfMeshMode[GltfMeshMode["Lines"] = 1] = "Lines";
18
+ GltfMeshMode[GltfMeshMode["LineStrip"] = 3] = "LineStrip";
19
+ GltfMeshMode[GltfMeshMode["Triangles"] = 4] = "Triangles";
20
+ /** Not currently supported. */
21
+ GltfMeshMode[GltfMeshMode["TriangleStrip"] = 5] = "TriangleStrip";
22
+ /** Not currently supported. */
23
+ GltfMeshMode[GltfMeshMode["TriangleFan"] = 6] = "TriangleFan";
24
+ })(GltfMeshMode = exports.GltfMeshMode || (exports.GltfMeshMode = {}));
25
+ /** Enumerates the basic data types supported by accessors, material values, technique uniforms, etc.
26
+ * @internal
27
+ */
28
+ var GltfDataType;
29
+ (function (GltfDataType) {
30
+ GltfDataType[GltfDataType["SignedByte"] = 5120] = "SignedByte";
31
+ GltfDataType[GltfDataType["UnsignedByte"] = 5121] = "UnsignedByte";
32
+ GltfDataType[GltfDataType["SignedShort"] = 5122] = "SignedShort";
33
+ GltfDataType[GltfDataType["UnsignedShort"] = 5123] = "UnsignedShort";
34
+ GltfDataType[GltfDataType["UInt32"] = 5125] = "UInt32";
35
+ GltfDataType[GltfDataType["Float"] = 5126] = "Float";
36
+ GltfDataType[GltfDataType["Rgb"] = 6407] = "Rgb";
37
+ GltfDataType[GltfDataType["Rgba"] = 6408] = "Rgba";
38
+ GltfDataType[GltfDataType["IntVec2"] = 35667] = "IntVec2";
39
+ GltfDataType[GltfDataType["IntVec3"] = 35668] = "IntVec3";
40
+ GltfDataType[GltfDataType["FloatVec2"] = 35664] = "FloatVec2";
41
+ GltfDataType[GltfDataType["FloatVec3"] = 35665] = "FloatVec3";
42
+ GltfDataType[GltfDataType["FloatVec4"] = 35666] = "FloatVec4";
43
+ GltfDataType[GltfDataType["FloatMat3"] = 35675] = "FloatMat3";
44
+ GltfDataType[GltfDataType["FloatMat4"] = 35676] = "FloatMat4";
45
+ GltfDataType[GltfDataType["Sampler2d"] = 35678] = "Sampler2d";
46
+ })(GltfDataType = exports.GltfDataType || (exports.GltfDataType = {}));
47
+ /** @internal */
48
+ var GltfMagFilter;
49
+ (function (GltfMagFilter) {
50
+ GltfMagFilter[GltfMagFilter["Nearest"] = 9728] = "Nearest";
51
+ GltfMagFilter[GltfMagFilter["Linear"] = 9729] = "Linear";
52
+ })(GltfMagFilter = exports.GltfMagFilter || (exports.GltfMagFilter = {}));
53
+ /** @internal */
54
+ var GltfMinFilter;
55
+ (function (GltfMinFilter) {
56
+ GltfMinFilter[GltfMinFilter["Nearest"] = 9728] = "Nearest";
57
+ GltfMinFilter[GltfMinFilter["Linear"] = 9729] = "Linear";
58
+ GltfMinFilter[GltfMinFilter["NearestMipMapNearest"] = 9984] = "NearestMipMapNearest";
59
+ GltfMinFilter[GltfMinFilter["LinearMipMapNearest"] = 9985] = "LinearMipMapNearest";
60
+ GltfMinFilter[GltfMinFilter["NearestMipMapLinear"] = 9986] = "NearestMipMapLinear";
61
+ GltfMinFilter[GltfMinFilter["LinearMipMapLinear"] = 9987] = "LinearMipMapLinear";
62
+ })(GltfMinFilter = exports.GltfMinFilter || (exports.GltfMinFilter = {}));
63
+ /** Describes how texture coordinates outside of the range [0..1] are handled.
64
+ * @internal
65
+ */
66
+ var GltfWrapMode;
67
+ (function (GltfWrapMode) {
68
+ GltfWrapMode[GltfWrapMode["ClampToEdge"] = 33071] = "ClampToEdge";
69
+ GltfWrapMode[GltfWrapMode["MirroredRepeat"] = 33648] = "MirroredRepeat";
70
+ GltfWrapMode[GltfWrapMode["Repeat"] = 10497] = "Repeat";
71
+ })(GltfWrapMode = exports.GltfWrapMode || (exports.GltfWrapMode = {}));
72
+ /** Describes the intended target of a [[GltfBufferViewProps]].
73
+ * @internal
74
+ */
75
+ var GltfBufferTarget;
76
+ (function (GltfBufferTarget) {
77
+ GltfBufferTarget[GltfBufferTarget["ArrayBuffer"] = 34962] = "ArrayBuffer";
78
+ GltfBufferTarget[GltfBufferTarget["ElementArrayBuffer"] = 24963] = "ElementArrayBuffer";
79
+ })(GltfBufferTarget = exports.GltfBufferTarget || (exports.GltfBufferTarget = {}));
80
+ /** Iterate the contents of a [[GltfDictionary]].
81
+ * @internal
82
+ */
83
+ function* gltfDictionaryIterator(dict) {
84
+ if (Array.isArray(dict)) {
85
+ for (const elem of dict)
86
+ yield elem;
87
+ }
88
+ else {
89
+ for (const key of Object.keys(dict)) {
90
+ const value = dict[key];
91
+ if (undefined !== value)
92
+ yield value;
93
+ }
94
+ }
95
+ }
96
+ exports.gltfDictionaryIterator = gltfDictionaryIterator;
97
+ /** Get the Ids of the meshes associated with a node.
98
+ * @internal
99
+ */
100
+ function getGltfNodeMeshIds(node) {
101
+ if (undefined !== node.meshes)
102
+ return typeof node.meshes === "string" ? [node.meshes] : node.meshes;
103
+ else if (undefined !== node.mesh)
104
+ return [node.mesh];
105
+ return [];
106
+ }
107
+ exports.getGltfNodeMeshIds = getGltfNodeMeshIds;
108
+ /** @internal */
109
+ function* traverseGltfNodes(ids, nodes, traversed) {
110
+ for (const id of ids) {
111
+ if (traversed.has(id))
112
+ throw new Error("Cycle detected while traversing glTF nodes");
113
+ const node = nodes[id];
114
+ if (!node)
115
+ continue;
116
+ traversed.add(id);
117
+ yield node;
118
+ if (node.children)
119
+ for (const child of traverseGltfNodes(node.children, nodes, traversed))
120
+ yield child;
121
+ }
122
+ }
123
+ exports.traverseGltfNodes = traverseGltfNodes;
124
+ /** GL states that can be enabled by a [[GltfTechnique]]. Only those queried by this implementation are enumerated.
125
+ * @internal
126
+ */
127
+ var GltfTechniqueState;
128
+ (function (GltfTechniqueState) {
129
+ /** Enables alpha blending. */
130
+ GltfTechniqueState[GltfTechniqueState["Blend"] = 3042] = "Blend";
131
+ })(GltfTechniqueState = exports.GltfTechniqueState || (exports.GltfTechniqueState = {}));
132
+ /** @internal */
133
+ function isGltf1Material(material) {
134
+ const mat1 = material;
135
+ return undefined !== mat1.technique || undefined !== mat1.values;
136
+ }
137
+ exports.isGltf1Material = isGltf1Material;
138
+ //# sourceMappingURL=GltfSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GltfSchema.js","sourceRoot":"","sources":["../../../src/gltf/GltfSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;GAEG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,yDAAa,CAAA;IACb,+BAA+B;IAC/B,iEAAiB,CAAA;IACjB,+BAA+B;IAC/B,6DAAe,CAAA;AACjB,CAAC,EATW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QASvB;AAED;;GAEG;AACH,IAAY,YAiBX;AAjBD,WAAY,Y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;AAHD,WAAY,kBAAkB;IAC5B,8BAA8B;IAC9B,gEAAY,CAAA;AACd,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B;AAyFD,gBAAgB;AAChB,SAAgB,eAAe,CAAC,QAAsB;IACpD,MAAM,IAAI,GAAG,QAAyB,CAAC;IACvC,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC,MAAM,CAAC;AACnE,CAAC;AAHD,0CAGC","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\n/** Enumerates the types of [[GltfMeshPrimitive]] topologies.\r\n * @internal\r\n */\r\nexport enum GltfMeshMode {\r\n Points = 0,\r\n Lines = 1,\r\n LineStrip = 3,\r\n Triangles = 4,\r\n /** Not currently supported. */\r\n TriangleStrip = 5,\r\n /** Not currently supported. */\r\n TriangleFan = 6,\r\n}\r\n\r\n/** Enumerates the basic data types supported by accessors, material values, technique uniforms, etc.\r\n * @internal\r\n */\r\nexport enum GltfDataType {\r\n SignedByte = 0x1400,\r\n UnsignedByte = 0x1401,\r\n SignedShort = 5122,\r\n UnsignedShort = 5123,\r\n UInt32 = 5125,\r\n Float = 5126,\r\n Rgb = 6407,\r\n Rgba = 6408,\r\n IntVec2 = 0x8b53,\r\n IntVec3 = 0x8b54,\r\n FloatVec2 = 35664,\r\n FloatVec3 = 35665,\r\n FloatVec4 = 35666,\r\n FloatMat3 = 35675,\r\n FloatMat4 = 35676,\r\n Sampler2d = 35678,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfMagFilter {\r\n Nearest = 9728,\r\n Linear = 9729,\r\n}\r\n\r\n/** @internal */\r\nexport enum GltfMinFilter {\r\n Nearest = GltfMagFilter.Nearest,\r\n Linear = GltfMagFilter.Linear,\r\n NearestMipMapNearest = 9984,\r\n LinearMipMapNearest = 9985,\r\n NearestMipMapLinear = 9986,\r\n LinearMipMapLinear = 9987,\r\n}\r\n\r\n/** Describes how texture coordinates outside of the range [0..1] are handled.\r\n * @internal\r\n */\r\nexport enum GltfWrapMode {\r\n ClampToEdge = 33071,\r\n MirroredRepeat = 33648,\r\n Repeat = 10497,\r\n}\r\n\r\n/** Describes the intended target of a [[GltfBufferViewProps]].\r\n * @internal\r\n */\r\nexport enum GltfBufferTarget {\r\n ArrayBuffer = 34962,\r\n ElementArrayBuffer = 24963,\r\n}\r\n\r\n/** The type used to refer to an entry in a GltfDictionary in a glTF 1.0 asset. @internal */\r\nexport type Gltf1Id = string;\r\n/** The type used to refer to an entry in a GltfDictionary in a glTF 2.0 asset. @internal */\r\nexport type Gltf2Id = number;\r\n/** The type used to refer to an entry in a GltfDictionary. @internal */\r\nexport type GltfId = Gltf1Id | Gltf2Id;\r\n\r\n/** A collection of resources of some type defined at the top-level of a [[GltfDocument]].\r\n * In glTF 1.0, these are defined as objects; each resource is referenced and accessed by its string key.\r\n * In glTF 2.0, these are defined as arrays; each resource is referenced and accessed by its integer array index.\r\n * @internal\r\n */\r\nexport interface GltfDictionary<T extends GltfChildOfRootProperty> {\r\n [key: GltfId]: T | undefined;\r\n}\r\n\r\n/** @internal */\r\nexport interface GltfStringMap<T> {\r\n [key: string]: T | undefined;\r\n}\r\n\r\n/** Iterate the contents of a [[GltfDictionary]].\r\n * @internal\r\n */\r\nexport function * gltfDictionaryIterator<T extends GltfChildOfRootProperty>(dict: GltfDictionary<T>): Iterable<T> {\r\n if (Array.isArray(dict)) {\r\n for (const elem of dict)\r\n yield elem;\r\n } else {\r\n for (const key of Object.keys(dict)) {\r\n const value = dict[key];\r\n if (undefined !== value)\r\n yield value;\r\n }\r\n }\r\n}\r\n\r\n/** Optional extensions applied to a [[GltfProperty]] to enable behavior not defined in the core specification.\r\n * @internal\r\n */\r\nexport type GltfExtensions = GltfStringMap<unknown>;\r\n\r\n/** The base interface provided by most objects in a glTF asset, permitting additional data to be associated with the object.\r\n * @internal\r\n */\r\nexport interface GltfProperty {\r\n extensions?: GltfExtensions;\r\n extras?: any;\r\n}\r\n\r\n/** The base interface provided by top-level properties of a [[GltfDocument]].\r\n * @internal\r\n */\r\nexport interface GltfChildOfRootProperty extends GltfProperty {\r\n /** Optional name, strictly for human consumption. */\r\n name?: string;\r\n}\r\n\r\n/** @internal */\r\nexport interface DracoMeshCompression {\r\n bufferView: GltfId;\r\n // TEXCOORD_0, POSITION, etc\r\n attributes: GltfStringMap<number>;\r\n}\r\n\r\n/** @internal */\r\nexport interface MeshFeature extends GltfProperty {\r\n featureCount: number;\r\n nullFeatureId?: number;\r\n label?: string;\r\n propertyTable?: number;\r\n texture?: unknown;\r\n attribute?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface MeshFeatures {\r\n featureIds: MeshFeature[];\r\n}\r\n\r\n/** A unit of geometry belonging to a [[GltfMesh]]. @internal */\r\nexport interface GltfMeshPrimitive extends GltfProperty {\r\n /** Maps the name of each mesh attribute semantic to the Id of the [[GltfAccessor]] providing the attribute's data. */\r\n attributes: GltfStringMap<GltfId>;\r\n /** The Id of the [[GltfAccessor]] providing the vertex indices. */\r\n indices?: GltfId;\r\n /** The Id of the [[GltfMaterial]] to apply to the primitive when rendering. */\r\n material?: GltfId;\r\n /** The primitive topology type. */\r\n mode?: GltfMeshMode;\r\n /** Morph targets - currently unsupported. */\r\n targets?: GltfStringMap<GltfId>;\r\n extensions?: GltfExtensions & {\r\n /** The [CESIUM_primitive_outline](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/CESIUM_primitive_outline) extension\r\n * describes how to draw outline edges for a triangle mesh.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CESIUM_primitive_outline?: {\r\n /** The Id of the [[GltfBufferViewProps]] supplying the endpoints of each edge as indices into the triangle mesh's vertex array.\r\n * The number of indices must be even; each consecutive pair of indices describes one line segment. No connectivity between\r\n * line segments is implied.\r\n */\r\n indices?: GltfId;\r\n };\r\n /** The [KHR_draco_mesh_compression](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) extension\r\n * allows glTF to support geometry compressed with Draco geometry compression.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_draco_mesh_compression?: DracoMeshCompression;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n EXT_mesh_features?: MeshFeatures;\r\n };\r\n}\r\n\r\n/** A collection of [[GltfMeshPrimitive]]s to be rendered. Each mesh is referenced by a node. Multiple nodes can refer to the same mesh.\r\n * The node's transform is applied when rendering the mesh.\r\n * @internal\r\n */\r\nexport interface GltfMesh extends GltfChildOfRootProperty {\r\n /** The collection of primitives to be rendered. */\r\n primitives?: GltfMeshPrimitive[];\r\n /** For morph targets - currently unsupported. */\r\n weights?: number[];\r\n}\r\n\r\n/** Properties common to [[Gltf1Node]] and [[Gltf2Node]]. @internal */\r\nexport interface GltfNodeBaseProps {\r\n /** The Ids of the child nodes. @see [[GltfNode]]. */\r\n children?: GltfId[];\r\n /** Currently ignored. */\r\n camera?: GltfId;\r\n /** Currently ignored. */\r\n skin?: GltfId;\r\n /** A 4x4 column-major transformation matrix. Mutually exclusive with [[rotation]], [[scale]], and [[translation]]. */\r\n matrix?: number[];\r\n /** Unit quaternion as [x, y, z, w], where w is the scalar. */\r\n rotation?: number[];\r\n /** Non-uniform scale as [x, y, z]. */\r\n scale?: number[];\r\n /** Translation as [x, y, z]. */\r\n translation?: number[];\r\n}\r\n\r\n/** glTF 1.0 representation of a [[GltfNode]]. Unlike a [[Gltf2Node]], a Gltf1Node may refer to any number of [[GltfMesh]]es.\r\n * @internal\r\n */\r\nexport interface Gltf1Node extends GltfChildOfRootProperty, GltfNodeBaseProps {\r\n /** The Ids of the [[GltfMesh]]es to be rendered by this node.\r\n * @note The spec defines this as an array of strings, but the original implementation of [[GltfReader]] was written to treat it as a string instead.\r\n * In case this was because of non-spec-compliant glTF that placed a string here instead of an array, either is permitted.\r\n */\r\n meshes?: GltfId[] | string;\r\n mesh?: never;\r\n /** Currently ignored. */\r\n jointName?: GltfId;\r\n /** Currently ignored. */\r\n skeletons?: GltfId[];\r\n}\r\n\r\n/** glTF 2.0 representation of a [[GltfNode]]. Unlike a [[Gltf1Node]], a Gltf2Node may refer to at most one [[GltfMesh]].\r\n * @internal\r\n */\r\nexport interface Gltf2Node extends GltfChildOfRootProperty, GltfNodeBaseProps {\r\n /** The Id of the [[GltfMesh]] to be rendered by this node. */\r\n mesh?: GltfId;\r\n meshes?: never;\r\n /** Morph targets - currently ignored. */\r\n weights?: number[];\r\n}\r\n\r\n/** Describes a node in a [[GltfScene]]. Each node may be associated with zero, one (glTF 2.0), or any number of (glTF 1.0) [[GltfMesh]]es.\r\n * Each node may define a transform. Each node may have any number of child nodes. A child node's transform is multiplied by its parent node's transform.\r\n * Some nodes may be associated with other types of data like cameras, skins, lights, etc - these types of data are currently unsupported.\r\n * Rendering a node means rendering its meshes and the meshes of all of its descendants, with transforms applied.\r\n * @internal\r\n */\r\nexport type GltfNode = Gltf1Node | Gltf2Node;\r\n\r\n/** Get the Ids of the meshes associated with a node.\r\n * @internal\r\n */\r\nexport function getGltfNodeMeshIds(node: GltfNode): GltfId[] {\r\n if (undefined !== node.meshes)\r\n return typeof node.meshes === \"string\" ? [node.meshes] : node.meshes;\r\n else if (undefined !== node.mesh)\r\n return [node.mesh];\r\n\r\n return [];\r\n}\r\n\r\n/** @internal */\r\nexport function * traverseGltfNodes(ids: Iterable<GltfId>, nodes: GltfDictionary<GltfNode>, traversed: Set<GltfId>): Iterable<GltfNode> {\r\n for (const id of ids) {\r\n if (traversed.has(id))\r\n throw new Error(\"Cycle detected while traversing glTF nodes\");\r\n\r\n const node = nodes[id];\r\n if (!node)\r\n continue;\r\n\r\n traversed.add(id);\r\n yield node;\r\n if (node.children)\r\n for (const child of traverseGltfNodes(node.children, nodes, traversed))\r\n yield child;\r\n }\r\n}\r\n\r\n/** Describes a scene graph that composes any number of [[GltfNode]]s to produce a rendering of the [[GltfDocument]] asset.\r\n * An asset may define any number of scenes; the default scene is specified by [[Gltf.scene]].\r\n * @internal\r\n */\r\nexport interface GltfScene extends GltfChildOfRootProperty {\r\n /** The Ids of the nodes comprising the scene graph. */\r\n nodes?: GltfId[];\r\n}\r\n\r\n/** Provides metadata about a [[GltfDocument]] asset.\r\n * @internal\r\n */\r\nexport interface GltfAsset extends GltfProperty {\r\n /** A copyright message suitable for display to credit the content creator. */\r\n copyright?: string;\r\n /** The name of the tool that generated the asset. */\r\n generator?: string;\r\n /** The glTF version targeted by the asset, in the form \"major.minor\" where \"major\" and \"minor\" are integers. */\r\n version: string;\r\n /** The minimum glTF version required to properly load this asset, in the same form as [[version]].\r\n * This minimum version must be no greater than [[version]].\r\n */\r\n minVersion?: string;\r\n}\r\n\r\n/** Describes an image such as one used for a [[GltfTexture]]. The image may be referenced by a [[uri]] or a [[bufferView]].\r\n * @internal\r\n */\r\nexport interface GltfImage extends GltfChildOfRootProperty {\r\n /** URI from which the image data can be obtained, either as a base-64-encoded data URI or an external resource.\r\n * Mutually exclusive with [[bufferView]].\r\n */\r\n uri?: string;\r\n /** The image's media type. This property is required if [[bufferView]] is defined. */\r\n mimeType?: \"image/jpeg\" | \"image/png\";\r\n /** The Id of the [[GltfBufferViewProps]] containing the image data. Mutually exclusive with [[uri]]. */\r\n bufferView?: GltfId;\r\n extensions?: GltfExtensions & {\r\n /** The [KHR_binary_glTF](https://github.com/KhronosGroup/glTF/tree/main/extensions/1.0/Khronos/KHR_binary_glTF) allows an image to\r\n * be embedded in a binary chunk appended to the glTF asset's JSON, instead of being referenced by an external URI.\r\n * This is superseded in glTF 2.0 by support for the glb file format specification.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_binary_glTF?: {\r\n /** The Id of the [[GltfBufferViewProps]] that contains the binary image data. */\r\n bufferView?: GltfId;\r\n /** Required - @see [[GltfImage.mimeType]]. */\r\n mimeType?: string;\r\n };\r\n };\r\n}\r\n\r\n/** Describes a reference to a [[GltfTexture]]. @internal */\r\nexport interface GltfTextureInfo extends GltfProperty {\r\n /** The Id of the [[GltfTexture]]. */\r\n index: GltfId;\r\n /** The set index of the texture's TEXCOORD attribute used for texture coordinate mapping.\r\n * For example, if `texCoord` is `2`, an attribute named `TEXCOORD_2` must exist containing the texture coordinates.\r\n * Default: 0.\r\n */\r\n texCoord?: number;\r\n}\r\n\r\n/** Describes a texture and its sampler.\r\n * @internal\r\n */\r\nexport interface GltfTexture extends GltfChildOfRootProperty {\r\n /** The Id of the [[GltfSampler]] used by this texture.\r\n * If undefined, a sampler with repeat wrapping and auto filtering should be used by default.\r\n */\r\n sampler?: GltfId;\r\n /** The Id of the [[GltfImage]] used by this texture.\r\n * If undefined, an extension or other mechanism should supply an alternate image source - otherwise, the behavior is undefined.\r\n */\r\n source?: GltfId;\r\n}\r\n\r\n/** Describes the filtering and wrapping behavior to be applied to a [[GltfTexture]].\r\n * @note The implementation currently does not support MirroredRepeat and does not support different wrapping for U and V;\r\n * effectively, unless `wrapS` or `wrapT` is set to ClampToEdge, the sampler will use GltfWrapMode.Repeat.\r\n * @internal\r\n */\r\nexport interface GltfSampler extends GltfChildOfRootProperty {\r\n /** Magnification filter. */\r\n magFilter?: GltfMagFilter;\r\n /** Minification filter. */\r\n minFilter?: GltfMinFilter;\r\n /** S (U) wrapping mode. Default: Repeat. */\r\n wrapS?: GltfWrapMode;\r\n /** T (V) wrapping mode. Default: Repeat. */\r\n wrapT?: GltfWrapMode;\r\n}\r\n\r\n/** GL states that can be enabled by a [[GltfTechnique]]. Only those queried by this implementation are enumerated.\r\n * @internal\r\n */\r\nexport enum GltfTechniqueState {\r\n /** Enables alpha blending. */\r\n Blend = 3042,\r\n}\r\n\r\n/** For glTF 1.0 only, describes shader programs and shader state associated with a [[Gltf1Material]], used to render meshes associated with the material.\r\n * This implementation uses it strictly to identify techniques that require alpha blending.\r\n * @internal\r\n */\r\nexport interface GltfTechnique extends GltfChildOfRootProperty {\r\n /** GL render states to be applied by the technique. */\r\n states?: {\r\n /** An array of integers corresponding to boolean GL states that should be enabled using GL's `enable` function.\r\n * For example, the value [[GltfTechniqueState.Blend]] (3042) indicates that blending should be enabled.\r\n */\r\n enable?: GltfTechniqueState[];\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport interface Gltf1Material extends GltfChildOfRootProperty {\r\n diffuse?: string;\r\n emission?: number[];\r\n shininess?: number;\r\n specular?: number[];\r\n technique?: GltfId;\r\n values?: {\r\n texStep?: number[];\r\n color?: number[];\r\n tex?: number | string;\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport interface GltfMaterialPbrMetallicRoughness extends GltfProperty {\r\n // Default [1,1,1,1]\r\n baseColorFactor?: number[];\r\n baseColorTexture?: GltfTextureInfo;\r\n // Default 1\r\n metallicFactor?: number;\r\n // Default 1\r\n roughnessFactor?: number;\r\n metallicRoughnessTexture?: GltfTextureInfo;\r\n}\r\n\r\n/** @internal */\r\nexport type GltfAlphaMode = \"OPAQUE\" | \"MASK\" | \"BLEND\";\r\n\r\n/** @internal */\r\nexport interface Gltf2Material extends GltfChildOfRootProperty {\r\n pbrMetallicRoughness?: GltfMaterialPbrMetallicRoughness;\r\n normalTexture?: GltfTextureInfo;\r\n occlusionTexture?: unknown;\r\n emissiveTexture?: GltfTextureInfo;\r\n emissiveFactor?: number[];\r\n // Default OPAQUE\r\n alphaMode?: GltfAlphaMode;\r\n // Default 0.5. Ignored unless alphaMode=MASK\r\n alphaCutoff?: number;\r\n doubleSided?: boolean;\r\n extensions?: GltfExtensions & {\r\n /** The [KHR_materials_unlit](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_unlit) extension\r\n * indicates that the material should be displayed without lighting. The extension adds no additional properties; it is effectively a boolean flag.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_materials_unlit?: { };\r\n /** The [KHR_techniques_webgl extension](https://github.com/KhronosGroup/glTF/blob/c1c12bd100e88ff468ccef1cb88cfbec56a69af2/extensions/2.0/Khronos/KHR_techniques_webgl/README.md)\r\n * allows \"techniques\" to be associated with [[GltfMaterial]]s. Techniques can supply custom shader programs to render geometry; this was a core feature of glTF 1.0 (see [[GltfTechnique]]).\r\n * Here, it is only used to extract uniform values.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_techniques_webgl?: {\r\n technique?: number;\r\n // An object containing uniform values. Each property name corresponds to a uniform in the material's technique and must conform to that uniform's type and count properties.\r\n // A handful of uniforms referenced in this implementation by name are defined below.\r\n values?: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n u_texStep?: number[];\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n u_color?: number[];\r\n // Diffuse texture.\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n u_diffuse?: { index: number, texCoord: number };\r\n [k: string]: unknown | undefined;\r\n };\r\n };\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport type GltfMaterial = Gltf1Material | Gltf2Material;\r\n\r\n/** @internal */\r\nexport function isGltf1Material(material: GltfMaterial): material is Gltf1Material {\r\n const mat1 = material as Gltf1Material;\r\n return undefined !== mat1.technique || undefined !== mat1.values;\r\n}\r\n\r\n/** @internal */\r\nexport interface GltfBuffer extends GltfChildOfRootProperty {\r\n uri?: string;\r\n byteLength?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface GltfBufferViewProps extends GltfChildOfRootProperty {\r\n buffer: GltfId;\r\n byteLength?: number;\r\n byteOffset?: number;\r\n byteStride?: number;\r\n target?: GltfBufferTarget;\r\n}\r\n\r\n/** @internal */\r\nexport interface GltfAccessor extends GltfChildOfRootProperty {\r\n bufferView?: GltfId;\r\n byteOffset?: number;\r\n componentType?: GltfDataType.SignedByte | GltfDataType.UnsignedByte | GltfDataType.SignedShort | GltfDataType.UnsignedShort | GltfDataType.UInt32 | GltfDataType.Float;\r\n normalized?: boolean;\r\n count: number;\r\n type: \"SCALAR\" | \"VEC2\" | \"VEC3\" | \"VEC4\" | \"MAT2\" | \"MAT3\" | \"MAT4\";\r\n max?: number[];\r\n min?: number[];\r\n sparse?: unknown; // ###TODO sparse accessors\r\n extensions?: GltfExtensions & {\r\n /** Quantized attributes for glTF 1.0. Superceded by KHR_mesh_quantization. */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n WEB3D_quantized_attributes?: {\r\n decodedMin: number[];\r\n decodedMax: number[];\r\n /** Currently ignored. */\r\n decodeMatrix: number[];\r\n };\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport namespace GltfStructuralMetadata {\r\n export type ClassPropertyType = \"SCALAR\" | \"STRING\" | \"BOOLEAN\" | \"ENUM\" | \"VEC2\" | \"VEC3\" | \"VEC4\" | \"MAT2\" | \"MAT3\" | \"MAT4\" | string;\r\n export type ClassPropertyComponentType = \"INT8\" | \"UINT8\" | \"INT16\" | \"UINT16\" | \"INT32\" | \"UINT32\" | \"INT64\" | \"UINT64\" | \"FLOAT32\" | \"FLOAT64\" | string;\r\n\r\n // Ignoring VECN and MATN types because they complicate offset, scale, min, and max, all of which are otherwise only relevant to SCALAR in which case they're all just numbers.\r\n export interface ClassProperty extends GltfProperty {\r\n type: ClassPropertyType;\r\n name?: string;\r\n description?: string;\r\n componentType?: ClassPropertyComponentType;\r\n enumType?: string;\r\n array?: boolean;\r\n count?: number;\r\n normalized?: boolean;\r\n offset?: number;\r\n scale?: number;\r\n min?: number;\r\n max?: number;\r\n required?: boolean;\r\n noData?: unknown;\r\n default?: unknown;\r\n semantic?: string;\r\n }\r\n\r\n export interface EnumValue extends GltfProperty {\r\n name: string;\r\n value: number; // an integer\r\n description?: string;\r\n }\r\n\r\n export interface Enum extends GltfProperty {\r\n values: EnumValue[];\r\n // Default: UINT16\r\n valueType?: \"INT8\" | \"UINT8\" | \"INT16\" | \"UINT16\" | \"INT32\" | \"UINT32\" | \"INT64\" | \"UINT64\" | string;\r\n name?: string;\r\n description?: string;\r\n }\r\n\r\n export interface Class extends GltfProperty {\r\n name?: string;\r\n description?: string;\r\n properties?: {\r\n [propertyId: string]: ClassProperty | undefined;\r\n };\r\n }\r\n\r\n export interface Schema extends GltfProperty {\r\n id: string;\r\n name?: string;\r\n description?: string;\r\n version?: string;\r\n classes?: Class[];\r\n enums?: Enum[];\r\n }\r\n\r\n // Ignoring VECN and MATN types because they complicate offset, scale, min, and max, all of which are otherwise only relevant to SCALAR in which case they're all just numbers.\r\n export interface PropertyTableProperty extends GltfProperty {\r\n values: GltfId;\r\n arrayOffsets?: GltfId;\r\n stringOffsets?: GltfId;\r\n arrayOffsetType?: \"UINT8\" | \"UINT16\" | \"UINT32\" | \"UINT64\" | string;\r\n stringOffsetType?: \"UINT8\" | \"UINT16\" | \"UINT32\" | \"UINT64\" | string;\r\n offset?: number;\r\n scale?: number;\r\n min?: number;\r\n max?: number;\r\n }\r\n\r\n export interface PropertyTable {\r\n class: string;\r\n count: number;\r\n properties?: {\r\n [propertyId: string]: PropertyTableProperty | undefined;\r\n };\r\n }\r\n\r\n export interface Extension extends GltfProperty {\r\n // Exactly one of schema or schemaUri must be present.\r\n schemaUri?: string;\r\n schema?: Schema;\r\n propertyTables?: PropertyTable[];\r\n propertyTextures?: unknown;\r\n propertyAttributes?: unknown;\r\n }\r\n}\r\n\r\n/** Describes the top-level structure of a glTF asset.\r\n * This interface, along with all of the related Gltf* types defined in this file, is primarily based upon the [official glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html).\r\n * However, it can also represent a [glTF 1.0](https://github.com/KhronosGroup/glTF/tree/main/specification/1.0#reference-node) asset.\r\n * Some types are combined. For example, the top-level dictionaries in glTF 1.0 are objects, while in glTF 2.0 they are arrays; the GltfDictionary interface supports accessing\r\n * items using either strings or numeric indexes represented by [[GltfId]].\r\n * For types that differ significantly between the two specs, Gltf1* and Gltf2* versions are defined (e.g., GltfMaterial is a union of Gltf1Material and Gltf2Material).\r\n * These interfaces also accommodate some deviations from both specs that are known to exist in the wild.\r\n * Most aspects of the specifications that are not implemented here are omitted (e.g., skinning, animations).\r\n * @internal\r\n */\r\nexport interface GltfDocument extends GltfProperty {\r\n /** Metadata about the glTF asset.\r\n * @note This property is required in glTF 2.0, but optional in 1.0.\r\n */\r\n asset?: GltfAsset;\r\n /** The Id of the default [[GltfScene]] in [[scenes]]. */\r\n scene?: GltfId;\r\n extensions?: GltfExtensions & {\r\n /** The [CESIUM_RTC extension](https://github.com/KhronosGroup/glTF/blob/main/extensions/1.0/Vendor/CESIUM_RTC/README.md) defines a centroid\r\n * relative to which all coordinates in the asset are defined, to reduce floating-point precision errors for large coordinates.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CESIUM_RTC?: {\r\n center?: number[];\r\n };\r\n /** The [KHR_techniques_webgl extension](https://github.com/KhronosGroup/glTF/blob/c1c12bd100e88ff468ccef1cb88cfbec56a69af2/extensions/2.0/Khronos/KHR_techniques_webgl/README.md)\r\n * allows \"techniques\" to be associated with [[GltfMaterial]]s. Techniques can supply custom shader programs to render geometry; this was a core feature of glTF 1.0 (see [[GltfTechnique]]).\r\n * Here, it is only used to extract uniform values.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_techniques_webgl?: {\r\n techniques?: Array<{\r\n uniforms?: {\r\n [key: string]: { type: GltfDataType, value?: any } | undefined;\r\n };\r\n }>;\r\n };\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n EXT_structural_metadata?: GltfStructuralMetadata.Extension;\r\n };\r\n /** Names of glTF extensions used in the asset. */\r\n extensionsUsed?: string[];\r\n /** Names of glTF extensions required to properly load the asset. */\r\n extensionsRequired?: string[];\r\n accessors?: GltfDictionary<GltfAccessor>;\r\n /** Not currently supported. */\r\n animations?: GltfDictionary<any>;\r\n buffers?: GltfDictionary<GltfBuffer>;\r\n bufferViews?: GltfDictionary<GltfBufferViewProps>;\r\n /** Not currently used. */\r\n cameras?: GltfDictionary<any>;\r\n images?: GltfDictionary<GltfImage>;\r\n materials?: GltfDictionary<GltfMaterial>;\r\n meshes?: GltfDictionary<GltfMesh>;\r\n nodes?: GltfDictionary<GltfNode>;\r\n samplers?: GltfDictionary<GltfSampler>;\r\n scenes?: GltfDictionary<GltfScene>;\r\n /** Not currently supported. */\r\n skins?: GltfDictionary<any>;\r\n textures?: GltfDictionary<GltfTexture>;\r\n /** For glTF 1.0 only, techniques associated with [[Gltf1Material]]s. */\r\n techniques?: GltfDictionary<GltfTechnique>;\r\n}\r\n"]}
@@ -348,8 +348,11 @@ export declare abstract class GraphicBuilder {
348
348
  * @param primitive The graphic primitive to append.
349
349
  */
350
350
  addPrimitive(primitive: GraphicPrimitive): void;
351
- /** Add Range3d edges. Useful for debugging. */
352
- addRangeBox(range: Range3d): void;
351
+ /** Add a box representing a volume of space. Typically used for debugging purposes.
352
+ * @param range The volume of space.
353
+ * @param solid If true, a [[Box]] solid primitive will be added; otherwise, a wireframe outline of the box will be added.
354
+ */
355
+ addRangeBox(range: Range3d, solid?: boolean): void;
353
356
  /** Add Frustum edges. Useful for debugging. */
354
357
  addFrustum(frustum: Frustum): void;
355
358
  /** Add range edges from corner points */
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicBuilder.d.ts","sourceRoot":"","sources":["../../../src/render/GraphicBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EACrG,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAO,MAAM,oBAAoB,CAAC;AAC9H,OA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AW,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAEtE,+CAA+C;aAC/B,iBAAiB,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;IAEvE;;OAEG;IACI,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAyCtD;;;OAGG;IACI,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,UAAQ,GAAG,IAAI;IAWvD,+CAA+C;IACxC,UAAU,CAAC,OAAO,EAAE,OAAO;IAIlC,yCAAyC;IAClC,sBAAsB,CAAC,CAAC,EAAE,OAAO,EAAE;IAmB1C;;;;;;OAMG;IACI,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,aAAmB;IAI9G;;;;;OAKG;IACI,eAAe,CAAC,SAAS,EAAE,QAAQ;CAC3C"}
@@ -234,9 +234,18 @@ class GraphicBuilder {
234
234
  break;
235
235
  }
236
236
  }
237
- /** Add Range3d edges. Useful for debugging. */
238
- addRangeBox(range) {
239
- this.addFrustum(core_common_1.Frustum.fromRange(range));
237
+ /** Add a box representing a volume of space. Typically used for debugging purposes.
238
+ * @param range The volume of space.
239
+ * @param solid If true, a [[Box]] solid primitive will be added; otherwise, a wireframe outline of the box will be added.
240
+ */
241
+ addRangeBox(range, solid = false) {
242
+ if (!solid) {
243
+ this.addFrustum(core_common_1.Frustum.fromRange(range));
244
+ return;
245
+ }
246
+ const box = core_geometry_1.Box.createRange(range, true);
247
+ if (box)
248
+ this.addSolidPrimitive(box);
240
249
  }
241
250
  /** Add Frustum edges. Useful for debugging. */
242
251
  addFrustum(frustum) {
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicBuilder.js","sourceRoot":"","sources":["../../../src/render/GraphicBuilder.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,wDAE8B;AAC9B,oDAA8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AAC,gBAAgB,CAAC,CAAC,KAAK,EAAE;SAChC,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,iBAAG,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAG,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,iBAAG,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAG,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,iBAAG,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAG,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;IAED;;;;;;OAMG;IACI,YAAY,CAAC,SAAmB,EAAE,SAAmB,EAAE,SAAiB,EAAE,UAAU,GAAG,wBAAU,CAAC,KAAK;QAC5G,IAAI,CAAC,qBAAqB,CAAC,2BAAa,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACvG,CAAC;IAED;;;;;OAKG;IACI,eAAe,CAAC,SAAmB,IAAI,IAAI,CAAC,qBAAqB,CAAC,2BAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CACvH;AA/UD,wCA+UC","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, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n AnyCurvePrimitive, Arc3d, Loop, Path, Point2d, Point3d, Polyface, Range3d, SolidPrimitive, Transform,\r\n} from \"@itwin/core-geometry\";\r\nimport { AnalysisStyle, ColorDef, Feature, Frustum, GeometryClass, GraphicParams, LinePixels, Npc } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { RenderGraphic } from \"./RenderGraphic\";\r\nimport { GraphicPrimitive } from \"./GraphicPrimitive\";\r\n\r\n/**\r\n * Describes the type of a [[GraphicBuilder]], which defines the coordinate system in which the builder's geometry is defined and\r\n * controls the behavior of the [[RenderGraphic]] produced by the builder.\r\n * @note For those types for which depth-testing is disabled, the order in which the individual geometric primitives are drawn determines which geometry draws on top of other geometry.\r\n * - Within a [[GraphicList]], each [[RenderGraphic]] is rendered in the order in which it appears in the list; and\r\n * - Within a single [[RenderGraphic]], each geometric primitive is rendered in the ordered in which it was added to the GraphicBuilder.\r\n * @public\r\n * @extensions\r\n */\r\nexport enum GraphicType {\r\n /**\r\n * Renders behind all other graphics. For example, the border of a [[SheetViewState]] is of this type.\r\n * Coordinates: [[CoordSystem.View]].\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]].\r\n * Lighting: none.\r\n * Depth-testing: disabled.\r\n * @see [[Decorations.viewBackground]]\r\n */\r\n ViewBackground,\r\n /** Used for the scene itself, dynamics, and 'normal' decorations. */\r\n /**\r\n * Renders as if it were part of the scene. All of the [[ViewFlags]] applied to the view's normal geometry also applies to these types of decorations.\r\n * Coordinates: [[CoordSystem.World]].\r\n * Lighting and [[RenderMode]]: from view.\r\n * Depth-testing: enabled.\r\n * @see [[Decorations.normal]].\r\n */\r\n Scene,\r\n /** Renders within the scene. Coordinates: world. RenderMode: smooth. Lighting: default. Z-testing: enabled */\r\n /** Renders within the scene, but ignores the view's [[ViewFlags]].\r\n * Coordinates: [[CoordSystem.World]].\r\n * Lighting: default.\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]].\r\n * Depth-testing: enabled.\r\n * @see [[Decorations.world]].\r\n */\r\n WorldDecoration,\r\n /**\r\n * Renders as an overlay on top of the scene. These decorations differ from [[GraphicType.WorldDecoration]] only in that depth-testing is disabled.\r\n * For example, the ACS triad and [[WindowAreaTool]] decorations are of this type.\r\n * Coordinates: [[CoordSystem.World]].\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]]\r\n * Lighting: default.\r\n * Depth-testing: disabled.\r\n * Renders atop the scene. Coordinates: world. RenderMode: smooth. Lighting: none. Z-testing: disabled\r\n * @note Overlay decorations typically employ some degree of transparency to ensure that they do not fully obscure the scene.\r\n * @see [[Decorations.worldOverlay]]\r\n */\r\n WorldOverlay,\r\n /**\r\n * Renders as an overlay on top of the scene. These decorations differ from [[GraphicType.WorldOverlay]] only in that their geometry is defined in view coordinates rather than world.\r\n * Coordinates: [[CoordSystem.View]].\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]]\r\n * Lighting: default.\r\n * Depth-testing: disabled.\r\n * @note For more flexibility in defining view overlay decorations, consider using a [[CanvasDecorationList]].\r\n * @see [[Decorations.viewOverlay]]\r\n */\r\n ViewOverlay,\r\n}\r\n\r\n/** Options used when constructing a `Batch` - that is, a [[RenderGraphic]] with an associated [FeatureTable]($common) describing individual [Feature]($common)s within the\r\n * graphic. Individual features can be resymbolized in a variety of ways including flashing and hiliting.\r\n * For example, to prevent graphics produced by [[readElementGraphics]] from being hilited when their corresponding element is in the [[SelectionSet]],\r\n * pass `{ noHilite: true }` to [[readElementGraphics]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface BatchOptions {\r\n /** Identifies the [[Tile]] associated with the batch, chiefly for debugging purposes.\r\n * @beta\r\n */\r\n tileId?: string;\r\n /** If true, features within the batch will not be flashed on mouseover. */\r\n noFlash?: boolean;\r\n /** If true, features within the batch will not be hilited when their corresponding element is in the [[SelectionSet]]. */\r\n noHilite?: boolean;\r\n /** If true, features within the batch will not be emphasized when the corresponding [[Feature]] is emphasized using [FeatureOverrides]($common). */\r\n noEmphasis?: boolean;\r\n /** If true, the contents of the batch will only be drawn by [[Viewport.readPixels]], not [[Viewport.renderFrame]], causing them to be locatable but invisible. */\r\n locateOnly?: boolean;\r\n}\r\n\r\n/** Options used as part of [[GraphicBuilderOptions]] to describe a [pickable]($docs/learning/frontend/ViewDecorations#pickable-view-graphic-decorations) [[RenderGraphic]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface PickableGraphicOptions extends BatchOptions {\r\n /** A unique identifier for the graphic.\r\n * @see [[IModelConnection.transientIds]] to obtain a unique Id in the context of an iModel.\r\n * @see [[GraphicBuilder.activatePickableId]] or [[GraphicBuilder.activateFeature]] to change the pickable object while adding geometry.\r\n */\r\n id: Id64String;\r\n /** Optional Id of the subcategory with which the graphic should be associated. */\r\n subCategoryId?: Id64String;\r\n /** Optional geometry class for the graphic - defaults to [GeometryClass.Primary]($common). */\r\n geometryClass?: GeometryClass;\r\n /** The optional Id of the model with which the graphic should be associated. */\r\n modelId?: Id64String;\r\n}\r\n\r\n/** Options for creating a [[GraphicBuilder]] used by functions like [[DecorateContext.createGraphic]] and [[RenderSystem.createGraphic]].\r\n * @see [[ViewportGraphicBuilderOptions]] to create a graphic builder for a [[Viewport]].\r\n * @see [[CustomGraphicBuilderOptions]] to create a graphic builder unassociated with any [[Viewport]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface GraphicBuilderOptions {\r\n /** The type of graphic to produce. */\r\n type: GraphicType;\r\n\r\n /** The local-to-world transform in which the builder's geometry is to be defined - by default, an identity transform. */\r\n placement?: Transform;\r\n\r\n /** If the graphic is to be pickable, specifies the pickable Id and other options. */\r\n pickable?: PickableGraphicOptions;\r\n\r\n /** If true, the order in which geometry is added to the builder is preserved.\r\n * This is useful for overlay and background graphics because they draw without using the depth buffer. For example, to draw an overlay containing a red shape with a white outline,\r\n * you would add the shape to the GraphicBuilder first, followed by the outline, to ensure the outline draws \"in front of\" the shape.\r\n * It defaults to true for overlays and background graphics, and false for other graphic types.\r\n * It is not useful for other types of graphics and imposes a performance penalty due to increased number of draw calls.\r\n * For overlay and background graphics that do not need to draw in any particular order, the performance penalty can be eliminated by setting this to `false`.\r\n */\r\n preserveOrder?: boolean;\r\n\r\n /** Controls whether normals are generated for surfaces. Normals allow 3d geometry to receive lighting; without them the geometry will be unaffected by lighting.\r\n * By default, normals are generated only for graphics of type [[GraphicType.Scene]]; or for any type of graphic if [[GraphicBuilder.wantEdges]] is true, because\r\n * normals are required to prevent z-fighting between surfaces and their edges. This default can be overridden by explicitly specifying `true` or `false`.\r\n * @see [[GraphicType]] for a description of whether and how different types of graphics are affected by lighting.\r\n */\r\n wantNormals?: boolean;\r\n\r\n /** Controls whether edges are generated for surfaces.\r\n * Edges are only displayed if [ViewFlags.renderMode]($common) is not [RenderMode.SmoothShade]($common) or [ViewFlags.visibleEdges]($common) is `true`.\r\n * Since all decoration graphics except [[GraphicType.Scene]] are drawn in smooth shaded mode with no visible edges, by default edges are only produced for scene graphics, and\r\n * - if a [[Viewport]] is supplied with the options - only if [ViewFlags.edgesRequired]($common) is true for the viewport.\r\n * That default can be overridden by explicitly specifying `true` or `false`. This can be useful for non-scene decorations contained in a [[GraphicBranch]] that applies [ViewFlagOverrides]($common)\r\n * that change the edge display settings; or for scene decorations that might be cached for reuse after the viewport's edge settings are changed.\r\n * @note Edges will tend to z-fight with their surfaces unless the graphic is [[pickable]].\r\n */\r\n generateEdges?: boolean;\r\n\r\n /** If defined, specifies a point about which the graphic will rotate such that it always faces the viewer.\r\n * This can be particular useful for planar regions to create a billboarding effect - e.g., to implement [[Marker]]-like WebGL decorations.\r\n * The graphic's [[placement]] transform is not applied to the point.\r\n * @note This has no effect for graphics displayed in a 2d view.\r\n */\r\n viewIndependentOrigin?: Point3d;\r\n}\r\n\r\n/** Options for creating a [[GraphicBuilder]] to produce a [[RenderGraphic]] to be displayed in a specific [[Viewport]].\r\n * The level of detail of the graphic will be computed from the position of its geometry within the viewport's [Frustum]($common).\r\n * Default values for [[GraphicBuilderOptions.wantNormals]] and [[GraphicBuilderOptions.generateEdges]] will be determined by the viewport's [ViewFlags]($common).\r\n * The [[GraphicBuilder.iModel]] will be set to the viewport's [[IModelConnection]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface ViewportGraphicBuilderOptions extends GraphicBuilderOptions {\r\n /** The viewport in which the resultant [[RenderGraphic]] is to be drawn. */\r\n viewport: Viewport;\r\n\r\n /** If true, [[ViewState.getAspectRatioSkew]] will be taken into account when computing the level of detail for the produced graphics. */\r\n applyAspectRatioSkew?: boolean;\r\n\r\n iModel?: never;\r\n computeChordTolerance?: never;\r\n}\r\n\r\n/** Arguments used to compute the chord tolerance (level of detail) of the [[RenderGraphic]]s produced by a [[GraphicBuilder]].\r\n * Generally, the chord tolerance should be roughly equivalent to the size in meters of one pixel on screen where the graphic is to be displayed.\r\n * For [[GraphicType.ViewOverlay]] and [[GraphicType.ViewBackground]], which already define their geometry in pixels, the chord tolerance should typically be 1.\r\n * @see [[CustomGraphicBuilderOptions.computeChordTolerance]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface ComputeChordToleranceArgs {\r\n /** The graphic builder being used to produce the graphics. */\r\n readonly graphic: GraphicBuilder;\r\n /** A function that computes a range enclosing all of the geometry that was added to the builder. */\r\n readonly computeRange: () => Range3d;\r\n}\r\n\r\n/** Options for creating a [[GraphicBuilder]] to produce a [[RenderGraphic]] that is not associated with any particular [[Viewport]] and may not be associated with\r\n * any particular [[IModelConnection]].\r\n * This is primarily useful when the same graphic is to be saved and reused for display in multiple viewports and for which a chord tolerance can be computed\r\n * independently of each viewport's [Frustum]($common).\r\n * @public\r\n * @extensions\r\n */\r\nexport interface CustomGraphicBuilderOptions extends GraphicBuilderOptions {\r\n /** Optionally, the IModelConnection with which the graphic is associated. */\r\n iModel?: IModelConnection;\r\n /** A function that can compute the level of detail for the graphics produced by the builder. */\r\n computeChordTolerance: (args: ComputeChordToleranceArgs) => number;\r\n\r\n applyAspectRatioSkew?: never;\r\n viewport?: never;\r\n}\r\n\r\n/** Provides methods for constructing a [[RenderGraphic]] from geometric primitives.\r\n * GraphicBuilder is primarily used for creating [[Decorations]] to be displayed inside a [[Viewport]].\r\n *\r\n * The typical process for constructing a [[RenderGraphic]] proceeds as follows:\r\n * 1. Use [[DecorateContext.createGraphic]] or [[RenderSystem.createGraphic]] to obtain a builder.\r\n * 2. Set up the symbology using [[GraphicBuilder.activateGraphicParams]] or [[GraphicBuilder.setSymbology]].\r\n * 3. Add one or more geometric primitives using methods like [[GraphicBuilder.addShape]] and [[GraphicBuilder.addLineString]], possibly setting new symbology in between.\r\n * 4. Use [[GraphicBuilder.finish]] to produce the finished [[RenderGraphic]].\r\n *\r\n * @note Most of the methods which add geometry to the builder take ownership of their inputs rather than cloning them.\r\n * So, for example, if you pass an array of points to addLineString(), you should not subsequently modify that array.\r\n *\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class GraphicBuilder {\r\n /** The local coordinate system transform applied to this builder's geometry.\r\n * @see [[GraphicBuilderOptions.placement]].\r\n */\r\n public readonly placement: Transform;\r\n\r\n /** The iModel associated with this builder, if any. */\r\n public readonly iModel?: IModelConnection;\r\n\r\n /** The type of graphic to be produced by this builder.\r\n * @see [[GraphicBuilderOptions.type]].\r\n */\r\n public readonly type: GraphicType;\r\n\r\n /** If the graphic is to be pickable, specifies the pickable Id and other options. */\r\n public readonly pickable?: Readonly<PickableGraphicOptions>;\r\n\r\n /** If true, the order in which geometry is added to the builder is preserved.\r\n * @see [[GraphicBuilderOptions.preserveOrder]] for more details.\r\n */\r\n public readonly preserveOrder: boolean;\r\n\r\n /** Controls whether normals are generated for surfaces.\r\n * @note Normals are required for proper edge display, so by default they are always produced if [[wantEdges]] is `true`.\r\n * @see [[GraphicBuilderOptions.wantNormals]] for more details.\r\n */\r\n public readonly wantNormals: boolean;\r\n\r\n /** Controls whether edges are generated for surfaces.\r\n * @see [[GraphicBuilderOptions.generateEdges]] for more details.\r\n */\r\n public readonly wantEdges: boolean;\r\n\r\n /** @alpha */\r\n public readonly analysisStyle?: AnalysisStyle;\r\n\r\n protected readonly _computeChordTolerance: (args: ComputeChordToleranceArgs) => number;\r\n protected readonly _options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions;\r\n\r\n /** @internal */\r\n protected constructor(options: ViewportGraphicBuilderOptions | CustomGraphicBuilderOptions) {\r\n // Stored for potential use later in creating a new GraphicBuilder from this one (see PrimitiveBuilder.finishGraphic).\r\n this._options = options;\r\n\r\n const vp = options.viewport;\r\n this.placement = options.placement ?? Transform.createIdentity();\r\n this.iModel = vp?.iModel ?? options.iModel;\r\n this.type = options.type;\r\n this.pickable = options.pickable;\r\n this.wantEdges = options.generateEdges ?? (this.type === GraphicType.Scene && (!vp || vp.viewFlags.edgesRequired()));\r\n this.wantNormals = options.wantNormals ?? (this.wantEdges || this.type === GraphicType.Scene);\r\n this.preserveOrder = options.preserveOrder ?? (this.isOverlay || this.isViewBackground);\r\n\r\n if (!options.viewport) {\r\n this._computeChordTolerance = options.computeChordTolerance;\r\n return;\r\n }\r\n\r\n this.analysisStyle = options.viewport.displayStyle.settings.analysisStyle;\r\n\r\n this._computeChordTolerance = (args: ComputeChordToleranceArgs) => {\r\n let pixelSize = 1;\r\n if (!this.isViewCoordinates) {\r\n // Compute the horizontal distance in meters between two adjacent pixels at the center of the geometry.\r\n pixelSize = options.viewport.getPixelSizeAtPoint(args.computeRange().center);\r\n pixelSize = options.viewport.target.adjustPixelSizeForLOD(pixelSize);\r\n\r\n // Aspect ratio skew > 1.0 stretches the view in Y. In that case use the smaller vertical pixel distance for our stroke tolerance.\r\n const skew = options.applyAspectRatioSkew ? options.viewport.view.getAspectRatioSkew() : 0;\r\n if (skew > 1)\r\n pixelSize /= skew;\r\n }\r\n\r\n return pixelSize * 0.25;\r\n };\r\n }\r\n\r\n /** The Id to be associated with the graphic for picking.\r\n * @see [[GraphicBuilderOptions.pickable]] for more options.\r\n * @deprecated in 3.x. This provides only the **first** pickable Id for this graphic - you should keep track of the **current** pickable Id yourself.\r\n */\r\n public get pickId(): Id64String | undefined {\r\n return this.pickable?.id;\r\n }\r\n\r\n /** Whether the builder's geometry is defined in [[CoordSystem.View]] coordinates.\r\n * @see [[isWorldCoordinates]].\r\n */\r\n public get isViewCoordinates(): boolean {\r\n return this.type === GraphicType.ViewBackground || this.type === GraphicType.ViewOverlay;\r\n }\r\n\r\n /** Whether the builder's geometry is defined in [[CoordSystem.World]] coordinates.\r\n * @see [[isViewCoordinates]].\r\n */\r\n public get isWorldCoordinates(): boolean {\r\n return !this.isViewCoordinates;\r\n }\r\n\r\n /** True if the builder produces a graphic of [[GraphicType.Scene]]. */\r\n public get isSceneGraphic(): boolean {\r\n return this.type === GraphicType.Scene;\r\n }\r\n\r\n /** True if the builder produces a graphic of [[GraphicType.ViewBackground]]. */\r\n public get isViewBackground(): boolean {\r\n return this.type === GraphicType.ViewBackground;\r\n }\r\n\r\n /** True if the builder produces a graphic of [[GraphicType.WorldOverlay]] or [[GraphicType.ViewOerlay]]. */\r\n public get isOverlay(): boolean {\r\n return this.type === GraphicType.ViewOverlay || this.type === GraphicType.WorldOverlay;\r\n }\r\n\r\n /**\r\n * Processes the accumulated symbology and geometry to produce a renderable graphic.\r\n * This function can only be called once; after the [[RenderGraphic]] has been extracted the [[GraphicBuilder]] should no longer be used.\r\n */\r\n public abstract finish(): RenderGraphic;\r\n\r\n /** Sets the current active symbology for this builder. Any new geometry subsequently added to the builder will be drawn using the specified symbology.\r\n * @param graphicParams The symbology to apply to subsequent geometry.\r\n * @see [[GraphicBuilder.setSymbology]] for a convenient way to set common symbology options.\r\n */\r\n public abstract activateGraphicParams(graphicParams: GraphicParams): void;\r\n\r\n /** Called by [[activateFeature]] after validation to change the [Feature]($common) to be associated with subsequently-added geometry.\r\n * This default implementation does nothing.\r\n */\r\n protected _activateFeature(_feature: Feature): void { }\r\n\r\n /** Change the [Feature]($common) to be associated with subsequently-added geometry. This permits multiple features to be batched together into a single graphic\r\n * for more efficient rendering.\r\n * @note This method has no effect if [[GraphicBuilderOptions.pickable]] was not supplied to the GraphicBuilder's constructor.\r\n */\r\n public activateFeature(feature: Feature): void {\r\n assert(undefined !== this._options.pickable, \"GraphicBuilder.activateFeature has no effect if PickableGraphicOptions were not supplied\");\r\n if (this._options.pickable)\r\n this._activateFeature(feature);\r\n }\r\n\r\n /** Change the pickable Id to be associated with subsequently-added geometry. This permits multiple pickable objects to be batched together into a single graphic\r\n * for more efficient rendering. This method calls [[activateFeature]], using the subcategory Id and [GeometryClass]($common) specified in [[GraphicBuilder.pickable]]\r\n * at construction, if any.\r\n * @note This method has no effect if [[GraphicBuilderOptions.pickable]] was not supplied to the GraphicBuilder's constructor.\r\n */\r\n public activatePickableId(id: Id64String): void {\r\n const pick = this._options.pickable;\r\n this.activateFeature(new Feature(id, pick?.subCategoryId, pick?.geometryClass));\r\n }\r\n\r\n /**\r\n * Appends a 3d line string to the builder.\r\n * @param points Array of vertices in the line string.\r\n */\r\n public abstract addLineString(points: Point3d[]): void;\r\n\r\n /**\r\n * Appends a 2d line string to the builder.\r\n * @param points Array of vertices in the line string.\r\n * @param zDepth Z value in local coordinates to use for each point.\r\n */\r\n public abstract addLineString2d(points: Point2d[], zDepth: number): void;\r\n\r\n /**\r\n * Appends a 3d point string to the builder. The points are drawn disconnected, with a diameter in pixels defined by the builder's active [[GraphicParams.rasterWidth]].\r\n * @param points Array of vertices in the point string.\r\n */\r\n public abstract addPointString(points: Point3d[]): void;\r\n\r\n /**\r\n * Appends a 2d point string to the builder. The points are drawn disconnected, with a diameter in pixels defined by the builder's active [[GraphicParams.rasterWidth]].\r\n * @param points Array of vertices in the point string.\r\n * @param zDepth Z value in local coordinates to use for each point.\r\n */\r\n public abstract addPointString2d(points: Point2d[], zDepth: number): void;\r\n\r\n /**\r\n * Appends a closed 3d planar region to the builder.\r\n * @param points Array of vertices of the shape.\r\n */\r\n public abstract addShape(points: Point3d[]): void;\r\n\r\n /**\r\n * Appends a closed 2d region to the builder.\r\n * @param points Array of vertices of the shape.\r\n * @param zDepth Z value in local coordinates to use for each point.\r\n */\r\n public abstract addShape2d(points: Point2d[], zDepth: number): void;\r\n\r\n /**\r\n * Appends a 3d open arc or closed ellipse to the builder.\r\n * @param arc Description of the arc or ellipse.\r\n * @param isEllipse If true, and if the arc defines a full sweep, then draw as a closed ellipse instead of an arc.\r\n * @param filled If true, and isEllipse is also true, then draw ellipse filled.\r\n */\r\n public abstract addArc(arc: Arc3d, isEllipse: boolean, filled: boolean): void;\r\n\r\n /**\r\n * Appends a 2d open arc or closed ellipse to the builder.\r\n * @param arc Description of the arc or ellipse.\r\n * @param isEllipse If true, and if the arc defines a full sweep, then draw as a closed ellipse instead of an arc.\r\n * @param filled If true, and isEllipse is also true, then draw ellipse filled.\r\n * @param zDepth Z value in local coordinates to use for each point in the arc or ellipse.\r\n */\r\n public abstract addArc2d(ellipse: Arc3d, isEllipse: boolean, filled: boolean, zDepth: number): void;\r\n\r\n /** Append a 3d open path to the builder. */\r\n public abstract addPath(path: Path): void;\r\n\r\n /** Append a 3d planar region to the builder. */\r\n public abstract addLoop(loop: Loop): void;\r\n\r\n /** Append a [CurvePrimitive]($core-geometry) to the builder. */\r\n public addCurvePrimitive(curve: AnyCurvePrimitive): void {\r\n switch (curve.curvePrimitiveType) {\r\n case \"lineString\":\r\n this.addLineString(curve.points);\r\n break;\r\n case \"lineSegment\":\r\n this.addLineString([curve.startPoint(), curve.endPoint()]);\r\n break;\r\n case \"arc\":\r\n this.addArc(curve, false, false);\r\n break;\r\n default:\r\n const path = new Path();\r\n if (path.tryAddChild(curve))\r\n this.addPath(path);\r\n\r\n break;\r\n }\r\n }\r\n\r\n /** Append a mesh to the builder.\r\n * @param meshData Describes the mesh\r\n * @param filled If the mesh describes a planar region, indicates whether its interior area should be drawn with fill in [[RenderMode.Wireframe]].\r\n */\r\n public abstract addPolyface(meshData: Polyface, filled: boolean): void;\r\n\r\n /** Append a solid primitive to the builder. */\r\n public abstract addSolidPrimitive(solidPrimitive: SolidPrimitive): void;\r\n\r\n /** Append any primitive to the builder.\r\n * @param primitive The graphic primitive to append.\r\n */\r\n public addPrimitive(primitive: GraphicPrimitive): void {\r\n switch (primitive.type) {\r\n case \"linestring\":\r\n this.addLineString(primitive.points);\r\n break;\r\n case \"linestring2d\":\r\n this.addLineString2d(primitive.points, primitive.zDepth);\r\n break;\r\n case \"pointstring\":\r\n this.addPointString(primitive.points);\r\n break;\r\n case \"pointstring2d\":\r\n this.addPointString2d(primitive.points, primitive.zDepth);\r\n break;\r\n case \"shape\":\r\n this.addShape(primitive.points);\r\n break;\r\n case \"shape2d\":\r\n this.addShape2d(primitive.points, primitive.zDepth);\r\n break;\r\n case \"arc\":\r\n this.addArc(primitive.arc, true === primitive.isEllipse, true === primitive.filled);\r\n break;\r\n case \"arc2d\":\r\n this.addArc2d(primitive.arc, true === primitive.isEllipse, true === primitive.filled, primitive.zDepth);\r\n break;\r\n case \"path\":\r\n this.addPath(primitive.path);\r\n break;\r\n case \"loop\":\r\n this.addLoop(primitive.loop);\r\n break;\r\n case \"polyface\":\r\n this.addPolyface(primitive.polyface, true === primitive.filled);\r\n break;\r\n case \"solidPrimitive\":\r\n this.addSolidPrimitive(primitive.solidPrimitive);\r\n break;\r\n }\r\n }\r\n\r\n /** Add Range3d edges. Useful for debugging. */\r\n public addRangeBox(range: Range3d) {\r\n this.addFrustum(Frustum.fromRange(range));\r\n }\r\n\r\n /** Add Frustum edges. Useful for debugging. */\r\n public addFrustum(frustum: Frustum) {\r\n this.addRangeBoxFromCorners(frustum.points);\r\n }\r\n\r\n /** Add range edges from corner points */\r\n public addRangeBoxFromCorners(p: Point3d[]) {\r\n this.addLineString([\r\n p[Npc.LeftBottomFront],\r\n p[Npc.LeftTopFront],\r\n p[Npc.RightTopFront],\r\n p[Npc.RightBottomFront],\r\n p[Npc.RightBottomRear],\r\n p[Npc.RightTopRear],\r\n p[Npc.LeftTopRear],\r\n p[Npc.LeftBottomRear],\r\n p[Npc.LeftBottomFront].clone(),\r\n p[Npc.RightBottomFront].clone(),\r\n ]);\r\n\r\n this.addLineString([p[Npc.LeftTopFront].clone(), p[Npc.LeftTopRear].clone()]);\r\n this.addLineString([p[Npc.RightTopFront].clone(), p[Npc.RightTopRear].clone()]);\r\n this.addLineString([p[Npc.LeftBottomRear].clone(), p[Npc.RightBottomRear].clone()]);\r\n }\r\n\r\n /** Sets the current active symbology for this builder. Any new geometry subsequently added will be drawn using the specified symbology.\r\n * @param lineColor The color in which to draw lines.\r\n * @param fillColor The color in which to draw filled regions.\r\n * @param lineWidth The width in pixels to draw lines. The renderer will clamp this value to an integer in the range [1, 32].\r\n * @param linePixels The pixel pattern in which to draw lines.\r\n * @see [[GraphicBuilder.activateGraphicParams]] for additional symbology options.\r\n */\r\n public setSymbology(lineColor: ColorDef, fillColor: ColorDef, lineWidth: number, linePixels = LinePixels.Solid) {\r\n this.activateGraphicParams(GraphicParams.fromSymbology(lineColor, fillColor, lineWidth, linePixels));\r\n }\r\n\r\n /** Set the current active symbology for this builder to be a blanking fill before adding a planar region.\r\n * A planar region drawn with blanking fill renders behind other geometry in the same graphic.\r\n * Blanking fill is not affected by the fill [[ViewFlags]] being disabled.\r\n * An example would be to add a line to a graphic containing a shape with blanking fill so that the line is always shown in front of the fill.\r\n * @param fillColor The color in which to draw filled regions.\r\n */\r\n public setBlankingFill(fillColor: ColorDef) { this.activateGraphicParams(GraphicParams.fromBlankingFill(fillColor)); }\r\n}\r\n"]}
1
+ {"version":3,"file":"GraphicBuilder.js","sourceRoot":"","sources":["../../../src/render/GraphicBuilder.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,wDAE8B;AAC9B,oDAA8H;AAM9H;;;;;;;;GAQG;AACH,IAAY,WAkDX;AAlDD,WAAY,WAAW;IACrB;;;;;;;OAOG;IACH,iEAAc,CAAA;IACd,qEAAqE;IACrE;;;;;;OAMG;IACH,+CAAK,CAAA;IACL,8GAA8G;IAC9G;;;;;;OAMG;IACH,mEAAe,CAAA;IACf;;;;;;;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G,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAAE;SAChC,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,iBAAG,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAG,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,iBAAG,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAG,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,iBAAG,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,iBAAG,CAAC,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;IAED;;;;;;OAMG;IACI,YAAY,CAAC,SAAmB,EAAE,SAAmB,EAAE,SAAiB,EAAE,UAAU,GAAG,wBAAU,CAAC,KAAK;QAC5G,IAAI,CAAC,qBAAqB,CAAC,2BAAa,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACvG,CAAC;IAED;;;;;OAKG;IACI,eAAe,CAAC,SAAmB,IAAI,IAAI,CAAC,qBAAqB,CAAC,2BAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CACvH;AAzVD,wCAyVC","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, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n AnyCurvePrimitive, Arc3d, Box, Loop, Path, Point2d, Point3d, Polyface, Range3d, SolidPrimitive, Transform,\r\n} from \"@itwin/core-geometry\";\r\nimport { AnalysisStyle, ColorDef, Feature, Frustum, GeometryClass, GraphicParams, LinePixels, Npc } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { RenderGraphic } from \"./RenderGraphic\";\r\nimport { GraphicPrimitive } from \"./GraphicPrimitive\";\r\n\r\n/**\r\n * Describes the type of a [[GraphicBuilder]], which defines the coordinate system in which the builder's geometry is defined and\r\n * controls the behavior of the [[RenderGraphic]] produced by the builder.\r\n * @note For those types for which depth-testing is disabled, the order in which the individual geometric primitives are drawn determines which geometry draws on top of other geometry.\r\n * - Within a [[GraphicList]], each [[RenderGraphic]] is rendered in the order in which it appears in the list; and\r\n * - Within a single [[RenderGraphic]], each geometric primitive is rendered in the ordered in which it was added to the GraphicBuilder.\r\n * @public\r\n * @extensions\r\n */\r\nexport enum GraphicType {\r\n /**\r\n * Renders behind all other graphics. For example, the border of a [[SheetViewState]] is of this type.\r\n * Coordinates: [[CoordSystem.View]].\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]].\r\n * Lighting: none.\r\n * Depth-testing: disabled.\r\n * @see [[Decorations.viewBackground]]\r\n */\r\n ViewBackground,\r\n /** Used for the scene itself, dynamics, and 'normal' decorations. */\r\n /**\r\n * Renders as if it were part of the scene. All of the [[ViewFlags]] applied to the view's normal geometry also applies to these types of decorations.\r\n * Coordinates: [[CoordSystem.World]].\r\n * Lighting and [[RenderMode]]: from view.\r\n * Depth-testing: enabled.\r\n * @see [[Decorations.normal]].\r\n */\r\n Scene,\r\n /** Renders within the scene. Coordinates: world. RenderMode: smooth. Lighting: default. Z-testing: enabled */\r\n /** Renders within the scene, but ignores the view's [[ViewFlags]].\r\n * Coordinates: [[CoordSystem.World]].\r\n * Lighting: default.\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]].\r\n * Depth-testing: enabled.\r\n * @see [[Decorations.world]].\r\n */\r\n WorldDecoration,\r\n /**\r\n * Renders as an overlay on top of the scene. These decorations differ from [[GraphicType.WorldDecoration]] only in that depth-testing is disabled.\r\n * For example, the ACS triad and [[WindowAreaTool]] decorations are of this type.\r\n * Coordinates: [[CoordSystem.World]].\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]]\r\n * Lighting: default.\r\n * Depth-testing: disabled.\r\n * Renders atop the scene. Coordinates: world. RenderMode: smooth. Lighting: none. Z-testing: disabled\r\n * @note Overlay decorations typically employ some degree of transparency to ensure that they do not fully obscure the scene.\r\n * @see [[Decorations.worldOverlay]]\r\n */\r\n WorldOverlay,\r\n /**\r\n * Renders as an overlay on top of the scene. These decorations differ from [[GraphicType.WorldOverlay]] only in that their geometry is defined in view coordinates rather than world.\r\n * Coordinates: [[CoordSystem.View]].\r\n * [[RenderMode]]: [[RenderMode.SmoothShade]]\r\n * Lighting: default.\r\n * Depth-testing: disabled.\r\n * @note For more flexibility in defining view overlay decorations, consider using a [[CanvasDecorationList]].\r\n * @see [[Decorations.viewOverlay]]\r\n */\r\n ViewOverlay,\r\n}\r\n\r\n/** Options used when constructing a `Batch` - that is, a [[RenderGraphic]] with an associated [FeatureTable]($common) describing individual [Feature]($common)s within the\r\n * graphic. Individual features can be resymbolized in a variety of ways including flashing and hiliting.\r\n * For example, to prevent graphics produced by [[readElementGraphics]] from being hilited when their corresponding element is in the [[SelectionSet]],\r\n * pass `{ noHilite: true }` to [[readElementGraphics]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface BatchOptions {\r\n /** Identifies the [[Tile]] associated with the batch, chiefly for debugging purposes.\r\n * @beta\r\n */\r\n tileId?: string;\r\n /** If true, features within the batch will not be flashed on mouseover. */\r\n noFlash?: boolean;\r\n /** If true, features within the batch will not be hilited when their corresponding element is in the [[SelectionSet]]. */\r\n noHilite?: boolean;\r\n /** If true, features within the batch will not be emphasized when the corresponding [[Feature]] is emphasized using [FeatureOverrides]($common). */\r\n noEmphasis?: boolean;\r\n /** If true, the contents of the batch will only be drawn by [[Viewport.readPixels]], not [[Viewport.renderFrame]], causing them to be locatable but invisible. */\r\n locateOnly?: boolean;\r\n}\r\n\r\n/** Options used as part of [[GraphicBuilderOptions]] to describe a [pickable]($docs/learning/frontend/ViewDecorations#pickable-view-graphic-decorations) [[RenderGraphic]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface PickableGraphicOptions extends BatchOptions {\r\n /** A unique identifier for the graphic.\r\n * @see [[IModelConnection.transientIds]] to obtain a unique Id in the context of an iModel.\r\n * @see [[GraphicBuilder.activatePickableId]] or [[GraphicBuilder.activateFeature]] to change the pickable object while adding geometry.\r\n */\r\n id: Id64String;\r\n /** Optional Id of the subcategory with which the graphic should be associated. */\r\n subCategoryId?: Id64String;\r\n /** Optional geometry class for the graphic - defaults to [GeometryClass.Primary]($common). */\r\n geometryClass?: GeometryClass;\r\n /** The optional Id of the model with which the graphic should be associated. */\r\n modelId?: Id64String;\r\n}\r\n\r\n/** Options for creating a [[GraphicBuilder]] used by functions like [[DecorateContext.createGraphic]] and [[RenderSystem.createGraphic]].\r\n * @see [[ViewportGraphicBuilderOptions]] to create a graphic builder for a [[Viewport]].\r\n * @see [[CustomGraphicBuilderOptions]] to create a graphic builder unassociated with any [[Viewport]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface GraphicBuilderOptions {\r\n /** The type of graphic to produce. */\r\n type: GraphicType;\r\n\r\n /** The local-to-world transform in which the builder's geometry is to be defined - by default, an identity transform. */\r\n placement?: Transform;\r\n\r\n /** If the graphic is to be pickable, specifies the pickable Id and other options. */\r\n pickable?: PickableGraphicOptions;\r\n\r\n /** If true, the order in which geometry is added to the builder is preserved.\r\n * This is useful for overlay and background graphics because they draw without using the depth buffer. For example, to draw an overlay containing a red shape with a white outline,\r\n * you would add the shape to the GraphicBuilder first, followed by the outline, to ensure the outline draws \"in front of\" the shape.\r\n * It defaults to true for overlays and background graphics, and false for other graphic types.\r\n * It is not useful for other types of graphics and imposes a performance penalty due to increased number of draw calls.\r\n * For overlay and background graphics that do not need to draw in any particular order, the performance penalty can be eliminated by setting this to `false`.\r\n */\r\n preserveOrder?: boolean;\r\n\r\n /** Controls whether normals are generated for surfaces. Normals allow 3d geometry to receive lighting; without them the geometry will be unaffected by lighting.\r\n * By default, normals are generated only for graphics of type [[GraphicType.Scene]]; or for any type of graphic if [[GraphicBuilder.wantEdges]] is true, because\r\n * normals are required to prevent z-fighting between surfaces and their edges. This default can be overridden by explicitly specifying `true` or `false`.\r\n * @see [[GraphicType]] for a description of whether and how different types of graphics are affected by lighting.\r\n */\r\n wantNormals?: boolean;\r\n\r\n /** Controls whether edges are generated for surfaces.\r\n * Edges are only displayed if [ViewFlags.renderMode]($common) is not [RenderMode.SmoothShade]($common) or [ViewFlags.visibleEdges]($common) is `true`.\r\n * Since all decoration graphics except [[GraphicType.Scene]] are drawn in smooth shaded mode with no visible edges, by default edges are only produced for scene graphics, and\r\n * - if a [[Viewport]] is supplied with the options - only if [ViewFlags.edgesRequired]($common) is true for the viewport.\r\n * That default can be overridden by explicitly specifying `true` or `false`. This can be useful for non-scene decorations contained in a [[GraphicBranch]] that applies [ViewFlagOverrides]($common)\r\n * that change the edge display settings; or for scene decorations that might be cached for reuse after the viewport's edge settings are changed.\r\n * @note Edges will tend to z-fight with their surfaces unless the graphic is [[pickable]].\r\n */\r\n generateEdges?: boolean;\r\n\r\n /** If defined, specifies a point about which the graphic will rotate such that it always faces the viewer.\r\n * This can be particular useful for planar regions to create a billboarding effect - e.g., to implement [[Marker]]-like WebGL decorations.\r\n * The graphic's [[placement]] transform is not applied to the point.\r\n * @note This has no effect for graphics displayed in a 2d view.\r\n */\r\n viewIndependentOrigin?: Point3d;\r\n}\r\n\r\n/** Options for creating a [[GraphicBuilder]] to produce a [[RenderGraphic]] to be displayed in a specific [[Viewport]].\r\n * The level of detail of the graphic will be computed from the position of its geometry within the viewport's [Frustum]($common).\r\n * Default values for [[GraphicBuilderOptions.wantNormals]] and [[GraphicBuilderOptions.generateEdges]] will be determined by the viewport's [ViewFlags]($common).\r\n * The [[GraphicBuilder.iModel]] will be set to the viewport's [[IModelConnection]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface ViewportGraphicBuilderOptions extends GraphicBuilderOptions {\r\n /** The viewport in which the resultant [[RenderGraphic]] is to be drawn. */\r\n viewport: Viewport;\r\n\r\n /** If true, [[ViewState.getAspectRatioSkew]] will be taken into account when computing the level of detail for the produced graphics. */\r\n applyAspectRatioSkew?: boolean;\r\n\r\n iModel?: never;\r\n computeChordTolerance?: never;\r\n}\r\n\r\n/** Arguments used to compute the chord tolerance (level of detail) of the [[RenderGraphic]]s produced by a [[GraphicBuilder]].\r\n * Generally, the chord tolerance should be roughly equivalent to the size in meters of one pixel on screen where the graphic is to be displayed.\r\n * For [[GraphicType.ViewOverlay]] and [[GraphicType.ViewBackground]], which already define their geometry in pixels, the chord tolerance should typically be 1.\r\n * @see [[CustomGraphicBuilderOptions.computeChordTolerance]].\r\n * @public\r\n * @extensions\r\n */\r\nexport interface ComputeChordToleranceArgs {\r\n /** The graphic builder being used to produce the graphics. */\r\n readonly graphic: GraphicBuilder;\r\n /** A function that computes a range enclosing all of the geometry that was added to the builder. */\r\n readonly computeRange: () => Range3d;\r\n}\r\n\r\n/** Options for creating a [[GraphicBuilder]] to produce a [[RenderGraphic]] that is not associated with any particular [[Viewport]] and may not be associated with\r\n * any particular [[IModelConnection]].\r\n * This is primarily useful when the same graphic is to be saved and reused for display in multiple viewports and for which a chord tolerance can be computed\r\n * independently of each viewport's [Frustum]($common).\r\n * @public\r\n * @extensions\r\n */\r\nexport interface CustomGraphicBuilderOptions extends GraphicBuilderOptions {\r\n /** Optionally, the IModelConnection with which the graphic is associated. */\r\n iModel?: IModelConnection;\r\n /** A function that can compute the level of detail for the graphics produced by the builder. */\r\n computeChordTolerance: (args: ComputeChordToleranceArgs) => number;\r\n\r\n applyAspectRatioSkew?: never;\r\n viewport?: never;\r\n}\r\n\r\n/** Provides methods for constructing a [[RenderGraphic]] from geometric primitives.\r\n * GraphicBuilder is primarily used for creating [[Decorations]] to be displayed inside a [[Viewport]].\r\n *\r\n * The typical process for constructing a [[RenderGraphic]] proceeds as follows:\r\n * 1. Use [[DecorateContext.createGraphic]] or [[RenderSystem.createGraphic]] to obtain a builder.\r\n * 2. Set up the symbology using [[GraphicBuilder.activateGraphicParams]] or [[GraphicBuilder.setSymbology]].\r\n * 3. Add one or more geometric primitives using methods like [[GraphicBuilder.addShape]] and [[GraphicBuilder.addLineString]], possibly setting new symbology in between.\r\n * 4. Use [[GraphicBuilder.finish]] to produce the finished [[RenderGraphic]].\r\n *\r\n * @note Most of the methods which add geometry to the builder take ownership of their inputs rather than cloning them.\r\n * So, for example, if you pass an array of points to addLineString(), you should not subsequently modify that array.\r\n *\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class GraphicBuilder {\r\n /** The local coordinate system transform applied to this builder's geometry.\r\n * @see [[GraphicBuilderOptions.placement]].\r\n */\r\n public readonly placement: Transform;\r\n\r\n /** The iModel associated with this builder, if any. */\r\n public readonly iModel?: IModelConnection;\r\n\r\n /** The type of graphic to be produced by this builder.\r\n * @see [[GraphicBuilderOptions.type]].\r\n */\r\n public readonly type: GraphicType;\r\n\r\n /** If the graphic is to be pickable, specifies the pickable Id and other options. */\r\n public readonly pickable?: Readonly<PickableGraphicOptions>;\r\n\r\n /** If true, the order in which geometry is added to the builder is preserved.\r\n * @see [[GraphicBuilderOptions.preserveOrder]] for more details.\r\n */\r\n public readonly preserveOrder: boolean;\r\n\r\n /** Controls whether normals are generated for surfaces.\r\n * @note Normals are required for proper edge display, so by default they are always produced if [[wantEdges]] is `true`.\r\n * @see [[GraphicBuilderOptions.wantNormals]] for more details.\r\n */\r\n public readonly wantNormals: boolean;\r\n\r\n /** Controls whether edges are generated for surfaces.\r\n * @see [[GraphicBuilderOptions.generateEdges]] for more details.\r\n */\r\n public readonly wantEdges: boolean;\r\n\r\n /** @alpha */\r\n public readonly analysisStyle?: AnalysisStyle;\r\n\r\n protected readonly _computeChordTolerance: (args: ComputeChordToleranceArgs) => number;\r\n protected readonly _options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions;\r\n\r\n /** @internal */\r\n protected constructor(options: ViewportGraphicBuilderOptions | CustomGraphicBuilderOptions) {\r\n // Stored for potential use later in creating a new GraphicBuilder from this one (see PrimitiveBuilder.finishGraphic).\r\n this._options = options;\r\n\r\n const vp = options.viewport;\r\n this.placement = options.placement ?? Transform.createIdentity();\r\n this.iModel = vp?.iModel ?? options.iModel;\r\n this.type = options.type;\r\n this.pickable = options.pickable;\r\n this.wantEdges = options.generateEdges ?? (this.type === GraphicType.Scene && (!vp || vp.viewFlags.edgesRequired()));\r\n this.wantNormals = options.wantNormals ?? (this.wantEdges || this.type === GraphicType.Scene);\r\n this.preserveOrder = options.preserveOrder ?? (this.isOverlay || this.isViewBackground);\r\n\r\n if (!options.viewport) {\r\n this._computeChordTolerance = options.computeChordTolerance;\r\n return;\r\n }\r\n\r\n this.analysisStyle = options.viewport.displayStyle.settings.analysisStyle;\r\n\r\n this._computeChordTolerance = (args: ComputeChordToleranceArgs) => {\r\n let pixelSize = 1;\r\n if (!this.isViewCoordinates) {\r\n // Compute the horizontal distance in meters between two adjacent pixels at the center of the geometry.\r\n pixelSize = options.viewport.getPixelSizeAtPoint(args.computeRange().center);\r\n pixelSize = options.viewport.target.adjustPixelSizeForLOD(pixelSize);\r\n\r\n // Aspect ratio skew > 1.0 stretches the view in Y. In that case use the smaller vertical pixel distance for our stroke tolerance.\r\n const skew = options.applyAspectRatioSkew ? options.viewport.view.getAspectRatioSkew() : 0;\r\n if (skew > 1)\r\n pixelSize /= skew;\r\n }\r\n\r\n return pixelSize * 0.25;\r\n };\r\n }\r\n\r\n /** The Id to be associated with the graphic for picking.\r\n * @see [[GraphicBuilderOptions.pickable]] for more options.\r\n * @deprecated in 3.x. This provides only the **first** pickable Id for this graphic - you should keep track of the **current** pickable Id yourself.\r\n */\r\n public get pickId(): Id64String | undefined {\r\n return this.pickable?.id;\r\n }\r\n\r\n /** Whether the builder's geometry is defined in [[CoordSystem.View]] coordinates.\r\n * @see [[isWorldCoordinates]].\r\n */\r\n public get isViewCoordinates(): boolean {\r\n return this.type === GraphicType.ViewBackground || this.type === GraphicType.ViewOverlay;\r\n }\r\n\r\n /** Whether the builder's geometry is defined in [[CoordSystem.World]] coordinates.\r\n * @see [[isViewCoordinates]].\r\n */\r\n public get isWorldCoordinates(): boolean {\r\n return !this.isViewCoordinates;\r\n }\r\n\r\n /** True if the builder produces a graphic of [[GraphicType.Scene]]. */\r\n public get isSceneGraphic(): boolean {\r\n return this.type === GraphicType.Scene;\r\n }\r\n\r\n /** True if the builder produces a graphic of [[GraphicType.ViewBackground]]. */\r\n public get isViewBackground(): boolean {\r\n return this.type === GraphicType.ViewBackground;\r\n }\r\n\r\n /** True if the builder produces a graphic of [[GraphicType.WorldOverlay]] or [[GraphicType.ViewOerlay]]. */\r\n public get isOverlay(): boolean {\r\n return this.type === GraphicType.ViewOverlay || this.type === GraphicType.WorldOverlay;\r\n }\r\n\r\n /**\r\n * Processes the accumulated symbology and geometry to produce a renderable graphic.\r\n * This function can only be called once; after the [[RenderGraphic]] has been extracted the [[GraphicBuilder]] should no longer be used.\r\n */\r\n public abstract finish(): RenderGraphic;\r\n\r\n /** Sets the current active symbology for this builder. Any new geometry subsequently added to the builder will be drawn using the specified symbology.\r\n * @param graphicParams The symbology to apply to subsequent geometry.\r\n * @see [[GraphicBuilder.setSymbology]] for a convenient way to set common symbology options.\r\n */\r\n public abstract activateGraphicParams(graphicParams: GraphicParams): void;\r\n\r\n /** Called by [[activateFeature]] after validation to change the [Feature]($common) to be associated with subsequently-added geometry.\r\n * This default implementation does nothing.\r\n */\r\n protected _activateFeature(_feature: Feature): void { }\r\n\r\n /** Change the [Feature]($common) to be associated with subsequently-added geometry. This permits multiple features to be batched together into a single graphic\r\n * for more efficient rendering.\r\n * @note This method has no effect if [[GraphicBuilderOptions.pickable]] was not supplied to the GraphicBuilder's constructor.\r\n */\r\n public activateFeature(feature: Feature): void {\r\n assert(undefined !== this._options.pickable, \"GraphicBuilder.activateFeature has no effect if PickableGraphicOptions were not supplied\");\r\n if (this._options.pickable)\r\n this._activateFeature(feature);\r\n }\r\n\r\n /** Change the pickable Id to be associated with subsequently-added geometry. This permits multiple pickable objects to be batched together into a single graphic\r\n * for more efficient rendering. This method calls [[activateFeature]], using the subcategory Id and [GeometryClass]($common) specified in [[GraphicBuilder.pickable]]\r\n * at construction, if any.\r\n * @note This method has no effect if [[GraphicBuilderOptions.pickable]] was not supplied to the GraphicBuilder's constructor.\r\n */\r\n public activatePickableId(id: Id64String): void {\r\n const pick = this._options.pickable;\r\n this.activateFeature(new Feature(id, pick?.subCategoryId, pick?.geometryClass));\r\n }\r\n\r\n /**\r\n * Appends a 3d line string to the builder.\r\n * @param points Array of vertices in the line string.\r\n */\r\n public abstract addLineString(points: Point3d[]): void;\r\n\r\n /**\r\n * Appends a 2d line string to the builder.\r\n * @param points Array of vertices in the line string.\r\n * @param zDepth Z value in local coordinates to use for each point.\r\n */\r\n public abstract addLineString2d(points: Point2d[], zDepth: number): void;\r\n\r\n /**\r\n * Appends a 3d point string to the builder. The points are drawn disconnected, with a diameter in pixels defined by the builder's active [[GraphicParams.rasterWidth]].\r\n * @param points Array of vertices in the point string.\r\n */\r\n public abstract addPointString(points: Point3d[]): void;\r\n\r\n /**\r\n * Appends a 2d point string to the builder. The points are drawn disconnected, with a diameter in pixels defined by the builder's active [[GraphicParams.rasterWidth]].\r\n * @param points Array of vertices in the point string.\r\n * @param zDepth Z value in local coordinates to use for each point.\r\n */\r\n public abstract addPointString2d(points: Point2d[], zDepth: number): void;\r\n\r\n /**\r\n * Appends a closed 3d planar region to the builder.\r\n * @param points Array of vertices of the shape.\r\n */\r\n public abstract addShape(points: Point3d[]): void;\r\n\r\n /**\r\n * Appends a closed 2d region to the builder.\r\n * @param points Array of vertices of the shape.\r\n * @param zDepth Z value in local coordinates to use for each point.\r\n */\r\n public abstract addShape2d(points: Point2d[], zDepth: number): void;\r\n\r\n /**\r\n * Appends a 3d open arc or closed ellipse to the builder.\r\n * @param arc Description of the arc or ellipse.\r\n * @param isEllipse If true, and if the arc defines a full sweep, then draw as a closed ellipse instead of an arc.\r\n * @param filled If true, and isEllipse is also true, then draw ellipse filled.\r\n */\r\n public abstract addArc(arc: Arc3d, isEllipse: boolean, filled: boolean): void;\r\n\r\n /**\r\n * Appends a 2d open arc or closed ellipse to the builder.\r\n * @param arc Description of the arc or ellipse.\r\n * @param isEllipse If true, and if the arc defines a full sweep, then draw as a closed ellipse instead of an arc.\r\n * @param filled If true, and isEllipse is also true, then draw ellipse filled.\r\n * @param zDepth Z value in local coordinates to use for each point in the arc or ellipse.\r\n */\r\n public abstract addArc2d(ellipse: Arc3d, isEllipse: boolean, filled: boolean, zDepth: number): void;\r\n\r\n /** Append a 3d open path to the builder. */\r\n public abstract addPath(path: Path): void;\r\n\r\n /** Append a 3d planar region to the builder. */\r\n public abstract addLoop(loop: Loop): void;\r\n\r\n /** Append a [CurvePrimitive]($core-geometry) to the builder. */\r\n public addCurvePrimitive(curve: AnyCurvePrimitive): void {\r\n switch (curve.curvePrimitiveType) {\r\n case \"lineString\":\r\n this.addLineString(curve.points);\r\n break;\r\n case \"lineSegment\":\r\n this.addLineString([curve.startPoint(), curve.endPoint()]);\r\n break;\r\n case \"arc\":\r\n this.addArc(curve, false, false);\r\n break;\r\n default:\r\n const path = new Path();\r\n if (path.tryAddChild(curve))\r\n this.addPath(path);\r\n\r\n break;\r\n }\r\n }\r\n\r\n /** Append a mesh to the builder.\r\n * @param meshData Describes the mesh\r\n * @param filled If the mesh describes a planar region, indicates whether its interior area should be drawn with fill in [[RenderMode.Wireframe]].\r\n */\r\n public abstract addPolyface(meshData: Polyface, filled: boolean): void;\r\n\r\n /** Append a solid primitive to the builder. */\r\n public abstract addSolidPrimitive(solidPrimitive: SolidPrimitive): void;\r\n\r\n /** Append any primitive to the builder.\r\n * @param primitive The graphic primitive to append.\r\n */\r\n public addPrimitive(primitive: GraphicPrimitive): void {\r\n switch (primitive.type) {\r\n case \"linestring\":\r\n this.addLineString(primitive.points);\r\n break;\r\n case \"linestring2d\":\r\n this.addLineString2d(primitive.points, primitive.zDepth);\r\n break;\r\n case \"pointstring\":\r\n this.addPointString(primitive.points);\r\n break;\r\n case \"pointstring2d\":\r\n this.addPointString2d(primitive.points, primitive.zDepth);\r\n break;\r\n case \"shape\":\r\n this.addShape(primitive.points);\r\n break;\r\n case \"shape2d\":\r\n this.addShape2d(primitive.points, primitive.zDepth);\r\n break;\r\n case \"arc\":\r\n this.addArc(primitive.arc, true === primitive.isEllipse, true === primitive.filled);\r\n break;\r\n case \"arc2d\":\r\n this.addArc2d(primitive.arc, true === primitive.isEllipse, true === primitive.filled, primitive.zDepth);\r\n break;\r\n case \"path\":\r\n this.addPath(primitive.path);\r\n break;\r\n case \"loop\":\r\n this.addLoop(primitive.loop);\r\n break;\r\n case \"polyface\":\r\n this.addPolyface(primitive.polyface, true === primitive.filled);\r\n break;\r\n case \"solidPrimitive\":\r\n this.addSolidPrimitive(primitive.solidPrimitive);\r\n break;\r\n }\r\n }\r\n\r\n /** Add a box representing a volume of space. Typically used for debugging purposes.\r\n * @param range The volume of space.\r\n * @param solid If true, a [[Box]] solid primitive will be added; otherwise, a wireframe outline of the box will be added.\r\n */\r\n public addRangeBox(range: Range3d, solid = false): void {\r\n if (!solid) {\r\n this.addFrustum(Frustum.fromRange(range));\r\n return;\r\n }\r\n\r\n const box = Box.createRange(range, true);\r\n if (box)\r\n this.addSolidPrimitive(box);\r\n }\r\n\r\n /** Add Frustum edges. Useful for debugging. */\r\n public addFrustum(frustum: Frustum) {\r\n this.addRangeBoxFromCorners(frustum.points);\r\n }\r\n\r\n /** Add range edges from corner points */\r\n public addRangeBoxFromCorners(p: Point3d[]) {\r\n this.addLineString([\r\n p[Npc.LeftBottomFront],\r\n p[Npc.LeftTopFront],\r\n p[Npc.RightTopFront],\r\n p[Npc.RightBottomFront],\r\n p[Npc.RightBottomRear],\r\n p[Npc.RightTopRear],\r\n p[Npc.LeftTopRear],\r\n p[Npc.LeftBottomRear],\r\n p[Npc.LeftBottomFront].clone(),\r\n p[Npc.RightBottomFront].clone(),\r\n ]);\r\n\r\n this.addLineString([p[Npc.LeftTopFront].clone(), p[Npc.LeftTopRear].clone()]);\r\n this.addLineString([p[Npc.RightTopFront].clone(), p[Npc.RightTopRear].clone()]);\r\n this.addLineString([p[Npc.LeftBottomRear].clone(), p[Npc.RightBottomRear].clone()]);\r\n }\r\n\r\n /** Sets the current active symbology for this builder. Any new geometry subsequently added will be drawn using the specified symbology.\r\n * @param lineColor The color in which to draw lines.\r\n * @param fillColor The color in which to draw filled regions.\r\n * @param lineWidth The width in pixels to draw lines. The renderer will clamp this value to an integer in the range [1, 32].\r\n * @param linePixels The pixel pattern in which to draw lines.\r\n * @see [[GraphicBuilder.activateGraphicParams]] for additional symbology options.\r\n */\r\n public setSymbology(lineColor: ColorDef, fillColor: ColorDef, lineWidth: number, linePixels = LinePixels.Solid) {\r\n this.activateGraphicParams(GraphicParams.fromSymbology(lineColor, fillColor, lineWidth, linePixels));\r\n }\r\n\r\n /** Set the current active symbology for this builder to be a blanking fill before adding a planar region.\r\n * A planar region drawn with blanking fill renders behind other geometry in the same graphic.\r\n * Blanking fill is not affected by the fill [[ViewFlags]] being disabled.\r\n * An example would be to add a line to a graphic containing a shape with blanking fill so that the line is always shown in front of the fill.\r\n * @param fillColor The color in which to draw filled regions.\r\n */\r\n public setBlankingFill(fillColor: ColorDef) { this.activateGraphicParams(GraphicParams.fromBlankingFill(fillColor)); }\r\n}\r\n"]}
@@ -7,6 +7,7 @@ import { ElementAlignedBox3d } from "@itwin/core-common";
7
7
  import { IModelConnection } from "../IModelConnection";
8
8
  import { Mesh } from "../render/primitives/mesh/MeshPrimitives";
9
9
  import { RenderSystem } from "../render/RenderSystem";
10
+ import { GltfMeshPrimitive } from "../gltf/GltfSchema";
10
11
  import { BatchedTileIdMap, GltfReader, GltfReaderResult, ShouldAbortReadGltf } from "./internal";
11
12
  /**
12
13
  * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.
@@ -26,6 +27,6 @@ export declare class B3dmReader extends GltfReader {
26
27
  static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d, system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform, isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices?: boolean): B3dmReader | undefined;
27
28
  private constructor();
28
29
  read(): Promise<GltfReaderResult>;
29
- protected readBatchTable(mesh: Mesh, json: any): void;
30
+ protected readBatchTable(mesh: Mesh, json: GltfMeshPrimitive): void;
30
31
  }
31
32
  //# sourceMappingURL=B3dmReader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"B3dmReader.d.ts","sourceRoot":"","sources":["../../../src/tile/B3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAa,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAY,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAwB,mBAAmB,EAAyC,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAAgC,UAAU,EAAmB,gBAAgB,EAAE,mBAAmB,EACnH,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,UAAW,SAAQ,UAAU;IAsCtC,OAAO,CAAC,MAAM;IAAuB,OAAO,CAAC,OAAO;IAAW,O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AAM,oBAAoB,CAAC;AACrE,OAAO,EACL,gBAAgB,EAAkB,UAAU,EAAmB,gBAAgB,EAAE,mBAAmB,EACrG,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,UAAW,SAAQ,UAAU;IAsCtC,OAAO,CAAC,MAAM;IAAuB,OAAO,CAAC,OAAO;IAAW,OAAO,CAAC,iBAAiB;IAAU,OAAO,CAAC,gBAAgB,CAAC;IAAa,OAAO,CAAC,eAAe,CAAC;IAC3H,OAAO,CAAC,MAAM,CAAC;IAAoB,OAAO,CAAC,cAAc,CAAC;IAtCjG,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;WAExB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAC/H,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,SAAS,EACzG,UAAU,CAAC,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,gBAAgB,EAAE,mBAAmB,UAAM,GAAG,UAAU,GAAG,SAAS;IA8BhH,OAAO;IAUM,IAAI,IAAI,OAAO,CAAC,gBAAgB,CAAC;cAiF3B,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB;CA+BtE"}
@@ -11,6 +11,7 @@ exports.B3dmReader = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_geometry_1 = require("@itwin/core-geometry");
13
13
  const core_common_1 = require("@itwin/core-common");
14
+ const GltfSchema_1 = require("../gltf/GltfSchema");
14
15
  const internal_1 = require("./internal");
15
16
  /**
16
17
  * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.
@@ -137,7 +138,7 @@ class B3dmReader extends internal_1.GltfReader {
137
138
  if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {
138
139
  const view = this.getBufferView(json.attributes, "_BATCHID");
139
140
  let batchIds;
140
- if (undefined !== view && (undefined !== (batchIds = view.toBufferData(internal_1.GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(internal_1.GltfDataType.Float)))) {
141
+ if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfSchema_1.GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfSchema_1.GltfDataType.Float)))) {
141
142
  const indices = [];
142
143
  const { colors, colorMap } = mesh;
143
144
  let colorRemap;
@@ -1 +1 @@
1
- {"version":3,"file":"B3dmReader.js","sourceRoot":"","sources":["../../../src/tile/B3dmReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAwE;AACxE,wDAAoE;AACpE,oDAAsH;AAItH,yCAEoB;AAEpB;;;GAGG;AACH,MAAa,UAAW,SAAQ,qBAAU;IAqCxC,YAAoB,KAAsB,EAAE,MAAwB,EAAE,OAAmB,EAAE,IAAa,EAAE,MAAoB,EACpH,MAA2B,EAAU,OAAgB,EAAU,iBAAyB,EAAU,gBAA4B,EAAU,eAAqB,EACnK,WAAiC,EAAU,MAAyB,EAAU,cAAyB,EAAE,mBAAmB,GAAC,KAAK;QACpI,KAAK,CAAC;YACJ,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;YACvD,IAAI,EAAE,CAAC,IAAI;SACZ,CAAC,CAAC;QALK,WAAM,GAAN,MAAM,CAAqB;QAAU,YAAO,GAAP,OAAO,CAAS;QAAU,sBAAiB,GAAjB,iBAAiB,CAAQ;QAAU,qBAAgB,GAAhB,gBAAgB,CAAY;QAAU,oBAAe,GAAf,eAAe,CAAM;QACxH,WAAM,GAAN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,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAClD,IAAI,UAAU;4BACZ,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;qBACpC;oBACD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;iBAEnC;aACF;iBAAM;gBACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,qBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;aAClD;SACF;IACH,CAAC;CACF;AA/JD,gCA+JC","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 { ByteStream, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { B3dmHeader, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport {\r\n BatchedTileIdMap, GltfBufferData, GltfDataType, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf,\r\n} from \"./internal\";\r\n\r\n/**\r\n * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n * @internal\r\n */\r\nexport class B3dmReader extends GltfReader {\r\n private _batchIdRemap = new Map<number, number>();\r\n private _colors?: Array<number>;\r\n private readonly _modelId: Id64String;\r\n\r\n public static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d,\r\n system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform,\r\n isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false): B3dmReader | undefined {\r\n const header = new B3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n let returnToCenterTransform, pseudoRtcBias;\r\n if (header.featureTableJson && Array.isArray(header.featureTableJson.RTC_CENTER)) {\r\n returnToCenterTransform = Transform.createTranslationXYZ(header.featureTableJson.RTC_CENTER[0], header.featureTableJson.RTC_CENTER[1], header.featureTableJson.RTC_CENTER[2]);\r\n } else {\r\n /**\r\n * This is a workaround for tiles generated by\r\n * context capture which have a large offset from the tileset origin that exceeds the\r\n * capacity of 32 bit integers. It is essentially an ad hoc RTC applied at read time only if the tile is far from the\r\n * origin and there is no RTC supplied either with the B3DM of the GLTF.\r\n * as the vertices are supplied in a quantized format, applying the RTC bias to\r\n * quantization origin will make these tiles work correctly.\r\n */\r\n pseudoRtcBias = Vector3d.create(tileCenter.x, tileCenter.y, tileCenter.z);\r\n }\r\n\r\n if (undefined !== returnToCenterTransform)\r\n transformToRoot = transformToRoot ? transformToRoot.multiplyTransformTransform(returnToCenterTransform) : returnToCenterTransform;\r\n\r\n const props = GltfReaderProps.create(stream.nextBytes(header.length - stream.curPos), yAxisUp);\r\n const batchTableLength = header.featureTableJson ? JsonUtils.asInt(header.featureTableJson.BATCH_LENGTH, 0) : 0;\r\n\r\n return undefined !== props ? new B3dmReader(props, iModel, modelId, is3d, system, range, isLeaf, batchTableLength,\r\n transformToRoot, header.batchTableJson, isCanceled, idMap, pseudoRtcBias, deduplicateVertices) : undefined;\r\n }\r\n\r\n private constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem,\r\n private _range: ElementAlignedBox3d, private _isLeaf: boolean, private _batchTableLength: number, private _transformToRoot?: Transform, private _batchTableJson?: any\r\n , shouldAbort?: ShouldAbortReadGltf, private _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false) {\r\n super({\r\n props, iModel, system, shouldAbort, deduplicateVertices,\r\n is2d: !is3d,\r\n });\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const featureTable: FeatureTable = new FeatureTable(this._batchTableLength ? this._batchTableLength : 1, this._modelId, this._type);\r\n if (this._batchTableLength > 0 && this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n if (this._batchTableJson.extensions && this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"]) {\r\n const hierarchy = this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"];\r\n const { classIds, classes, parentIds, parentCounts, instancesLength } = hierarchy;\r\n if (classes !== undefined && classIds !== undefined && instancesLength !== 0) {\r\n const classCounts = new Array<number>(classes.length);\r\n classCounts.fill(0);\r\n const classIndexes = new Uint16Array(instancesLength);\r\n for (let i = 0; i < instancesLength; ++i) {\r\n const classId = classIds[i];\r\n classIndexes[i] = classCounts[classId]++;\r\n }\r\n\r\n let parentMap: [][] | undefined;\r\n if (parentIds) {\r\n parentMap = new Array<[]>();\r\n for (let i = 0, parentIndex = 0; i < instancesLength; i++) {\r\n const parentCount = parentCounts === undefined ? 1 : parentCounts[i];\r\n parentMap[i] = parentIds.slice(parentIndex, parentIndex += parentCount);\r\n }\r\n }\r\n\r\n const getProperties = (instance: any, instanceIndex: number) => {\r\n const classId = classIds[instanceIndex];\r\n const instanceClass = classes[classId];\r\n const instances = instanceClass.instances;\r\n const indexInClass = classIndexes[instanceIndex];\r\n for (const key in instances) { // eslint-disable-line guard-for-in\r\n const value = instances[key][indexInClass];\r\n if (value !== undefined && value !== null)\r\n instance[key] = value;\r\n }\r\n if (parentIds !== undefined) {\r\n const thisParents = parentMap![instanceIndex];\r\n for (const parentId of thisParents) {\r\n if (parentId !== instanceIndex)\r\n getProperties(instance, parentId);\r\n }\r\n }\r\n };\r\n for (let batchId = 0; batchId < instancesLength; batchId++) {\r\n const instance: any = {};\r\n getProperties(instance, batchId);\r\n this._batchIdRemap.set(batchId, featureTable.insert(new Feature(this._idMap.getBatchId(instance))));\r\n const cesiumColor = instance[\"cesium#color\"];\r\n if (undefined !== cesiumColor) {\r\n if (!this._colors) {\r\n this._colors = new Array<number>(instancesLength);\r\n this._colors.fill(ColorDef.white.tbgr);\r\n }\r\n this._colors[batchId] = ColorDef.create(cesiumColor).tbgr;\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < this._batchTableLength; i++) {\r\n const feature: any = {};\r\n for (const key in this._batchTableJson) // eslint-disable-line guard-for-in\r\n feature[key] = this._batchTableJson[key][i];\r\n\r\n this._batchIdRemap.set(i, featureTable.insert(new Feature(this._idMap.getBatchId(feature))));\r\n }\r\n }\r\n }\r\n\r\n if (featureTable.isEmpty) {\r\n this._batchIdRemap.set(0, 0);\r\n const feature = new Feature(this._modelId);\r\n featureTable.insert(feature);\r\n }\r\n\r\n await this.resolveResources();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, featureTable, this._range, this._transformToRoot, this._pseudoRtcBias);\r\n }\r\n\r\n protected override readBatchTable(mesh: Mesh, json: any) {\r\n if (mesh.features !== undefined) {\r\n if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {\r\n const view = this.getBufferView(json.attributes, \"_BATCHID\");\r\n let batchIds: undefined | GltfBufferData;\r\n if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfDataType.Float)))) {\r\n const indices = [];\r\n const { colors, colorMap } = mesh;\r\n let colorRemap: Uint32Array | undefined;\r\n if (this._colors && this._colors.length === this._batchTableLength) {\r\n colorRemap = new Uint32Array(this._batchTableLength);\r\n\r\n for (let i = 0; i < this._batchTableLength; i++)\r\n colorRemap[i] = colorMap.insert(this._colors[i]);\r\n }\r\n\r\n for (let i = 0; i < batchIds.count; i++) {\r\n const batchId = batchIds.buffer[i * view.stride];\r\n const remapId = this._batchIdRemap.get(batchId);\r\n indices.push(remapId === undefined ? 0 : remapId);\r\n if (colorRemap)\r\n colors.push(colorRemap[batchId]);\r\n }\r\n mesh.features.setIndices(indices);\r\n\r\n }\r\n } else {\r\n mesh.features.add(new Feature(this._modelId), 1);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"B3dmReader.js","sourceRoot":"","sources":["../../../src/tile/B3dmReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAwE;AACxE,wDAAoE;AACpE,oDAAsH;AAItH,mDAAqE;AACrE,yCAEoB;AAEpB;;;GAGG;AACH,MAAa,UAAW,SAAQ,qBAAU;IAqCxC,YAAoB,KAAsB,EAAE,MAAwB,EAAE,OAAmB,EAAE,IAAa,EAAE,MAAoB,EACpH,MAA2B,EAAU,OAAgB,EAAU,iBAAyB,EAAU,gBAA4B,EAAU,eAAqB,EACnK,WAAiC,EAAU,MAAyB,EAAU,cAAyB,EAAE,mBAAmB,GAAC,KAAK;QACpI,KAAK,CAAC;YACJ,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;YACvD,IAAI,EAAE,CAAC,IAAI;SACZ,CAAC,CAAC;QALK,WAAM,GAAN,MAAM,CAAqB;QAAU,YAAO,GAAP,OAAO,CAAS;QAAU,sBAAiB,GAAjB,iBAAiB,CAAQ;QAAU,qBAAgB,GAAhB,gBAAgB,CAAY;QAAU,oBAAe,GAAf,eAAe,CAAM;QACxH,WAAM,GAAN,MAAM,CAAmB;QAAU,mBAAc,GAAd,cAAc,CAAW;QAtCnG,kBAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QA2ChD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAxCM,MAAM,CAAC,MAAM,CA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C,OAAO,CAAC,CAAC;iBAEnC;aACF;iBAAM;gBACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,qBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;aAClD;SACF;IACH,CAAC;CACF;AA/JD,gCA+JC","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 { ByteStream, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { B3dmHeader, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { GltfDataType, GltfMeshPrimitive } from \"../gltf/GltfSchema\";\r\nimport {\r\n BatchedTileIdMap, GltfBufferData, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf,\r\n} from \"./internal\";\r\n\r\n/**\r\n * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n * @internal\r\n */\r\nexport class B3dmReader extends GltfReader {\r\n private _batchIdRemap = new Map<number, number>();\r\n private _colors?: Array<number>;\r\n private readonly _modelId: Id64String;\r\n\r\n public static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d,\r\n system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform,\r\n isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false): B3dmReader | undefined {\r\n const header = new B3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n let returnToCenterTransform, pseudoRtcBias;\r\n if (header.featureTableJson && Array.isArray(header.featureTableJson.RTC_CENTER)) {\r\n returnToCenterTransform = Transform.createTranslationXYZ(header.featureTableJson.RTC_CENTER[0], header.featureTableJson.RTC_CENTER[1], header.featureTableJson.RTC_CENTER[2]);\r\n } else {\r\n /**\r\n * This is a workaround for tiles generated by\r\n * context capture which have a large offset from the tileset origin that exceeds the\r\n * capacity of 32 bit integers. It is essentially an ad hoc RTC applied at read time only if the tile is far from the\r\n * origin and there is no RTC supplied either with the B3DM of the GLTF.\r\n * as the vertices are supplied in a quantized format, applying the RTC bias to\r\n * quantization origin will make these tiles work correctly.\r\n */\r\n pseudoRtcBias = Vector3d.create(tileCenter.x, tileCenter.y, tileCenter.z);\r\n }\r\n\r\n if (undefined !== returnToCenterTransform)\r\n transformToRoot = transformToRoot ? transformToRoot.multiplyTransformTransform(returnToCenterTransform) : returnToCenterTransform;\r\n\r\n const props = GltfReaderProps.create(stream.nextBytes(header.length - stream.curPos), yAxisUp);\r\n const batchTableLength = header.featureTableJson ? JsonUtils.asInt(header.featureTableJson.BATCH_LENGTH, 0) : 0;\r\n\r\n return undefined !== props ? new B3dmReader(props, iModel, modelId, is3d, system, range, isLeaf, batchTableLength,\r\n transformToRoot, header.batchTableJson, isCanceled, idMap, pseudoRtcBias, deduplicateVertices) : undefined;\r\n }\r\n\r\n private constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem,\r\n private _range: ElementAlignedBox3d, private _isLeaf: boolean, private _batchTableLength: number, private _transformToRoot?: Transform, private _batchTableJson?: any\r\n , shouldAbort?: ShouldAbortReadGltf, private _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false) {\r\n super({\r\n props, iModel, system, shouldAbort, deduplicateVertices,\r\n is2d: !is3d,\r\n });\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const featureTable: FeatureTable = new FeatureTable(this._batchTableLength ? this._batchTableLength : 1, this._modelId, this._type);\r\n if (this._batchTableLength > 0 && this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n if (this._batchTableJson.extensions && this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"]) {\r\n const hierarchy = this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"];\r\n const { classIds, classes, parentIds, parentCounts, instancesLength } = hierarchy;\r\n if (classes !== undefined && classIds !== undefined && instancesLength !== 0) {\r\n const classCounts = new Array<number>(classes.length);\r\n classCounts.fill(0);\r\n const classIndexes = new Uint16Array(instancesLength);\r\n for (let i = 0; i < instancesLength; ++i) {\r\n const classId = classIds[i];\r\n classIndexes[i] = classCounts[classId]++;\r\n }\r\n\r\n let parentMap: [][] | undefined;\r\n if (parentIds) {\r\n parentMap = new Array<[]>();\r\n for (let i = 0, parentIndex = 0; i < instancesLength; i++) {\r\n const parentCount = parentCounts === undefined ? 1 : parentCounts[i];\r\n parentMap[i] = parentIds.slice(parentIndex, parentIndex += parentCount);\r\n }\r\n }\r\n\r\n const getProperties = (instance: any, instanceIndex: number) => {\r\n const classId = classIds[instanceIndex];\r\n const instanceClass = classes[classId];\r\n const instances = instanceClass.instances;\r\n const indexInClass = classIndexes[instanceIndex];\r\n for (const key in instances) { // eslint-disable-line guard-for-in\r\n const value = instances[key][indexInClass];\r\n if (value !== undefined && value !== null)\r\n instance[key] = value;\r\n }\r\n if (parentIds !== undefined) {\r\n const thisParents = parentMap![instanceIndex];\r\n for (const parentId of thisParents) {\r\n if (parentId !== instanceIndex)\r\n getProperties(instance, parentId);\r\n }\r\n }\r\n };\r\n for (let batchId = 0; batchId < instancesLength; batchId++) {\r\n const instance: any = {};\r\n getProperties(instance, batchId);\r\n this._batchIdRemap.set(batchId, featureTable.insert(new Feature(this._idMap.getBatchId(instance))));\r\n const cesiumColor = instance[\"cesium#color\"];\r\n if (undefined !== cesiumColor) {\r\n if (!this._colors) {\r\n this._colors = new Array<number>(instancesLength);\r\n this._colors.fill(ColorDef.white.tbgr);\r\n }\r\n this._colors[batchId] = ColorDef.create(cesiumColor).tbgr;\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < this._batchTableLength; i++) {\r\n const feature: any = {};\r\n for (const key in this._batchTableJson) // eslint-disable-line guard-for-in\r\n feature[key] = this._batchTableJson[key][i];\r\n\r\n this._batchIdRemap.set(i, featureTable.insert(new Feature(this._idMap.getBatchId(feature))));\r\n }\r\n }\r\n }\r\n\r\n if (featureTable.isEmpty) {\r\n this._batchIdRemap.set(0, 0);\r\n const feature = new Feature(this._modelId);\r\n featureTable.insert(feature);\r\n }\r\n\r\n await this.resolveResources();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, featureTable, this._range, this._transformToRoot, this._pseudoRtcBias);\r\n }\r\n\r\n protected override readBatchTable(mesh: Mesh, json: GltfMeshPrimitive) {\r\n if (mesh.features !== undefined) {\r\n if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {\r\n const view = this.getBufferView(json.attributes, \"_BATCHID\");\r\n let batchIds: undefined | GltfBufferData;\r\n if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfDataType.Float)))) {\r\n const indices = [];\r\n const { colors, colorMap } = mesh;\r\n let colorRemap: Uint32Array | undefined;\r\n if (this._colors && this._colors.length === this._batchTableLength) {\r\n colorRemap = new Uint32Array(this._batchTableLength);\r\n\r\n for (let i = 0; i < this._batchTableLength; i++)\r\n colorRemap[i] = colorMap.insert(this._colors[i]);\r\n }\r\n\r\n for (let i = 0; i < batchIds.count; i++) {\r\n const batchId = batchIds.buffer[i * view.stride];\r\n const remapId = this._batchIdRemap.get(batchId);\r\n indices.push(remapId === undefined ? 0 : remapId);\r\n if (colorRemap)\r\n colors.push(colorRemap[batchId]);\r\n }\r\n mesh.features.setIndices(indices);\r\n\r\n }\r\n } else {\r\n mesh.features.add(new Feature(this._modelId), 1);\r\n }\r\n }\r\n }\r\n}\r\n"]}