@itwin/core-frontend 3.6.0-dev.40 → 3.6.0-dev.44

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 (70) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/IModelApp.d.ts +3 -3
  3. package/lib/cjs/IModelApp.d.ts.map +1 -1
  4. package/lib/cjs/IModelApp.js +1 -1
  5. package/lib/cjs/IModelApp.js.map +1 -1
  6. package/lib/cjs/ViewContext.js +1 -1
  7. package/lib/cjs/ViewContext.js.map +1 -1
  8. package/lib/cjs/ViewState.d.ts +4 -5
  9. package/lib/cjs/ViewState.d.ts.map +1 -1
  10. package/lib/cjs/ViewState.js +0 -1
  11. package/lib/cjs/ViewState.js.map +1 -1
  12. package/lib/cjs/Viewport.d.ts +0 -1
  13. package/lib/cjs/Viewport.d.ts.map +1 -1
  14. package/lib/cjs/Viewport.js +0 -1
  15. package/lib/cjs/Viewport.js.map +1 -1
  16. package/lib/cjs/extension/ExtensionRuntime.js +1 -0
  17. package/lib/cjs/extension/ExtensionRuntime.js.map +1 -1
  18. package/lib/cjs/render/VisibleFeature.d.ts +5 -5
  19. package/lib/cjs/render/VisibleFeature.js.map +1 -1
  20. package/lib/cjs/render/webgl/BackgroundMapDrape.js +1 -1
  21. package/lib/cjs/render/webgl/BackgroundMapDrape.js.map +1 -1
  22. package/lib/cjs/render/webgl/PlanarClassifier.d.ts.map +1 -1
  23. package/lib/cjs/render/webgl/PlanarClassifier.js +2 -1
  24. package/lib/cjs/render/webgl/PlanarClassifier.js.map +1 -1
  25. package/lib/cjs/render/webgl/PlanarTextureProjection.js +1 -1
  26. package/lib/cjs/render/webgl/PlanarTextureProjection.js.map +1 -1
  27. package/lib/cjs/render/webgl/RenderCommands.js +1 -1
  28. package/lib/cjs/render/webgl/RenderCommands.js.map +1 -1
  29. package/lib/cjs/render/webgl/SolarShadowMap.js +1 -1
  30. package/lib/cjs/render/webgl/SolarShadowMap.js.map +1 -1
  31. package/lib/cjs/tile/RealityTileTree.d.ts.map +1 -1
  32. package/lib/cjs/tile/RealityTileTree.js +1 -3
  33. package/lib/cjs/tile/RealityTileTree.js.map +1 -1
  34. package/lib/cjs/tile/TileDrawArgs.js +1 -1
  35. package/lib/cjs/tile/TileDrawArgs.js.map +1 -1
  36. package/lib/esm/IModelApp.d.ts +3 -3
  37. package/lib/esm/IModelApp.d.ts.map +1 -1
  38. package/lib/esm/IModelApp.js +1 -1
  39. package/lib/esm/IModelApp.js.map +1 -1
  40. package/lib/esm/ViewContext.js +1 -1
  41. package/lib/esm/ViewContext.js.map +1 -1
  42. package/lib/esm/ViewState.d.ts +4 -5
  43. package/lib/esm/ViewState.d.ts.map +1 -1
  44. package/lib/esm/ViewState.js +0 -1
  45. package/lib/esm/ViewState.js.map +1 -1
  46. package/lib/esm/Viewport.d.ts +0 -1
  47. package/lib/esm/Viewport.d.ts.map +1 -1
  48. package/lib/esm/Viewport.js +0 -1
  49. package/lib/esm/Viewport.js.map +1 -1
  50. package/lib/esm/extension/ExtensionRuntime.js +2 -1
  51. package/lib/esm/extension/ExtensionRuntime.js.map +1 -1
  52. package/lib/esm/render/VisibleFeature.d.ts +5 -5
  53. package/lib/esm/render/VisibleFeature.js.map +1 -1
  54. package/lib/esm/render/webgl/BackgroundMapDrape.js +1 -1
  55. package/lib/esm/render/webgl/BackgroundMapDrape.js.map +1 -1
  56. package/lib/esm/render/webgl/PlanarClassifier.d.ts.map +1 -1
  57. package/lib/esm/render/webgl/PlanarClassifier.js +2 -1
  58. package/lib/esm/render/webgl/PlanarClassifier.js.map +1 -1
  59. package/lib/esm/render/webgl/PlanarTextureProjection.js +1 -1
  60. package/lib/esm/render/webgl/PlanarTextureProjection.js.map +1 -1
  61. package/lib/esm/render/webgl/RenderCommands.js +1 -1
  62. package/lib/esm/render/webgl/RenderCommands.js.map +1 -1
  63. package/lib/esm/render/webgl/SolarShadowMap.js +1 -1
  64. package/lib/esm/render/webgl/SolarShadowMap.js.map +1 -1
  65. package/lib/esm/tile/RealityTileTree.d.ts.map +1 -1
  66. package/lib/esm/tile/RealityTileTree.js +1 -3
  67. package/lib/esm/tile/RealityTileTree.js.map +1 -1
  68. package/lib/esm/tile/TileDrawArgs.js +1 -1
  69. package/lib/esm/tile/TileDrawArgs.js.map +1 -1
  70. package/package.json +20 -20
