@xeokit/xeokit-sdk 2.4.0-alpha-81 → 2.4.0-alpha-83

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 (390) hide show
  1. package/dist/xeokit-sdk.cjs.js +5 -1
  2. package/dist/xeokit-sdk.es.js +5 -1
  3. package/dist/xeokit-sdk.es5.js +1 -1
  4. package/dist/xeokit-sdk.min.cjs.js +1 -1
  5. package/dist/xeokit-sdk.min.es.js +1 -1
  6. package/dist/xeokit-sdk.min.es5.js +1 -1
  7. package/package.json +2 -1
  8. package/src/extras/ContextMenu/ContextMenu.js +907 -0
  9. package/src/extras/ContextMenu/index.js +1 -0
  10. package/src/extras/index.js +1 -0
  11. package/src/index.js +3 -0
  12. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +658 -0
  13. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.js +418 -0
  14. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.js +400 -0
  15. package/src/plugins/AngleMeasurementsPlugin/index.js +1 -0
  16. package/src/plugins/AnnotationsPlugin/Annotation.js +368 -0
  17. package/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +583 -0
  18. package/src/plugins/AnnotationsPlugin/index.js +1 -0
  19. package/src/plugins/AxisGizmoPlugin/AxisGizmoPlugin.js +333 -0
  20. package/src/plugins/AxisGizmoPlugin/index.js +1 -0
  21. package/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js +955 -0
  22. package/src/plugins/BCFViewpointsPlugin/index.js +1 -0
  23. package/src/plugins/CityJSONLoaderPlugin/CityJSONDefaultDataSource.js +29 -0
  24. package/src/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.js +751 -0
  25. package/src/plugins/CityJSONLoaderPlugin/index.js +1 -0
  26. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +870 -0
  27. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.js +376 -0
  28. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +454 -0
  29. package/src/plugins/DistanceMeasurementsPlugin/index.js +1 -0
  30. package/src/plugins/FaceAlignedSectionPlanesPlugin/FaceAlignedSectionPlanesControl.js +639 -0
  31. package/src/plugins/FaceAlignedSectionPlanesPlugin/FaceAlignedSectionPlanesPlugin.js +436 -0
  32. package/src/plugins/FaceAlignedSectionPlanesPlugin/Overview.js +247 -0
  33. package/src/plugins/FaceAlignedSectionPlanesPlugin/Plane.js +167 -0
  34. package/src/plugins/FaceAlignedSectionPlanesPlugin/index.js +1 -0
  35. package/src/plugins/FastNavPlugin/FastNavPlugin.js +429 -0
  36. package/src/plugins/FastNavPlugin/index.js +1 -0
  37. package/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +139 -0
  38. package/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +421 -0
  39. package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +669 -0
  40. package/src/plugins/GLTFLoaderPlugin/index.js +2 -0
  41. package/src/plugins/LASLoaderPlugin/LASDefaultDataSource.js +58 -0
  42. package/src/plugins/LASLoaderPlugin/LASLoaderPlugin.js +518 -0
  43. package/src/plugins/LASLoaderPlugin/index.js +1 -0
  44. package/src/plugins/LASLoaderPlugin/loadLASHeader.js +183 -0
  45. package/src/plugins/NavCubePlugin/CubeTextureCanvas.js +289 -0
  46. package/src/plugins/NavCubePlugin/NavCubePlugin.js +752 -0
  47. package/src/plugins/NavCubePlugin/index.js +1 -0
  48. package/src/plugins/OBJLoaderPlugin/OBJLoaderPlugin.js +145 -0
  49. package/src/plugins/OBJLoaderPlugin/OBJSceneGraphLoader.js +777 -0
  50. package/src/plugins/OBJLoaderPlugin/index.js +1 -0
  51. package/src/plugins/STLLoaderPlugin/STLDefaultDataSource.js +33 -0
  52. package/src/plugins/STLLoaderPlugin/STLLoaderPlugin.js +274 -0
  53. package/src/plugins/STLLoaderPlugin/STLSceneGraphLoader.js +313 -0
  54. package/src/plugins/STLLoaderPlugin/index.js +2 -0
  55. package/src/plugins/SectionPlanesPlugin/Control.js +1328 -0
  56. package/src/plugins/SectionPlanesPlugin/Overview.js +249 -0
  57. package/src/plugins/SectionPlanesPlugin/Plane.js +169 -0
  58. package/src/plugins/SectionPlanesPlugin/SectionPlanesPlugin.js +404 -0
  59. package/src/plugins/SectionPlanesPlugin/index.js +1 -0
  60. package/src/plugins/SkyboxesPlugin/SkyboxesPlugin.js +134 -0
  61. package/src/plugins/SkyboxesPlugin/index.js +1 -0
  62. package/src/plugins/StoreyViewsPlugin/IFCStoreyPlanObjectStates.js +77 -0
  63. package/src/plugins/StoreyViewsPlugin/Storey.js +61 -0
  64. package/src/plugins/StoreyViewsPlugin/StoreyMap.js +57 -0
  65. package/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +825 -0
  66. package/src/plugins/StoreyViewsPlugin/index.js +1 -0
  67. package/src/plugins/TreeViewPlugin/TreeViewNode.js +97 -0
  68. package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +1424 -0
  69. package/src/plugins/TreeViewPlugin/index.js +1 -0
  70. package/src/plugins/ViewCullPlugin/ViewCullPlugin.js +295 -0
  71. package/src/plugins/ViewCullPlugin/index.js +1 -0
  72. package/src/plugins/WebIFCLoaderPlugin/WebIFCDefaultDataSource.js +58 -0
  73. package/src/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.js +942 -0
  74. package/src/plugins/WebIFCLoaderPlugin/index.js +1 -0
  75. package/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +95 -0
  76. package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +1107 -0
  77. package/src/plugins/XKTLoaderPlugin/index.js +2 -0
  78. package/src/plugins/XKTLoaderPlugin/parsers/ParserV1.js +169 -0
  79. package/src/plugins/XKTLoaderPlugin/parsers/ParserV10.js +656 -0
  80. package/src/plugins/XKTLoaderPlugin/parsers/ParserV2.js +230 -0
  81. package/src/plugins/XKTLoaderPlugin/parsers/ParserV3.js +223 -0
  82. package/src/plugins/XKTLoaderPlugin/parsers/ParserV4.js +283 -0
  83. package/src/plugins/XKTLoaderPlugin/parsers/ParserV5.js +246 -0
  84. package/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +301 -0
  85. package/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +439 -0
  86. package/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +563 -0
  87. package/src/plugins/XKTLoaderPlugin/parsers/ParserV9.js +518 -0
  88. package/src/plugins/XKTLoaderPlugin/parsers/lib/pako.js +2 -0
  89. package/src/plugins/XML3DLoaderPlugin/XML3DLoaderPlugin.js +238 -0
  90. package/src/plugins/XML3DLoaderPlugin/XML3DSceneGraphLoader.js +1279 -0
  91. package/src/plugins/XML3DLoaderPlugin/index.js +1 -0
  92. package/src/plugins/XML3DLoaderPlugin/zipjs/.jshintrc +11 -0
  93. package/src/plugins/XML3DLoaderPlugin/zipjs/deflate.js +2060 -0
  94. package/src/plugins/XML3DLoaderPlugin/zipjs/inflate.js +2155 -0
  95. package/src/plugins/XML3DLoaderPlugin/zipjs/mime-types.js +1002 -0
  96. package/src/plugins/XML3DLoaderPlugin/zipjs/pako/codecs.js +64 -0
  97. package/src/plugins/XML3DLoaderPlugin/zipjs/z-worker.js +153 -0
  98. package/src/plugins/XML3DLoaderPlugin/zipjs/zip-ext.js +267 -0
  99. package/src/plugins/XML3DLoaderPlugin/zipjs/zip-fs.js +553 -0
  100. package/src/plugins/XML3DLoaderPlugin/zipjs/zip.js +991 -0
  101. package/src/plugins/XML3DLoaderPlugin/zipjs/zlib-asm/codecs.js +49 -0
  102. package/src/plugins/index.js +21 -0
  103. package/src/plugins/lib/culling/ObjectCullStates.js +208 -0
  104. package/src/plugins/lib/earcut.js +677 -0
  105. package/src/plugins/lib/html/Dot.js +145 -0
  106. package/src/plugins/lib/html/Label.js +156 -0
  107. package/src/plugins/lib/html/Wire.js +191 -0
  108. package/src/viewer/Configs.js +79 -0
  109. package/src/viewer/Plugin.js +224 -0
  110. package/src/viewer/Viewer.js +535 -0
  111. package/src/viewer/index.js +5 -0
  112. package/src/viewer/localization/LocaleService.js +475 -0
  113. package/src/viewer/metadata/IFCObjectDefaultColors.js +162 -0
  114. package/src/viewer/metadata/IFCObjectDefaults.js +17 -0
  115. package/src/viewer/metadata/MetaModel.js +389 -0
  116. package/src/viewer/metadata/MetaObject.js +218 -0
  117. package/src/viewer/metadata/MetaScene.js +336 -0
  118. package/src/viewer/metadata/Property.js +55 -0
  119. package/src/viewer/metadata/PropertySet.js +77 -0
  120. package/src/viewer/scene/Bitmap/Bitmap.js +470 -0
  121. package/src/viewer/scene/Bitmap/index.js +1 -0
  122. package/src/viewer/scene/CameraControl/CameraControl.js +1737 -0
  123. package/src/viewer/scene/CameraControl/lib/CameraUpdater.js +312 -0
  124. package/src/viewer/scene/CameraControl/lib/controllers/PanController.js +112 -0
  125. package/src/viewer/scene/CameraControl/lib/controllers/PickController.js +264 -0
  126. package/src/viewer/scene/CameraControl/lib/controllers/PivotController.js +384 -0
  127. package/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +122 -0
  128. package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +183 -0
  129. package/src/viewer/scene/CameraControl/lib/handlers/MouseMiscHandler.js +68 -0
  130. package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +345 -0
  131. package/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +372 -0
  132. package/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +269 -0
  133. package/src/viewer/scene/CameraControl/lib/handlers/TouchPickHandler.js +235 -0
  134. package/src/viewer/scene/Component.js +907 -0
  135. package/src/viewer/scene/Entity.js +502 -0
  136. package/src/viewer/scene/ImagePlane/ImagePlane.js +570 -0
  137. package/src/viewer/scene/ImagePlane/index.js +1 -0
  138. package/src/viewer/scene/LineSet/LineSet.js +164 -0
  139. package/src/viewer/scene/LineSet/index.js +1 -0
  140. package/src/viewer/scene/camera/Camera.js +912 -0
  141. package/src/viewer/scene/camera/CameraFlightAnimation.js +669 -0
  142. package/src/viewer/scene/camera/CameraPath.js +194 -0
  143. package/src/viewer/scene/camera/CameraPathAnimation.js +326 -0
  144. package/src/viewer/scene/camera/CustomProjection.js +149 -0
  145. package/src/viewer/scene/camera/Frustum.js +316 -0
  146. package/src/viewer/scene/camera/Ortho.js +286 -0
  147. package/src/viewer/scene/camera/Perspective.js +304 -0
  148. package/src/viewer/scene/camera/index.js +2 -0
  149. package/src/viewer/scene/canvas/Canvas.js +492 -0
  150. package/src/viewer/scene/canvas/Spinner.js +323 -0
  151. package/src/viewer/scene/constants/constants.js +371 -0
  152. package/src/viewer/scene/core.js +233 -0
  153. package/src/viewer/scene/geometry/Geometry.js +33 -0
  154. package/src/viewer/scene/geometry/ReadableGeometry.js +682 -0
  155. package/src/viewer/scene/geometry/VBOGeometry.js +319 -0
  156. package/src/viewer/scene/geometry/builders/buildBoxGeometry.js +238 -0
  157. package/src/viewer/scene/geometry/builders/buildBoxLinesGeometry.js +106 -0
  158. package/src/viewer/scene/geometry/builders/buildCylinderGeometry.js +271 -0
  159. package/src/viewer/scene/geometry/builders/buildGridGeometry.js +102 -0
  160. package/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +168 -0
  161. package/src/viewer/scene/geometry/builders/buildSphereGeometry.js +161 -0
  162. package/src/viewer/scene/geometry/builders/buildTorusGeometry.js +172 -0
  163. package/src/viewer/scene/geometry/builders/buildVectorTextGeometry.js +1721 -0
  164. package/src/viewer/scene/geometry/builders/index.js +8 -0
  165. package/src/viewer/scene/geometry/index.js +4 -0
  166. package/src/viewer/scene/geometry/loaders/index.js +2 -0
  167. package/src/viewer/scene/geometry/loaders/load3DSGeometry.js +103 -0
  168. package/src/viewer/scene/geometry/loaders/loadOBJGeometry.js +130 -0
  169. package/src/viewer/scene/index.js +23 -0
  170. package/src/viewer/scene/input/Input.js +1325 -0
  171. package/src/viewer/scene/libs/k3d.js +1032 -0
  172. package/src/viewer/scene/lights/AmbientLight.js +175 -0
  173. package/src/viewer/scene/lights/CubeTexture.js +156 -0
  174. package/src/viewer/scene/lights/DirLight.js +314 -0
  175. package/src/viewer/scene/lights/Light.js +29 -0
  176. package/src/viewer/scene/lights/LightMap.js +77 -0
  177. package/src/viewer/scene/lights/PointLight.js +395 -0
  178. package/src/viewer/scene/lights/ReflectionMap.js +79 -0
  179. package/src/viewer/scene/lights/Shadow.js +138 -0
  180. package/src/viewer/scene/lights/index.js +5 -0
  181. package/src/viewer/scene/lod/LOD.js +162 -0
  182. package/src/viewer/scene/lod/LODCullingManager.js +83 -0
  183. package/src/viewer/scene/lod/LODState.js +125 -0
  184. package/src/viewer/scene/lod/index.js +1 -0
  185. package/src/viewer/scene/marker/Marker.js +383 -0
  186. package/src/viewer/scene/marker/SpriteMarker.js +356 -0
  187. package/src/viewer/scene/marker/index.js +2 -0
  188. package/src/viewer/scene/materials/EdgeMaterial.js +359 -0
  189. package/src/viewer/scene/materials/EmphasisMaterial.js +613 -0
  190. package/src/viewer/scene/materials/Fresnel.js +222 -0
  191. package/src/viewer/scene/materials/LambertMaterial.js +378 -0
  192. package/src/viewer/scene/materials/LinesMaterial.js +169 -0
  193. package/src/viewer/scene/materials/Material.js +39 -0
  194. package/src/viewer/scene/materials/MetallicMaterial.js +820 -0
  195. package/src/viewer/scene/materials/PhongMaterial.js +860 -0
  196. package/src/viewer/scene/materials/PointsMaterial.js +409 -0
  197. package/src/viewer/scene/materials/SpecularMaterial.js +807 -0
  198. package/src/viewer/scene/materials/Texture.js +513 -0
  199. package/src/viewer/scene/materials/index.js +8 -0
  200. package/src/viewer/scene/math/Frustum.js +118 -0
  201. package/src/viewer/scene/math/buildEdgeIndices.js +162 -0
  202. package/src/viewer/scene/math/geometryCompressionUtils.js +365 -0
  203. package/src/viewer/scene/math/index.js +3 -0
  204. package/src/viewer/scene/math/math.js +5363 -0
  205. package/src/viewer/scene/math/rtcCoords.js +139 -0
  206. package/src/viewer/scene/mementos/CameraMemento.js +200 -0
  207. package/src/viewer/scene/mementos/ModelMemento.js +263 -0
  208. package/src/viewer/scene/mementos/ObjectsMemento.js +259 -0
  209. package/src/viewer/scene/mementos/index.js +3 -0
  210. package/src/viewer/scene/mesh/Mesh.js +2202 -0
  211. package/src/viewer/scene/mesh/draw/DrawRenderer.js +986 -0
  212. package/src/viewer/scene/mesh/draw/DrawShaderSource.js +1570 -0
  213. package/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +249 -0
  214. package/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +158 -0
  215. package/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +276 -0
  216. package/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +261 -0
  217. package/src/viewer/scene/mesh/index.js +1 -0
  218. package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +207 -0
  219. package/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +156 -0
  220. package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +210 -0
  221. package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +142 -0
  222. package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +186 -0
  223. package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +116 -0
  224. package/src/viewer/scene/mesh/shadow/ShadowRenderer.js +214 -0
  225. package/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +98 -0
  226. package/src/viewer/scene/metriqs/Metriqs.js +259 -0
  227. package/src/viewer/scene/model/ENTITY_FLAGS.js +21 -0
  228. package/src/viewer/scene/model/PerformanceModel.js +26 -0
  229. package/src/viewer/scene/model/RENDER_PASSES.js +34 -0
  230. package/src/viewer/scene/model/SceneModel.js +3817 -0
  231. package/src/viewer/scene/model/SceneModelEntity.js +478 -0
  232. package/src/viewer/scene/model/SceneModelMesh.js +160 -0
  233. package/src/viewer/scene/model/SceneModelTexture.js +17 -0
  234. package/src/viewer/scene/model/SceneModelTextureSet.js +17 -0
  235. package/src/viewer/scene/model/VBOSceneModel.js +26 -0
  236. package/src/viewer/scene/model/compression.js +227 -0
  237. package/src/viewer/scene/model/dtx/triangles/BindableDataTexture.js +31 -0
  238. package/src/viewer/scene/model/dtx/triangles/DataTextureGenerator.js +631 -0
  239. package/src/viewer/scene/model/dtx/triangles/DataTextureState.js +288 -0
  240. package/src/viewer/scene/model/dtx/triangles/TrianglesDataTextureBuffer.js +31 -0
  241. package/src/viewer/scene/model/dtx/triangles/TrianglesDataTextureLayer.js +1329 -0
  242. package/src/viewer/scene/model/dtx/triangles/TrianglesDataTextureRenderers.js +278 -0
  243. package/src/viewer/scene/model/dtx/triangles/calculateUniquePositions.js +126 -0
  244. package/src/viewer/scene/model/dtx/triangles/dataTextureRamStats.js +54 -0
  245. package/src/viewer/scene/model/dtx/triangles/rebucketPositions.js +347 -0
  246. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureColorRenderer.js +633 -0
  247. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureDepthRenderer.js +475 -0
  248. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +426 -0
  249. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +430 -0
  250. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureNormalsRenderer.js +341 -0
  251. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureOcclusionRenderer.js +442 -0
  252. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickDepthRenderer.js +451 -0
  253. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js +436 -0
  254. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +502 -0
  255. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +430 -0
  256. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js +469 -0
  257. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +451 -0
  258. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +424 -0
  259. package/src/viewer/scene/model/index.js +3 -0
  260. package/src/viewer/scene/model/vbo/ScratchMemory.js +63 -0
  261. package/src/viewer/scene/model/vbo/VBOSceneModelRenderers.js +805 -0
  262. package/src/viewer/scene/model/vbo/float16.js +760 -0
  263. package/src/viewer/scene/model/vbo/linesBatching/LinesBatchingBuffer.js +21 -0
  264. package/src/viewer/scene/model/vbo/linesBatching/LinesBatchingLayer.js +744 -0
  265. package/src/viewer/scene/model/vbo/linesBatching/LinesBatchingRenderers.js +71 -0
  266. package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingColorRenderer.js +116 -0
  267. package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +126 -0
  268. package/src/viewer/scene/model/vbo/linesInstancing/LinesInstancingLayer.js +653 -0
  269. package/src/viewer/scene/model/vbo/linesInstancing/LinesInstancingRenderers.js +71 -0
  270. package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingColorRenderer.js +150 -0
  271. package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +128 -0
  272. package/src/viewer/scene/model/vbo/pointsBatching/PointsBatchingBuffer.js +22 -0
  273. package/src/viewer/scene/model/vbo/pointsBatching/PointsBatchingLayer.js +753 -0
  274. package/src/viewer/scene/model/vbo/pointsBatching/PointsBatchingRenderers.js +116 -0
  275. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingColorRenderer.js +167 -0
  276. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +135 -0
  277. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +154 -0
  278. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +146 -0
  279. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingShadowRenderer.js +108 -0
  280. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +147 -0
  281. package/src/viewer/scene/model/vbo/pointsInstancing/PointsInstancingLayer.js +684 -0
  282. package/src/viewer/scene/model/vbo/pointsInstancing/PointsInstancingRenderers.js +146 -0
  283. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingColorRenderer.js +174 -0
  284. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +156 -0
  285. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +151 -0
  286. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +167 -0
  287. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +151 -0
  288. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +121 -0
  289. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +156 -0
  290. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthBufInitRenderer.js +351 -0
  291. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthRenderer.js +365 -0
  292. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingRenderers.js +71 -0
  293. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthBufInitRenderer.js +381 -0
  294. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthRenderer.js +374 -0
  295. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingRenderers.js +71 -0
  296. package/src/viewer/scene/model/vbo/trianglesBatching/TrianglesBatchingBuffer.js +26 -0
  297. package/src/viewer/scene/model/vbo/trianglesBatching/TrianglesBatchingLayer.js +1322 -0
  298. package/src/viewer/scene/model/vbo/trianglesBatching/TrianglesBatchingRenderers.js +322 -0
  299. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +240 -0
  300. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorTextureRenderer.js +271 -0
  301. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +127 -0
  302. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +129 -0
  303. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +134 -0
  304. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingFlatColorRenderer.js +237 -0
  305. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +139 -0
  306. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +127 -0
  307. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPBRRenderer.js +563 -0
  308. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +143 -0
  309. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +130 -0
  310. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsFlatRenderer.js +119 -0
  311. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +129 -0
  312. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +108 -0
  313. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +137 -0
  314. package/src/viewer/scene/model/vbo/trianglesInstancing/TrianglesInstancingLayer.js +1167 -0
  315. package/src/viewer/scene/model/vbo/trianglesInstancing/TrianglesInstancingRenderers.js +322 -0
  316. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +253 -0
  317. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorTextureRenderer.js +278 -0
  318. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +125 -0
  319. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +131 -0
  320. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +134 -0
  321. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatColorRenderer.js +244 -0
  322. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatNormalsRenderer.js +130 -0
  323. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +140 -0
  324. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +130 -0
  325. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPBRRenderer.js +563 -0
  326. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +148 -0
  327. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +135 -0
  328. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsFlatRenderer.js +130 -0
  329. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +144 -0
  330. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +113 -0
  331. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +141 -0
  332. package/src/viewer/scene/nodes/Node.js +1383 -0
  333. package/src/viewer/scene/nodes/index.js +1 -0
  334. package/src/viewer/scene/paths/CubicBezierCurve.js +194 -0
  335. package/src/viewer/scene/paths/Curve.js +183 -0
  336. package/src/viewer/scene/paths/Path.js +239 -0
  337. package/src/viewer/scene/paths/QuadraticBezierCurve.js +161 -0
  338. package/src/viewer/scene/paths/SplineCurve.js +133 -0
  339. package/src/viewer/scene/paths/index.js +5 -0
  340. package/src/viewer/scene/postfx/SAO.js +543 -0
  341. package/src/viewer/scene/scene/Scene.js +2627 -0
  342. package/src/viewer/scene/sectionPlane/SectionPlane.js +194 -0
  343. package/src/viewer/scene/sectionPlane/index.js +1 -0
  344. package/src/viewer/scene/skybox/Skybox.js +123 -0
  345. package/src/viewer/scene/skybox/index.js +1 -0
  346. package/src/viewer/scene/stats.js +44 -0
  347. package/src/viewer/scene/utils/Cache.js +29 -0
  348. package/src/viewer/scene/utils/FileLoader.js +160 -0
  349. package/src/viewer/scene/utils/Loader.js +55 -0
  350. package/src/viewer/scene/utils/LoadingManager.js +86 -0
  351. package/src/viewer/scene/utils/Map.js +45 -0
  352. package/src/viewer/scene/utils/Queue.js +56 -0
  353. package/src/viewer/scene/utils/WorkerPool.js +73 -0
  354. package/src/viewer/scene/utils/index.js +6 -0
  355. package/src/viewer/scene/utils/textureTranscoders/KTX2TextureTranscoder/KTX2TextureTranscoder.js +650 -0
  356. package/src/viewer/scene/utils/textureTranscoders/KTX2TextureTranscoder/index.js +1 -0
  357. package/src/viewer/scene/utils/textureTranscoders/TextureTranscoder.js +31 -0
  358. package/src/viewer/scene/utils/textureTranscoders/index.js +2 -0
  359. package/src/viewer/scene/utils.js +452 -0
  360. package/src/viewer/scene/vfc/VFC.js +82 -0
  361. package/src/viewer/scene/vfc/VFCManager.js +54 -0
  362. package/src/viewer/scene/vfc/VFCState.js +391 -0
  363. package/src/viewer/scene/vfc/cluster-helper.js +134 -0
  364. package/src/viewer/scene/vfc/index.js +1 -0
  365. package/src/viewer/scene/vfc/rbush3d.js +848 -0
  366. package/src/viewer/scene/vfc/xeokit-cluster.js +418 -0
  367. package/src/viewer/scene/viewport/Viewport.js +212 -0
  368. package/src/viewer/scene/webgl/ArrayBuf.js +121 -0
  369. package/src/viewer/scene/webgl/Attribute.js +23 -0
  370. package/src/viewer/scene/webgl/Drawable.js +270 -0
  371. package/src/viewer/scene/webgl/FrameContext.js +313 -0
  372. package/src/viewer/scene/webgl/PickResult.js +339 -0
  373. package/src/viewer/scene/webgl/Pickable.js +69 -0
  374. package/src/viewer/scene/webgl/Program.js +181 -0
  375. package/src/viewer/scene/webgl/RenderBuffer.js +350 -0
  376. package/src/viewer/scene/webgl/RenderBufferManager.js +34 -0
  377. package/src/viewer/scene/webgl/RenderFlags.js +203 -0
  378. package/src/viewer/scene/webgl/RenderState.js +40 -0
  379. package/src/viewer/scene/webgl/Renderer.js +1654 -0
  380. package/src/viewer/scene/webgl/Sampler.js +18 -0
  381. package/src/viewer/scene/webgl/Shader.js +49 -0
  382. package/src/viewer/scene/webgl/Texture2D.js +442 -0
  383. package/src/viewer/scene/webgl/convertConstant.js +244 -0
  384. package/src/viewer/scene/webgl/getExtension.js +32 -0
  385. package/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +214 -0
  386. package/src/viewer/scene/webgl/occlusion/OcclusionTester.js +426 -0
  387. package/src/viewer/scene/webgl/sao/SAODepthLimitedBlurRenderer.js +324 -0
  388. package/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +376 -0
  389. package/src/viewer/scene/webgl/webglEnums.js +61 -0
  390. package/src/viewer/scene/webglInfo.js +47 -0
