@itwin/core-frontend 3.0.0-dev.155 → 3.0.0-dev.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/render/GraphicBuilder.d.ts +1 -1
- package/lib/cjs/render/GraphicBuilder.js.map +1 -1
- package/lib/cjs/tile/B3dmReader.d.ts +1 -0
- package/lib/cjs/tile/B3dmReader.d.ts.map +1 -1
- package/lib/cjs/tile/B3dmReader.js +3 -2
- package/lib/cjs/tile/B3dmReader.js.map +1 -1
- package/lib/cjs/tile/GltfReader.d.ts +438 -32
- package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
- package/lib/cjs/tile/GltfReader.js +409 -166
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/I3dmReader.d.ts +1 -0
- package/lib/cjs/tile/I3dmReader.d.ts.map +1 -1
- package/lib/cjs/tile/I3dmReader.js +2 -1
- package/lib/cjs/tile/I3dmReader.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts +334 -10
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +84 -44
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/cjs/tools/ToolAdmin.d.ts.map +1 -1
- package/lib/cjs/tools/ToolAdmin.js +17 -7
- package/lib/cjs/tools/ToolAdmin.js.map +1 -1
- package/lib/esm/render/GraphicBuilder.d.ts +1 -1
- package/lib/esm/render/GraphicBuilder.js.map +1 -1
- package/lib/esm/tile/B3dmReader.d.ts +1 -0
- package/lib/esm/tile/B3dmReader.d.ts.map +1 -1
- package/lib/esm/tile/B3dmReader.js +4 -3
- package/lib/esm/tile/B3dmReader.js.map +1 -1
- package/lib/esm/tile/GltfReader.d.ts +438 -32
- package/lib/esm/tile/GltfReader.d.ts.map +1 -1
- package/lib/esm/tile/GltfReader.js +384 -143
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/I3dmReader.d.ts +1 -0
- package/lib/esm/tile/I3dmReader.d.ts.map +1 -1
- package/lib/esm/tile/I3dmReader.js +2 -1
- package/lib/esm/tile/I3dmReader.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts +334 -10
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +86 -46
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/lib/esm/tools/ToolAdmin.d.ts.map +1 -1
- package/lib/esm/tools/ToolAdmin.js +17 -7
- package/lib/esm/tools/ToolAdmin.js.map +1 -1
- package/package.json +22 -22
|
@@ -87,7 +87,7 @@ export interface BatchOptions {
|
|
|
87
87
|
/** If true, the contents of the batch will only be drawn by [[Viewport.readPixels]], not [[Viewport.renderFrame]], causing them to be locatable but invisible. */
|
|
88
88
|
locateOnly?: boolean;
|
|
89
89
|
}
|
|
90
|
-
/** Options used as part of [[GraphicBuilderOptions]] to describe a pickable [[RenderGraphic]].
|
|
90
|
+
/** Options used as part of [[GraphicBuilderOptions]] to describe a [pickable]($docs/learning/frontend/ViewDecorations#pickable-view-graphic-decorations) [[RenderGraphic]].
|
|
91
91
|
* @public
|
|
92
92
|
*/
|
|
93
93
|
export interface PickableGraphicOptions extends BatchOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicBuilder.js","sourceRoot":"","sources":["../../../src/render/GraphicBuilder.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAE8B;AAC9B,oDAAsG;AAMtG;;;;;;;GAOG;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;;;;;;;;;;OAUG;IACH,6DAAY,CAAA;IACZ;;;;;;;;OAQG;IACH,2DAAW,CAAA;AACb,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C,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;AArTD,wCAqTC","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 { 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, Frustum, 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 */\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 */\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 [[RenderGraphic]].\r\n * @public\r\n */\r\nexport interface PickableGraphicOptions extends BatchOptions {\r\n /** Unique identifier for the graphic.\r\n * @see [[IModelConnection.transientIds]] to obtain a unique Id in the context of an iModel.\r\n */\r\n id: 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 */\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\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 */\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 */\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 */\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 */\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 */\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 /**\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.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AAC,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;AArTD,wCAqTC","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 { 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, Frustum, 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 */\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 */\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 */\r\nexport interface PickableGraphicOptions extends BatchOptions {\r\n /** Unique identifier for the graphic.\r\n * @see [[IModelConnection.transientIds]] to obtain a unique Id in the context of an iModel.\r\n */\r\n id: 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 */\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\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 */\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 */\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 */\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 */\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 */\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 /**\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"]}
|
|
@@ -22,6 +22,7 @@ export declare class B3dmReader extends GltfReader {
|
|
|
22
22
|
private _pseudoRtcBias?;
|
|
23
23
|
private _batchIdRemap;
|
|
24
24
|
private _colors?;
|
|
25
|
+
private readonly _modelId;
|
|
25
26
|
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;
|
|
26
27
|
private constructor();
|
|
27
28
|
read(): Promise<GltfReaderResult>;
|
|
@@ -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,EAAmC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"B3dmReader.d.ts","sourceRoot":"","sources":["../../../src/tile/B3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE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I,EAAE,IAAI,EAAE,GAAG;CA+BxD"}
|
|
@@ -18,7 +18,7 @@ const internal_1 = require("./internal");
|
|
|
18
18
|
*/
|
|
19
19
|
class B3dmReader extends internal_1.GltfReader {
|
|
20
20
|
constructor(props, iModel, modelId, is3d, system, _range, _isLeaf, _batchTableLength, _transformToRoot, _batchTableJson, isCanceled, _idMap, _pseudoRtcBias, deduplicateVertices = false) {
|
|
21
|
-
super(props, iModel,
|
|
21
|
+
super(props, iModel, is3d, system, core_common_1.BatchType.Primary, isCanceled, deduplicateVertices);
|
|
22
22
|
this._range = _range;
|
|
23
23
|
this._isLeaf = _isLeaf;
|
|
24
24
|
this._batchTableLength = _batchTableLength;
|
|
@@ -27,6 +27,7 @@ class B3dmReader extends internal_1.GltfReader {
|
|
|
27
27
|
this._idMap = _idMap;
|
|
28
28
|
this._pseudoRtcBias = _pseudoRtcBias;
|
|
29
29
|
this._batchIdRemap = new Map();
|
|
30
|
+
this._modelId = modelId;
|
|
30
31
|
}
|
|
31
32
|
static create(stream, iModel, modelId, is3d, range, system, yAxisUp, isLeaf, tileCenter, transformToRoot, isCanceled, idMap, deduplicateVertices = false) {
|
|
32
33
|
const header = new core_common_1.B3dmHeader(stream);
|
|
@@ -133,7 +134,7 @@ class B3dmReader extends internal_1.GltfReader {
|
|
|
133
134
|
if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {
|
|
134
135
|
const view = this.getBufferView(json.attributes, "_BATCHID");
|
|
135
136
|
let batchIds;
|
|
136
|
-
if (undefined !== view && (undefined !== (batchIds = view.toBufferData(
|
|
137
|
+
if (undefined !== view && (undefined !== (batchIds = view.toBufferData(internal_1.GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(internal_1.GltfDataType.Float)))) {
|
|
137
138
|
const indices = [];
|
|
138
139
|
const { colors, colorMap } = mesh;
|
|
139
140
|
let colorRemap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"B3dmReader.js","sourceRoot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WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;wBAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE;4BAC7C,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;qBACpD;oBAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;wBACvC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;wBAChD,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,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;AA1JD,gCA0JC","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, BatchType, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, GltfBufferData, GltfDataType, 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 { BatchedTileIdMap, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf } 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\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, 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 , isCanceled?: ShouldAbortReadGltf, private _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false) {\r\n super(props, iModel, modelId, is3d, system, BatchType.Primary, isCanceled, deduplicateVertices);\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.loadTextures();\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,oDAAiI;AAIjI,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,UAAgC,EAAU,MAAyB,EAAU,cAAyB,E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E,CAAC,EAAE,EAAE;wBACvC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;wBAChD,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,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;AA5JD,gCA4JC","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, BatchType, 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, 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 , isCanceled?: ShouldAbortReadGltf, private _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false) {\r\n super(props, iModel, is3d, system, BatchType.Primary, isCanceled, deduplicateVertices);\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.loadTextures();\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"]}
|