@@ -1 +1 @@
1
- {"version":3,"file":"PlanarTextureProjection.js","sourceRoot":"","sources":["../../../../src/render/webgl/PlanarTextureProjection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,oDAA6E;AAC7E,wDAG8B;AAC9B,+EAA4E;AAI5E,+CAA4C;AAG5C,MAAM,YAAY,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC1C,MAAM,YAAY,GAAG,qBAAK,CAAC,cAAc,EAAE,CAAC;AAC5C,MAAM,eAAe,GAAG,wBAAQ,CAAC,cAAc,EAAE,CAAC;AAClD,MAAa,uBAAuB;IAG3B,MAAM,CAAC,8BAA8B,CAC1C,YAA0C,EAC1C,YAA0B,EAC1B,MAA8C,EAC9C,SAA8B,EAC9B,SAAsB,EACtB,YAAoB,EACpB,aAAqB,EACrB,YAAsB;QACtB,MAAM,QAAQ,GAAG,YAAY,CAAC,YAAY,EAAE,CAAC;QAC7C,MAAM,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;QAC/C,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,iBAAiB,GAAG,MAAM,CAAC;QAEjC,IAAI,KAAK,KAAK,SAAS;YACrB,OAAO,EAAE,CAAC,CAAM,0BAA0B;QAE5C,IAAI,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,QAAQ,CAAC;QACb,IAAI,QAAQ,CAAC,SAAS,EAA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AC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { Frustum, FrustumPlanes, Npc, RenderMode } from \"@itwin/core-common\";\r\nimport {\r\n ClipUtilities, ConvexClipPlaneSet, GrowableXYZArray, Map4d, Matrix3d, Matrix4d, Plane3dByOriginAndUnitNormal, Point3d, Range1d, Range2d, Range3d,\r\n Ray3d, Transform,\r\n} from \"@itwin/core-geometry\";\r\nimport { ApproximateTerrainHeights } from \"../../ApproximateTerrainHeights\";\r\nimport { Tile, TileTreeReference } from \"../../tile/internal\";\r\nimport { SceneContext } from \"../../ViewContext\";\r\nimport { ViewState3d } from \"../../ViewState\";\r\nimport { RenderState } from \"./RenderState\";\r\nimport { Target } from \"./Target\";\r\n\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchMap4d = Map4d.createIdentity();\r\nconst scratchMatrix4d = Matrix4d.createIdentity();\r\nexport class PlanarTextureProjection {\r\n private static _postProjectionMatrixNpc = Matrix4d.createRowValues(/* Row 1 */ 0, 1, 0, 0, /* Row 1 */ 0, 0, 1, 0, /* Row 3 */ 1, 0, 0, 0, /* Row 4 */ 0, 0, 0, 1);\r\n\r\n public static computePlanarTextureProjection(\r\n texturePlane: Plane3dByOriginAndUnitNormal,\r\n sceneContext: SceneContext,\r\n target: { tiles: Tile[], location: Transform },\r\n drapeRefs: TileTreeReference[],\r\n viewState: ViewState3d,\r\n textureWidth: number,\r\n textureHeight: number,\r\n _heightRange?: Range1d): { textureFrustum?: Frustum, worldToViewMap?: Map4d, projectionMatrix?: Matrix4d, debugFrustum?: Frustum, zValue?: number } {\r\n const textureZ = texturePlane.getNormalRef();\r\n const viewingSpace = sceneContext.viewingSpace;\r\n const viewX = viewingSpace.rotation.rowX();\r\n const viewZ = viewingSpace.rotation.rowZ();\r\n const minCrossMagnitude = 1.0E-4;\r\n\r\n if (viewZ === undefined)\r\n return {}; // View without depth?....\r\n\r\n let textureX = viewZ.crossProduct(textureZ);\r\n let textureY;\r\n if (textureX.magnitude() < minCrossMagnitude) {\r\n textureY = viewX.crossProduct(textureZ);\r\n textureX = textureY.crossProduct(textureZ).normalize()!;\r\n } else {\r\n textureX.normalizeInPlace();\r\n textureY = textureZ.crossProduct(textureX).normalize()!;\r\n }\r\n\r\n const frustumX = textureZ, frustumY = textureX, frustumZ = textureY;\r\n const textureMatrix = Matrix3d.createRows(frustumX, frustumY, frustumZ);\r\n const textureTransform = Transform.createRefs(Point3d.createZero(), textureMatrix);\r\n const viewFrustum = viewingSpace.getFrustum().transformBy(textureTransform);\r\n const viewPlanes = new FrustumPlanes(viewFrustum);\r\n const viewClipPlanes = ConvexClipPlaneSet.createPlanes(viewPlanes.planes!);\r\n\r\n let textureRange = Range3d.createNull();\r\n const tileToTexture = textureTransform.multiplyTransformTransform(target.location);\r\n for (const tile of target.tiles) {\r\n textureRange.extendRange(tileToTexture.multiplyRange(tile.range, scratchRange));\r\n }\r\n\r\n if (textureRange.isNull)\r\n return {};\r\n\r\n textureRange = ClipUtilities.rangeOfClipperIntersectionWithRange(viewClipPlanes, textureRange);\r\n\r\n const drapeRange = Range3d.createNull();\r\n for (const drapeRef of drapeRefs) {\r\n const drapeTree = drapeRef.treeOwner.tileTree;\r\n\r\n if (!drapeTree)\r\n return {};\r\n if (drapeTree.isContentUnbounded) {\r\n let heightRange = viewingSpace.getTerrainHeightRange();\r\n if (!heightRange)\r\n heightRange = ApproximateTerrainHeights.instance.globalHeightRange;\r\n\r\n textureRange.low.x = Math.min(textureRange.low.x, heightRange.low);\r\n textureRange.high.x = Math.max(textureRange.high.x, heightRange.high);\r\n } else {\r\n const contentRange = textureTransform.multiplyRange(drapeRef.computeWorldContentRange());\r\n if (!contentRange.isNull)\r\n drapeRange.extendRange(contentRange);\r\n }\r\n }\r\n if (!drapeRange.isNull) {\r\n // Union of height\r\n textureRange.low.x = Math.min(textureRange.low.x, drapeRange.low.x);\r\n textureRange.high.x = Math.max(textureRange.high.x, drapeRange.high.x);\r\n\r\n // Intersection of texture extents.\r\n textureRange.low.y = Math.max(textureRange.low.y, drapeRange.low.y);\r\n textureRange.high.y = Math.min(textureRange.high.y, drapeRange.high.y);\r\n textureRange.low.z = Math.max(textureRange.low.z, drapeRange.low.z);\r\n textureRange.high.z = Math.min(textureRange.high.z, drapeRange.high.z);\r\n }\r\n\r\n const epsilon = .01;\r\n textureRange.low.x -= epsilon;\r\n textureRange.high.x += epsilon;\r\n\r\n const textureFrustum = Frustum.fromRange(textureRange);\r\n const debugFrustum = textureFrustum.clone();\r\n textureTransform.multiplyInversePoint3dArray(debugFrustum.points, debugFrustum.points);\r\n\r\n if (viewState.isCameraOn) {\r\n const eyeHeight = (textureRange.low.x + textureRange.high.x) / 2.0;\r\n const eyePlane = Plane3dByOriginAndUnitNormal.create(Point3d.createScale(textureZ, eyeHeight), textureZ); // Centered in range - parallel to texture.\r\n const projectionRay = Ray3d.create(viewState.getEyePoint(), viewZ.crossProduct(textureX).normalize()!);\r\n let projectionDistance = projectionRay.intersectionWithPlane(eyePlane!);\r\n const minNearToFarRatio = .01; // Smaller value allows texture projection to conform tightly to view frustum.\r\n if (undefined !== projectionDistance) {\r\n projectionDistance = Math.max(.1, projectionDistance);\r\n const eyePoint = textureTransform.multiplyPoint3d(projectionRay.fractionToPoint(projectionDistance));\r\n let near = eyePoint.z - textureRange.high.z;\r\n let far = eyePoint.z - textureRange.low.z;\r\n\r\n if (near / far < minNearToFarRatio) {\r\n // If the near-far ratio is less than minimum move the camera back.\r\n far = (textureRange.high.z - textureRange.low.z) / (1.0 - minNearToFarRatio);\r\n near = far * minNearToFarRatio;\r\n eyePoint.z = near + textureRange.high.z;\r\n }\r\n const farRange = Range2d.createNull();\r\n const nearRange = Range2d.createNull();\r\n // Create a frustum that includes the entire view frustum and all Z values.\r\n nearRange.low.x = textureRange.low.x;\r\n nearRange.high.x = textureRange.high.x;\r\n farRange.low.x = eyePoint.x + far / near * (textureRange.low.x - eyePoint.x);\r\n farRange.high.x = eyePoint.x + far / near * (textureRange.high.x - eyePoint.x);\r\n ClipUtilities.announceLoopsOfConvexClipPlaneSetIntersectRange(viewClipPlanes, textureRange, (points: GrowableXYZArray) => {\r\n points.getPoint3dArray().forEach((rangePoint) => {\r\n const farScale = far / (eyePoint.z - rangePoint.z);\r\n const nearScale = near / (eyePoint.z - rangePoint.z);\r\n const nearY = eyePoint.y + nearScale * (rangePoint.y - eyePoint.y);\r\n const farY = eyePoint.y + farScale * (rangePoint.y - eyePoint.y);\r\n nearRange.low.y = Math.min(nearRange.low.y, nearY);\r\n nearRange.high.y = Math.max(nearRange.high.y, nearY);\r\n farRange.low.y = Math.min(farRange.low.y, farY);\r\n farRange.high.y = Math.max(farRange.high.y, farY);\r\n });\r\n });\r\n textureFrustum.points[Npc._000].set(farRange.low.x, farRange.low.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._100].set(farRange.high.x, farRange.low.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._010].set(farRange.low.x, farRange.high.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._110].set(farRange.high.x, farRange.high.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._001].set(nearRange.low.x, nearRange.low.y, eyePoint.z - near);\r\n textureFrustum.points[Npc._101].set(nearRange.high.x, nearRange.low.y, eyePoint.z - near);\r\n textureFrustum.points[Npc._011].set(nearRange.low.x, nearRange.high.y, eyePoint.z - near);\r\n textureFrustum.points[Npc._111].set(nearRange.high.x, nearRange.high.y, eyePoint.z - near);\r\n }\r\n }\r\n textureMatrix.transposeInPlace();\r\n textureMatrix.multiplyVectorArrayInPlace(textureFrustum.points);\r\n const frustumMap = textureFrustum.toMap4d();\r\n if (undefined === frustumMap) {\r\n return {};\r\n }\r\n const worldToNpc = PlanarTextureProjection._postProjectionMatrixNpc.multiplyMatrixMatrix(frustumMap.transform0);\r\n const npcToView = Map4d.createBoxMap(Point3d.create(0, 0, 0), Point3d.create(1, 1, 1), Point3d.create(0, 0, 0), Point3d.create(textureWidth, textureHeight, 1), scratchMap4d)!;\r\n const npcToWorld = worldToNpc.createInverse(scratchMatrix4d);\r\n if (undefined === npcToWorld) {\r\n return {};\r\n }\r\n const worldToNpcMap = Map4d.createRefs(worldToNpc, npcToWorld);\r\n const worldToViewMap = npcToView.multiplyMapMap(worldToNpcMap);\r\n\r\n return { textureFrustum, projectionMatrix: worldToNpc, worldToViewMap, debugFrustum };\r\n }\r\n\r\n public static getTextureDrawingParams(target: Target) {\r\n const state = new RenderState();\r\n state.flags.depthMask = false;\r\n state.flags.blend = false;\r\n state.flags.depthTest = false;\r\n\r\n const viewFlags = target.currentViewFlags.copy({\r\n renderMode: RenderMode.SmoothShade,\r\n wiremesh: false,\r\n transparency: false,\r\n textures: false,\r\n lighting: false,\r\n shadows: false,\r\n monochrome: false,\r\n materials: false,\r\n ambientOcclusion: false,\r\n visibleEdges: false,\r\n hiddenEdges: false,\r\n });\r\n\r\n return { state, viewFlags };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PlanarTextureProjection.js","sourceRoot":"","sources":["../../../../src/render/webgl/PlanarTextureProjection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,oDAA6E;AAC7E,wDAG8B;AAC9B,+EAA4E;AAI5E,+CAA4C;AAG5C,MAAM,YAAY,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC1C,MAAM,YAAY,GAAG,qBAAK,CAAC,cAAc,EAAE,CAAC;AAC5C,M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AAW,EAAE,CAAC;QAChC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;QAC9B,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QAC1B,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;QAE9B,MAAM,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC7C,UAAU,EAAE,wBAAU,CAAC,WAAW;YAClC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,gBAAgB,EAAE,KAAK;YACvB,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;QAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAC9B,CAAC;;AA9KH,0DA+KC;AA9KgB,gDAAwB,GAAG,wBAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { Frustum, FrustumPlanes, Npc, RenderMode } from \"@itwin/core-common\";\r\nimport {\r\n ClipUtilities, ConvexClipPlaneSet, GrowableXYZArray, Map4d, Matrix3d, Matrix4d, Plane3dByOriginAndUnitNormal, Point3d, Range1d, Range2d, Range3d,\r\n Ray3d, Transform,\r\n} from \"@itwin/core-geometry\";\r\nimport { ApproximateTerrainHeights } from \"../../ApproximateTerrainHeights\";\r\nimport { Tile, TileTreeReference } from \"../../tile/internal\";\r\nimport { SceneContext } from \"../../ViewContext\";\r\nimport { ViewState3d } from \"../../ViewState\";\r\nimport { RenderState } from \"./RenderState\";\r\nimport { Target } from \"./Target\";\r\n\r\nconst scratchRange = Range3d.createNull();\r\nconst scratchMap4d = Map4d.createIdentity();\r\nconst scratchMatrix4d = Matrix4d.createIdentity();\r\nexport class PlanarTextureProjection {\r\n private static _postProjectionMatrixNpc = Matrix4d.createRowValues(/* Row 1 */ 0, 1, 0, 0, /* Row 1 */ 0, 0, 1, 0, /* Row 3 */ 1, 0, 0, 0, /* Row 4 */ 0, 0, 0, 1);\r\n\r\n public static computePlanarTextureProjection(\r\n texturePlane: Plane3dByOriginAndUnitNormal,\r\n sceneContext: SceneContext,\r\n target: { tiles: Tile[], location: Transform },\r\n drapeRefs: TileTreeReference[],\r\n viewState: ViewState3d,\r\n textureWidth: number,\r\n textureHeight: number,\r\n _heightRange?: Range1d): { textureFrustum?: Frustum, worldToViewMap?: Map4d, projectionMatrix?: Matrix4d, debugFrustum?: Frustum, zValue?: number } {\r\n const textureZ = texturePlane.getNormalRef();\r\n const viewingSpace = sceneContext.viewingSpace;\r\n const viewX = viewingSpace.rotation.rowX();\r\n const viewZ = viewingSpace.rotation.rowZ();\r\n const minCrossMagnitude = 1.0E-4;\r\n\r\n if (viewZ === undefined)\r\n return {}; // View without depth?....\r\n\r\n let textureX = viewZ.crossProduct(textureZ);\r\n let textureY;\r\n if (textureX.magnitude() < minCrossMagnitude) {\r\n textureY = viewX.crossProduct(textureZ);\r\n textureX = textureY.crossProduct(textureZ).normalize()!;\r\n } else {\r\n textureX.normalizeInPlace();\r\n textureY = textureZ.crossProduct(textureX).normalize()!;\r\n }\r\n\r\n const frustumX = textureZ, frustumY = textureX, frustumZ = textureY;\r\n const textureMatrix = Matrix3d.createRows(frustumX, frustumY, frustumZ);\r\n const textureTransform = Transform.createRefs(Point3d.createZero(), textureMatrix);\r\n const viewFrustum = viewingSpace.getFrustum().transformBy(textureTransform);\r\n const viewPlanes = FrustumPlanes.fromFrustum(viewFrustum);\r\n const viewClipPlanes = ConvexClipPlaneSet.createPlanes(viewPlanes.planes);\r\n\r\n let textureRange = Range3d.createNull();\r\n const tileToTexture = textureTransform.multiplyTransformTransform(target.location);\r\n for (const tile of target.tiles) {\r\n textureRange.extendRange(tileToTexture.multiplyRange(tile.range, scratchRange));\r\n }\r\n\r\n if (textureRange.isNull)\r\n return {};\r\n\r\n textureRange = ClipUtilities.rangeOfClipperIntersectionWithRange(viewClipPlanes, textureRange);\r\n\r\n const drapeRange = Range3d.createNull();\r\n for (const drapeRef of drapeRefs) {\r\n const drapeTree = drapeRef.treeOwner.tileTree;\r\n\r\n if (!drapeTree)\r\n return {};\r\n if (drapeTree.isContentUnbounded) {\r\n let heightRange = viewingSpace.getTerrainHeightRange();\r\n if (!heightRange)\r\n heightRange = ApproximateTerrainHeights.instance.globalHeightRange;\r\n\r\n textureRange.low.x = Math.min(textureRange.low.x, heightRange.low);\r\n textureRange.high.x = Math.max(textureRange.high.x, heightRange.high);\r\n } else {\r\n const contentRange = textureTransform.multiplyRange(drapeRef.computeWorldContentRange());\r\n if (!contentRange.isNull)\r\n drapeRange.extendRange(contentRange);\r\n }\r\n }\r\n if (!drapeRange.isNull) {\r\n // Union of height\r\n textureRange.low.x = Math.min(textureRange.low.x, drapeRange.low.x);\r\n textureRange.high.x = Math.max(textureRange.high.x, drapeRange.high.x);\r\n\r\n // Intersection of texture extents.\r\n textureRange.low.y = Math.max(textureRange.low.y, drapeRange.low.y);\r\n textureRange.high.y = Math.min(textureRange.high.y, drapeRange.high.y);\r\n textureRange.low.z = Math.max(textureRange.low.z, drapeRange.low.z);\r\n textureRange.high.z = Math.min(textureRange.high.z, drapeRange.high.z);\r\n }\r\n\r\n const epsilon = .01;\r\n textureRange.low.x -= epsilon;\r\n textureRange.high.x += epsilon;\r\n\r\n const textureFrustum = Frustum.fromRange(textureRange);\r\n const debugFrustum = textureFrustum.clone();\r\n textureTransform.multiplyInversePoint3dArray(debugFrustum.points, debugFrustum.points);\r\n\r\n if (viewState.isCameraOn) {\r\n const eyeHeight = (textureRange.low.x + textureRange.high.x) / 2.0;\r\n const eyePlane = Plane3dByOriginAndUnitNormal.create(Point3d.createScale(textureZ, eyeHeight), textureZ); // Centered in range - parallel to texture.\r\n const projectionRay = Ray3d.create(viewState.getEyePoint(), viewZ.crossProduct(textureX).normalize()!);\r\n let projectionDistance = projectionRay.intersectionWithPlane(eyePlane!);\r\n const minNearToFarRatio = .01; // Smaller value allows texture projection to conform tightly to view frustum.\r\n if (undefined !== projectionDistance) {\r\n projectionDistance = Math.max(.1, projectionDistance);\r\n const eyePoint = textureTransform.multiplyPoint3d(projectionRay.fractionToPoint(projectionDistance));\r\n let near = eyePoint.z - textureRange.high.z;\r\n let far = eyePoint.z - textureRange.low.z;\r\n\r\n if (near / far < minNearToFarRatio) {\r\n // If the near-far ratio is less than minimum move the camera back.\r\n far = (textureRange.high.z - textureRange.low.z) / (1.0 - minNearToFarRatio);\r\n near = far * minNearToFarRatio;\r\n eyePoint.z = near + textureRange.high.z;\r\n }\r\n const farRange = Range2d.createNull();\r\n const nearRange = Range2d.createNull();\r\n // Create a frustum that includes the entire view frustum and all Z values.\r\n nearRange.low.x = textureRange.low.x;\r\n nearRange.high.x = textureRange.high.x;\r\n farRange.low.x = eyePoint.x + far / near * (textureRange.low.x - eyePoint.x);\r\n farRange.high.x = eyePoint.x + far / near * (textureRange.high.x - eyePoint.x);\r\n ClipUtilities.announceLoopsOfConvexClipPlaneSetIntersectRange(viewClipPlanes, textureRange, (points: GrowableXYZArray) => {\r\n points.getPoint3dArray().forEach((rangePoint) => {\r\n const farScale = far / (eyePoint.z - rangePoint.z);\r\n const nearScale = near / (eyePoint.z - rangePoint.z);\r\n const nearY = eyePoint.y + nearScale * (rangePoint.y - eyePoint.y);\r\n const farY = eyePoint.y + farScale * (rangePoint.y - eyePoint.y);\r\n nearRange.low.y = Math.min(nearRange.low.y, nearY);\r\n nearRange.high.y = Math.max(nearRange.high.y, nearY);\r\n farRange.low.y = Math.min(farRange.low.y, farY);\r\n farRange.high.y = Math.max(farRange.high.y, farY);\r\n });\r\n });\r\n textureFrustum.points[Npc._000].set(farRange.low.x, farRange.low.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._100].set(farRange.high.x, farRange.low.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._010].set(farRange.low.x, farRange.high.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._110].set(farRange.high.x, farRange.high.y, eyePoint.z - far);\r\n textureFrustum.points[Npc._001].set(nearRange.low.x, nearRange.low.y, eyePoint.z - near);\r\n textureFrustum.points[Npc._101].set(nearRange.high.x, nearRange.low.y, eyePoint.z - near);\r\n textureFrustum.points[Npc._011].set(nearRange.low.x, nearRange.high.y, eyePoint.z - near);\r\n textureFrustum.points[Npc._111].set(nearRange.high.x, nearRange.high.y, eyePoint.z - near);\r\n }\r\n }\r\n textureMatrix.transposeInPlace();\r\n textureMatrix.multiplyVectorArrayInPlace(textureFrustum.points);\r\n const frustumMap = textureFrustum.toMap4d();\r\n if (undefined === frustumMap) {\r\n return {};\r\n }\r\n const worldToNpc = PlanarTextureProjection._postProjectionMatrixNpc.multiplyMatrixMatrix(frustumMap.transform0);\r\n const npcToView = Map4d.createBoxMap(Point3d.create(0, 0, 0), Point3d.create(1, 1, 1), Point3d.create(0, 0, 0), Point3d.create(textureWidth, textureHeight, 1), scratchMap4d)!;\r\n const npcToWorld = worldToNpc.createInverse(scratchMatrix4d);\r\n if (undefined === npcToWorld) {\r\n return {};\r\n }\r\n const worldToNpcMap = Map4d.createRefs(worldToNpc, npcToWorld);\r\n const worldToViewMap = npcToView.multiplyMapMap(worldToNpcMap);\r\n\r\n return { textureFrustum, projectionMatrix: worldToNpc, worldToViewMap, debugFrustum };\r\n }\r\n\r\n public static getTextureDrawingParams(target: Target) {\r\n const state = new RenderState();\r\n state.flags.depthMask = false;\r\n state.flags.blend = false;\r\n state.flags.depthTest = false;\r\n\r\n const viewFlags = target.currentViewFlags.copy({\r\n renderMode: RenderMode.SmoothShade,\r\n wiremesh: false,\r\n transparency: false,\r\n textures: false,\r\n lighting: false,\r\n shadows: false,\r\n monochrome: false,\r\n materials: false,\r\n ambientOcclusion: false,\r\n visibleEdges: false,\r\n hiddenEdges: false,\r\n });\r\n\r\n return { state, viewFlags };\r\n }\r\n}\r\n"]}
@@ -562,7 +562,7 @@ class RenderCommands {
562
562
  this._batchState.pop();
563
563
  }
564
564
  // Define a culling frustum. Commands associated with Graphics whose ranges do not intersect the frustum will be skipped.
565
- setCheckRange(frustum) { this._frustumPlanes = new core_common_1.FrustumPlanes(frustum); }
565
+ setCheckRange(frustum) { this._frustumPlanes = core_common_1.FrustumPlanes.fromFrustum(frustum); }
566
566
  // Clear the culling frustum.
567
567
  clearCheckRange() { this._frustumPlanes = undefined; }
568
568
  setupClassificationByVolume() {
@@ -1 +1 @@
1
- {"version":3,"file":"RenderCommands.js","sourceRoot":"","sources":["../../../../src/render/webgl/RenderCommands.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,wDAA+C;AAC/C,oDAAmF;AAEnF,+DAA0D;AAM1D,+CAGuB;AACvB,uCAAkE;AAElE,mDAAoD;AACpD,iCAAqC;AAErC,+CAA8E;AAK9E;;GAEG;AACH,MAAa,cAAc;IA4DzB,YAAY,MAAc,EAAE,KAAkB,EAAE,UAAsB;QA1DrD,oBAAe,GAAG,IAAI,qBAAO,EAAE,CAAC;QAChC,kBAAa,GAAG,IAAI,uBAAO,EAAE,CAAC;QAC9B,cAAS,GAAG,IAAI,KAAK,gBAAgC,CAAC;QAI/D,sBAAiB,kBAA+B;QAChD,+BAA0B,GAAG,K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AAK,eAAe;wBAClB,KAAK,GAAG,CAAC,CAAC;wBACV,MAAM;oBACR,KAAK,WAAW;wBACd,KAAK,GAAG,CAAC,CAAC;wBACV,MAAM;oBACR,KAAK,YAAY;wBACf,KAAK,GAAG,CAAC,CAAC;wBACV,MAAM;oBACR;wBACE,SAAS;iBACZ;gBAED,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;aACrB;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/tBD,wCA+tBC","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 WebGL\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { Frustum, FrustumPlanes, RenderMode, ViewFlags } from \"@itwin/core-common\";\r\nimport { Decorations } from \"../Decorations\";\r\nimport { SurfaceType } from \"../primitives/SurfaceParams\";\r\nimport { GraphicList, RenderGraphic } from \"../RenderGraphic\";\r\nimport { AnimationBranchState } from \"../GraphicBranch\";\r\nimport { BranchStack } from \"./BranchStack\";\r\nimport { BatchState } from \"./BatchState\";\r\nimport { BranchState } from \"./BranchState\";\r\nimport {\r\n DrawCommands, PopBatchCommand, PopBranchCommand, PopClipCommand, PopCommand, PrimitiveCommand, PushBatchCommand,\r\n PushBranchCommand, PushClipCommand, PushCommand, PushStateCommand,\r\n} from \"./DrawCommand\";\r\nimport { Batch, Branch, Graphic, GraphicsArray } from \"./Graphic\";\r\nimport { Layer, LayerContainer } from \"./Layer\";\r\nimport { LayerCommandLists } from \"./LayerCommands\";\r\nimport { MeshGraphic } from \"./Mesh\";\r\nimport { Primitive } from \"./Primitive\";\r\nimport { CompositeFlags, Pass, RenderOrder, RenderPass } from \"./RenderFlags\";\r\nimport { TargetGraphics } from \"./TargetGraphics\";\r\nimport { Target } from \"./Target\";\r\nimport { ClipVolume } from \"./ClipVolume\";\r\n\r\n/** A list of DrawCommands to be rendered, ordered by render pass.\r\n * @internal\r\n */\r\nexport class RenderCommands implements Iterable<DrawCommands> {\r\n private _frustumPlanes?: FrustumPlanes;\r\n private readonly _scratchFrustum = new Frustum();\r\n private readonly _scratchRange = new Range3d();\r\n private readonly _commands = new Array<DrawCommands>(RenderPass.COUNT);\r\n private _target: Target;\r\n private _stack: BranchStack; // refers to the Target's BranchStack\r\n private _batchState: BatchState; // refers to the Target's BatchState\r\n private _forcedRenderPass: RenderPass = RenderPass.None;\r\n private _addLayersAsNormalGraphics = false;\r\n private _opaqueOverrides = false;\r\n private _translucentOverrides = false;\r\n private _addTranslucentAsOpaque = false; // true when rendering for _ReadPixels to force translucent items to be drawn in opaque pass.\r\n private readonly _layers: LayerCommandLists;\r\n\r\n public get target(): Target { return this._target; }\r\n\r\n public [Symbol.iterator](): Iterator<DrawCommands> {\r\n return this._commands[Symbol.iterator]();\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n for (const commands of this._commands)\r\n if (0 < commands.length)\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n public get isDrawingLayers() {\r\n switch (this._forcedRenderPass) {\r\n case RenderPass.OpaqueLayers:\r\n case RenderPass.TranslucentLayers:\r\n case RenderPass.OverlayLayers:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n public get currentViewFlags(): ViewFlags { return this._stack.top.viewFlags; }\r\n public get compositeFlags(): CompositeFlags {\r\n let flags = CompositeFlags.None;\r\n if (this.hasCommands(RenderPass.Translucent))\r\n flags |= CompositeFlags.Translucent;\r\n\r\n if (this.hasCommands(RenderPass.Hilite) || this.hasCommands(RenderPass.HiliteClassification) || this.hasCommands(RenderPass.HilitePlanarClassification))\r\n flags |= CompositeFlags.Hilite;\r\n\r\n if (this.target.wantAmbientOcclusion)\r\n flags |= CompositeFlags.AmbientOcclusion;\r\n\r\n return flags;\r\n }\r\n\r\n private get _curBatch(): Batch | undefined { return this._batchState.currentBatch; }\r\n\r\n public hasCommands(pass: RenderPass): boolean { return 0 !== this.getCommands(pass).length; }\r\n public isOpaquePass(pass: RenderPass): boolean { return pass >= RenderPass.OpaqueLinear && pass <= RenderPass.OpaqueGeneral; }\r\n\r\n constructor(target: Target, stack: BranchStack, batchState: BatchState) {\r\n this._target = target;\r\n this._stack = stack;\r\n this._batchState = batchState;\r\n this._layers = new LayerCommandLists(this);\r\n\r\n for (let i = 0; i < RenderPass.COUNT; ++i)\r\n this._commands[i] = [];\r\n }\r\n\r\n public reset(target: Target, stack: BranchStack, batchState: BatchState): void {\r\n this._target = target;\r\n this._stack = stack;\r\n this._batchState = batchState;\r\n this.clear();\r\n }\r\n\r\n public collectGraphicsForPlanarProjection(scene: GraphicList): void {\r\n assert(this._forcedRenderPass === RenderPass.None);\r\n assert(!this._addLayersAsNormalGraphics);\r\n\r\n this._addLayersAsNormalGraphics = true;\r\n this.addGraphics(scene);\r\n this._addLayersAsNormalGraphics = false;\r\n }\r\n\r\n public addGraphics(scene: GraphicList, forcedPass: RenderPass = RenderPass.None): void {\r\n this._forcedRenderPass = forcedPass;\r\n scene.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n /** Add backgroundMap graphics to their own render pass. */\r\n public addBackgroundMapGraphics(backgroundMapGraphics: GraphicList): void {\r\n this._forcedRenderPass = RenderPass.BackgroundMap;\r\n backgroundMapGraphics.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n /** Add overlay graphics to the world overlay pass */\r\n public addOverlayGraphics(overlayGraphics: GraphicList): void {\r\n this._forcedRenderPass = RenderPass.WorldOverlay;\r\n overlayGraphics.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addDecorations(dec: GraphicList, forcedPass: RenderPass = RenderPass.None): void {\r\n this._forcedRenderPass = forcedPass;\r\n for (const entry of dec) {\r\n (entry as Graphic).addCommands(this);\r\n }\r\n\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addWorldDecorations(decs: GraphicList): void {\r\n const world = this.target.getWorldDecorations(decs);\r\n this.pushAndPopBranch(world, () => {\r\n for (const entry of world.branch.entries) {\r\n (entry as Graphic).addCommands(this);\r\n }\r\n });\r\n }\r\n\r\n private addPickableDecorations(decs: Decorations): void {\r\n if (undefined !== decs.normal) {\r\n for (const normal of decs.normal) {\r\n const gf = normal as Graphic;\r\n if (gf.isPickable)\r\n gf.addCommands(this);\r\n }\r\n }\r\n\r\n if (undefined !== decs.world) {\r\n const world = this.target.getWorldDecorations(decs.world);\r\n this.pushAndPopBranch(world, () => {\r\n for (const gf of world.branch.entries) {\r\n if ((gf as Graphic).isPickable)\r\n (gf as Graphic).addCommands(this);\r\n }\r\n });\r\n }\r\n }\r\n\r\n public addBackground(gf?: Graphic): void {\r\n if (undefined === gf)\r\n return;\r\n\r\n assert(RenderPass.None === this._forcedRenderPass);\r\n\r\n this._forcedRenderPass = RenderPass.Background;\r\n this.pushAndPopState(this.target.decorationsState, () => gf.addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addSkyBox(gf?: Graphic): void {\r\n if (undefined === gf)\r\n return;\r\n\r\n assert(RenderPass.None === this._forcedRenderPass);\r\n\r\n this._forcedRenderPass = RenderPass.SkyBox;\r\n this.pushAndPopState(this.target.decorationsState, () => gf.addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addPrimitiveCommand(command: PrimitiveCommand, pass?: Pass): void {\r\n if (undefined === pass)\r\n pass = command.getPass(this.target);\r\n\r\n if (\"none\" === pass) // Edges will return none if they don't want to draw at all (edges not turned on).\r\n return;\r\n\r\n if (RenderPass.None !== this._forcedRenderPass) {\r\n // Add the command to the forced render pass (background).\r\n this.getCommands(this._forcedRenderPass).push(command);\r\n return;\r\n }\r\n\r\n if (!command.hasFeatures) {\r\n // Draw in general opaque pass so they are not in pick data.\r\n switch (pass) {\r\n case \"opaque-linear\":\r\n case \"opaque-planar\":\r\n pass = \"opaque\";\r\n break;\r\n case \"opaque-planar-translucent\":\r\n pass = \"opaque-translucent\";\r\n break;\r\n }\r\n }\r\n\r\n const haveFeatureOverrides = (this._opaqueOverrides || this._translucentOverrides) && command.opcode && command.hasFeatures;\r\n\r\n if (Pass.rendersTranslucent(pass) && this._addTranslucentAsOpaque) {\r\n switch (command.renderOrder) {\r\n case RenderOrder.PlanarLitSurface:\r\n case RenderOrder.PlanarUnlitSurface:\r\n case RenderOrder.BlankingRegion:\r\n pass = \"opaque-planar\";\r\n break;\r\n case RenderOrder.LitSurface:\r\n case RenderOrder.UnlitSurface:\r\n pass = \"opaque\";\r\n break;\r\n default:\r\n pass = \"opaque-linear\";\r\n break;\r\n }\r\n }\r\n\r\n const isDoublePass = Pass.rendersOpaqueAndTranslucent(pass);\r\n const renderTranslucentDuringOpaque = isDoublePass || (this._opaqueOverrides && haveFeatureOverrides);\r\n if (renderTranslucentDuringOpaque && Pass.rendersTranslucent(pass) && !command.primitive.cachedGeometry.alwaysRenderTranslucent) {\r\n let opaquePass: RenderPass;\r\n if (Pass.rendersOpaqueAndTranslucent(pass)) {\r\n opaquePass = Pass.toOpaquePass(pass);\r\n } else {\r\n switch (command.renderOrder) {\r\n case RenderOrder.PlanarLitSurface:\r\n case RenderOrder.PlanarUnlitSurface:\r\n case RenderOrder.BlankingRegion:\r\n opaquePass = RenderPass.OpaquePlanar;\r\n break;\r\n case RenderOrder.LitSurface:\r\n case RenderOrder.UnlitSurface:\r\n opaquePass = RenderPass.OpaqueGeneral;\r\n break;\r\n default:\r\n opaquePass = RenderPass.OpaqueLinear;\r\n break;\r\n }\r\n }\r\n\r\n this.getCommands(opaquePass).push(command);\r\n }\r\n\r\n const renderOpaqueDuringTranslucent = isDoublePass || (this._translucentOverrides && haveFeatureOverrides);\r\n if (renderOpaqueDuringTranslucent && Pass.rendersOpaque(pass) && !this._addTranslucentAsOpaque)\r\n this.getCommands(RenderPass.Translucent).push(command);\r\n\r\n if (!Pass.rendersOpaqueAndTranslucent(pass))\r\n this.getCommands(Pass.toRenderPass(pass)).push(command);\r\n }\r\n\r\n public getCommands(pass: RenderPass): DrawCommands {\r\n let idx = pass as number;\r\n assert(idx < this._commands.length);\r\n if (idx >= this._commands.length)\r\n idx -= 1;\r\n\r\n return this._commands[idx];\r\n }\r\n\r\n public replaceCommands(pass: RenderPass, cmds: DrawCommands): void {\r\n const idx = pass as number;\r\n this._commands[idx].splice(0);\r\n this._commands[idx] = cmds;\r\n }\r\n\r\n public addHiliteBranch(branch: Branch, pass: RenderPass): void {\r\n this.pushAndPopBranchForPass(pass, branch, () => {\r\n branch.branch.entries.forEach((entry: RenderGraphic) => (entry as Graphic).addHiliteCommands(this, pass));\r\n });\r\n }\r\n\r\n public processLayers(container: LayerContainer): void {\r\n assert(RenderPass.None === this._forcedRenderPass);\r\n if (RenderPass.None !== this._forcedRenderPass)\r\n return;\r\n\r\n this._forcedRenderPass = container.renderPass;\r\n this._layers.processLayers(container, () => container.graphic.addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addLayerCommands(layer: Layer): void {\r\n if (this._addLayersAsNormalGraphics) {\r\n // GraphicsCollectorDrawArgs wants to collect graphics to project to a plane for masking.\r\n // It bypasses PlanProjectionTreeReference.createDrawArgs which would otherwise wrap the graphics in a LayerContainer.\r\n assert(this._forcedRenderPass === RenderPass.None);\r\n this._forcedRenderPass = RenderPass.OpaqueGeneral;\r\n layer.graphic.addCommands(this);\r\n this._forcedRenderPass = RenderPass.None;\r\n return;\r\n }\r\n\r\n assert(this.isDrawingLayers);\r\n if (!this.isDrawingLayers)\r\n return;\r\n\r\n // Let the graphic add its commands. Afterward, pull them out and add them to the LayerCommands.\r\n this._layers.currentLayer = layer;\r\n layer.graphic.addCommands(this);\r\n\r\n const cmds = this.getCommands(this._forcedRenderPass);\r\n this._layers.addCommands(cmds);\r\n\r\n cmds.length = 0;\r\n this._layers.currentLayer = undefined;\r\n }\r\n\r\n public addHiliteLayerCommands(graphic: Graphic, pass: RenderPass): void {\r\n assert(this.isDrawingLayers || this._addLayersAsNormalGraphics);\r\n if (!this.isDrawingLayers && !this._addLayersAsNormalGraphics)\r\n return;\r\n\r\n const prevPass = this._forcedRenderPass;\r\n this._forcedRenderPass = RenderPass.None;\r\n\r\n graphic.addHiliteCommands(this, pass);\r\n\r\n this._forcedRenderPass = prevPass;\r\n }\r\n\r\n private getAnimationBranchState(branch: Branch): AnimationBranchState | undefined {\r\n const animId = branch.branch.animationId;\r\n return undefined !== animId ? this.target.animationBranches?.branchStates.get(animId) : undefined;\r\n }\r\n\r\n private pushAndPopBranchForPass(pass: RenderPass, branch: Branch, func: () => void): void {\r\n assert(!this.isDrawingLayers);\r\n\r\n const animState = this.getAnimationBranchState(branch);\r\n if (animState?.omit)\r\n return;\r\n\r\n assert(RenderPass.None !== pass);\r\n\r\n this._stack.pushBranch(branch);\r\n if (branch.planarClassifier)\r\n branch.planarClassifier.pushBatchState(this._batchState);\r\n\r\n if (branch.secondaryClassifiers)\r\n branch.secondaryClassifiers.forEach((classifier) => classifier.pushBatchState(this._batchState));\r\n\r\n const cmds = this.getCommands(pass);\r\n const clip = animState?.clip as ClipVolume | undefined;\r\n const pushClip = undefined !== clip ? new PushClipCommand(clip) : undefined;\r\n if (pushClip)\r\n cmds.push(pushClip);\r\n\r\n const push = new PushBranchCommand(branch);\r\n cmds.push(push);\r\n\r\n func();\r\n\r\n this._stack.pop();\r\n if (cmds[cmds.length - 1] === push) {\r\n cmds.pop();\r\n if (pushClip)\r\n cmds.pop();\r\n } else {\r\n cmds.push(PopBranchCommand.instance);\r\n if (pushClip)\r\n cmds.push(PopClipCommand.instance);\r\n }\r\n }\r\n\r\n private pushAndPop(push: PushCommand, pop: PopCommand, func: () => void): void {\r\n if (this.isDrawingLayers) {\r\n this._commands[RenderPass.Hilite].push(push);\r\n this._layers.pushAndPop(push, pop, func);\r\n\r\n const cmds = this._commands[RenderPass.Hilite];\r\n if (0 < cmds.length && cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n\r\n return;\r\n }\r\n\r\n if (RenderPass.None === this._forcedRenderPass) {\r\n // Need to make sure the push command precedes any subsequent commands added to any render pass.\r\n for (const cmds of this._commands)\r\n cmds.push(push);\r\n } else {\r\n // May want to add hilite commands as well - add the push command to that pass.\r\n this._commands[this._forcedRenderPass].push(push);\r\n this._commands[RenderPass.Hilite].push(push);\r\n }\r\n\r\n func();\r\n\r\n // Remove push command from any passes that didn't receive any commands; add the pop command to any passes that did.\r\n if (RenderPass.None === this._forcedRenderPass) {\r\n for (const cmds of this._commands) {\r\n assert(0 < cmds.length);\r\n if (0 < cmds.length && cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n }\r\n } else {\r\n assert(0 < this._commands[this._forcedRenderPass].length);\r\n assert(0 < this._commands[RenderPass.Hilite].length);\r\n\r\n let cmds = this._commands[this._forcedRenderPass];\r\n if (cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n\r\n cmds = this._commands[RenderPass.Hilite];\r\n if (cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n }\r\n }\r\n\r\n public pushAndPopBranch(branch: Branch, func: () => void): void {\r\n const animState = this.getAnimationBranchState(branch);\r\n if (animState?.omit)\r\n return;\r\n\r\n if (animState?.clip)\r\n this.pushAndPop(new PushClipCommand(animState.clip as ClipVolume), PopClipCommand.instance, () => this._pushAndPopBranch(branch, func));\r\n else\r\n this._pushAndPopBranch(branch, func);\r\n }\r\n\r\n private _pushAndPopBranch(branch: Branch, func: () => void): void {\r\n this._stack.pushBranch(branch);\r\n if (branch.planarClassifier)\r\n branch.planarClassifier.pushBatchState(this._batchState);\r\n\r\n if (branch.secondaryClassifiers)\r\n branch.secondaryClassifiers.forEach((classifier) => classifier.pushBatchState(this._batchState));\r\n\r\n this.pushAndPop(new PushBranchCommand(branch), PopBranchCommand.instance, func);\r\n\r\n this._stack.pop();\r\n }\r\n\r\n public pushAndPopState(state: BranchState, func: () => void): void {\r\n this._stack.pushState(state);\r\n this.pushAndPop(new PushStateCommand(state), PopBranchCommand.instance, func);\r\n this._stack.pop();\r\n }\r\n\r\n public clear(): void {\r\n assert(this._batchState.isEmpty);\r\n this._clearCommands();\r\n }\r\n\r\n private _clearCommands(): void {\r\n this._commands.forEach((cmds: DrawCommands) => cmds.splice(0));\r\n this._layers.clear();\r\n }\r\n\r\n private initForPickOverlayDecorations(overlays: GraphicList): void {\r\n for (const overlay of overlays) {\r\n const gf = overlay as Graphic;\r\n if (gf.isPickable)\r\n gf.addCommands(this);\r\n }\r\n }\r\n\r\n public initForPickOverlays(sceneOverlays: GraphicList, worldOverlayDecorations: GraphicList | undefined, viewOverlayDecorations: GraphicList | undefined): void {\r\n this._clearCommands();\r\n\r\n this._addTranslucentAsOpaque = true;\r\n\r\n for (const sceneGf of sceneOverlays)\r\n (sceneGf as Graphic).addCommands(this);\r\n\r\n if (worldOverlayDecorations?.length) {\r\n this.pushAndPopState(this.target.decorationsState, () => {\r\n this.initForPickOverlayDecorations(worldOverlayDecorations);\r\n });\r\n }\r\n\r\n if (viewOverlayDecorations?.length) {\r\n this.pushAndPopState(this.target.decorationsState.withViewCoords(), () => {\r\n this.initForPickOverlayDecorations(viewOverlayDecorations);\r\n });\r\n }\r\n\r\n this._addTranslucentAsOpaque = false;\r\n }\r\n\r\n public initForReadPixels(gfx: TargetGraphics): void {\r\n this.clear();\r\n\r\n // Set flag to force translucent geometry to be put into the opaque pass.\r\n this._addTranslucentAsOpaque = true;\r\n\r\n // Add the scene graphics.\r\n this.addGraphics(gfx.foreground);\r\n\r\n // Also add any pickable decorations.\r\n if (undefined !== gfx.decorations)\r\n this.addPickableDecorations(gfx.decorations);\r\n\r\n // Also background map is pickable\r\n this.addBackgroundMapGraphics(gfx.background);\r\n\r\n this._addTranslucentAsOpaque = false;\r\n\r\n this.setupClassificationByVolume();\r\n this._layers.outputCommands();\r\n }\r\n\r\n public initForRender(gfx: TargetGraphics): void {\r\n this.clear();\r\n\r\n this.addGraphics(gfx.foreground);\r\n this.addBackgroundMapGraphics(gfx.background);\r\n this.addOverlayGraphics(gfx.overlays);\r\n\r\n const dynamics = gfx.dynamics;\r\n if (dynamics && dynamics.length > 0)\r\n this.addDecorations(dynamics);\r\n\r\n const dec = gfx.decorations;\r\n if (undefined !== dec) {\r\n this.addBackground(dec.viewBackground as Graphic);\r\n\r\n this.addSkyBox(dec.skyBox as Graphic);\r\n\r\n if (undefined !== dec.normal && 0 < dec.normal.length)\r\n this.addGraphics(dec.normal);\r\n\r\n if (undefined !== dec.world && 0 < dec.world.length)\r\n this.addWorldDecorations(dec.world);\r\n\r\n this.pushAndPopState(this.target.decorationsState, () => {\r\n if (undefined !== dec.viewOverlay && 0 < dec.viewOverlay.length)\r\n this.addDecorations(dec.viewOverlay, RenderPass.ViewOverlay);\r\n\r\n if (undefined !== dec.worldOverlay && 0 < dec.worldOverlay.length)\r\n this.addDecorations(dec.worldOverlay, RenderPass.WorldOverlay);\r\n });\r\n }\r\n\r\n this.setupClassificationByVolume();\r\n this._layers.outputCommands();\r\n }\r\n\r\n public addPrimitive(prim: Primitive): void {\r\n // ###TODO Would be nice if we could detect outside active volume here, but active volume only applies to specific render passes\r\n // if (this.target.isGeometryOutsideActiveVolume(prim.cachedGeometry))\r\n // return;\r\n\r\n if (undefined !== this._frustumPlanes) { // See if we can cull this primitive.\r\n if (\"classification\" === prim.getPass(this.target)) {\r\n const geom = prim.cachedGeometry;\r\n geom.computeRange(this._scratchRange);\r\n let frustum = Frustum.fromRange(this._scratchRange, this._scratchFrustum);\r\n frustum = frustum.transformBy(this.target.currentTransform, frustum);\r\n if (FrustumPlanes.Containment.Outside === this._frustumPlanes.computeFrustumContainment(frustum)) {\r\n return;\r\n }\r\n }\r\n }\r\n\r\n const command = new PrimitiveCommand(prim);\r\n this.addPrimitiveCommand(command);\r\n\r\n if (RenderPass.None === this._forcedRenderPass && prim.isEdge) {\r\n const vf: ViewFlags = this.target.currentViewFlags;\r\n if (vf.renderMode !== RenderMode.Wireframe && vf.hiddenEdges)\r\n this.getCommands(RenderPass.HiddenEdge).push(command);\r\n }\r\n }\r\n\r\n public addBranch(branch: Branch): void {\r\n this.pushAndPopBranch(branch, () => {\r\n branch.branch.entries.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n });\r\n }\r\n\r\n public computeBatchHiliteRenderPass(batch: Batch): RenderPass {\r\n let pass = RenderPass.Hilite;\r\n if (batch.graphic instanceof MeshGraphic) {\r\n const mg = batch.graphic;\r\n if (SurfaceType.VolumeClassifier === mg.surfaceType)\r\n pass = RenderPass.HiliteClassification;\r\n } else if (batch.graphic instanceof GraphicsArray) {\r\n const ga = batch.graphic;\r\n if (ga.graphics[0] instanceof MeshGraphic) {\r\n const mg = ga.graphics[0];\r\n if (SurfaceType.VolumeClassifier === mg.surfaceType)\r\n pass = RenderPass.HiliteClassification;\r\n } else if (ga.graphics[0] instanceof Branch) {\r\n const b = ga.graphics[0];\r\n if (b.branch.entries.length > 0 && b.branch.entries[0] instanceof MeshGraphic) {\r\n const mg = b.branch.entries[0];\r\n if (SurfaceType.VolumeClassifier === mg.surfaceType)\r\n pass = RenderPass.HiliteClassification;\r\n }\r\n }\r\n }\r\n return pass;\r\n }\r\n\r\n public addBatch(batch: Batch): void {\r\n if (batch.locateOnly && !this.target.isReadPixelsInProgress)\r\n return;\r\n\r\n // Batches (aka element tiles) should only draw during ordinary (translucent or opaque) passes.\r\n // They may draw during both, or neither.\r\n // NB: This is no longer true - pickable overlay decorations are defined as Batches. Problem?\r\n // assert(RenderPass.None === this._forcedRenderPass);\r\n assert(!this._opaqueOverrides && !this._translucentOverrides);\r\n assert(undefined === this._curBatch);\r\n\r\n // If all features are overridden to be invisible, draw no graphics in this batch\r\n const overrides = batch.getOverrides(this.target);\r\n if (overrides.allHidden)\r\n return;\r\n\r\n if (!batch.range.isNull) {\r\n // ###TODO Would be nice if we could detect outside active volume here, but active volume only applies to specific render passes\r\n // if (this.target.isRangeOutsideActiveVolume(batch.range))\r\n // return;\r\n\r\n if (undefined !== this._frustumPlanes) {\r\n let frustum = Frustum.fromRange(batch.range, this._scratchFrustum);\r\n frustum = frustum.transformBy(this.target.currentTransform, frustum);\r\n if (FrustumPlanes.Containment.Outside === this._frustumPlanes.computeFrustumContainment(frustum)) {\r\n return;\r\n }\r\n }\r\n }\r\n\r\n const classifier = this._stack.top.planarClassifier;\r\n\r\n this._batchState.push(batch, true);\r\n\r\n this.pushAndPop(new PushBatchCommand(batch), PopBatchCommand.instance, () => {\r\n if (this.currentViewFlags.transparency || overrides.anyViewIndependentTranslucent) {\r\n this._opaqueOverrides = overrides.anyOpaque;\r\n this._translucentOverrides = overrides.anyTranslucent;\r\n\r\n if (undefined !== classifier) {\r\n this._opaqueOverrides = this._opaqueOverrides || classifier.anyOpaque;\r\n this._translucentOverrides = this._translucentOverrides || classifier.anyTranslucent;\r\n }\r\n }\r\n\r\n // If we have an active volume classifier then force all batches for the reality data being classified into a special render pass.\r\n let savedForcedRenderPass = RenderPass.None;\r\n if (undefined !== this.target.activeVolumeClassifierModelId && batch.featureTable.modelId === this.target.activeVolumeClassifierModelId) {\r\n savedForcedRenderPass = this._forcedRenderPass;\r\n this._forcedRenderPass = RenderPass.VolumeClassifiedRealityData;\r\n }\r\n\r\n (batch.graphic as Graphic).addCommands(this);\r\n\r\n if (RenderPass.VolumeClassifiedRealityData === this._forcedRenderPass)\r\n this._forcedRenderPass = savedForcedRenderPass;\r\n\r\n // If the batch contains hilited features, need to render them in the hilite pass\r\n const anyHilited = overrides.anyHilited;\r\n const planarClassifierHilited = undefined !== classifier && classifier.anyHilited;\r\n if (anyHilited || planarClassifierHilited)\r\n (batch.graphic as Graphic).addHiliteCommands(this, planarClassifierHilited ? RenderPass.HilitePlanarClassification : this.computeBatchHiliteRenderPass(batch));\r\n\r\n });\r\n\r\n this._opaqueOverrides = this._translucentOverrides = false;\r\n this._batchState.pop();\r\n }\r\n\r\n // Define a culling frustum. Commands associated with Graphics whose ranges do not intersect the frustum will be skipped.\r\n public setCheckRange(frustum: Frustum) { this._frustumPlanes = new FrustumPlanes(frustum); }\r\n // Clear the culling frustum.\r\n public clearCheckRange(): void { this._frustumPlanes = undefined; }\r\n\r\n private setupClassificationByVolume(): void {\r\n // To make it easier to process the classifiers individually, set up a secondary command list for them where they\r\n // are each separated by their own pushes & pops so that they can easily be drawn individually. This now supports\r\n // nested branches and batches.\r\n const groupedCmds = this._commands[RenderPass.Classification];\r\n const byIndexCmds = this._commands[RenderPass.ClassificationByIndex];\r\n const pushCommands: DrawCommands = []; // will contain current set of pushes ahead of a primitive\r\n for (const cmd of groupedCmds) {\r\n switch (cmd.opcode) {\r\n case \"pushBranch\":\r\n case \"pushBatch\":\r\n case \"pushState\":\r\n pushCommands.push(cmd);\r\n break;\r\n case \"drawPrimitive\":\r\n for (const pushCmd of pushCommands) {\r\n byIndexCmds.push(pushCmd);\r\n }\r\n byIndexCmds.push(cmd);\r\n for (let i = pushCommands.length - 1; i >= 0; --i) {\r\n if (\"pushBatch\" === pushCommands[i].opcode)\r\n byIndexCmds.push(PopBatchCommand.instance);\r\n else // should be eith pushBranch or pushState opcode\r\n byIndexCmds.push(PopBranchCommand.instance);\r\n }\r\n break;\r\n case \"popBatch\":\r\n case \"popBranch\":\r\n pushCommands.pop();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n public dump(): Array<{ name: string, count: number }> {\r\n const dump = [\r\n { name: \"Primitives\", count: 0 },\r\n { name: \"Batches\", count: 0 },\r\n { name: \"Branches\", count: 0 },\r\n ];\r\n\r\n for (const cmds of this._commands) {\r\n for (const cmd of cmds) {\r\n let index;\r\n switch (cmd.opcode) {\r\n case \"drawPrimitive\":\r\n index = 0;\r\n break;\r\n case \"pushBatch\":\r\n index = 1;\r\n break;\r\n case \"pushBranch\":\r\n index = 2;\r\n break;\r\n default:\r\n continue;\r\n }\r\n\r\n dump[index].count++;\r\n }\r\n }\r\n\r\n return dump;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RenderCommands.js","sourceRoot":"","sources":["../../../../src/render/webgl/RenderCommands.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,wDAA+C;AAC/C,oDAAmF;AAEnF,+DAA0D;AAM1D,+CAGuB;AACvB,uCAAkE;AAElE,mDAAoD;AACpD,iCAAqC;AAErC,+CAA8E;AAK9E;;GAEG;AACH,MAAa,cAAc;IA4DzB,YAAY,MAAc,EAAE,KAAkB,EAAE,UAAsB;QA1DrD,oBAAe,GAAG,IAAI,qBAAO,EAAE,CAAC;QAChC,kBAAa,GAAG,IAAI,uBAAO,EAAE,CAAC;QAC9B,cAAS,GAAG,IAAI,KAAK,gBAAgC,CAAC;QAI/D,sBAAiB,kBAA+B;QAChD,+BAA0B,GAAG,KAAK,CAAC;QACnC,qBAAgB,GAAG,KAAK,CAAC;QACzB,0BAAqB,GAAG,KAAK,CAAC;QAC9B,4BAAuB,GAAG,KAAK,CAAC,CAAC,6FAA6F;QAiDpI,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,iCAAiB,CAAC,IAAI,CAAC,CAAC;QAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAmB,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;IArDD,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,OAAO,CAAC,C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YAAY,CAAC,CAAC,CAAC,CAAC,MAAM;4BACxC,WAAW,CAAC,IAAI,CAAC,6BAAe,CAAC,QAAQ,CAAC,CAAC;6BACxC,gDAAgD;4BACnD,WAAW,CAAC,IAAI,CAAC,8BAAgB,CAAC,QAAQ,CAAC,CAAC;qBAC/C;oBACD,MAAM;gBACR,KAAK,UAAU,CAAC;gBAChB,KAAK,WAAW;oBACd,YAAY,CAAC,GAAG,EAAE,CAAC;oBACnB,MAAM;aACT;SACF;IACH,CAAC;IAEM,IAAI;QACT,MAAM,IAAI,GAAG;YACX,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE;YAChC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE;YAC7B,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE;SAC/B,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;YACjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;gBACtB,IAAI,KAAK,CAAC;gBACV,QAAQ,GAAG,CAAC,MAAM,EAAE;oBAClB,KAAK,eAAe;wBAClB,KAAK,GAAG,CAAC,CAAC;wBACV,MAAM;oBACR,KAAK,WAAW;wBACd,KAAK,GAAG,CAAC,CAAC;wBACV,MAAM;oBACR,KAAK,YAAY;wBACf,KAAK,GAAG,CAAC,CAAC;wBACV,MAAM;oBACR;wBACE,SAAS;iBACZ;gBAED,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;aACrB;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/tBD,wCA+tBC","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 WebGL\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { Frustum, FrustumPlanes, RenderMode, ViewFlags } from \"@itwin/core-common\";\r\nimport { Decorations } from \"../Decorations\";\r\nimport { SurfaceType } from \"../primitives/SurfaceParams\";\r\nimport { GraphicList, RenderGraphic } from \"../RenderGraphic\";\r\nimport { AnimationBranchState } from \"../GraphicBranch\";\r\nimport { BranchStack } from \"./BranchStack\";\r\nimport { BatchState } from \"./BatchState\";\r\nimport { BranchState } from \"./BranchState\";\r\nimport {\r\n DrawCommands, PopBatchCommand, PopBranchCommand, PopClipCommand, PopCommand, PrimitiveCommand, PushBatchCommand,\r\n PushBranchCommand, PushClipCommand, PushCommand, PushStateCommand,\r\n} from \"./DrawCommand\";\r\nimport { Batch, Branch, Graphic, GraphicsArray } from \"./Graphic\";\r\nimport { Layer, LayerContainer } from \"./Layer\";\r\nimport { LayerCommandLists } from \"./LayerCommands\";\r\nimport { MeshGraphic } from \"./Mesh\";\r\nimport { Primitive } from \"./Primitive\";\r\nimport { CompositeFlags, Pass, RenderOrder, RenderPass } from \"./RenderFlags\";\r\nimport { TargetGraphics } from \"./TargetGraphics\";\r\nimport { Target } from \"./Target\";\r\nimport { ClipVolume } from \"./ClipVolume\";\r\n\r\n/** A list of DrawCommands to be rendered, ordered by render pass.\r\n * @internal\r\n */\r\nexport class RenderCommands implements Iterable<DrawCommands> {\r\n private _frustumPlanes?: FrustumPlanes;\r\n private readonly _scratchFrustum = new Frustum();\r\n private readonly _scratchRange = new Range3d();\r\n private readonly _commands = new Array<DrawCommands>(RenderPass.COUNT);\r\n private _target: Target;\r\n private _stack: BranchStack; // refers to the Target's BranchStack\r\n private _batchState: BatchState; // refers to the Target's BatchState\r\n private _forcedRenderPass: RenderPass = RenderPass.None;\r\n private _addLayersAsNormalGraphics = false;\r\n private _opaqueOverrides = false;\r\n private _translucentOverrides = false;\r\n private _addTranslucentAsOpaque = false; // true when rendering for _ReadPixels to force translucent items to be drawn in opaque pass.\r\n private readonly _layers: LayerCommandLists;\r\n\r\n public get target(): Target { return this._target; }\r\n\r\n public [Symbol.iterator](): Iterator<DrawCommands> {\r\n return this._commands[Symbol.iterator]();\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n for (const commands of this._commands)\r\n if (0 < commands.length)\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n public get isDrawingLayers() {\r\n switch (this._forcedRenderPass) {\r\n case RenderPass.OpaqueLayers:\r\n case RenderPass.TranslucentLayers:\r\n case RenderPass.OverlayLayers:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n public get currentViewFlags(): ViewFlags { return this._stack.top.viewFlags; }\r\n public get compositeFlags(): CompositeFlags {\r\n let flags = CompositeFlags.None;\r\n if (this.hasCommands(RenderPass.Translucent))\r\n flags |= CompositeFlags.Translucent;\r\n\r\n if (this.hasCommands(RenderPass.Hilite) || this.hasCommands(RenderPass.HiliteClassification) || this.hasCommands(RenderPass.HilitePlanarClassification))\r\n flags |= CompositeFlags.Hilite;\r\n\r\n if (this.target.wantAmbientOcclusion)\r\n flags |= CompositeFlags.AmbientOcclusion;\r\n\r\n return flags;\r\n }\r\n\r\n private get _curBatch(): Batch | undefined { return this._batchState.currentBatch; }\r\n\r\n public hasCommands(pass: RenderPass): boolean { return 0 !== this.getCommands(pass).length; }\r\n public isOpaquePass(pass: RenderPass): boolean { return pass >= RenderPass.OpaqueLinear && pass <= RenderPass.OpaqueGeneral; }\r\n\r\n constructor(target: Target, stack: BranchStack, batchState: BatchState) {\r\n this._target = target;\r\n this._stack = stack;\r\n this._batchState = batchState;\r\n this._layers = new LayerCommandLists(this);\r\n\r\n for (let i = 0; i < RenderPass.COUNT; ++i)\r\n this._commands[i] = [];\r\n }\r\n\r\n public reset(target: Target, stack: BranchStack, batchState: BatchState): void {\r\n this._target = target;\r\n this._stack = stack;\r\n this._batchState = batchState;\r\n this.clear();\r\n }\r\n\r\n public collectGraphicsForPlanarProjection(scene: GraphicList): void {\r\n assert(this._forcedRenderPass === RenderPass.None);\r\n assert(!this._addLayersAsNormalGraphics);\r\n\r\n this._addLayersAsNormalGraphics = true;\r\n this.addGraphics(scene);\r\n this._addLayersAsNormalGraphics = false;\r\n }\r\n\r\n public addGraphics(scene: GraphicList, forcedPass: RenderPass = RenderPass.None): void {\r\n this._forcedRenderPass = forcedPass;\r\n scene.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n /** Add backgroundMap graphics to their own render pass. */\r\n public addBackgroundMapGraphics(backgroundMapGraphics: GraphicList): void {\r\n this._forcedRenderPass = RenderPass.BackgroundMap;\r\n backgroundMapGraphics.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n /** Add overlay graphics to the world overlay pass */\r\n public addOverlayGraphics(overlayGraphics: GraphicList): void {\r\n this._forcedRenderPass = RenderPass.WorldOverlay;\r\n overlayGraphics.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addDecorations(dec: GraphicList, forcedPass: RenderPass = RenderPass.None): void {\r\n this._forcedRenderPass = forcedPass;\r\n for (const entry of dec) {\r\n (entry as Graphic).addCommands(this);\r\n }\r\n\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addWorldDecorations(decs: GraphicList): void {\r\n const world = this.target.getWorldDecorations(decs);\r\n this.pushAndPopBranch(world, () => {\r\n for (const entry of world.branch.entries) {\r\n (entry as Graphic).addCommands(this);\r\n }\r\n });\r\n }\r\n\r\n private addPickableDecorations(decs: Decorations): void {\r\n if (undefined !== decs.normal) {\r\n for (const normal of decs.normal) {\r\n const gf = normal as Graphic;\r\n if (gf.isPickable)\r\n gf.addCommands(this);\r\n }\r\n }\r\n\r\n if (undefined !== decs.world) {\r\n const world = this.target.getWorldDecorations(decs.world);\r\n this.pushAndPopBranch(world, () => {\r\n for (const gf of world.branch.entries) {\r\n if ((gf as Graphic).isPickable)\r\n (gf as Graphic).addCommands(this);\r\n }\r\n });\r\n }\r\n }\r\n\r\n public addBackground(gf?: Graphic): void {\r\n if (undefined === gf)\r\n return;\r\n\r\n assert(RenderPass.None === this._forcedRenderPass);\r\n\r\n this._forcedRenderPass = RenderPass.Background;\r\n this.pushAndPopState(this.target.decorationsState, () => gf.addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addSkyBox(gf?: Graphic): void {\r\n if (undefined === gf)\r\n return;\r\n\r\n assert(RenderPass.None === this._forcedRenderPass);\r\n\r\n this._forcedRenderPass = RenderPass.SkyBox;\r\n this.pushAndPopState(this.target.decorationsState, () => gf.addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addPrimitiveCommand(command: PrimitiveCommand, pass?: Pass): void {\r\n if (undefined === pass)\r\n pass = command.getPass(this.target);\r\n\r\n if (\"none\" === pass) // Edges will return none if they don't want to draw at all (edges not turned on).\r\n return;\r\n\r\n if (RenderPass.None !== this._forcedRenderPass) {\r\n // Add the command to the forced render pass (background).\r\n this.getCommands(this._forcedRenderPass).push(command);\r\n return;\r\n }\r\n\r\n if (!command.hasFeatures) {\r\n // Draw in general opaque pass so they are not in pick data.\r\n switch (pass) {\r\n case \"opaque-linear\":\r\n case \"opaque-planar\":\r\n pass = \"opaque\";\r\n break;\r\n case \"opaque-planar-translucent\":\r\n pass = \"opaque-translucent\";\r\n break;\r\n }\r\n }\r\n\r\n const haveFeatureOverrides = (this._opaqueOverrides || this._translucentOverrides) && command.opcode && command.hasFeatures;\r\n\r\n if (Pass.rendersTranslucent(pass) && this._addTranslucentAsOpaque) {\r\n switch (command.renderOrder) {\r\n case RenderOrder.PlanarLitSurface:\r\n case RenderOrder.PlanarUnlitSurface:\r\n case RenderOrder.BlankingRegion:\r\n pass = \"opaque-planar\";\r\n break;\r\n case RenderOrder.LitSurface:\r\n case RenderOrder.UnlitSurface:\r\n pass = \"opaque\";\r\n break;\r\n default:\r\n pass = \"opaque-linear\";\r\n break;\r\n }\r\n }\r\n\r\n const isDoublePass = Pass.rendersOpaqueAndTranslucent(pass);\r\n const renderTranslucentDuringOpaque = isDoublePass || (this._opaqueOverrides && haveFeatureOverrides);\r\n if (renderTranslucentDuringOpaque && Pass.rendersTranslucent(pass) && !command.primitive.cachedGeometry.alwaysRenderTranslucent) {\r\n let opaquePass: RenderPass;\r\n if (Pass.rendersOpaqueAndTranslucent(pass)) {\r\n opaquePass = Pass.toOpaquePass(pass);\r\n } else {\r\n switch (command.renderOrder) {\r\n case RenderOrder.PlanarLitSurface:\r\n case RenderOrder.PlanarUnlitSurface:\r\n case RenderOrder.BlankingRegion:\r\n opaquePass = RenderPass.OpaquePlanar;\r\n break;\r\n case RenderOrder.LitSurface:\r\n case RenderOrder.UnlitSurface:\r\n opaquePass = RenderPass.OpaqueGeneral;\r\n break;\r\n default:\r\n opaquePass = RenderPass.OpaqueLinear;\r\n break;\r\n }\r\n }\r\n\r\n this.getCommands(opaquePass).push(command);\r\n }\r\n\r\n const renderOpaqueDuringTranslucent = isDoublePass || (this._translucentOverrides && haveFeatureOverrides);\r\n if (renderOpaqueDuringTranslucent && Pass.rendersOpaque(pass) && !this._addTranslucentAsOpaque)\r\n this.getCommands(RenderPass.Translucent).push(command);\r\n\r\n if (!Pass.rendersOpaqueAndTranslucent(pass))\r\n this.getCommands(Pass.toRenderPass(pass)).push(command);\r\n }\r\n\r\n public getCommands(pass: RenderPass): DrawCommands {\r\n let idx = pass as number;\r\n assert(idx < this._commands.length);\r\n if (idx >= this._commands.length)\r\n idx -= 1;\r\n\r\n return this._commands[idx];\r\n }\r\n\r\n public replaceCommands(pass: RenderPass, cmds: DrawCommands): void {\r\n const idx = pass as number;\r\n this._commands[idx].splice(0);\r\n this._commands[idx] = cmds;\r\n }\r\n\r\n public addHiliteBranch(branch: Branch, pass: RenderPass): void {\r\n this.pushAndPopBranchForPass(pass, branch, () => {\r\n branch.branch.entries.forEach((entry: RenderGraphic) => (entry as Graphic).addHiliteCommands(this, pass));\r\n });\r\n }\r\n\r\n public processLayers(container: LayerContainer): void {\r\n assert(RenderPass.None === this._forcedRenderPass);\r\n if (RenderPass.None !== this._forcedRenderPass)\r\n return;\r\n\r\n this._forcedRenderPass = container.renderPass;\r\n this._layers.processLayers(container, () => container.graphic.addCommands(this));\r\n this._forcedRenderPass = RenderPass.None;\r\n }\r\n\r\n public addLayerCommands(layer: Layer): void {\r\n if (this._addLayersAsNormalGraphics) {\r\n // GraphicsCollectorDrawArgs wants to collect graphics to project to a plane for masking.\r\n // It bypasses PlanProjectionTreeReference.createDrawArgs which would otherwise wrap the graphics in a LayerContainer.\r\n assert(this._forcedRenderPass === RenderPass.None);\r\n this._forcedRenderPass = RenderPass.OpaqueGeneral;\r\n layer.graphic.addCommands(this);\r\n this._forcedRenderPass = RenderPass.None;\r\n return;\r\n }\r\n\r\n assert(this.isDrawingLayers);\r\n if (!this.isDrawingLayers)\r\n return;\r\n\r\n // Let the graphic add its commands. Afterward, pull them out and add them to the LayerCommands.\r\n this._layers.currentLayer = layer;\r\n layer.graphic.addCommands(this);\r\n\r\n const cmds = this.getCommands(this._forcedRenderPass);\r\n this._layers.addCommands(cmds);\r\n\r\n cmds.length = 0;\r\n this._layers.currentLayer = undefined;\r\n }\r\n\r\n public addHiliteLayerCommands(graphic: Graphic, pass: RenderPass): void {\r\n assert(this.isDrawingLayers || this._addLayersAsNormalGraphics);\r\n if (!this.isDrawingLayers && !this._addLayersAsNormalGraphics)\r\n return;\r\n\r\n const prevPass = this._forcedRenderPass;\r\n this._forcedRenderPass = RenderPass.None;\r\n\r\n graphic.addHiliteCommands(this, pass);\r\n\r\n this._forcedRenderPass = prevPass;\r\n }\r\n\r\n private getAnimationBranchState(branch: Branch): AnimationBranchState | undefined {\r\n const animId = branch.branch.animationId;\r\n return undefined !== animId ? this.target.animationBranches?.branchStates.get(animId) : undefined;\r\n }\r\n\r\n private pushAndPopBranchForPass(pass: RenderPass, branch: Branch, func: () => void): void {\r\n assert(!this.isDrawingLayers);\r\n\r\n const animState = this.getAnimationBranchState(branch);\r\n if (animState?.omit)\r\n return;\r\n\r\n assert(RenderPass.None !== pass);\r\n\r\n this._stack.pushBranch(branch);\r\n if (branch.planarClassifier)\r\n branch.planarClassifier.pushBatchState(this._batchState);\r\n\r\n if (branch.secondaryClassifiers)\r\n branch.secondaryClassifiers.forEach((classifier) => classifier.pushBatchState(this._batchState));\r\n\r\n const cmds = this.getCommands(pass);\r\n const clip = animState?.clip as ClipVolume | undefined;\r\n const pushClip = undefined !== clip ? new PushClipCommand(clip) : undefined;\r\n if (pushClip)\r\n cmds.push(pushClip);\r\n\r\n const push = new PushBranchCommand(branch);\r\n cmds.push(push);\r\n\r\n func();\r\n\r\n this._stack.pop();\r\n if (cmds[cmds.length - 1] === push) {\r\n cmds.pop();\r\n if (pushClip)\r\n cmds.pop();\r\n } else {\r\n cmds.push(PopBranchCommand.instance);\r\n if (pushClip)\r\n cmds.push(PopClipCommand.instance);\r\n }\r\n }\r\n\r\n private pushAndPop(push: PushCommand, pop: PopCommand, func: () => void): void {\r\n if (this.isDrawingLayers) {\r\n this._commands[RenderPass.Hilite].push(push);\r\n this._layers.pushAndPop(push, pop, func);\r\n\r\n const cmds = this._commands[RenderPass.Hilite];\r\n if (0 < cmds.length && cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n\r\n return;\r\n }\r\n\r\n if (RenderPass.None === this._forcedRenderPass) {\r\n // Need to make sure the push command precedes any subsequent commands added to any render pass.\r\n for (const cmds of this._commands)\r\n cmds.push(push);\r\n } else {\r\n // May want to add hilite commands as well - add the push command to that pass.\r\n this._commands[this._forcedRenderPass].push(push);\r\n this._commands[RenderPass.Hilite].push(push);\r\n }\r\n\r\n func();\r\n\r\n // Remove push command from any passes that didn't receive any commands; add the pop command to any passes that did.\r\n if (RenderPass.None === this._forcedRenderPass) {\r\n for (const cmds of this._commands) {\r\n assert(0 < cmds.length);\r\n if (0 < cmds.length && cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n }\r\n } else {\r\n assert(0 < this._commands[this._forcedRenderPass].length);\r\n assert(0 < this._commands[RenderPass.Hilite].length);\r\n\r\n let cmds = this._commands[this._forcedRenderPass];\r\n if (cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n\r\n cmds = this._commands[RenderPass.Hilite];\r\n if (cmds[cmds.length - 1] === push)\r\n cmds.pop();\r\n else\r\n cmds.push(pop);\r\n }\r\n }\r\n\r\n public pushAndPopBranch(branch: Branch, func: () => void): void {\r\n const animState = this.getAnimationBranchState(branch);\r\n if (animState?.omit)\r\n return;\r\n\r\n if (animState?.clip)\r\n this.pushAndPop(new PushClipCommand(animState.clip as ClipVolume), PopClipCommand.instance, () => this._pushAndPopBranch(branch, func));\r\n else\r\n this._pushAndPopBranch(branch, func);\r\n }\r\n\r\n private _pushAndPopBranch(branch: Branch, func: () => void): void {\r\n this._stack.pushBranch(branch);\r\n if (branch.planarClassifier)\r\n branch.planarClassifier.pushBatchState(this._batchState);\r\n\r\n if (branch.secondaryClassifiers)\r\n branch.secondaryClassifiers.forEach((classifier) => classifier.pushBatchState(this._batchState));\r\n\r\n this.pushAndPop(new PushBranchCommand(branch), PopBranchCommand.instance, func);\r\n\r\n this._stack.pop();\r\n }\r\n\r\n public pushAndPopState(state: BranchState, func: () => void): void {\r\n this._stack.pushState(state);\r\n this.pushAndPop(new PushStateCommand(state), PopBranchCommand.instance, func);\r\n this._stack.pop();\r\n }\r\n\r\n public clear(): void {\r\n assert(this._batchState.isEmpty);\r\n this._clearCommands();\r\n }\r\n\r\n private _clearCommands(): void {\r\n this._commands.forEach((cmds: DrawCommands) => cmds.splice(0));\r\n this._layers.clear();\r\n }\r\n\r\n private initForPickOverlayDecorations(overlays: GraphicList): void {\r\n for (const overlay of overlays) {\r\n const gf = overlay as Graphic;\r\n if (gf.isPickable)\r\n gf.addCommands(this);\r\n }\r\n }\r\n\r\n public initForPickOverlays(sceneOverlays: GraphicList, worldOverlayDecorations: GraphicList | undefined, viewOverlayDecorations: GraphicList | undefined): void {\r\n this._clearCommands();\r\n\r\n this._addTranslucentAsOpaque = true;\r\n\r\n for (const sceneGf of sceneOverlays)\r\n (sceneGf as Graphic).addCommands(this);\r\n\r\n if (worldOverlayDecorations?.length) {\r\n this.pushAndPopState(this.target.decorationsState, () => {\r\n this.initForPickOverlayDecorations(worldOverlayDecorations);\r\n });\r\n }\r\n\r\n if (viewOverlayDecorations?.length) {\r\n this.pushAndPopState(this.target.decorationsState.withViewCoords(), () => {\r\n this.initForPickOverlayDecorations(viewOverlayDecorations);\r\n });\r\n }\r\n\r\n this._addTranslucentAsOpaque = false;\r\n }\r\n\r\n public initForReadPixels(gfx: TargetGraphics): void {\r\n this.clear();\r\n\r\n // Set flag to force translucent geometry to be put into the opaque pass.\r\n this._addTranslucentAsOpaque = true;\r\n\r\n // Add the scene graphics.\r\n this.addGraphics(gfx.foreground);\r\n\r\n // Also add any pickable decorations.\r\n if (undefined !== gfx.decorations)\r\n this.addPickableDecorations(gfx.decorations);\r\n\r\n // Also background map is pickable\r\n this.addBackgroundMapGraphics(gfx.background);\r\n\r\n this._addTranslucentAsOpaque = false;\r\n\r\n this.setupClassificationByVolume();\r\n this._layers.outputCommands();\r\n }\r\n\r\n public initForRender(gfx: TargetGraphics): void {\r\n this.clear();\r\n\r\n this.addGraphics(gfx.foreground);\r\n this.addBackgroundMapGraphics(gfx.background);\r\n this.addOverlayGraphics(gfx.overlays);\r\n\r\n const dynamics = gfx.dynamics;\r\n if (dynamics && dynamics.length > 0)\r\n this.addDecorations(dynamics);\r\n\r\n const dec = gfx.decorations;\r\n if (undefined !== dec) {\r\n this.addBackground(dec.viewBackground as Graphic);\r\n\r\n this.addSkyBox(dec.skyBox as Graphic);\r\n\r\n if (undefined !== dec.normal && 0 < dec.normal.length)\r\n this.addGraphics(dec.normal);\r\n\r\n if (undefined !== dec.world && 0 < dec.world.length)\r\n this.addWorldDecorations(dec.world);\r\n\r\n this.pushAndPopState(this.target.decorationsState, () => {\r\n if (undefined !== dec.viewOverlay && 0 < dec.viewOverlay.length)\r\n this.addDecorations(dec.viewOverlay, RenderPass.ViewOverlay);\r\n\r\n if (undefined !== dec.worldOverlay && 0 < dec.worldOverlay.length)\r\n this.addDecorations(dec.worldOverlay, RenderPass.WorldOverlay);\r\n });\r\n }\r\n\r\n this.setupClassificationByVolume();\r\n this._layers.outputCommands();\r\n }\r\n\r\n public addPrimitive(prim: Primitive): void {\r\n // ###TODO Would be nice if we could detect outside active volume here, but active volume only applies to specific render passes\r\n // if (this.target.isGeometryOutsideActiveVolume(prim.cachedGeometry))\r\n // return;\r\n\r\n if (undefined !== this._frustumPlanes) { // See if we can cull this primitive.\r\n if (\"classification\" === prim.getPass(this.target)) {\r\n const geom = prim.cachedGeometry;\r\n geom.computeRange(this._scratchRange);\r\n let frustum = Frustum.fromRange(this._scratchRange, this._scratchFrustum);\r\n frustum = frustum.transformBy(this.target.currentTransform, frustum);\r\n if (FrustumPlanes.Containment.Outside === this._frustumPlanes.computeFrustumContainment(frustum)) {\r\n return;\r\n }\r\n }\r\n }\r\n\r\n const command = new PrimitiveCommand(prim);\r\n this.addPrimitiveCommand(command);\r\n\r\n if (RenderPass.None === this._forcedRenderPass && prim.isEdge) {\r\n const vf: ViewFlags = this.target.currentViewFlags;\r\n if (vf.renderMode !== RenderMode.Wireframe && vf.hiddenEdges)\r\n this.getCommands(RenderPass.HiddenEdge).push(command);\r\n }\r\n }\r\n\r\n public addBranch(branch: Branch): void {\r\n this.pushAndPopBranch(branch, () => {\r\n branch.branch.entries.forEach((entry: RenderGraphic) => (entry as Graphic).addCommands(this));\r\n });\r\n }\r\n\r\n public computeBatchHiliteRenderPass(batch: Batch): RenderPass {\r\n let pass = RenderPass.Hilite;\r\n if (batch.graphic instanceof MeshGraphic) {\r\n const mg = batch.graphic;\r\n if (SurfaceType.VolumeClassifier === mg.surfaceType)\r\n pass = RenderPass.HiliteClassification;\r\n } else if (batch.graphic instanceof GraphicsArray) {\r\n const ga = batch.graphic;\r\n if (ga.graphics[0] instanceof MeshGraphic) {\r\n const mg = ga.graphics[0];\r\n if (SurfaceType.VolumeClassifier === mg.surfaceType)\r\n pass = RenderPass.HiliteClassification;\r\n } else if (ga.graphics[0] instanceof Branch) {\r\n const b = ga.graphics[0];\r\n if (b.branch.entries.length > 0 && b.branch.entries[0] instanceof MeshGraphic) {\r\n const mg = b.branch.entries[0];\r\n if (SurfaceType.VolumeClassifier === mg.surfaceType)\r\n pass = RenderPass.HiliteClassification;\r\n }\r\n }\r\n }\r\n return pass;\r\n }\r\n\r\n public addBatch(batch: Batch): void {\r\n if (batch.locateOnly && !this.target.isReadPixelsInProgress)\r\n return;\r\n\r\n // Batches (aka element tiles) should only draw during ordinary (translucent or opaque) passes.\r\n // They may draw during both, or neither.\r\n // NB: This is no longer true - pickable overlay decorations are defined as Batches. Problem?\r\n // assert(RenderPass.None === this._forcedRenderPass);\r\n assert(!this._opaqueOverrides && !this._translucentOverrides);\r\n assert(undefined === this._curBatch);\r\n\r\n // If all features are overridden to be invisible, draw no graphics in this batch\r\n const overrides = batch.getOverrides(this.target);\r\n if (overrides.allHidden)\r\n return;\r\n\r\n if (!batch.range.isNull) {\r\n // ###TODO Would be nice if we could detect outside active volume here, but active volume only applies to specific render passes\r\n // if (this.target.isRangeOutsideActiveVolume(batch.range))\r\n // return;\r\n\r\n if (undefined !== this._frustumPlanes) {\r\n let frustum = Frustum.fromRange(batch.range, this._scratchFrustum);\r\n frustum = frustum.transformBy(this.target.currentTransform, frustum);\r\n if (FrustumPlanes.Containment.Outside === this._frustumPlanes.computeFrustumContainment(frustum)) {\r\n return;\r\n }\r\n }\r\n }\r\n\r\n const classifier = this._stack.top.planarClassifier;\r\n\r\n this._batchState.push(batch, true);\r\n\r\n this.pushAndPop(new PushBatchCommand(batch), PopBatchCommand.instance, () => {\r\n if (this.currentViewFlags.transparency || overrides.anyViewIndependentTranslucent) {\r\n this._opaqueOverrides = overrides.anyOpaque;\r\n this._translucentOverrides = overrides.anyTranslucent;\r\n\r\n if (undefined !== classifier) {\r\n this._opaqueOverrides = this._opaqueOverrides || classifier.anyOpaque;\r\n this._translucentOverrides = this._translucentOverrides || classifier.anyTranslucent;\r\n }\r\n }\r\n\r\n // If we have an active volume classifier then force all batches for the reality data being classified into a special render pass.\r\n let savedForcedRenderPass = RenderPass.None;\r\n if (undefined !== this.target.activeVolumeClassifierModelId && batch.featureTable.modelId === this.target.activeVolumeClassifierModelId) {\r\n savedForcedRenderPass = this._forcedRenderPass;\r\n this._forcedRenderPass = RenderPass.VolumeClassifiedRealityData;\r\n }\r\n\r\n (batch.graphic as Graphic).addCommands(this);\r\n\r\n if (RenderPass.VolumeClassifiedRealityData === this._forcedRenderPass)\r\n this._forcedRenderPass = savedForcedRenderPass;\r\n\r\n // If the batch contains hilited features, need to render them in the hilite pass\r\n const anyHilited = overrides.anyHilited;\r\n const planarClassifierHilited = undefined !== classifier && classifier.anyHilited;\r\n if (anyHilited || planarClassifierHilited)\r\n (batch.graphic as Graphic).addHiliteCommands(this, planarClassifierHilited ? RenderPass.HilitePlanarClassification : this.computeBatchHiliteRenderPass(batch));\r\n\r\n });\r\n\r\n this._opaqueOverrides = this._translucentOverrides = false;\r\n this._batchState.pop();\r\n }\r\n\r\n // Define a culling frustum. Commands associated with Graphics whose ranges do not intersect the frustum will be skipped.\r\n public setCheckRange(frustum: Frustum) { this._frustumPlanes = FrustumPlanes.fromFrustum(frustum); }\r\n // Clear the culling frustum.\r\n public clearCheckRange(): void { this._frustumPlanes = undefined; }\r\n\r\n private setupClassificationByVolume(): void {\r\n // To make it easier to process the classifiers individually, set up a secondary command list for them where they\r\n // are each separated by their own pushes & pops so that they can easily be drawn individually. This now supports\r\n // nested branches and batches.\r\n const groupedCmds = this._commands[RenderPass.Classification];\r\n const byIndexCmds = this._commands[RenderPass.ClassificationByIndex];\r\n const pushCommands: DrawCommands = []; // will contain current set of pushes ahead of a primitive\r\n for (const cmd of groupedCmds) {\r\n switch (cmd.opcode) {\r\n case \"pushBranch\":\r\n case \"pushBatch\":\r\n case \"pushState\":\r\n pushCommands.push(cmd);\r\n break;\r\n case \"drawPrimitive\":\r\n for (const pushCmd of pushCommands) {\r\n byIndexCmds.push(pushCmd);\r\n }\r\n byIndexCmds.push(cmd);\r\n for (let i = pushCommands.length - 1; i >= 0; --i) {\r\n if (\"pushBatch\" === pushCommands[i].opcode)\r\n byIndexCmds.push(PopBatchCommand.instance);\r\n else // should be eith pushBranch or pushState opcode\r\n byIndexCmds.push(PopBranchCommand.instance);\r\n }\r\n break;\r\n case \"popBatch\":\r\n case \"popBranch\":\r\n pushCommands.pop();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n public dump(): Array<{ name: string, count: number }> {\r\n const dump = [\r\n { name: \"Primitives\", count: 0 },\r\n { name: \"Batches\", count: 0 },\r\n { name: \"Branches\", count: 0 },\r\n ];\r\n\r\n for (const cmds of this._commands) {\r\n for (const cmd of cmds) {\r\n let index;\r\n switch (cmd.opcode) {\r\n case \"drawPrimitive\":\r\n index = 0;\r\n break;\r\n case \"pushBatch\":\r\n index = 1;\r\n break;\r\n case \"pushBranch\":\r\n index = 2;\r\n break;\r\n default:\r\n continue;\r\n }\r\n\r\n dump[index].count++;\r\n }\r\n }\r\n\r\n return dump;\r\n }\r\n}\r\n"]}
@@ -174,7 +174,7 @@ class ShadowMapParams {
174
174
  }
175
175
  const defaultSunDirection = core_geometry_1.Vector3d.create(-1, -1, -1).normalize();
176
176
  const scratchFrustum = new core_common_1.Frustum();
177
- const scratchFrustumPlanes = new core_common_1.FrustumPlanes();
177
+ const scratchFrustumPlanes = core_common_1.FrustumPlanes.createEmpty();
178
178
  class SolarShadowMap {
179
179
  constructor(target) {
180
180
  this._projectionMatrix = core_geometry_1.Matrix4d.createIdentity();
@@ -1 +1 @@
1
- {"version":3,"file":"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I,eAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,0BAA0B,IAAI,CAAC,SAAS,IAAI,eAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,8BAA8B,EAAE;YACrJ,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;YAChF,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;SACnE;QAED,eAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,kDAAkD;QAElD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAG,yBAAyB;QACrD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAElC,eAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB;QAC1G,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAlTD,wCAkTC","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\r\n/** @packageDocumentation\r\n * @module WebGL\r\n */\r\n\r\nimport { assert, dispose } from \"@itwin/core-bentley\";\r\nimport { ClipUtilities, ConvexClipPlaneSet, Geometry, GrowableXYZArray, Map4d, Matrix3d, Matrix4d, Point3d, Range3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport {\r\n Frustum, FrustumPlanes, RenderMode, RenderTexture, SolarShadowSettings, TextureTransparency, ViewFlags,\r\n} from \"@itwin/core-common\";\r\nimport { RenderType } from \"@itwin/webgl-compatibility\";\r\nimport { Tile, TileDrawArgs, TileTreeReference, TileVisibility } from \"../../tile/internal\";\r\nimport { SceneContext } from \"../../ViewContext\";\r\nimport { RenderGraphic } from \"../RenderGraphic\";\r\nimport { RenderMemory } from \"../RenderMemory\";\r\nimport { BranchStack } from \"./BranchStack\";\r\nimport { BatchState } from \"./BatchState\";\r\nimport { EVSMGeometry } from \"./CachedGeometry\";\r\nimport { WebGLDisposable } from \"./Disposable\";\r\nimport { FrameBuffer } from \"./FrameBuffer\";\r\nimport { GL } from \"./GL\";\r\nimport { RenderCommands } from \"./RenderCommands\";\r\nimport { RenderPass, TextureUnit } from \"./RenderFlags\";\r\nimport { RenderState } from \"./RenderState\";\r\nimport { getDrawParams } from \"./ScratchDrawParams\";\r\nimport { System } from \"./System\";\r\nimport { Target } from \"./Target\";\r\nimport { Texture, TextureHandle } from \"./Texture\";\r\n\r\ntype ProcessTiles = (tiles: Tile[]) => void;\r\n\r\nfunction createDrawArgs(sceneContext: SceneContext, solarShadowMap: SolarShadowMap, tree: TileTreeReference, frustumPlanes: FrustumPlanes, processTiles: ProcessTiles): TileDrawArgs | undefined {\r\n class SolarShadowMapDrawArgs extends TileDrawArgs {\r\n private _useViewportMap?: boolean;\r\n private readonly _processTiles: ProcessTiles;\r\n\r\n constructor(private _mapFrustumPlanes: FrustumPlanes, private _shadowMap: SolarShadowMap, args: TileDrawArgs, process: ProcessTiles) {\r\n super(args);\r\n this._processTiles = process;\r\n }\r\n\r\n // The solar shadow projection is parallel - which can cause excessive tile selection if it is along an axis of an unbounded tile\r\n // tree such as the OSM buildings. Rev limit the selection here.\r\n public override get maxRealityTreeSelectionCount(): undefined | number { return 500; }\r\n\r\n public override processSelectedTiles(tiles: Tile[]): void {\r\n this._processTiles(tiles);\r\n }\r\n\r\n public override get frustumPlanes(): FrustumPlanes {\r\n if (true === this._useViewportMap)\r\n return super.frustumPlanes;\r\n else\r\n return this._mapFrustumPlanes;\r\n }\r\n\r\n public override get worldToViewMap(): Map4d {\r\n if (true === this._useViewportMap)\r\n return super.worldToViewMap;\r\n else\r\n return this._shadowMap.worldToViewMap;\r\n }\r\n\r\n public override drawGraphics(): void {\r\n const graphics = this.produceGraphics();\r\n if (graphics)\r\n this._shadowMap.addGraphic(graphics);\r\n }\r\n\r\n public override getPixelSize(tile: Tile): number {\r\n // For tiles that are part of the scene, size them based on the viewport frustum so that shadow map uses same resolution tiles as scene\r\n // - otherwise artifacts like shadow acne may result.\r\n // For tiles that are NOT part of the scene, size them based on the shadow frustum, not the viewport frustum\r\n // - otherwise excessive numbers of excessively detailed may be requested for the shadow map.\r\n if (undefined === this._useViewportMap) {\r\n this._useViewportMap = true;\r\n const vis = tile.computeVisibility(this);\r\n this._useViewportMap = TileVisibility.OutsideFrustum !== vis;\r\n }\r\n\r\n const size = super.getPixelSize(tile);\r\n this._useViewportMap = undefined;\r\n return size;\r\n }\r\n\r\n public static create(context: SceneContext, shadowMap: SolarShadowMap, tileTree: TileTreeReference, planes: FrustumPlanes, process: ProcessTiles) {\r\n const args = tileTree.createDrawArgs(context);\r\n return undefined !== args ? new SolarShadowMapDrawArgs(planes, shadowMap, args, process) : undefined;\r\n }\r\n }\r\n\r\n return SolarShadowMapDrawArgs.create(sceneContext, solarShadowMap, tree, frustumPlanes, processTiles);\r\n}\r\n\r\nconst shadowMapWidth = 4096; // size of original depth buffer map\r\nconst shadowMapHeight = shadowMapWidth; // TBD - Adjust for aspect ratio.\r\nconst evsmWidth = shadowMapWidth / 2; // EVSM buffer is 1/2 size each direction\r\nconst evsmHeight = shadowMapHeight / 2;\r\nconst postProjectionMatrixNpc = Matrix4d.createRowValues(/* Row 1 */ 0, 1, 0, 0, /* Row 1 */ 0, 0, 1, 0, /* Row 3 */ 1, 0, 0, 0, /* Row 4 */ 0, 0, 0, 1);\r\n\r\n// Bundles up the disposable, create-once-and-reuse members of a SolarShadowMap.\r\nclass Bundle implements WebGLDisposable {\r\n private constructor(\r\n public readonly depthTexture: Texture,\r\n public readonly shadowMapTexture: Texture,\r\n public readonly fbo: FrameBuffer,\r\n public readonly fboSM: FrameBuffer,\r\n public readonly evsmGeom: EVSMGeometry,\r\n public readonly renderCommands: RenderCommands) {\r\n }\r\n\r\n public static create(target: Target, stack: BranchStack, batch: BatchState): Bundle | undefined {\r\n const depthTextureHandle = System.instance.createDepthBuffer(shadowMapWidth, shadowMapHeight) as TextureHandle;\r\n if (undefined === depthTextureHandle)\r\n return undefined;\r\n\r\n let pixelDataType = GL.Texture.DataType.Float;\r\n switch (System.instance.capabilities.maxRenderType) {\r\n case RenderType.TextureFloat:\r\n break;\r\n case RenderType.TextureHalfFloat:\r\n if (System.instance.capabilities.isWebGL2) {\r\n pixelDataType = (System.instance.context as WebGL2RenderingContext).HALF_FLOAT;\r\n break;\r\n } else {\r\n const exthf = System.instance.capabilities.queryExtensionObject<OES_texture_half_float>(\"OES_texture_half_float\");\r\n if (undefined !== exthf) {\r\n pixelDataType = exthf.HALF_FLOAT_OES;\r\n break;\r\n }\r\n }\r\n /* falls through */\r\n default:\r\n return undefined;\r\n }\r\n\r\n const colorTextures: TextureHandle[] = [];\r\n\r\n // Check if the system can render to a depth texture without a renderable color texture bound as well.\r\n // If it cannot, add a renderable color texture to the framebuffer.\r\n // MacOS Safari exhibited this behavior, which necessitated this code path.\r\n if (!System.instance.capabilities.canRenderDepthWithoutColor) {\r\n const colTex = TextureHandle.createForAttachment(shadowMapWidth, shadowMapHeight, GL.Texture.Format.Rgba, pixelDataType);\r\n if (undefined === colTex)\r\n return undefined;\r\n colorTextures.push(colTex);\r\n }\r\n\r\n const fbo = FrameBuffer.create(colorTextures, depthTextureHandle);\r\n if (undefined === fbo)\r\n return undefined;\r\n\r\n // shadowMap texture is 1/4 size the depth texture (and averaged down when converting)\r\n const shadowMapTextureHandle = TextureHandle.createForAttachment(evsmWidth, evsmHeight, GL.Texture.Format.Rgba, pixelDataType);\r\n if (undefined === shadowMapTextureHandle)\r\n return undefined;\r\n\r\n const fboSM = FrameBuffer.create([shadowMapTextureHandle]);\r\n if (undefined === fboSM)\r\n return undefined;\r\n\r\n const depthTexture = new Texture({ ownership: \"external\", type: RenderTexture.Type.TileSection, handle: depthTextureHandle, transparency: TextureTransparency.Opaque });\r\n const evsmGeom = EVSMGeometry.createGeometry(depthTexture.texture.getHandle()!, shadowMapWidth, shadowMapHeight);\r\n if (undefined === evsmGeom)\r\n return undefined;\r\n\r\n const shadowMapTexture = new Texture({ type: RenderTexture.Type.Normal, ownership: \"external\", handle: shadowMapTextureHandle, transparency: TextureTransparency.Opaque });\r\n const renderCommands = new RenderCommands(target, stack, batch);\r\n return new Bundle(depthTexture, shadowMapTexture, fbo, fboSM, evsmGeom, renderCommands);\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return this.depthTexture.isDisposed\r\n && this.shadowMapTexture.isDisposed\r\n && this.fbo.isDisposed\r\n && this.fboSM.isDisposed\r\n && this.evsmGeom.isDisposed;\r\n }\r\n\r\n public dispose(): void {\r\n dispose(this.depthTexture);\r\n dispose(this.shadowMapTexture);\r\n dispose(this.fbo);\r\n dispose(this.fboSM);\r\n dispose(this.evsmGeom);\r\n }\r\n}\r\n\r\n/** Describes the set of parameters which, when they change, require us to recreate the shadow map. */\r\nclass ShadowMapParams {\r\n public readonly direction = new Vector3d();\r\n public readonly viewFrustum = new Frustum();\r\n public settings: SolarShadowSettings;\r\n\r\n public constructor(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings) {\r\n direction.clone(this.direction);\r\n this.viewFrustum.setFrom(viewFrustum);\r\n this.settings = settings;\r\n }\r\n\r\n public update(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings): void {\r\n this.settings = settings;\r\n this.viewFrustum.setFrom(viewFrustum);\r\n direction.clone(this.direction);\r\n }\r\n}\r\n\r\nconst defaultSunDirection = Vector3d.create(-1, -1, -1).normalize()!;\r\nconst scratchFrustum = new Frustum();\r\nconst scratchFrustumPlanes = new FrustumPlanes();\r\n\r\nexport class SolarShadowMap implements RenderMemory.Consumer, WebGLDisposable {\r\n private _bundle?: Bundle;\r\n private _projectionMatrix = Matrix4d.createIdentity();\r\n private _graphics: RenderGraphic[] = [];\r\n private _shadowFrustum = new Frustum();\r\n private _isReady = false;\r\n private _isDrawing = false;\r\n private _enabled = false;\r\n private _params?: ShadowMapParams;\r\n private readonly _scratchRange = Range3d.createNull();\r\n private readonly _scratchTransform = Transform.createIdentity();\r\n\r\n private readonly _scratchViewFlags = new ViewFlags();\r\n private readonly _renderState: RenderState;\r\n private readonly _noZRenderState: RenderState;\r\n private readonly _batchState: BatchState;\r\n private _worldToViewMap = Map4d.createIdentity();\r\n private readonly _target: Target;\r\n\r\n // This exists chiefly for debugging. See ToggleShadowMapTilesTool.\r\n public onGraphicsChanged?: (graphics: RenderGraphic[]) => void;\r\n\r\n private getBundle(target: Target): Bundle | undefined {\r\n if (undefined === this._bundle) {\r\n this._bundle = Bundle.create(target, target.uniforms.branch.stack, this._batchState);\r\n assert(undefined !== this._bundle);\r\n }\r\n\r\n return this._bundle;\r\n }\r\n\r\n public get isReady() { return this._isReady; }\r\n public get isDrawing() { return this._isDrawing; }\r\n public get isEnabled() { return this._enabled; }\r\n public get projectionMatrix(): Matrix4d { return this._projectionMatrix; }\r\n public get depthTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.depthTexture : undefined; }\r\n public get shadowMapTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.shadowMapTexture : undefined; }\r\n public get settings(): SolarShadowSettings | undefined { return undefined !== this._params ? this._params.settings : undefined; }\r\n public get direction(): Vector3d | undefined { return undefined !== this._params ? this._params.direction : undefined; }\r\n public get frustum(): Frustum { return this._shadowFrustum; }\r\n public get worldToViewMap(): Map4d { return this._worldToViewMap; }\r\n public addGraphic(graphic: RenderGraphic) { this._graphics.push(graphic); }\r\n\r\n public constructor(target: Target) {\r\n this._target = target;\r\n this._renderState = new RenderState();\r\n this._renderState.flags.depthMask = true;\r\n this._renderState.flags.blend = false;\r\n this._renderState.flags.depthTest = true;\r\n\r\n this._noZRenderState = new RenderState();\r\n this._noZRenderState.flags.depthMask = false;\r\n\r\n this._batchState = new BatchState(target.uniforms.branch.stack);\r\n }\r\n\r\n public disable() {\r\n this._enabled = this._isReady = false;\r\n this._bundle = dispose(this._bundle);\r\n this.clearGraphics(true);\r\n this._target.uniforms.shadow.update();\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n const bundle = this._bundle;\r\n if (undefined !== bundle)\r\n stats.addShadowMap(bundle.depthTexture.bytesUsed + bundle.shadowMapTexture.bytesUsed);\r\n }\r\n\r\n public get isDisposed(): boolean { return undefined === this._bundle && 0 === this._graphics.length; }\r\n\r\n public dispose() {\r\n this._bundle = dispose(this._bundle);\r\n this.clearGraphics(true);\r\n }\r\n\r\n private clearGraphics(notify: boolean) {\r\n for (const graphic of this._graphics)\r\n graphic.dispose();\r\n\r\n this._graphics.length = 0;\r\n if (notify)\r\n this.notifyGraphicsChanged();\r\n }\r\n\r\n private notifyGraphicsChanged(): void {\r\n if (undefined !== this.onGraphicsChanged)\r\n this.onGraphicsChanged(this._graphics);\r\n }\r\n\r\n public update(context: SceneContext | undefined) {\r\n this._isReady = false;\r\n this.clearGraphics(false);\r\n\r\n if (undefined === context || !context.viewport.view.isSpatialView()) {\r\n this.disable();\r\n this.notifyGraphicsChanged();\r\n return;\r\n }\r\n\r\n const view = context.viewport.view;\r\n const style = view.getDisplayStyle3d();\r\n const sunDirection = style.sunDirection ?? defaultSunDirection;\r\n\r\n const minimumHorizonDirection = -.01;\r\n if (sunDirection.z > minimumHorizonDirection) {\r\n this.notifyGraphicsChanged();\r\n return;\r\n }\r\n\r\n this._enabled = true;\r\n const viewFrustum = context.viewingSpace.getFrustum();\r\n const settings = style.settings.solarShadows;\r\n if (undefined === this._params)\r\n this._params = new ShadowMapParams(viewFrustum, sunDirection, settings);\r\n else\r\n this._params.update(viewFrustum, sunDirection, settings);\r\n\r\n const iModel = view.iModel;\r\n\r\n const worldToMapTransform = Transform.createRefs(Point3d.createZero(), Matrix3d.createRigidHeadsUp(this._params.direction.negate()).inverse()!);\r\n const worldToMap = Matrix4d.createTransform(worldToMapTransform);\r\n const mapToWorld = worldToMap.createInverse()!;\r\n\r\n // Start with entire project.\r\n const shadowRange = worldToMapTransform.multiplyRange(iModel.projectExtents);\r\n\r\n // Limit the map to only displayed models.\r\n const viewTileRange = Range3d.createNull();\r\n view.forEachTileTreeRef((ref) => {\r\n if (ref.castsShadows) {\r\n if (ref.isGlobal) {\r\n // A shadow-casting tile tree that spans the globe. Limit its range to the viewed extents.\r\n for (const p3 of viewFrustum.points) {\r\n const p4 = worldToMap.multiplyPoint3d(p3, 1);\r\n if (p4.w > 0.0001)\r\n viewTileRange.extendXYZW(p4.x, p4.y, p4.z, p4.w);\r\n else\r\n viewTileRange.high.z = Math.max(1.0, viewTileRange.high.z); // behind eye plane.\r\n }\r\n } else {\r\n ref.accumulateTransformedRange(viewTileRange, worldToMap, undefined);\r\n }\r\n }\r\n });\r\n\r\n if (!viewTileRange.isNull)\r\n viewTileRange.clone(shadowRange);\r\n\r\n // Expand shadow range to include both the shadowers and shadowed portion of background map.\r\n scratchFrustum.initFromRange(shadowRange);\r\n mapToWorld.multiplyPoint3dArrayQuietNormalize(scratchFrustum.points); // This frustum represents the shadwowing geometry. Intersect it with background geometry and expand the range depth to include that intersection.\r\n const backgroundMapGeometry = context.viewport.view.displayStyle.getBackgroundMapGeometry();\r\n if (undefined !== backgroundMapGeometry) {\r\n const backgroundDepthRange = backgroundMapGeometry.getFrustumIntersectionDepthRange(this._shadowFrustum, iModel.projectExtents);\r\n if (!backgroundDepthRange.isNull)\r\n shadowRange.low.z = Math.min(shadowRange.low.z, backgroundDepthRange.low);\r\n }\r\n\r\n this._params.viewFrustum.transformBy(worldToMapTransform, scratchFrustum);\r\n scratchFrustumPlanes.init(scratchFrustum);\r\n\r\n const viewIntersectShadowRange = Range3d.createNull();\r\n const viewClipPlanes = ConvexClipPlaneSet.createPlanes(scratchFrustumPlanes.planes!);\r\n ClipUtilities.announceLoopsOfConvexClipPlaneSetIntersectRange(viewClipPlanes, shadowRange, (points: GrowableXYZArray) => {\r\n for (const point of points.getPoint3dArray())\r\n viewIntersectShadowRange.extendPoint(point);\r\n });\r\n if (viewIntersectShadowRange.isNull) {\r\n this.notifyGraphicsChanged();\r\n return;\r\n }\r\n viewIntersectShadowRange.high.z = shadowRange.high.z; // We need to include shadowing geometry that may be outside view (along the solar axis).\r\n\r\n this._shadowFrustum.initFromRange(viewIntersectShadowRange);\r\n mapToWorld.multiplyPoint3dArrayQuietNormalize(this._shadowFrustum.points);\r\n\r\n const tileRange = Range3d.createNull();\r\n scratchFrustumPlanes.init(this._shadowFrustum);\r\n view.forEachTileTreeRef(((ref) => {\r\n if (!ref.castsShadows)\r\n return;\r\n\r\n const drawArgs = createDrawArgs(context, this, ref, scratchFrustumPlanes, (tiles: Tile[]) => {\r\n for (const tile of tiles)\r\n tileRange.extendRange(tileToMapTransform.multiplyRange(tile.range, this._scratchRange));\r\n });\r\n\r\n if (undefined === drawArgs)\r\n return;\r\n\r\n const tileToMapTransform = worldToMapTransform.multiplyTransformTransform(drawArgs.location, this._scratchTransform);\r\n drawArgs.tree.draw(drawArgs);\r\n }));\r\n\r\n if (tileRange.isNull) {\r\n this.clearGraphics(true);\r\n } else if (this._graphics.length > 0) {\r\n // Avoid an uninvertible matrix on empty range...\r\n if (Geometry.isAlmostEqualNumber(shadowRange.low.x, shadowRange.high.x) ||\r\n Geometry.isAlmostEqualNumber(shadowRange.low.y, shadowRange.high.y) ||\r\n Geometry.isAlmostEqualNumber(shadowRange.low.z, shadowRange.high.z)) {\r\n this.clearGraphics(true);\r\n return;\r\n }\r\n\r\n const frustumMap = this._shadowFrustum.toMap4d();\r\n if (undefined === frustumMap) {\r\n this.clearGraphics(true);\r\n assert(false);\r\n return;\r\n }\r\n\r\n this._projectionMatrix = frustumMap.transform0.clone();\r\n\r\n const worldToNpc = postProjectionMatrixNpc.multiplyMatrixMatrix(this._projectionMatrix);\r\n const npcToView = Map4d.createBoxMap(Point3d.create(0, 0, 0), Point3d.create(1, 1, 1), Point3d.create(0, 0, 0), Point3d.create(shadowMapWidth, shadowMapHeight, 1))!;\r\n const npcToWorld = worldToNpc.createInverse();\r\n if (undefined === npcToWorld) {\r\n this.clearGraphics(true);\r\n return;\r\n }\r\n\r\n const worldToNpcMap = Map4d.createRefs(worldToNpc, npcToWorld);\r\n this._worldToViewMap = npcToView.multiplyMapMap(worldToNpcMap);\r\n }\r\n\r\n this._target.uniforms.shadow.update();\r\n this.notifyGraphicsChanged();\r\n }\r\n\r\n public draw(target: Target) {\r\n assert(this.isEnabled);\r\n\r\n if (this.isReady || 0 === this._graphics.length)\r\n return;\r\n\r\n const bundle = this.getBundle(target);\r\n if (undefined === bundle)\r\n return;\r\n\r\n this._isDrawing = true;\r\n\r\n const prevState = System.instance.currentRenderState.clone();\r\n const gl = System.instance.context;\r\n gl.viewport(0, 0, shadowMapWidth, shadowMapHeight);\r\n\r\n // NB: textures and materials are needed because their transparencies affect whether or not a surface casts shadows\r\n const viewFlags = target.currentViewFlags.copy({\r\n renderMode: RenderMode.SmoothShade,\r\n wiremesh: false,\r\n transparency: false,\r\n lighting: false,\r\n shadows: false,\r\n monochrome: false,\r\n ambientOcclusion: false,\r\n visibleEdges: false,\r\n hiddenEdges: false,\r\n });\r\n\r\n System.instance.applyRenderState(this._renderState);\r\n const prevPlan = target.plan;\r\n\r\n target.changeFrustum(this._shadowFrustum, this._shadowFrustum.getFraction(), true);\r\n target.uniforms.branch.changeRenderPlan(viewFlags, target.plan.is3d, target.plan.hline);\r\n\r\n const renderCommands = bundle.renderCommands;\r\n renderCommands.reset(target, target.uniforms.branch.stack, this._batchState);\r\n renderCommands.addGraphics(this._graphics);\r\n\r\n System.instance.frameBufferStack.execute(bundle.fbo, true, false, () => {\r\n System.instance.context.clearDepth(1.0);\r\n System.instance.context.clear(GL.BufferBit.Depth);\r\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaquePlanar), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\r\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaqueGeneral), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\r\n });\r\n\r\n // copy depth buffer to EVSM shadow buffer and average down for AA effect\r\n gl.viewport(0, 0, evsmWidth, evsmHeight);\r\n System.instance.frameBufferStack.execute(bundle.fboSM, true, false, () => {\r\n System.instance.applyRenderState(this._noZRenderState);\r\n const params = getDrawParams(target, bundle.evsmGeom);\r\n target.techniques.draw(params);\r\n });\r\n\r\n // mipmap resulting EVSM texture and set filtering options\r\n System.instance.activateTexture2d(TextureUnit.ShadowMap, bundle.shadowMapTexture.texture.getHandle());\r\n gl.generateMipmap(gl.TEXTURE_2D);\r\n const fullFloat = System.instance.capabilities.maxRenderType === RenderType.TextureFloat;\r\n if (fullFloat && System.instance.capabilities.supportsTextureFloatLinear || !fullFloat && System.instance.capabilities.supportsTextureHalfFloatLinear) {\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n }\r\n\r\n System.instance.setMaxAnisotropy(undefined);\r\n // target.recordPerformanceMetric(\"Compute EVSM\");\r\n\r\n this._batchState.reset(); // Reset the batch Ids...\r\n target.changeRenderPlan(prevPlan);\r\n\r\n System.instance.applyRenderState(prevState);\r\n System.instance.context.viewport(0, 0, target.viewRect.width, target.viewRect.height); // Restore viewport\r\n this.clearGraphics(false);\r\n this._isDrawing = false;\r\n this._isReady = true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SolarShadowMap.js","sourceRoot":"","sources":["../../../../src/render/webgl/SolarShadowMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAAsD;AACtD,wDAAuK;AACvK,oDAE4B;AAC5B,oEAAwD;AACxD,kDAA4F;AAK5F,6CAA0C;AAC1C,qDAAgD;AAEhD,+CAA4C;AAC5C,6BAA0B;AAC1B,qDAAkD;AAClD,+CAAwD;AACxD,+CAA4C;AAC5C,2DAAoD;AACpD,qCAAkC;AAElC,uCAAmD;AAInD,SAAS,cAAc,CAAC,YAA0B,EAAE,cAA8B,EAAE,IAAuB,EAAE,aAA4B,EAAE,YAA0B;IACnK,MAAM,sBAAuB,SAAQ,uBAAY;QAI/C,YAAoB,iBAAgC,EAAU,UAA0B,EAAE,IAAkB,EAAE,OAAqB;YACjI,KAAK,CAAC,IAAI,CAAC,CAAC;YADM,sBAAiB,GAAjB,iBAAiB,CAAe;YAAU,eAAU,GAAV,UAAU,CAAgB;YAEtF,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC/B,CAAC;QAED,iIAAiI;QACjI,iEAAiE;QACjE,IAAoB,4BAA4B,KAAyB,OAAO,GAAG,CAAC,CAAC,CAAC;QAEtE,oBAAoB,CAAC,KAAa;YAChD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAED,IAAoB,aAAa;YAC/B,IAAI,IAAI,KAAK,IAAI,CAAC,eAAe;gBAC/B,OAAO,KAAK,CAAC,aAAa,CAAC;;gBAE3B,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAClC,CAAC;QAED,IAAoB,cAAc;YAChC,IAAI,IAAI,KAAK,IAAI,CAAC,eAAe;gBAC/B,OAAO,KAAK,CAAC,cAAc,CAAC;;gBAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC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AC,QAAQ,CAAC,YAAY,CAAC,aAAa,KAAK,gCAAU,CAAC,YAAY,CAAC;QACzF,IAAI,SAAS,IAAI,eAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,0BAA0B,IAAI,CAAC,SAAS,IAAI,eAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,8BAA8B,EAAE;YACrJ,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;YAChF,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;SACnE;QAED,eAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,kDAAkD;QAElD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAG,yBAAyB;QACrD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAElC,eAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB;QAC1G,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAlTD,wCAkTC","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\r\n/** @packageDocumentation\r\n * @module WebGL\r\n */\r\n\r\nimport { assert, dispose } from \"@itwin/core-bentley\";\r\nimport { ClipUtilities, ConvexClipPlaneSet, Geometry, GrowableXYZArray, Map4d, Matrix3d, Matrix4d, Point3d, Range3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport {\r\n Frustum, FrustumPlanes, RenderMode, RenderTexture, SolarShadowSettings, TextureTransparency, ViewFlags,\r\n} from \"@itwin/core-common\";\r\nimport { RenderType } from \"@itwin/webgl-compatibility\";\r\nimport { Tile, TileDrawArgs, TileTreeReference, TileVisibility } from \"../../tile/internal\";\r\nimport { SceneContext } from \"../../ViewContext\";\r\nimport { RenderGraphic } from \"../RenderGraphic\";\r\nimport { RenderMemory } from \"../RenderMemory\";\r\nimport { BranchStack } from \"./BranchStack\";\r\nimport { BatchState } from \"./BatchState\";\r\nimport { EVSMGeometry } from \"./CachedGeometry\";\r\nimport { WebGLDisposable } from \"./Disposable\";\r\nimport { FrameBuffer } from \"./FrameBuffer\";\r\nimport { GL } from \"./GL\";\r\nimport { RenderCommands } from \"./RenderCommands\";\r\nimport { RenderPass, TextureUnit } from \"./RenderFlags\";\r\nimport { RenderState } from \"./RenderState\";\r\nimport { getDrawParams } from \"./ScratchDrawParams\";\r\nimport { System } from \"./System\";\r\nimport { Target } from \"./Target\";\r\nimport { Texture, TextureHandle } from \"./Texture\";\r\n\r\ntype ProcessTiles = (tiles: Tile[]) => void;\r\n\r\nfunction createDrawArgs(sceneContext: SceneContext, solarShadowMap: SolarShadowMap, tree: TileTreeReference, frustumPlanes: FrustumPlanes, processTiles: ProcessTiles): TileDrawArgs | undefined {\r\n class SolarShadowMapDrawArgs extends TileDrawArgs {\r\n private _useViewportMap?: boolean;\r\n private readonly _processTiles: ProcessTiles;\r\n\r\n constructor(private _mapFrustumPlanes: FrustumPlanes, private _shadowMap: SolarShadowMap, args: TileDrawArgs, process: ProcessTiles) {\r\n super(args);\r\n this._processTiles = process;\r\n }\r\n\r\n // The solar shadow projection is parallel - which can cause excessive tile selection if it is along an axis of an unbounded tile\r\n // tree such as the OSM buildings. Rev limit the selection here.\r\n public override get maxRealityTreeSelectionCount(): undefined | number { return 500; }\r\n\r\n public override processSelectedTiles(tiles: Tile[]): void {\r\n this._processTiles(tiles);\r\n }\r\n\r\n public override get frustumPlanes(): FrustumPlanes {\r\n if (true === this._useViewportMap)\r\n return super.frustumPlanes;\r\n else\r\n return this._mapFrustumPlanes;\r\n }\r\n\r\n public override get worldToViewMap(): Map4d {\r\n if (true === this._useViewportMap)\r\n return super.worldToViewMap;\r\n else\r\n return this._shadowMap.worldToViewMap;\r\n }\r\n\r\n public override drawGraphics(): void {\r\n const graphics = this.produceGraphics();\r\n if (graphics)\r\n this._shadowMap.addGraphic(graphics);\r\n }\r\n\r\n public override getPixelSize(tile: Tile): number {\r\n // For tiles that are part of the scene, size them based on the viewport frustum so that shadow map uses same resolution tiles as scene\r\n // - otherwise artifacts like shadow acne may result.\r\n // For tiles that are NOT part of the scene, size them based on the shadow frustum, not the viewport frustum\r\n // - otherwise excessive numbers of excessively detailed may be requested for the shadow map.\r\n if (undefined === this._useViewportMap) {\r\n this._useViewportMap = true;\r\n const vis = tile.computeVisibility(this);\r\n this._useViewportMap = TileVisibility.OutsideFrustum !== vis;\r\n }\r\n\r\n const size = super.getPixelSize(tile);\r\n this._useViewportMap = undefined;\r\n return size;\r\n }\r\n\r\n public static create(context: SceneContext, shadowMap: SolarShadowMap, tileTree: TileTreeReference, planes: FrustumPlanes, process: ProcessTiles) {\r\n const args = tileTree.createDrawArgs(context);\r\n return undefined !== args ? new SolarShadowMapDrawArgs(planes, shadowMap, args, process) : undefined;\r\n }\r\n }\r\n\r\n return SolarShadowMapDrawArgs.create(sceneContext, solarShadowMap, tree, frustumPlanes, processTiles);\r\n}\r\n\r\nconst shadowMapWidth = 4096; // size of original depth buffer map\r\nconst shadowMapHeight = shadowMapWidth; // TBD - Adjust for aspect ratio.\r\nconst evsmWidth = shadowMapWidth / 2; // EVSM buffer is 1/2 size each direction\r\nconst evsmHeight = shadowMapHeight / 2;\r\nconst postProjectionMatrixNpc = Matrix4d.createRowValues(/* Row 1 */ 0, 1, 0, 0, /* Row 1 */ 0, 0, 1, 0, /* Row 3 */ 1, 0, 0, 0, /* Row 4 */ 0, 0, 0, 1);\r\n\r\n// Bundles up the disposable, create-once-and-reuse members of a SolarShadowMap.\r\nclass Bundle implements WebGLDisposable {\r\n private constructor(\r\n public readonly depthTexture: Texture,\r\n public readonly shadowMapTexture: Texture,\r\n public readonly fbo: FrameBuffer,\r\n public readonly fboSM: FrameBuffer,\r\n public readonly evsmGeom: EVSMGeometry,\r\n public readonly renderCommands: RenderCommands) {\r\n }\r\n\r\n public static create(target: Target, stack: BranchStack, batch: BatchState): Bundle | undefined {\r\n const depthTextureHandle = System.instance.createDepthBuffer(shadowMapWidth, shadowMapHeight) as TextureHandle;\r\n if (undefined === depthTextureHandle)\r\n return undefined;\r\n\r\n let pixelDataType = GL.Texture.DataType.Float;\r\n switch (System.instance.capabilities.maxRenderType) {\r\n case RenderType.TextureFloat:\r\n break;\r\n case RenderType.TextureHalfFloat:\r\n if (System.instance.capabilities.isWebGL2) {\r\n pixelDataType = (System.instance.context as WebGL2RenderingContext).HALF_FLOAT;\r\n break;\r\n } else {\r\n const exthf = System.instance.capabilities.queryExtensionObject<OES_texture_half_float>(\"OES_texture_half_float\");\r\n if (undefined !== exthf) {\r\n pixelDataType = exthf.HALF_FLOAT_OES;\r\n break;\r\n }\r\n }\r\n /* falls through */\r\n default:\r\n return undefined;\r\n }\r\n\r\n const colorTextures: TextureHandle[] = [];\r\n\r\n // Check if the system can render to a depth texture without a renderable color texture bound as well.\r\n // If it cannot, add a renderable color texture to the framebuffer.\r\n // MacOS Safari exhibited this behavior, which necessitated this code path.\r\n if (!System.instance.capabilities.canRenderDepthWithoutColor) {\r\n const colTex = TextureHandle.createForAttachment(shadowMapWidth, shadowMapHeight, GL.Texture.Format.Rgba, pixelDataType);\r\n if (undefined === colTex)\r\n return undefined;\r\n colorTextures.push(colTex);\r\n }\r\n\r\n const fbo = FrameBuffer.create(colorTextures, depthTextureHandle);\r\n if (undefined === fbo)\r\n return undefined;\r\n\r\n // shadowMap texture is 1/4 size the depth texture (and averaged down when converting)\r\n const shadowMapTextureHandle = TextureHandle.createForAttachment(evsmWidth, evsmHeight, GL.Texture.Format.Rgba, pixelDataType);\r\n if (undefined === shadowMapTextureHandle)\r\n return undefined;\r\n\r\n const fboSM = FrameBuffer.create([shadowMapTextureHandle]);\r\n if (undefined === fboSM)\r\n return undefined;\r\n\r\n const depthTexture = new Texture({ ownership: \"external\", type: RenderTexture.Type.TileSection, handle: depthTextureHandle, transparency: TextureTransparency.Opaque });\r\n const evsmGeom = EVSMGeometry.createGeometry(depthTexture.texture.getHandle()!, shadowMapWidth, shadowMapHeight);\r\n if (undefined === evsmGeom)\r\n return undefined;\r\n\r\n const shadowMapTexture = new Texture({ type: RenderTexture.Type.Normal, ownership: \"external\", handle: shadowMapTextureHandle, transparency: TextureTransparency.Opaque });\r\n const renderCommands = new RenderCommands(target, stack, batch);\r\n return new Bundle(depthTexture, shadowMapTexture, fbo, fboSM, evsmGeom, renderCommands);\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return this.depthTexture.isDisposed\r\n && this.shadowMapTexture.isDisposed\r\n && this.fbo.isDisposed\r\n && this.fboSM.isDisposed\r\n && this.evsmGeom.isDisposed;\r\n }\r\n\r\n public dispose(): void {\r\n dispose(this.depthTexture);\r\n dispose(this.shadowMapTexture);\r\n dispose(this.fbo);\r\n dispose(this.fboSM);\r\n dispose(this.evsmGeom);\r\n }\r\n}\r\n\r\n/** Describes the set of parameters which, when they change, require us to recreate the shadow map. */\r\nclass ShadowMapParams {\r\n public readonly direction = new Vector3d();\r\n public readonly viewFrustum = new Frustum();\r\n public settings: SolarShadowSettings;\r\n\r\n public constructor(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings) {\r\n direction.clone(this.direction);\r\n this.viewFrustum.setFrom(viewFrustum);\r\n this.settings = settings;\r\n }\r\n\r\n public update(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings): void {\r\n this.settings = settings;\r\n this.viewFrustum.setFrom(viewFrustum);\r\n direction.clone(this.direction);\r\n }\r\n}\r\n\r\nconst defaultSunDirection = Vector3d.create(-1, -1, -1).normalize()!;\r\nconst scratchFrustum = new Frustum();\r\nconst scratchFrustumPlanes = FrustumPlanes.createEmpty();\r\n\r\nexport class SolarShadowMap implements RenderMemory.Consumer, WebGLDisposable {\r\n private _bundle?: Bundle;\r\n private _projectionMatrix = Matrix4d.createIdentity();\r\n private _graphics: RenderGraphic[] = [];\r\n private _shadowFrustum = new Frustum();\r\n private _isReady = false;\r\n private _isDrawing = false;\r\n private _enabled = false;\r\n private _params?: ShadowMapParams;\r\n private readonly _scratchRange = Range3d.createNull();\r\n private readonly _scratchTransform = Transform.createIdentity();\r\n\r\n private readonly _scratchViewFlags = new ViewFlags();\r\n private readonly _renderState: RenderState;\r\n private readonly _noZRenderState: RenderState;\r\n private readonly _batchState: BatchState;\r\n private _worldToViewMap = Map4d.createIdentity();\r\n private readonly _target: Target;\r\n\r\n // This exists chiefly for debugging. See ToggleShadowMapTilesTool.\r\n public onGraphicsChanged?: (graphics: RenderGraphic[]) => void;\r\n\r\n private getBundle(target: Target): Bundle | undefined {\r\n if (undefined === this._bundle) {\r\n this._bundle = Bundle.create(target, target.uniforms.branch.stack, this._batchState);\r\n assert(undefined !== this._bundle);\r\n }\r\n\r\n return this._bundle;\r\n }\r\n\r\n public get isReady() { return this._isReady; }\r\n public get isDrawing() { return this._isDrawing; }\r\n public get isEnabled() { return this._enabled; }\r\n public get projectionMatrix(): Matrix4d { return this._projectionMatrix; }\r\n public get depthTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.depthTexture : undefined; }\r\n public get shadowMapTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.shadowMapTexture : undefined; }\r\n public get settings(): SolarShadowSettings | undefined { return undefined !== this._params ? this._params.settings : undefined; }\r\n public get direction(): Vector3d | undefined { return undefined !== this._params ? this._params.direction : undefined; }\r\n public get frustum(): Frustum { return this._shadowFrustum; }\r\n public get worldToViewMap(): Map4d { return this._worldToViewMap; }\r\n public addGraphic(graphic: RenderGraphic) { this._graphics.push(graphic); }\r\n\r\n public constructor(target: Target) {\r\n this._target = target;\r\n this._renderState = new RenderState();\r\n this._renderState.flags.depthMask = true;\r\n this._renderState.flags.blend = false;\r\n this._renderState.flags.depthTest = true;\r\n\r\n this._noZRenderState = new RenderState();\r\n this._noZRenderState.flags.depthMask = false;\r\n\r\n this._batchState = new BatchState(target.uniforms.branch.stack);\r\n }\r\n\r\n public disable() {\r\n this._enabled = this._isReady = false;\r\n this._bundle = dispose(this._bundle);\r\n this.clearGraphics(true);\r\n this._target.uniforms.shadow.update();\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n const bundle = this._bundle;\r\n if (undefined !== bundle)\r\n stats.addShadowMap(bundle.depthTexture.bytesUsed + bundle.shadowMapTexture.bytesUsed);\r\n }\r\n\r\n public get isDisposed(): boolean { return undefined === this._bundle && 0 === this._graphics.length; }\r\n\r\n public dispose() {\r\n this._bundle = dispose(this._bundle);\r\n this.clearGraphics(true);\r\n }\r\n\r\n private clearGraphics(notify: boolean) {\r\n for (const graphic of this._graphics)\r\n graphic.dispose();\r\n\r\n this._graphics.length = 0;\r\n if (notify)\r\n this.notifyGraphicsChanged();\r\n }\r\n\r\n private notifyGraphicsChanged(): void {\r\n if (undefined !== this.onGraphicsChanged)\r\n this.onGraphicsChanged(this._graphics);\r\n }\r\n\r\n public update(context: SceneContext | undefined) {\r\n this._isReady = false;\r\n this.clearGraphics(false);\r\n\r\n if (undefined === context || !context.viewport.view.isSpatialView()) {\r\n this.disable();\r\n this.notifyGraphicsChanged();\r\n return;\r\n }\r\n\r\n const view = context.viewport.view;\r\n const style = view.getDisplayStyle3d();\r\n const sunDirection = style.sunDirection ?? defaultSunDirection;\r\n\r\n const minimumHorizonDirection = -.01;\r\n if (sunDirection.z > minimumHorizonDirection) {\r\n this.notifyGraphicsChanged();\r\n return;\r\n }\r\n\r\n this._enabled = true;\r\n const viewFrustum = context.viewingSpace.getFrustum();\r\n const settings = style.settings.solarShadows;\r\n if (undefined === this._params)\r\n this._params = new ShadowMapParams(viewFrustum, sunDirection, settings);\r\n else\r\n this._params.update(viewFrustum, sunDirection, settings);\r\n\r\n const iModel = view.iModel;\r\n\r\n const worldToMapTransform = Transform.createRefs(Point3d.createZero(), Matrix3d.createRigidHeadsUp(this._params.direction.negate()).inverse()!);\r\n const worldToMap = Matrix4d.createTransform(worldToMapTransform);\r\n const mapToWorld = worldToMap.createInverse()!;\r\n\r\n // Start with entire project.\r\n const shadowRange = worldToMapTransform.multiplyRange(iModel.projectExtents);\r\n\r\n // Limit the map to only displayed models.\r\n const viewTileRange = Range3d.createNull();\r\n view.forEachTileTreeRef((ref) => {\r\n if (ref.castsShadows) {\r\n if (ref.isGlobal) {\r\n // A shadow-casting tile tree that spans the globe. Limit its range to the viewed extents.\r\n for (const p3 of viewFrustum.points) {\r\n const p4 = worldToMap.multiplyPoint3d(p3, 1);\r\n if (p4.w > 0.0001)\r\n viewTileRange.extendXYZW(p4.x, p4.y, p4.z, p4.w);\r\n else\r\n viewTileRange.high.z = Math.max(1.0, viewTileRange.high.z); // behind eye plane.\r\n }\r\n } else {\r\n ref.accumulateTransformedRange(viewTileRange, worldToMap, undefined);\r\n }\r\n }\r\n });\r\n\r\n if (!viewTileRange.isNull)\r\n viewTileRange.clone(shadowRange);\r\n\r\n // Expand shadow range to include both the shadowers and shadowed portion of background map.\r\n scratchFrustum.initFromRange(shadowRange);\r\n mapToWorld.multiplyPoint3dArrayQuietNormalize(scratchFrustum.points); // This frustum represents the shadwowing geometry. Intersect it with background geometry and expand the range depth to include that intersection.\r\n const backgroundMapGeometry = context.viewport.view.displayStyle.getBackgroundMapGeometry();\r\n if (undefined !== backgroundMapGeometry) {\r\n const backgroundDepthRange = backgroundMapGeometry.getFrustumIntersectionDepthRange(this._shadowFrustum, iModel.projectExtents);\r\n if (!backgroundDepthRange.isNull)\r\n shadowRange.low.z = Math.min(shadowRange.low.z, backgroundDepthRange.low);\r\n }\r\n\r\n this._params.viewFrustum.transformBy(worldToMapTransform, scratchFrustum);\r\n scratchFrustumPlanes.init(scratchFrustum);\r\n\r\n const viewIntersectShadowRange = Range3d.createNull();\r\n const viewClipPlanes = ConvexClipPlaneSet.createPlanes(scratchFrustumPlanes.planes);\r\n ClipUtilities.announceLoopsOfConvexClipPlaneSetIntersectRange(viewClipPlanes, shadowRange, (points: GrowableXYZArray) => {\r\n for (const point of points.getPoint3dArray())\r\n viewIntersectShadowRange.extendPoint(point);\r\n });\r\n if (viewIntersectShadowRange.isNull) {\r\n this.notifyGraphicsChanged();\r\n return;\r\n }\r\n viewIntersectShadowRange.high.z = shadowRange.high.z; // We need to include shadowing geometry that may be outside view (along the solar axis).\r\n\r\n this._shadowFrustum.initFromRange(viewIntersectShadowRange);\r\n mapToWorld.multiplyPoint3dArrayQuietNormalize(this._shadowFrustum.points);\r\n\r\n const tileRange = Range3d.createNull();\r\n scratchFrustumPlanes.init(this._shadowFrustum);\r\n view.forEachTileTreeRef(((ref) => {\r\n if (!ref.castsShadows)\r\n return;\r\n\r\n const drawArgs = createDrawArgs(context, this, ref, scratchFrustumPlanes, (tiles: Tile[]) => {\r\n for (const tile of tiles)\r\n tileRange.extendRange(tileToMapTransform.multiplyRange(tile.range, this._scratchRange));\r\n });\r\n\r\n if (undefined === drawArgs)\r\n return;\r\n\r\n const tileToMapTransform = worldToMapTransform.multiplyTransformTransform(drawArgs.location, this._scratchTransform);\r\n drawArgs.tree.draw(drawArgs);\r\n }));\r\n\r\n if (tileRange.isNull) {\r\n this.clearGraphics(true);\r\n } else if (this._graphics.length > 0) {\r\n // Avoid an uninvertible matrix on empty range...\r\n if (Geometry.isAlmostEqualNumber(shadowRange.low.x, shadowRange.high.x) ||\r\n Geometry.isAlmostEqualNumber(shadowRange.low.y, shadowRange.high.y) ||\r\n Geometry.isAlmostEqualNumber(shadowRange.low.z, shadowRange.high.z)) {\r\n this.clearGraphics(true);\r\n return;\r\n }\r\n\r\n const frustumMap = this._shadowFrustum.toMap4d();\r\n if (undefined === frustumMap) {\r\n this.clearGraphics(true);\r\n assert(false);\r\n return;\r\n }\r\n\r\n this._projectionMatrix = frustumMap.transform0.clone();\r\n\r\n const worldToNpc = postProjectionMatrixNpc.multiplyMatrixMatrix(this._projectionMatrix);\r\n const npcToView = Map4d.createBoxMap(Point3d.create(0, 0, 0), Point3d.create(1, 1, 1), Point3d.create(0, 0, 0), Point3d.create(shadowMapWidth, shadowMapHeight, 1))!;\r\n const npcToWorld = worldToNpc.createInverse();\r\n if (undefined === npcToWorld) {\r\n this.clearGraphics(true);\r\n return;\r\n }\r\n\r\n const worldToNpcMap = Map4d.createRefs(worldToNpc, npcToWorld);\r\n this._worldToViewMap = npcToView.multiplyMapMap(worldToNpcMap);\r\n }\r\n\r\n this._target.uniforms.shadow.update();\r\n this.notifyGraphicsChanged();\r\n }\r\n\r\n public draw(target: Target) {\r\n assert(this.isEnabled);\r\n\r\n if (this.isReady || 0 === this._graphics.length)\r\n return;\r\n\r\n const bundle = this.getBundle(target);\r\n if (undefined === bundle)\r\n return;\r\n\r\n this._isDrawing = true;\r\n\r\n const prevState = System.instance.currentRenderState.clone();\r\n const gl = System.instance.context;\r\n gl.viewport(0, 0, shadowMapWidth, shadowMapHeight);\r\n\r\n // NB: textures and materials are needed because their transparencies affect whether or not a surface casts shadows\r\n const viewFlags = target.currentViewFlags.copy({\r\n renderMode: RenderMode.SmoothShade,\r\n wiremesh: false,\r\n transparency: false,\r\n lighting: false,\r\n shadows: false,\r\n monochrome: false,\r\n ambientOcclusion: false,\r\n visibleEdges: false,\r\n hiddenEdges: false,\r\n });\r\n\r\n System.instance.applyRenderState(this._renderState);\r\n const prevPlan = target.plan;\r\n\r\n target.changeFrustum(this._shadowFrustum, this._shadowFrustum.getFraction(), true);\r\n target.uniforms.branch.changeRenderPlan(viewFlags, target.plan.is3d, target.plan.hline);\r\n\r\n const renderCommands = bundle.renderCommands;\r\n renderCommands.reset(target, target.uniforms.branch.stack, this._batchState);\r\n renderCommands.addGraphics(this._graphics);\r\n\r\n System.instance.frameBufferStack.execute(bundle.fbo, true, false, () => {\r\n System.instance.context.clearDepth(1.0);\r\n System.instance.context.clear(GL.BufferBit.Depth);\r\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaquePlanar), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\r\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaqueGeneral), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\r\n });\r\n\r\n // copy depth buffer to EVSM shadow buffer and average down for AA effect\r\n gl.viewport(0, 0, evsmWidth, evsmHeight);\r\n System.instance.frameBufferStack.execute(bundle.fboSM, true, false, () => {\r\n System.instance.applyRenderState(this._noZRenderState);\r\n const params = getDrawParams(target, bundle.evsmGeom);\r\n target.techniques.draw(params);\r\n });\r\n\r\n // mipmap resulting EVSM texture and set filtering options\r\n System.instance.activateTexture2d(TextureUnit.ShadowMap, bundle.shadowMapTexture.texture.getHandle());\r\n gl.generateMipmap(gl.TEXTURE_2D);\r\n const fullFloat = System.instance.capabilities.maxRenderType === RenderType.TextureFloat;\r\n if (fullFloat && System.instance.capabilities.supportsTextureFloatLinear || !fullFloat && System.instance.capabilities.supportsTextureHalfFloatLinear) {\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n }\r\n\r\n System.instance.setMaxAnisotropy(undefined);\r\n // target.recordPerformanceMetric(\"Compute EVSM\");\r\n\r\n this._batchState.reset(); // Reset the batch Ids...\r\n target.changeRenderPlan(prevPlan);\r\n\r\n System.instance.applyRenderState(prevState);\r\n System.instance.context.viewport(0, 0, target.viewRect.width, target.viewRect.height); // Restore viewport\r\n this.clearGraphics(false);\r\n this._isDrawing = false;\r\n this._isReady = true;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RealityTileTree.d.ts","sourceRoot":"","sources":["../../../src/tile/RealityTileTree.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACc,OAAO,EAAE,SAAS,EACtC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAC+B,WAAW,EAAuB,iBAAiB,EAAE,iBAAiB,EAAE,IAAI,EAAE,YAAY,EAAE,qBAAqB,EACpI,UAAU,EAAE,QAAQ,EAAE,cAAc,EACtD,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,qBAAa,gBAAgB;IACpB,cAAc,SAAqB;IACnC,eAAe,UAAS;IACxB,gBAAgB,UAAS;IAEzB,UAAU;CAKlB;AACD,gBAAgB;AAChB,qBAAa,wBAAwB;IACnC,OAAO,CAAC,aAAa,CAA0B;IAExC,UAAU;IAIV,cAAc,CAAC,KAAK,EAAE,MAAM;IAO5B,OAAO,CAAC,aAAa,EAAE,gBAAgB;CAW/C;AAED,gBAAgB;AAChB,qBAAa,yBAAyB;IAIjB,QAAQ,EAAE,IAAI,EAAE;IAAS,oBAAoB,EAAE,IAAI,EAAE,EAAE;IAAS,mBAAmB,CAAC;IAAkB,OAAO,CAAC,kBAAkB,CAAC;IAH7I,SAAS,mBAA0B;IACnC,OAAO,gBAA4B;IAC1C,IAAW,sBAAsB,YAAqI;gBACnJ,QAAQ,EAAE,IAAI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