@@ -0,0 +1,1329 @@
1
+ import {ENTITY_FLAGS} from '../../ENTITY_FLAGS.js';
2
+ import {RENDER_PASSES} from '../../RENDER_PASSES.js';
3
+ import {math} from "../../../math/math.js";
4
+ import {RenderState} from "../../../webgl/RenderState.js";
5
+ import {geometryCompressionUtils} from "../../../math/geometryCompressionUtils.js";
6
+ import {getDataTextureRenderers} from "./TrianglesDataTextureRenderers.js";
7
+ import {TrianglesDataTextureBuffer} from "./TrianglesDataTextureBuffer.js";
8
+ import {DataTextureState} from "./DataTextureState.js"
9
+ import {DataTextureGenerator} from "./DataTextureGenerator";
10
+ import {dataTextureRamStats} from "./dataTextureRamStats";
11
+
12
+ /**
13
+ * 12-bits allowed for object ids.
14
+ * Limits the per-object texture height in the layer.
15
+ */
16
+ const MAX_NUMBER_OF_OBJECTS_IN_LAYER = (1 << 16);
17
+
18
+ /**
19
+ * 4096 is max data texture height.
20
+ * Limits the aggregated geometry texture height in the layer.
21
+ */
22
+ const MAX_DATA_TEXTURE_HEIGHT = (1 << 12);
23
+
24
+ /**
25
+ * Align `indices` and `edgeIndices` memory layout to 8 elements.
26
+ *
27
+ * Used as an optimization for the `...portionIds...` texture, so it
28
+ * can just be stored 1 out of 8 `portionIds` corresponding to a given
29
+ * `triangle-index` or `edge-index`.
30
+ */
31
+ const INDICES_EDGE_INDICES_ALIGNEMENT_SIZE = 8;
32
+
33
+ /**
34
+ * Number of maximum allowed per-object flags update per render frame
35
+ * before switching to batch update mode.
36
+ */
37
+ const MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE = 10;
38
+
39
+ const tempVec4a = math.vec4([0, 0, 0, 1]);
40
+ const tempVec4b = math.vec4([0, 0, 0, 1]);
41
+ const tempVec4c = math.vec4([0, 0, 0, 1]);
42
+ const tempUint8Array4 = new Uint8Array(4);
43
+ const tempFloat32Array3 = new Float32Array(3);
44
+
45
+ const tempAABB3b = math.AABB3();
46
+
47
+ let numLayers = 0;
48
+
49
+ const DEFAULT_MATRIX = math.identityMat4();
50
+
51
+ /**
52
+ * @private
53
+ */
54
+ export class TrianglesDataTextureLayer {
55
+
56
+ constructor(model, cfg) {
57
+
58
+ dataTextureRamStats.numberOfLayers++;
59
+
60
+ this._layerNumber = numLayers++;
61
+ this.sortId = `TriDTX-${this._layerNumber}`; // State sorting key.
62
+ this.layerIndex = cfg.layerIndex; // Index of this TrianglesDataTextureLayer in {@link SceneModel#_layerList}.
63
+
64
+ this._dataTextureRenderers = getDataTextureRenderers(model.scene);
65
+ this.model = model;
66
+ this._buffer = new TrianglesDataTextureBuffer();
67
+ this._dataTextureState = new DataTextureState();
68
+ this._dataTextureGenerator = new DataTextureGenerator();
69
+
70
+ this._state = new RenderState({
71
+ origin: math.vec3(cfg.origin),
72
+ metallicRoughnessBuf: null,
73
+ positionsDecodeMatrix: math.mat4(),
74
+ textureState: this._dataTextureState,
75
+ numIndices8Bits: 0,
76
+ numIndices16Bits: 0,
77
+ numIndices32Bits: 0,
78
+ numEdgeIndices8Bits: 0,
79
+ numEdgeIndices16Bits: 0,
80
+ numEdgeIndices32Bits: 0,
81
+ numVertices: 0,
82
+ });
83
+
84
+ this._numPortions = 0; // These counts are used to avoid unnecessary render passes
85
+ this._numVisibleLayerPortions = 0;
86
+ this._numTransparentLayerPortions = 0;
87
+ this._numXRayedLayerPortions = 0;
88
+ this._numSelectedLayerPortions = 0;
89
+ this._numHighlightedLayerPortions = 0;
90
+ this._numClippableLayerPortions = 0;
91
+ this._numEdgesLayerPortions = 0;
92
+ this._numPickableLayerPortions = 0;
93
+ this._numCulledLayerPortions = 0;
94
+
95
+ this._subPortions = [];
96
+
97
+ /**
98
+ * Due to `index rebucketting` process in ```prepareMeshGeometry``` function, it's possible that a single
99
+ * portion is expanded to more than 1 real sub-portion.
100
+ *
101
+ * This Array tracks the mapping between:
102
+ *
103
+ * - external `portionIds` as seen by consumers of this class.
104
+ * - internal `sub-portionIds` actually managed by this class.
105
+ *
106
+ * The outer index of this array is the externally seen `portionId`.
107
+ * The inner value of the array, are `sub-portionIds` corresponding to the `portionId`.
108
+ */
109
+ this._portionToSubPortionsMap = [];
110
+
111
+ this._bucketGeometries = {};
112
+
113
+ /**
114
+ * The axis-aligned World-space boundary of this TrianglesDataTextureLayer's positions.
115
+ */
116
+ this.aabb = math.collapseAABB3();
117
+
118
+ /**
119
+ * The number of updates in the current frame;
120
+ */
121
+ this._numUpdatesInFrame = 0;
122
+
123
+ this._finalized = false;
124
+ }
125
+
126
+ /**
127
+ * Returns whether the ```TrianglesDataTextureLayer``` has room for more portions.
128
+ *
129
+ * @param {object} portionCfg An object containing the geometrical data (`positions`, `indices`, `edgeIndices`) for the portion.
130
+ * @returns {Boolean} Wheter the requested portion can be created
131
+ */
132
+ canCreatePortion(portionCfg) {
133
+ if (this._finalized) {
134
+ throw "Already finalized";
135
+ }
136
+ const numNewPortions = portionCfg.buckets.length;
137
+ if ((this._numPortions + numNewPortions) > MAX_NUMBER_OF_OBJECTS_IN_LAYER) {
138
+ dataTextureRamStats.cannotCreatePortion.because10BitsObjectId++;
139
+ }
140
+ let retVal = (this._numPortions + numNewPortions) <= MAX_NUMBER_OF_OBJECTS_IN_LAYER;
141
+ const bucketIndex = 0; // TODO: Is this a bug?
142
+ const bucketGeometryId = portionCfg.geometryId !== undefined && portionCfg.geometryId !== null
143
+ ? `${portionCfg.geometryId}#${bucketIndex}`
144
+ : `${portionCfg.id}#${bucketIndex}`;
145
+ const alreadyHasPortionGeometry = this._bucketGeometries[bucketGeometryId];
146
+ if (!alreadyHasPortionGeometry) {
147
+ const maxIndicesOfAnyBits = Math.max(this._state.numIndices8Bits, this._state.numIndices16Bits, this._state.numIndices32Bits,);
148
+ let numVertices = 0;
149
+ let numIndices = 0;
150
+ portionCfg.buckets.forEach(bucket => {
151
+ numVertices += bucket.positionsCompressed.length / 3;
152
+ numIndices += bucket.indices.length / 3;
153
+ });
154
+ if ((this._state.numVertices + numVertices) > MAX_DATA_TEXTURE_HEIGHT * 4096 ||
155
+ (maxIndicesOfAnyBits + numIndices) > MAX_DATA_TEXTURE_HEIGHT * 4096) {
156
+ dataTextureRamStats.cannotCreatePortion.becauseTextureSize++;
157
+ }
158
+ retVal &&=
159
+ (this._state.numVertices + numVertices) <= MAX_DATA_TEXTURE_HEIGHT * 4096 &&
160
+ (maxIndicesOfAnyBits + numIndices) <= MAX_DATA_TEXTURE_HEIGHT * 4096;
161
+ }
162
+ return retVal;
163
+ }
164
+
165
+ /**
166
+ * Creates a new portion within this TrianglesDataTextureLayer, returns the new portion ID.
167
+ *
168
+ * Gives the portion the specified geometry, color and matrix.
169
+ *
170
+ * @param portionCfg.positionsCompressed Flat float Local-space positionsCompressed array.
171
+ * @param [portionCfg.normals] Flat float normals array.
172
+ * @param [portionCfg.colors] Flat float colors array.
173
+ * @param portionCfg.indices Flat int indices array.
174
+ * @param [portionCfg.edgeIndices] Flat int edges indices array.
175
+ * @param portionCfg.color Quantized RGB color [0..255,0..255,0..255,0..255]
176
+ * @param portionCfg.metallic Metalness factor [0..255]
177
+ * @param portionCfg.roughness Roughness factor [0..255]
178
+ * @param portionCfg.opacity Opacity [0..255]
179
+ * @param [portionCfg.meshMatrix] Flat float 4x4 matrix - transforms the portion within the coordinate system that's local to the SceneModel
180
+ * @param portionCfg.worldAABB Flat float AABB World-space AABB
181
+ * @param portionCfg.pickColor Quantized pick color
182
+ * @returns {number} Portion ID
183
+ */
184
+ createPortion(portionCfg) {
185
+ if (this._finalized) {
186
+ throw "Already finalized";
187
+ }
188
+ const subPortionIds = [];
189
+ const portionAABB = portionCfg.worldAABB;
190
+ portionCfg.buckets.forEach((bucket, bucketIndex) => {
191
+ const bucketGeometryId = portionCfg.geometryId !== undefined && portionCfg.geometryId !== null
192
+ ? `${portionCfg.geometryId}#${bucketIndex}`
193
+ : `${portionCfg.id}#${bucketIndex}`;
194
+ let bucketGeometry = this._bucketGeometries[bucketGeometryId];
195
+ if (!bucketGeometry) {
196
+ bucketGeometry = this._createBucketGeometry(portionCfg, bucket);
197
+ this._bucketGeometries[bucketGeometryId] = bucketGeometry;
198
+ }
199
+ const subPortionAABB = math.collapseAABB3(tempAABB3b);
200
+ const subPortionId = this._createSubPortion(portionCfg, bucketGeometry, bucket, subPortionAABB);
201
+ math.expandAABB3(portionAABB, subPortionAABB);
202
+ subPortionIds.push(subPortionId);
203
+ });
204
+ const origin = this._state.origin;
205
+ if (origin[0] !== 0 || origin[1] !== 0 || origin[2] !== 0) {
206
+ portionAABB[0] += origin[0];
207
+ portionAABB[1] += origin[1];
208
+ portionAABB[2] += origin[2];
209
+ portionAABB[3] += origin[0];
210
+ portionAABB[4] += origin[1];
211
+ portionAABB[5] += origin[2];
212
+ }
213
+ math.expandAABB3(this.aabb, portionAABB);
214
+ const portionId = this._portionToSubPortionsMap.length;
215
+ this._portionToSubPortionsMap.push(subPortionIds);
216
+ this.model.numPortions++;
217
+ return portionId;
218
+ }
219
+
220
+ _createBucketGeometry(portionCfg, bucket) {
221
+
222
+ // Indices alignement
223
+ // This will make every mesh consume a multiple of INDICES_EDGE_INDICES_ALIGNEMENT_SIZE
224
+ // array items for storing the triangles of the mesh, and it supports:
225
+ // - a memory optimization of factor INDICES_EDGE_INDICES_ALIGNEMENT_SIZE
226
+ // - in exchange for a small RAM overhead
227
+ // (by adding some padding until a size that is multiple of INDICES_EDGE_INDICES_ALIGNEMENT_SIZE)
228
+
229
+ if (bucket.indices) {
230
+ const alignedIndicesLen = Math.ceil((bucket.indices.length / 3) / INDICES_EDGE_INDICES_ALIGNEMENT_SIZE) * INDICES_EDGE_INDICES_ALIGNEMENT_SIZE * 3;
231
+ dataTextureRamStats.overheadSizeAlignementIndices += 2 * (alignedIndicesLen - bucket.indices.length);
232
+ const alignedIndices = new Uint32Array(alignedIndicesLen);
233
+ alignedIndices.fill(0);
234
+ alignedIndices.set(bucket.indices);
235
+ bucket.indices = alignedIndices;
236
+ }
237
+
238
+ // EdgeIndices alignement
239
+ // This will make every mesh consume a multiple of INDICES_EDGE_INDICES_ALIGNEMENT_SIZE
240
+ // array items for storing the edges of the mesh, and it supports:
241
+ // - a memory optimization of factor INDICES_EDGE_INDICES_ALIGNEMENT_SIZE
242
+ // - in exchange for a small RAM overhead
243
+ // (by adding some padding until a size that is multiple of INDICES_EDGE_INDICES_ALIGNEMENT_SIZE)
244
+
245
+ if (bucket.edgeIndices) {
246
+ const alignedEdgeIndicesLen = Math.ceil((bucket.edgeIndices.length / 2) / INDICES_EDGE_INDICES_ALIGNEMENT_SIZE) * INDICES_EDGE_INDICES_ALIGNEMENT_SIZE * 2;
247
+ dataTextureRamStats.overheadSizeAlignementEdgeIndices += 2 * (alignedEdgeIndicesLen - bucket.edgeIndices.length);
248
+ const alignedEdgeIndices = new Uint32Array(alignedEdgeIndicesLen);
249
+ alignedEdgeIndices.fill(0);
250
+ alignedEdgeIndices.set(bucket.edgeIndices);
251
+ bucket.edgeIndices = alignedEdgeIndices;
252
+ }
253
+
254
+ const positionsCompressed = bucket.positionsCompressed;
255
+ const indices = bucket.indices;
256
+ const edgeIndices = bucket.edgeIndices;
257
+ const buffer = this._buffer;
258
+ const vertexBase = buffer.positionsCompressed.length / 3;
259
+ const numVertices = positionsCompressed.length / 3;
260
+
261
+ for (let i = 0, len = positionsCompressed.length; i < len; i++) {
262
+ buffer.positionsCompressed.push(positionsCompressed[i]);
263
+ }
264
+
265
+ let indicesBase;
266
+ let numTriangles = 0;
267
+ if (indices) {
268
+ numTriangles = indices.length / 3;
269
+ let indicesBuffer;
270
+ if (numVertices <= (1 << 8)) {
271
+ indicesBuffer = buffer.indices8Bits;
272
+ } else if (numVertices <= (1 << 16)) {
273
+ indicesBuffer = buffer.indices16Bits;
274
+ } else {
275
+ indicesBuffer = buffer.indices32Bits;
276
+ }
277
+ indicesBase = indicesBuffer.length / 3;
278
+ for (let i = 0, len = indices.length; i < len; i++) {
279
+ indicesBuffer.push(indices[i]);
280
+ }
281
+ }
282
+
283
+ let edgeIndicesBase;
284
+ let numEdges = 0;
285
+ if (edgeIndices) {
286
+ numEdges = edgeIndices.length / 2;
287
+ let edgeIndicesBuffer;
288
+ if (numVertices <= (1 << 8)) {
289
+ edgeIndicesBuffer = buffer.edgeIndices8Bits;
290
+ } else if (numVertices <= (1 << 16)) {
291
+ edgeIndicesBuffer = buffer.edgeIndices16Bits;
292
+ } else {
293
+ edgeIndicesBuffer = buffer.edgeIndices32Bits;
294
+ }
295
+ edgeIndicesBase = edgeIndicesBuffer.length / 2;
296
+ for (let i = 0, len = edgeIndices.length; i < len; i++) {
297
+ edgeIndicesBuffer.push(edgeIndices[i]);
298
+ }
299
+ }
300
+
301
+ this._state.numVertices += numVertices;
302
+
303
+ dataTextureRamStats.numberOfGeometries++;
304
+
305
+ const aabb = math.collapseAABB3();
306
+ math.expandAABB3Points3(aabb, bucket.positionsCompressed);
307
+ geometryCompressionUtils.decompressAABB(aabb, portionCfg.positionsDecodeMatrix);
308
+
309
+ const bucketGeometry = {
310
+ vertexBase,
311
+ numVertices,
312
+ numTriangles,
313
+ numEdges,
314
+ indicesBase,
315
+ edgeIndicesBase,
316
+ aabb,
317
+ obb: null // Lazy-created in _createSubPortion if needed
318
+ };
319
+
320
+ return bucketGeometry;
321
+ }
322
+
323
+ _createSubPortion(portionCfg, bucketGeometry, bucket, subPortionAABB) {
324
+
325
+ const color = portionCfg.color;
326
+ const metallic = portionCfg.metallic;
327
+ const roughness = portionCfg.roughness;
328
+ const colors = portionCfg.colors;
329
+ const opacity = portionCfg.opacity;
330
+ const meshMatrix = portionCfg.meshMatrix;
331
+ const pickColor = portionCfg.pickColor;
332
+ const buffer = this._buffer;
333
+ const state = this._state;
334
+
335
+ buffer.perObjectPositionsDecodeMatrices.push(portionCfg.positionsDecodeMatrix);
336
+ buffer.perObjectInstancePositioningMatrices.push(meshMatrix || DEFAULT_MATRIX);
337
+
338
+ if (meshMatrix) { // NB: SceneModel world matrix is used in shaders and SceneModelMesh.aabb
339
+
340
+ if (!bucketGeometry.obb) {
341
+ bucketGeometry.obb = math.AABB3ToOBB3(bucketGeometry.aabb);
342
+ }
343
+ const geometryOBB = bucketGeometry.obb;
344
+ for (let i = 0, len = geometryOBB.length; i < len; i += 4) {
345
+ tempVec4a[0] = geometryOBB[i + 0];
346
+ tempVec4a[1] = geometryOBB[i + 1];
347
+ tempVec4a[2] = geometryOBB[i + 2];
348
+ tempVec4a[3] = 1.0;
349
+ if (meshMatrix) {
350
+ math.transformPoint4(meshMatrix, tempVec4a, tempVec4b);
351
+ }
352
+ math.expandAABB3Point3(subPortionAABB, tempVec4b);
353
+ }
354
+ } else {
355
+ math.expandAABB3(subPortionAABB, bucketGeometry.aabb);
356
+ }
357
+
358
+ buffer.perObjectSolid.push(!!portionCfg.solid);
359
+
360
+ if (colors) {
361
+ buffer.perObjectColors.push([colors[0] * 255, colors[1] * 255, colors[2] * 255, 255]);
362
+ } else if (color) { // Color is pre-quantized by SceneModel
363
+ buffer.perObjectColors.push([color[0], color[1], color[2], opacity]);
364
+ }
365
+
366
+ buffer.perObjectPickColors.push(pickColor);
367
+ buffer.perObjectVertexBases.push(bucketGeometry.vertexBase);
368
+
369
+ {
370
+ let currentNumIndices;
371
+ if (bucketGeometry.numVertices <= (1 << 8)) {
372
+ currentNumIndices = state.numIndices8Bits;
373
+ } else if (bucketGeometry.numVertices <= (1 << 16)) {
374
+ currentNumIndices = state.numIndices16Bits;
375
+ } else {
376
+ currentNumIndices = state.numIndices32Bits;
377
+ }
378
+ buffer.perObjectIndexBaseOffsets.push(currentNumIndices / 3 - bucketGeometry.indicesBase);
379
+ }
380
+
381
+ {
382
+ let currentNumEdgeIndices;
383
+ if (bucketGeometry.numVertices <= (1 << 8)) {
384
+ currentNumEdgeIndices = state.numEdgeIndices8Bits;
385
+ } else if (bucketGeometry.numVertices <= (1 << 16)) {
386
+ currentNumEdgeIndices = state.numEdgeIndices16Bits;
387
+ } else {
388
+ currentNumEdgeIndices = state.numEdgeIndices32Bits;
389
+ }
390
+ buffer.perObjectEdgeIndexBaseOffsets.push(currentNumEdgeIndices / 2 - bucketGeometry.edgeIndicesBase);
391
+ }
392
+
393
+ const subPortionId = this._subPortions.length;
394
+ if (bucketGeometry.numTriangles > 0) {
395
+ let numIndices = bucketGeometry.numTriangles * 3;
396
+ let indicesPortionIdBuffer;
397
+ if (bucketGeometry.numVertices <= (1 << 8)) {
398
+ indicesPortionIdBuffer = buffer.perTriangleNumberPortionId8Bits;
399
+ state.numIndices8Bits += numIndices;
400
+ dataTextureRamStats.totalPolygons8Bits += bucketGeometry.numTriangles;
401
+ } else if (bucketGeometry.numVertices <= (1 << 16)) {
402
+ indicesPortionIdBuffer = buffer.perTriangleNumberPortionId16Bits;
403
+ state.numIndices16Bits += numIndices;
404
+ dataTextureRamStats.totalPolygons16Bits += bucketGeometry.numTriangles;
405
+ } else {
406
+ indicesPortionIdBuffer = buffer.perTriangleNumberPortionId32Bits;
407
+ state.numIndices32Bits += numIndices;
408
+ dataTextureRamStats.totalPolygons32Bits += bucketGeometry.numTriangles;
409
+ }
410
+ dataTextureRamStats.totalPolygons += bucketGeometry.numTriangles;
411
+ for (let i = 0; i < bucketGeometry.numTriangles; i += INDICES_EDGE_INDICES_ALIGNEMENT_SIZE) {
412
+ indicesPortionIdBuffer.push(subPortionId);
413
+ }
414
+ }
415
+
416
+ if (bucketGeometry.numEdges > 0) {
417
+ let numEdgeIndices = bucketGeometry.numEdges * 2;
418
+ let edgeIndicesPortionIdBuffer;
419
+ if (bucketGeometry.numVertices <= (1 << 8)) {
420
+ edgeIndicesPortionIdBuffer = buffer.perEdgeNumberPortionId8Bits;
421
+ state.numEdgeIndices8Bits += numEdgeIndices;
422
+ dataTextureRamStats.totalEdges8Bits += bucketGeometry.numEdges;
423
+ } else if (bucketGeometry.numVertices <= (1 << 16)) {
424
+ edgeIndicesPortionIdBuffer = buffer.perEdgeNumberPortionId16Bits;
425
+ state.numEdgeIndices16Bits += numEdgeIndices;
426
+ dataTextureRamStats.totalEdges16Bits += bucketGeometry.numEdges;
427
+ } else {
428
+ edgeIndicesPortionIdBuffer = buffer.perEdgeNumberPortionId32Bits;
429
+ state.numEdgeIndices32Bits += numEdgeIndices;
430
+ dataTextureRamStats.totalEdges32Bits += bucketGeometry.numEdges;
431
+ }
432
+ dataTextureRamStats.totalEdges += bucketGeometry.numEdges;
433
+ for (let i = 0; i < bucketGeometry.numEdges; i += INDICES_EDGE_INDICES_ALIGNEMENT_SIZE) {
434
+ edgeIndicesPortionIdBuffer.push(subPortionId);
435
+ }
436
+ }
437
+
438
+ // buffer.perObjectOffsets.push([0, 0, 0]);
439
+
440
+ this._subPortions.push({
441
+ // vertsBase: vertsIndex,
442
+ numVertices: bucketGeometry.numTriangles
443
+ });
444
+
445
+ this._numPortions++;
446
+
447
+ dataTextureRamStats.numberOfPortions++;
448
+
449
+ return subPortionId;
450
+ }
451
+
452
+ /**
453
+ * Builds data textures from the appended geometries and loads them into the GPU.
454
+ *
455
+ * No more portions can then be created.
456
+ */
457
+ finalize() {
458
+
459
+ if (this._finalized) {
460
+ return;
461
+ }
462
+
463
+ const state = this._state;
464
+ const textureState = this._dataTextureState;
465
+ const gl = this.model.scene.canvas.gl;
466
+ const buffer = this._buffer;
467
+
468
+ state.gl = gl;
469
+
470
+ textureState.texturePerObjectIdColorsAndFlags = this._dataTextureGenerator.generateTextureForColorsAndFlags(
471
+ gl,
472
+ buffer.perObjectColors,
473
+ buffer.perObjectPickColors,
474
+ buffer.perObjectVertexBases,
475
+ buffer.perObjectIndexBaseOffsets,
476
+ buffer.perObjectEdgeIndexBaseOffsets,
477
+ buffer.perObjectSolid);
478
+
479
+ textureState.texturePerObjectIdOffsets
480
+ = this._dataTextureGenerator.generateTextureForObjectOffsets(gl, this._numPortions);
481
+
482
+ textureState.texturePerObjectIdPositionsDecodeMatrix = this._dataTextureGenerator.generateTextureForPositionsDecodeMatrices(
483
+ gl,
484
+ buffer.perObjectPositionsDecodeMatrices,
485
+ buffer.perObjectInstancePositioningMatrices);
486
+
487
+ textureState.texturePerVertexIdCoordinates = this._dataTextureGenerator.generateTextureForPositions(
488
+ gl,
489
+ buffer.positionsCompressed);
490
+
491
+ textureState.texturePerPolygonIdPortionIds8Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
492
+ gl,
493
+ buffer.perTriangleNumberPortionId8Bits);
494
+
495
+ textureState.texturePerPolygonIdPortionIds16Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
496
+ gl,
497
+ buffer.perTriangleNumberPortionId16Bits);
498
+
499
+ textureState.texturePerPolygonIdPortionIds32Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
500
+ gl,
501
+ buffer.perTriangleNumberPortionId32Bits);
502
+
503
+ if (buffer.perEdgeNumberPortionId8Bits.length > 0) {
504
+ textureState.texturePerEdgeIdPortionIds8Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
505
+ gl,
506
+ buffer.perEdgeNumberPortionId8Bits);
507
+ }
508
+
509
+ if (buffer.perEdgeNumberPortionId16Bits.length > 0) {
510
+ textureState.texturePerEdgeIdPortionIds16Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
511
+ gl,
512
+ buffer.perEdgeNumberPortionId16Bits);
513
+ }
514
+
515
+
516
+ if (buffer.perEdgeNumberPortionId32Bits.length > 0) {
517
+ textureState.texturePerEdgeIdPortionIds32Bits = this._dataTextureGenerator.generateTextureForPackedPortionIds(
518
+ gl,
519
+ buffer.perEdgeNumberPortionId32Bits);
520
+ }
521
+
522
+ if (buffer.indices8Bits.length > 0) {
523
+ textureState.texturePerPolygonIdIndices8Bits = this._dataTextureGenerator.generateTextureFor8BitIndices(
524
+ gl,
525
+ buffer.indices8Bits);
526
+ }
527
+
528
+ if (buffer.indices16Bits.length > 0) {
529
+ textureState.texturePerPolygonIdIndices16Bits = this._dataTextureGenerator.generateTextureFor16BitIndices(
530
+ gl,
531
+ buffer.indices16Bits);
532
+ }
533
+
534
+ if (buffer.indices32Bits.length > 0) {
535
+ textureState.texturePerPolygonIdIndices32Bits = this._dataTextureGenerator.generateTextureFor32BitIndices(
536
+ gl,
537
+ buffer.indices32Bits);
538
+ }
539
+
540
+ if (buffer.edgeIndices8Bits.length > 0) {
541
+ textureState.texturePerPolygonIdEdgeIndices8Bits = this._dataTextureGenerator.generateTextureFor8BitsEdgeIndices(
542
+ gl,
543
+ buffer.edgeIndices8Bits);
544
+ }
545
+
546
+ if (buffer.edgeIndices16Bits.length > 0) {
547
+ textureState.texturePerPolygonIdEdgeIndices16Bits = this._dataTextureGenerator.generateTextureFor16BitsEdgeIndices(
548
+ gl,
549
+ buffer.edgeIndices16Bits);
550
+ }
551
+
552
+ if (buffer.edgeIndices32Bits.length > 0) {
553
+ textureState.texturePerPolygonIdEdgeIndices32Bits = this._dataTextureGenerator.generateTextureFor32BitsEdgeIndices(
554
+ gl,
555
+ buffer.edgeIndices32Bits);
556
+ }
557
+
558
+ // if (buffer.metallicRoughness.length > 0) {
559
+ // const metallicRoughness = new Uint8Array(buffer.metallicRoughness);
560
+ // let normalized = false;
561
+ // state.metallicRoughnessBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, metallicRoughness, buffer.metallicRoughness.length, 2, gl.STATIC_DRAW, normalized);
562
+ // }
563
+
564
+ // Model matrices texture
565
+ if (!this.model._modelMatricesTexture) {
566
+ this.model._modelMatricesTexture = this._dataTextureGenerator.generateModelTexture(gl, this.model);
567
+ }
568
+
569
+ textureState.textureModelMatrices = this.model._modelMatricesTexture;
570
+
571
+ // Camera textures
572
+
573
+ textureState.cameraTexture = this._dataTextureGenerator.generateCameraDataTexture(
574
+ this.model.scene.canvas.gl,
575
+ this.model.scene.camera,
576
+ this.model.scene,
577
+ this._state.origin.slice());
578
+
579
+ textureState.textureCameraMatrices = textureState.cameraTexture;
580
+
581
+ textureState.texturePickCameraMatrices = this._dataTextureGenerator.generatePickCameraDataTexture(
582
+ this.model.scene.canvas.gl,
583
+ this.model.scene.camera,
584
+ this._state.origin.slice());
585
+
586
+ textureState.finalize();
587
+
588
+ // Free up memory
589
+ this._buffer = null;
590
+ this._bucketGeometries = {};
591
+ this._finalized = true;
592
+ this._deferredSetFlagsDirty = false; //
593
+
594
+ this._onSceneRendering = this.model.scene.on("rendering", () => {
595
+ if (this._deferredSetFlagsDirty) {
596
+ this._uploadDeferredFlags();
597
+ }
598
+ this._numUpdatesInFrame = 0;
599
+ });
600
+ }
601
+
602
+ isEmpty() {
603
+ return this._numPortions === 0;
604
+ }
605
+
606
+ initFlags(portionId, flags, meshTransparent) {
607
+ if (flags & ENTITY_FLAGS.VISIBLE) {
608
+ this._numVisibleLayerPortions++;
609
+ this.model.numVisibleLayerPortions++;
610
+ }
611
+ if (flags & ENTITY_FLAGS.HIGHLIGHTED) {
612
+ this._numHighlightedLayerPortions++;
613
+ this.model.numHighlightedLayerPortions++;
614
+ }
615
+ if (flags & ENTITY_FLAGS.XRAYED) {
616
+ this._numXRayedLayerPortions++;
617
+ this.model.numXRayedLayerPortions++;
618
+ }
619
+ if (flags & ENTITY_FLAGS.SELECTED) {
620
+ this._numSelectedLayerPortions++;
621
+ this.model.numSelectedLayerPortions++;
622
+ }
623
+ if (flags & ENTITY_FLAGS.CLIPPABLE) {
624
+ this._numClippableLayerPortions++;
625
+ this.model.numClippableLayerPortions++;
626
+ }
627
+ if (flags & ENTITY_FLAGS.EDGES) {
628
+ this._numEdgesLayerPortions++;
629
+ this.model.numEdgesLayerPortions++;
630
+ }
631
+ if (flags & ENTITY_FLAGS.PICKABLE) {
632
+ this._numPickableLayerPortions++;
633
+ this.model.numPickableLayerPortions++;
634
+ }
635
+ if (flags & ENTITY_FLAGS.CULLED) {
636
+ this._numCulledLayerPortions++;
637
+ this.model.numCulledLayerPortions++;
638
+ }
639
+ if (meshTransparent) {
640
+ this._numTransparentLayerPortions++;
641
+ this.model.numTransparentLayerPortions++;
642
+ }
643
+ const deferred = true;
644
+ this._setFlags(portionId, flags, meshTransparent, deferred);
645
+ this._setFlags2(portionId, flags, deferred);
646
+ }
647
+
648
+ flushInitFlags() {
649
+ this._setDeferredFlags();
650
+ this._setDeferredFlags2();
651
+ }
652
+
653
+ setVisible(portionId, flags, transparent) {
654
+ if (!this._finalized) {
655
+ throw "Not finalized";
656
+ }
657
+ if (flags & ENTITY_FLAGS.VISIBLE) {
658
+ this._numVisibleLayerPortions++;
659
+ this.model.numVisibleLayerPortions++;
660
+ } else {
661
+ this._numVisibleLayerPortions--;
662
+ this.model.numVisibleLayerPortions--;
663
+ }
664
+ this._setFlags(portionId, flags, transparent);
665
+ }
666
+
667
+ setHighlighted(portionId, flags, transparent) {
668
+ if (!this._finalized) {
669
+ throw "Not finalized";
670
+ }
671
+ if (flags & ENTITY_FLAGS.HIGHLIGHTED) {
672
+ this._numHighlightedLayerPortions++;
673
+ this.model.numHighlightedLayerPortions++;
674
+ } else {
675
+ this._numHighlightedLayerPortions--;
676
+ this.model.numHighlightedLayerPortions--;
677
+ }
678
+ this._setFlags(portionId, flags, transparent);
679
+ }
680
+
681
+ setXRayed(portionId, flags, transparent) {
682
+ if (!this._finalized) {
683
+ throw "Not finalized";
684
+ }
685
+ if (flags & ENTITY_FLAGS.XRAYED) {
686
+ this._numXRayedLayerPortions++;
687
+ this.model.numXRayedLayerPortions++;
688
+ } else {
689
+ this._numXRayedLayerPortions--;
690
+ this.model.numXRayedLayerPortions--;
691
+ }
692
+ this._setFlags(portionId, flags, transparent);
693
+ }
694
+
695
+ setSelected(portionId, flags, transparent) {
696
+ if (!this._finalized) {
697
+ throw "Not finalized";
698
+ }
699
+ if (flags & ENTITY_FLAGS.SELECTED) {
700
+ this._numSelectedLayerPortions++;
701
+ this.model.numSelectedLayerPortions++;
702
+ } else {
703
+ this._numSelectedLayerPortions--;
704
+ this.model.numSelectedLayerPortions--;
705
+ }
706
+ this._setFlags(portionId, flags, transparent);
707
+ }
708
+
709
+ setEdges(portionId, flags, transparent) {
710
+ if (!this._finalized) {
711
+ throw "Not finalized";
712
+ }
713
+ if (flags & ENTITY_FLAGS.EDGES) {
714
+ this._numEdgesLayerPortions++;
715
+ this.model.numEdgesLayerPortions++;
716
+ } else {
717
+ this._numEdgesLayerPortions--;
718
+ this.model.numEdgesLayerPortions--;
719
+ }
720
+ this._setFlags(portionId, flags, transparent);
721
+ }
722
+
723
+ setClippable(portionId, flags) {
724
+ if (!this._finalized) {
725
+ throw "Not finalized";
726
+ }
727
+ if (flags & ENTITY_FLAGS.CLIPPABLE) {
728
+ this._numClippableLayerPortions++;
729
+ this.model.numClippableLayerPortions++;
730
+ } else {
731
+ this._numClippableLayerPortions--;
732
+ this.model.numClippableLayerPortions--;
733
+ }
734
+ this._setFlags2(portionId, flags);
735
+ }
736
+
737
+ /**
738
+ * This will _start_ a "set-flags transaction".
739
+ *
740
+ * After invoking this method, calling setFlags/setFlags2 will not update
741
+ * the colors+flags texture but only store the new flags/flag2 in the
742
+ * colors+flags texture data array.
743
+ *
744
+ * After invoking this method, and when all desired setFlags/setFlags2 have
745
+ * been called on needed portions of the layer, invoke `_uploadDeferredFlags`
746
+ * to actually upload the data array into the texture.
747
+ *
748
+ * In massive "set-flags" scenarios like VFC or LOD mechanisms, the combination of
749
+ * `_beginDeferredFlags` + `_uploadDeferredFlags`brings a speed-up of
750
+ * up to 80x when e.g. objects are massively (un)culled 🚀.
751
+ */
752
+ _beginDeferredFlags() {
753
+ this._deferredSetFlagsActive = true;
754
+ }
755
+
756
+ /**
757
+ * This will _commit_ a "set-flags transaction".
758
+ *
759
+ * Invoking this method will update the colors+flags texture data with new
760
+ * flags/flags2 set since the previous invocation of `_beginDeferredFlags`.
761
+ */
762
+ _uploadDeferredFlags() {
763
+ // console.log("_uploadDeferredFlags")
764
+ this._deferredSetFlagsActive = false;
765
+ if (!this._deferredSetFlagsDirty) {
766
+ return;
767
+ }
768
+ this._deferredSetFlagsDirty = false;
769
+ const gl = this.model.scene.canvas.gl;
770
+ const textureState = this._dataTextureState;
771
+ gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectIdColorsAndFlags._texture);
772
+ gl.texSubImage2D(
773
+ gl.TEXTURE_2D,
774
+ 0, // level
775
+ 0, // xoffset
776
+ 0, // yoffset
777
+ textureState.texturePerObjectIdColorsAndFlags._textureWidth, // width
778
+ textureState.texturePerObjectIdColorsAndFlags._textureHeight, // width
779
+ gl.RGBA_INTEGER,
780
+ gl.UNSIGNED_BYTE,
781
+ textureState.texturePerObjectIdColorsAndFlags._textureData
782
+ );
783
+ gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectIdOffsets._texture);
784
+ gl.texSubImage2D(
785
+ gl.TEXTURE_2D,
786
+ 0, // level
787
+ 0, // xoffset
788
+ 0, // yoffset
789
+ textureState.texturePerObjectIdOffsets._textureWidth, // width
790
+ textureState.texturePerObjectIdOffsets._textureHeight, // width
791
+ gl.RGB,
792
+ gl.FLOAT,
793
+ textureState.texturePerObjectIdOffsets._textureData
794
+ );
795
+ }
796
+
797
+ setCulled(portionId, flags, transparent) {
798
+ if (!this._finalized) {
799
+ throw "Not finalized";
800
+ }
801
+ if (flags & ENTITY_FLAGS.CULLED) {
802
+ this._numCulledLayerPortions += this._portionToSubPortionsMap[portionId].length;
803
+ this.model.numCulledLayerPortions++;
804
+ } else {
805
+ this._numCulledLayerPortions -= this._portionToSubPortionsMap[portionId].length;
806
+ this.model.numCulledLayerPortions--;
807
+ }
808
+ this._setFlags(portionId, flags, transparent);
809
+ }
810
+
811
+ setCollidable(portionId, flags) {
812
+ if (!this._finalized) {
813
+ throw "Not finalized";
814
+ }
815
+ }
816
+
817
+ setPickable(portionId, flags, transparent) {
818
+ if (!this._finalized) {
819
+ throw "Not finalized";
820
+ }
821
+ if (flags & ENTITY_FLAGS.PICKABLE) {
822
+ this._numPickableLayerPortions++;
823
+ this.model.numPickableLayerPortions++;
824
+ } else {
825
+ this._numPickableLayerPortions--;
826
+ this.model.numPickableLayerPortions--;
827
+ }
828
+ this._setFlags(portionId, flags, transparent);
829
+ }
830
+
831
+ setColor(portionId, color) {
832
+ const subPortionIds = this._portionToSubPortionsMap[portionId];
833
+ for (let i = 0, len = subPortionIds.length; i < len; i++) {
834
+ this._subPortionSetColor(subPortionIds[i], color);
835
+ }
836
+ }
837
+
838
+ _subPortionSetColor(subPortionId, color) {
839
+ if (!this._finalized) {
840
+ throw "Not finalized";
841
+ }
842
+ // Color
843
+ const textureState = this._dataTextureState;
844
+ const gl = this.model.scene.canvas.gl;
845
+ tempUint8Array4 [0] = color[0];
846
+ tempUint8Array4 [1] = color[1];
847
+ tempUint8Array4 [2] = color[2];
848
+ tempUint8Array4 [3] = color[3];
849
+ // object colors
850
+ textureState.texturePerObjectIdColorsAndFlags._textureData.set(tempUint8Array4, subPortionId * 32);
851
+ if (this._deferredSetFlagsActive) {
852
+ // console.log("_subPortionSetColor defer");
853
+ this._deferredSetFlagsDirty = true;
854
+ return;
855
+ }
856
+ if (++this._numUpdatesInFrame >= MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE) {
857
+ this._beginDeferredFlags(); // Subsequent flags updates now deferred
858
+ }
859
+ // console.log("_subPortionSetColor write through");
860
+ gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectIdColorsAndFlags._texture);
861
+ gl.texSubImage2D(
862
+ gl.TEXTURE_2D,
863
+ 0, // level
864
+ (subPortionId % 512) * 8, // xoffset
865
+ Math.floor(subPortionId / 512), // yoffset
866
+ 1, // width
867
+ 1, //height
868
+ gl.RGBA_INTEGER,
869
+ gl.UNSIGNED_BYTE,
870
+ tempUint8Array4
871
+ );
872
+ // gl.bindTexture (gl.TEXTURE_2D, null);
873
+ }
874
+
875
+ setTransparent(portionId, flags, transparent) {
876
+ if (transparent) {
877
+ this._numTransparentLayerPortions++;
878
+ this.model.numTransparentLayerPortions++;
879
+ } else {
880
+ this._numTransparentLayerPortions--;
881
+ this.model.numTransparentLayerPortions--;
882
+ }
883
+ this._setFlags(portionId, flags, transparent);
884
+ }
885
+
886
+ _setFlags(portionId, flags, transparent, deferred = false) {
887
+ const subPortionIds = this._portionToSubPortionsMap[portionId];
888
+ for (let i = 0, len = subPortionIds.length; i < len; i++) {
889
+ this._subPortionSetFlags(subPortionIds[i], flags, transparent, deferred);
890
+ }
891
+ }
892
+
893
+ _subPortionSetFlags(subPortionId, flags, transparent, deferred = false) {
894
+ if (!this._finalized) {
895
+ throw "Not finalized";
896
+ }
897
+
898
+ const visible = !!(flags & ENTITY_FLAGS.VISIBLE);
899
+ const xrayed = !!(flags & ENTITY_FLAGS.XRAYED);
900
+ const highlighted = !!(flags & ENTITY_FLAGS.HIGHLIGHTED);
901
+ const selected = !!(flags & ENTITY_FLAGS.SELECTED);
902
+ const edges = !!(flags & ENTITY_FLAGS.EDGES);
903
+ const pickable = !!(flags & ENTITY_FLAGS.PICKABLE);
904
+ const culled = !!(flags & ENTITY_FLAGS.CULLED);
905
+
906
+ // Color
907
+
908
+ let f0;
909
+ if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
910
+ f0 = RENDER_PASSES.NOT_RENDERED;
911
+ } else {
912
+ if (transparent) {
913
+ f0 = RENDER_PASSES.COLOR_TRANSPARENT;
914
+ } else {
915
+ f0 = RENDER_PASSES.COLOR_OPAQUE;
916
+ }
917
+ }
918
+
919
+ // Silhouette
920
+
921
+ let f1;
922
+ if (!visible || culled) {
923
+ f1 = RENDER_PASSES.NOT_RENDERED;
924
+ } else if (selected) {
925
+ f1 = RENDER_PASSES.SILHOUETTE_SELECTED;
926
+ } else if (highlighted) {
927
+ f1 = RENDER_PASSES.SILHOUETTE_HIGHLIGHTED;
928
+ } else if (xrayed) {
929
+ f1 = RENDER_PASSES.SILHOUETTE_XRAYED;
930
+ } else {
931
+ f1 = RENDER_PASSES.NOT_RENDERED;
932
+ }
933
+
934
+ // Edges
935
+
936
+ let f2 = 0;
937
+ if (!visible || culled) {
938
+ f2 = RENDER_PASSES.NOT_RENDERED;
939
+ } else if (selected) {
940
+ f2 = RENDER_PASSES.EDGES_SELECTED;
941
+ } else if (highlighted) {
942
+ f2 = RENDER_PASSES.EDGES_HIGHLIGHTED;
943
+ } else if (xrayed) {
944
+ f2 = RENDER_PASSES.EDGES_XRAYED;
945
+ } else if (edges) {
946
+ if (transparent) {
947
+ f2 = RENDER_PASSES.EDGES_COLOR_TRANSPARENT;
948
+ } else {
949
+ f2 = RENDER_PASSES.EDGES_COLOR_OPAQUE;
950
+ }
951
+ } else {
952
+ f2 = RENDER_PASSES.NOT_RENDERED;
953
+ }
954
+
955
+ // Pick
956
+
957
+ let f3 = (visible && pickable) ? RENDER_PASSES.PICK : RENDER_PASSES.NOT_RENDERED;
958
+ const textureState = this._dataTextureState;
959
+ const gl = this.model.scene.canvas.gl;
960
+ tempUint8Array4 [0] = f0;
961
+ tempUint8Array4 [1] = f1;
962
+ tempUint8Array4 [2] = f2;
963
+ tempUint8Array4 [3] = f3;
964
+ // object flags
965
+ textureState.texturePerObjectIdColorsAndFlags._textureData.set(tempUint8Array4, subPortionId * 32 + 8);
966
+ if (this._deferredSetFlagsActive || deferred) {
967
+ // console.log("_subPortionSetFlags set flags defer");
968
+ this._deferredSetFlagsDirty = true;
969
+ return;
970
+ }
971
+ if (++this._numUpdatesInFrame >= MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE) {
972
+ this._beginDeferredFlags(); // Subsequent flags updates now deferred
973
+ }
974
+ // console.log("_subPortionSetFlags set flags write through");
975
+ gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectIdColorsAndFlags._texture);
976
+ gl.texSubImage2D(
977
+ gl.TEXTURE_2D,
978
+ 0, // level
979
+ (subPortionId % 512) * 8 + 2, // xoffset
980
+ Math.floor(subPortionId / 512), // yoffset
981
+ 1, // width
982
+ 1, //height
983
+ gl.RGBA_INTEGER,
984
+ gl.UNSIGNED_BYTE,
985
+ tempUint8Array4
986
+ );
987
+ // gl.bindTexture (gl.TEXTURE_2D, null);
988
+ }
989
+
990
+ _setDeferredFlags() {
991
+ }
992
+
993
+ _setFlags2(portionId, flags, deferred = false) {
994
+ const subPortionIds = this._portionToSubPortionsMap[portionId];
995
+ for (let i = 0, len = subPortionIds.length; i < len; i++) {
996
+ this._subPortionSetFlags2(subPortionIds[i], flags, deferred);
997
+ }
998
+ }
999
+
1000
+ _subPortionSetFlags2(subPortionId, flags, deferred = false) {
1001
+ if (!this._finalized) {
1002
+ throw "Not finalized";
1003
+ }
1004
+ const clippable = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 255 : 0;
1005
+ const textureState = this._dataTextureState;
1006
+ const gl = this.model.scene.canvas.gl;
1007
+ tempUint8Array4 [0] = clippable;
1008
+ tempUint8Array4 [1] = 0;
1009
+ tempUint8Array4 [2] = 1;
1010
+ tempUint8Array4 [3] = 2;
1011
+ // object flags2
1012
+ textureState.texturePerObjectIdColorsAndFlags._textureData.set(tempUint8Array4, subPortionId * 32 + 12);
1013
+ if (this._deferredSetFlagsActive || deferred) {
1014
+ // console.log("_subPortionSetFlags2 set flags defer");
1015
+ this._deferredSetFlagsDirty = true;
1016
+ return;
1017
+ }
1018
+ if (++this._numUpdatesInFrame >= MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE) {
1019
+ this._beginDeferredFlags(); // Subsequent flags updates now deferred
1020
+ }
1021
+ // console.log("_subPortionSetFlags2 set flags write through");
1022
+ gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectIdColorsAndFlags._texture);
1023
+ gl.texSubImage2D(
1024
+ gl.TEXTURE_2D,
1025
+ 0, // level
1026
+ (subPortionId % 512) * 8 + 3, // xoffset
1027
+ Math.floor(subPortionId / 512), // yoffset
1028
+ 1, // width
1029
+ 1, //height
1030
+ gl.RGBA_INTEGER,
1031
+ gl.UNSIGNED_BYTE,
1032
+ tempUint8Array4
1033
+ );
1034
+ // gl.bindTexture (gl.TEXTURE_2D, null);
1035
+ }
1036
+
1037
+ _setDeferredFlags2() {
1038
+ }
1039
+
1040
+ setOffset(portionId, offset) {
1041
+ const subPortionIds = this._portionToSubPortionsMap[portionId];
1042
+ for (let i = 0, len = subPortionIds.length; i < len; i++) {
1043
+ this._subPortionSetOffset(subPortionIds[i], offset);
1044
+ }
1045
+ }
1046
+
1047
+ _subPortionSetOffset(subPortionId, offset) {
1048
+ if (!this._finalized) {
1049
+ throw "Not finalized";
1050
+ }
1051
+ // if (!this.model.scene.entityOffsetsEnabled) {
1052
+ // this.model.error("Entity#offset not enabled for this Viewer"); // See Viewer entityOffsetsEnabled
1053
+ // return;
1054
+ // }
1055
+ const textureState = this._dataTextureState;
1056
+ const gl = this.model.scene.canvas.gl;
1057
+ tempFloat32Array3 [0] = offset[0];
1058
+ tempFloat32Array3 [1] = offset[1];
1059
+ tempFloat32Array3 [2] = offset[2];
1060
+ // object offset
1061
+ textureState.texturePerObjectIdOffsets._textureData.set(tempFloat32Array3, subPortionId * 3);
1062
+ if (this._deferredSetFlagsActive) {
1063
+ this._deferredSetFlagsDirty = true;
1064
+ return;
1065
+ }
1066
+ if (++this._numUpdatesInFrame >= MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE) {
1067
+ this._beginDeferredFlags(); // Subsequent flags updates now deferred
1068
+ }
1069
+ gl.bindTexture(gl.TEXTURE_2D, textureState.texturePerObjectIdOffsets._texture);
1070
+ gl.texSubImage2D(
1071
+ gl.TEXTURE_2D,
1072
+ 0, // level
1073
+ 0, // x offset
1074
+ subPortionId, // yoffset
1075
+ 1, // width
1076
+ 1, // height
1077
+ gl.RGB,
1078
+ gl.FLOAT,
1079
+ tempFloat32Array3
1080
+ );
1081
+ // gl.bindTexture (gl.TEXTURE_2D, null);
1082
+ }
1083
+
1084
+ // ---------------------- COLOR RENDERING -----------------------------------
1085
+
1086
+ drawColorOpaque(renderFlags, frameCtx) {
1087
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === this._numPortions || this._numXRayedLayerPortions === this._numPortions) {
1088
+ return;
1089
+ }
1090
+ this._updateBackfaceCull(renderFlags, frameCtx);
1091
+ if (frameCtx.withSAO && this.model.saoEnabled) {
1092
+ if (this._dataTextureRenderers.colorRendererWithSAO) {
1093
+ this._dataTextureRenderers.colorRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
1094
+ }
1095
+ } else {
1096
+ if (this._dataTextureRenderers.colorRenderer) {
1097
+ this._dataTextureRenderers.colorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
1098
+ }
1099
+ }
1100
+ }
1101
+
1102
+ _updateBackfaceCull(renderFlags, frameCtx) {
1103
+ const backfaces = this.model.backfaces || renderFlags.sectioned;
1104
+ if (frameCtx.backfaces !== backfaces) {
1105
+ const gl = frameCtx.gl;
1106
+ if (backfaces) {
1107
+ gl.disable(gl.CULL_FACE);
1108
+ } else {
1109
+ gl.enable(gl.CULL_FACE);
1110
+ }
1111
+ frameCtx.backfaces = backfaces;
1112
+ }
1113
+ }
1114
+
1115
+ drawColorTransparent(renderFlags, frameCtx) {
1116
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === 0 || this._numXRayedLayerPortions === this._numPortions) {
1117
+ return;
1118
+ }
1119
+ this._updateBackfaceCull(renderFlags, frameCtx);
1120
+ if (this._dataTextureRenderers.colorRenderer) {
1121
+ this._dataTextureRenderers.colorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_TRANSPARENT);
1122
+ }
1123
+ }
1124
+
1125
+ // ---------------------- RENDERING SAO POST EFFECT TARGETS --------------
1126
+
1127
+ drawDepth(renderFlags, frameCtx) {
1128
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === this._numPortions || this._numXRayedLayerPortions === this._numPortions) {
1129
+ return;
1130
+ }
1131
+ this._updateBackfaceCull(renderFlags, frameCtx);
1132
+ if (this._dataTextureRenderers.depthRenderer) {
1133
+ this._dataTextureRenderers.depthRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE); // Assume whatever post-effect uses depth (eg SAO) does not apply to transparent objects
1134
+ }
1135
+ }
1136
+
1137
+ drawNormals(renderFlags, frameCtx) {
1138
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === this._numPortions || this._numXRayedLayerPortions === this._numPortions) {
1139
+ return;
1140
+ }
1141
+ this._updateBackfaceCull(renderFlags, frameCtx);
1142
+ if (this._dataTextureRenderers.normalsRenderer) {
1143
+ this._dataTextureRenderers.normalsRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE); // Assume whatever post-effect uses normals (eg SAO) does not apply to transparent objects
1144
+ }
1145
+ }
1146
+
1147
+ // ---------------------- SILHOUETTE RENDERING -----------------------------------
1148
+
1149
+ drawSilhouetteXRayed(renderFlags, frameCtx) {
1150
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numXRayedLayerPortions === 0) {
1151
+ return;
1152
+ }
1153
+ this._updateBackfaceCull(renderFlags, frameCtx);
1154
+ if (this._dataTextureRenderers.silhouetteRenderer) {
1155
+ this._dataTextureRenderers.silhouetteRenderer.drawLayer(frameCtx, this, RENDER_PASSES.SILHOUETTE_XRAYED);
1156
+ }
1157
+ }
1158
+
1159
+ drawSilhouetteHighlighted(renderFlags, frameCtx) {
1160
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numHighlightedLayerPortions === 0) {
1161
+ return;
1162
+ }
1163
+ this._updateBackfaceCull(renderFlags, frameCtx);
1164
+ if (this._dataTextureRenderers.silhouetteRenderer) {
1165
+ this._dataTextureRenderers.silhouetteRenderer.drawLayer(frameCtx, this, RENDER_PASSES.SILHOUETTE_HIGHLIGHTED);
1166
+ }
1167
+ }
1168
+
1169
+ drawSilhouetteSelected(renderFlags, frameCtx) {
1170
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numSelectedLayerPortions === 0) {
1171
+ return;
1172
+ }
1173
+ this._updateBackfaceCull(renderFlags, frameCtx);
1174
+ if (this._dataTextureRenderers.silhouetteRenderer) {
1175
+ this._dataTextureRenderers.silhouetteRenderer.drawLayer(frameCtx, this, RENDER_PASSES.SILHOUETTE_SELECTED);
1176
+ }
1177
+ }
1178
+
1179
+ // ---------------------- EDGES RENDERING -----------------------------------
1180
+
1181
+ drawEdgesColorOpaque(renderFlags, frameCtx) {
1182
+ if (this.model.scene.logarithmicDepthBufferEnabled) {
1183
+ if (!this.model.scene._loggedWarning) {
1184
+ console.log("Edge enhancement for SceneModel data texture layers currently disabled with logarithmic depth buffer");
1185
+ this.model.scene._loggedWarning = true;
1186
+ }
1187
+ return;
1188
+ }
1189
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numEdgesLayerPortions === 0) {
1190
+ return;
1191
+ }
1192
+ if (this._dataTextureRenderers.edgesColorRenderer) {
1193
+ this._dataTextureRenderers.edgesColorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_COLOR_OPAQUE);
1194
+ }
1195
+ }
1196
+
1197
+ drawEdgesColorTransparent(renderFlags, frameCtx) {
1198
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numEdgesLayerPortions === 0 || this._numTransparentLayerPortions === 0) {
1199
+ return;
1200
+ }
1201
+ if (this._dataTextureRenderers.edgesColorRenderer) {
1202
+ this._dataTextureRenderers.edgesColorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_COLOR_TRANSPARENT);
1203
+ }
1204
+ }
1205
+
1206
+ drawEdgesHighlighted(renderFlags, frameCtx) {
1207
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numHighlightedLayerPortions === 0) {
1208
+ return;
1209
+ }
1210
+ if (this._dataTextureRenderers.edgesRenderer) {
1211
+ this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_HIGHLIGHTED);
1212
+ }
1213
+ }
1214
+
1215
+ drawEdgesSelected(renderFlags, frameCtx) {
1216
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numSelectedLayerPortions === 0) {
1217
+ return;
1218
+ }
1219
+ if (this._dataTextureRenderers.edgesRenderer) {
1220
+ this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_SELECTED);
1221
+ }
1222
+ }
1223
+
1224
+ drawEdgesXRayed(renderFlags, frameCtx) {
1225
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numXRayedLayerPortions === 0) {
1226
+ return;
1227
+ }
1228
+ if (this._dataTextureRenderers.edgesRenderer) {
1229
+ this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_XRAYED);
1230
+ }
1231
+ }
1232
+
1233
+ // ---------------------- OCCLUSION CULL RENDERING -----------------------------------
1234
+
1235
+ drawOcclusion(renderFlags, frameCtx) {
1236
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
1237
+ return;
1238
+ }
1239
+ this._updateBackfaceCull(renderFlags, frameCtx);
1240
+ if (this._dataTextureRenderers.occlusionRenderer) {
1241
+ this._dataTextureRenderers.occlusionRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
1242
+ }
1243
+ }
1244
+
1245
+ // ---------------------- SHADOW BUFFER RENDERING -----------------------------------
1246
+
1247
+ drawShadow(renderFlags, frameCtx) {
1248
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
1249
+ return;
1250
+ }
1251
+ this._updateBackfaceCull(renderFlags, frameCtx);
1252
+ if (this._dataTextureRenderers.shadowRenderer) {
1253
+ this._dataTextureRenderers.shadowRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
1254
+ }
1255
+ }
1256
+
1257
+ //---- PICKING ----------------------------------------------------------------------------------------------------
1258
+
1259
+ setPickMatrices(pickViewMatrix, pickProjMatrix) {
1260
+ if (this._numVisibleLayerPortions === 0) {
1261
+ return;
1262
+ }
1263
+ this._dataTextureState.texturePickCameraMatrices.updateViewMatrix(pickViewMatrix, pickProjMatrix);
1264
+ }
1265
+
1266
+ drawPickMesh(renderFlags, frameCtx) {
1267
+ if (this._numVisibleLayerPortions === 0) {
1268
+ return;
1269
+ }
1270
+ this._updateBackfaceCull(renderFlags, frameCtx);
1271
+ if (this._dataTextureRenderers.pickMeshRenderer) {
1272
+ this._dataTextureRenderers.pickMeshRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
1273
+ }
1274
+ }
1275
+
1276
+ drawPickDepths(renderFlags, frameCtx) {
1277
+ if (this._numVisibleLayerPortions === 0) {
1278
+ return;
1279
+ }
1280
+ this._updateBackfaceCull(renderFlags, frameCtx);
1281
+ if (this._dataTextureRenderers.pickDepthRenderer) {
1282
+ this._dataTextureRenderers.pickDepthRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
1283
+ }
1284
+ }
1285
+
1286
+ drawSnapInitDepthBuf(renderFlags, frameCtx) {
1287
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
1288
+ return;
1289
+ }
1290
+ this._updateBackfaceCull(renderFlags, frameCtx);
1291
+ if (this._dataTextureRenderers.snapDepthBufInitRenderer) {
1292
+ this._dataTextureRenderers.snapDepthBufInitRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
1293
+ }
1294
+ }
1295
+
1296
+ drawSnapDepths(renderFlags, frameCtx) {
1297
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
1298
+ return;
1299
+ }
1300
+ this._updateBackfaceCull(renderFlags, frameCtx);
1301
+ if (this._dataTextureRenderers.vertexDepthRenderer) {
1302
+ this._dataTextureRenderers.vertexDepthRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
1303
+ }
1304
+ }
1305
+
1306
+ drawPickNormals(renderFlags, frameCtx) {
1307
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
1308
+ return;
1309
+ }
1310
+ this._updateBackfaceCull(renderFlags, frameCtx);
1311
+ if (this._dataTextureRenderers.pickNormalsRenderer) {
1312
+ this._dataTextureRenderers.pickNormalsRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
1313
+ }
1314
+ }
1315
+
1316
+ destroy() {
1317
+ if (this._destroyed) {
1318
+ return;
1319
+ }
1320
+ const state = this._state;
1321
+ if (state.metallicRoughnessBuf) {
1322
+ state.metallicRoughnessBuf.destroy();
1323
+ state.metallicRoughnessBuf = null;
1324
+ }
1325
+ this.model.scene.off(this._onSceneRendering);
1326
+ state.destroy();
1327
+ this._destroyed = true;
1328
+ }
1329
+ }