csyjk 1.1.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (323) hide show
  1. package/.babelrc +7 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/xx.iml +12 -0
  4. package/dist/app.js +43 -0
  5. package/{index.html → dist/index.html} +0 -0
  6. package/{style.css → dist/style.css} +1 -1
  7. package/package.json +40 -5
  8. package/public/gltf.js +2241 -0
  9. package/public/index.html +10 -0
  10. package/src/index.js +3 -0
  11. package/src/lib/gltf/assets/check.jpg +0 -0
  12. package/src/lib/gltf/assets/iconfont/iconfont.css +358 -0
  13. package/src/lib/gltf/assets/iconfont/iconfont.eot +0 -0
  14. package/src/lib/gltf/assets/iconfont/iconfont.js +1 -0
  15. package/src/lib/gltf/assets/iconfont/iconfont.json +604 -0
  16. package/src/lib/gltf/assets/iconfont/iconfont.svg +189 -0
  17. package/src/lib/gltf/assets/iconfont/iconfont.ttf +0 -0
  18. package/src/lib/gltf/assets/iconfont/iconfont.woff +0 -0
  19. package/src/lib/gltf/assets/iconfont/iconfont.woff2 +0 -0
  20. package/src/lib/gltf/assets/yjkkit-sdk/index.js +0 -0
  21. package/src/lib/gltf/assets/yjkkit-sdk/package.json +15 -0
  22. package/src/lib/gltf/assets/yjkkit-sdk/src/extras/ContextMenu/ContextMenu.js +863 -0
  23. package/src/lib/gltf/assets/yjkkit-sdk/src/extras/ContextMenu/index.js +1 -0
  24. package/src/lib/gltf/assets/yjkkit-sdk/src/extras/index.js +1 -0
  25. package/src/lib/gltf/assets/yjkkit-sdk/src/index.js +3 -0
  26. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +462 -0
  27. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.js +279 -0
  28. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.js +262 -0
  29. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AngleMeasurementsPlugin/index.js +1 -0
  30. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/Annotation.js +362 -0
  31. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +575 -0
  32. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AnnotationsPlugin/index.js +1 -0
  33. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AxisGizmoPlugin/AxisGizmoPlugin.js +333 -0
  34. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/AxisGizmoPlugin/index.js +1 -0
  35. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js +777 -0
  36. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/BCFViewpointsPlugin/index.js +1 -0
  37. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +525 -0
  38. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.js +242 -0
  39. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +297 -0
  40. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/DistanceMeasurementsPlugin/index.js +1 -0
  41. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/FastNavPlugin/FastNavPlugin.js +345 -0
  42. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/FastNavPlugin/index.js +1 -0
  43. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +122 -0
  44. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +462 -0
  45. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFPerformanceModelLoader.js +508 -0
  46. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/GLTFSceneGraphLoader.js +922 -0
  47. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/GLTFLoaderPlugin/index.js +2 -0
  48. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/CubeTextureCanvas.js +273 -0
  49. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/NavCubePlugin.js +687 -0
  50. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/NavCubePlugin/index.js +1 -0
  51. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/OBJLoaderPlugin.js +145 -0
  52. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/OBJSceneGraphLoader.js +777 -0
  53. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/OBJLoaderPlugin/index.js +1 -0
  54. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLDefaultDataSource.js +33 -0
  55. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLLoaderPlugin.js +273 -0
  56. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/STLSceneGraphLoader.js +313 -0
  57. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/STLLoaderPlugin/index.js +2 -0
  58. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Control.js +1328 -0
  59. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Overview.js +249 -0
  60. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/Plane.js +169 -0
  61. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/SectionPlanesPlugin.js +403 -0
  62. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SectionPlanesPlugin/index.js +1 -0
  63. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SkyboxesPlugin/SkyboxesPlugin.js +134 -0
  64. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/SkyboxesPlugin/index.js +1 -0
  65. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/IFCStoreyPlanObjectStates.js +77 -0
  66. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/Storey.js +61 -0
  67. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/StoreyMap.js +57 -0
  68. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +822 -0
  69. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/StoreyViewsPlugin/index.js +1 -0
  70. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/ModelTreeView.js +888 -0
  71. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/TreeViewNode.js +88 -0
  72. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/TreeViewPlugin.js +624 -0
  73. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/index.js +1 -0
  74. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/TreeViewPlugin/modelValidation.js +87 -0
  75. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/ViewCullPlugin/ViewCullPlugin.js +295 -0
  76. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/ViewCullPlugin/index.js +1 -0
  77. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +78 -0
  78. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +847 -0
  79. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/index.js +2 -0
  80. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV1.js +167 -0
  81. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV2.js +228 -0
  82. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV3.js +220 -0
  83. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV4.js +279 -0
  84. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV5.js +244 -0
  85. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +301 -0
  86. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +426 -0
  87. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +479 -0
  88. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XKTLoaderPlugin/parsers/lib/pako.js +6818 -0
  89. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/XML3DLoaderPlugin.js +238 -0
  90. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/XML3DSceneGraphLoader.js +1279 -0
  91. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/index.js +1 -0
  92. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/.jshintrc +11 -0
  93. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/deflate.js +2060 -0
  94. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/inflate.js +2155 -0
  95. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/mime-types.js +1002 -0
  96. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/pako/codecs.js +64 -0
  97. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/z-worker.js +153 -0
  98. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip-ext.js +267 -0
  99. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip-fs.js +553 -0
  100. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zip.js +991 -0
  101. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/XML3DLoaderPlugin/zipjs/zlib-asm/codecs.js +49 -0
  102. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/index.js +17 -0
  103. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/culling/ObjectCullStates.js +205 -0
  104. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Dot.js +78 -0
  105. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Label.js +97 -0
  106. package/src/lib/gltf/assets/yjkkit-sdk/src/plugins/lib/html/Wire.js +95 -0
  107. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/Plugin.js +112 -0
  108. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/Viewer.js +372 -0
  109. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/index.js +3 -0
  110. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/IFCObjectDefaultColors.js +162 -0
  111. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/IFCObjectDefaults.js +39 -0
  112. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaModel.js +145 -0
  113. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaObject.js +215 -0
  114. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/metadata/MetaScene.js +311 -0
  115. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/CameraControl.js +1669 -0
  116. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/cc.js +0 -0
  117. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/CameraUpdater.js +312 -0
  118. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PanController.js +112 -0
  119. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PickController.js +193 -0
  120. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/controllers/PivotController.js +289 -0
  121. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/cu.js +0 -0
  122. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +122 -0
  123. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +186 -0
  124. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MouseMiscHandler.js +68 -0
  125. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +439 -0
  126. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +361 -0
  127. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +258 -0
  128. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/TouchPickHandler.js +197 -0
  129. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/CameraControl/lib/handlers/mouspan.js +498 -0
  130. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/Component.js +908 -0
  131. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/Entity.js +475 -0
  132. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/ImagePlane/ImagePlane.js +570 -0
  133. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/ImagePlane/index.js +1 -0
  134. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/PerformanceModel.js +2623 -0
  135. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/index.js +1 -0
  136. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/ENTITY_FLAGS.js +21 -0
  137. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/PerformanceMesh.js +262 -0
  138. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/PerformanceNode.js +697 -0
  139. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/RENDER_PASSES.js +34 -0
  140. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/ScratchMemory.js +63 -0
  141. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/compression.js +183 -0
  142. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingBuffer.js +33 -0
  143. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingLayer.js +736 -0
  144. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/LinesBatchingRenderers.js +68 -0
  145. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/renderers/LinesBatchingColorRenderer.js +295 -0
  146. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +327 -0
  147. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/LinesInstancingLayer.js +698 -0
  148. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/LinesInstancingRenderers.js +68 -0
  149. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/renderers/LinesInstancingColorRenderer.js +364 -0
  150. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +356 -0
  151. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingBuffer.js +33 -0
  152. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingLayer.js +776 -0
  153. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/PointsBatchingRenderers.js +113 -0
  154. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingColorRenderer.js +340 -0
  155. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +312 -0
  156. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +343 -0
  157. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +331 -0
  158. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingShadowRenderer.js +242 -0
  159. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +348 -0
  160. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/PointsInstancingLayer.js +737 -0
  161. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/PointsInstancingRenderers.js +143 -0
  162. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingColorRenderer.js +373 -0
  163. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +366 -0
  164. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +370 -0
  165. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +386 -0
  166. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +376 -0
  167. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +293 -0
  168. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +382 -0
  169. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingBuffer.js +37 -0
  170. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingLayer.js +1017 -0
  171. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/TrianglesBatchingRenderers.js +246 -0
  172. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingColorQualityRenderer.js +809 -0
  173. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +504 -0
  174. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +297 -0
  175. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +300 -0
  176. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +322 -0
  177. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +311 -0
  178. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +291 -0
  179. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +319 -0
  180. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +305 -0
  181. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +300 -0
  182. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +242 -0
  183. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +323 -0
  184. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/TrianglesInstancingLayer.js +969 -0
  185. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/TrianglesInstancingRenderers.js +246 -0
  186. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingColorQualityRenderer.js +859 -0
  187. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +557 -0
  188. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +341 -0
  189. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +338 -0
  190. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +356 -0
  191. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +354 -0
  192. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +329 -0
  193. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +358 -0
  194. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +349 -0
  195. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +363 -0
  196. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +284 -0
  197. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/PerformanceModel/lib/layers/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +354 -0
  198. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Camera.js +880 -0
  199. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraFlightAnimation.js +669 -0
  200. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraPath.js +194 -0
  201. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CameraPathAnimation.js +326 -0
  202. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/CustomProjection.js +149 -0
  203. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Frustum.js +316 -0
  204. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Ortho.js +286 -0
  205. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/Perspective.js +302 -0
  206. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/camera/index.js +2 -0
  207. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/canvas/Canvas.js +464 -0
  208. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/canvas/Spinner.js +323 -0
  209. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/core.js +234 -0
  210. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/Geometry.js +33 -0
  211. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/ReadableGeometry.js +689 -0
  212. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/VBOGeometry.js +327 -0
  213. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildBoxGeometry.js +238 -0
  214. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildBoxLinesGeometry.js +106 -0
  215. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildCylinderGeometry.js +271 -0
  216. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildGridGeometry.js +102 -0
  217. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +168 -0
  218. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildSphereGeometry.js +161 -0
  219. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildTorusGeometry.js +172 -0
  220. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/buildVectorTextGeometry.js +1721 -0
  221. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/builders/index.js +8 -0
  222. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/index.js +4 -0
  223. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/index.js +2 -0
  224. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/load3DSGeometry.js +103 -0
  225. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/geometry/loaders/loadOBJGeometry.js +130 -0
  226. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/index.js +18 -0
  227. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/input/Input.js +1475 -0
  228. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/libs/canvas2image.js +218 -0
  229. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/libs/k3d.js +1032 -0
  230. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/AmbientLight.js +175 -0
  231. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/CubeTexture.js +156 -0
  232. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/DirLight.js +314 -0
  233. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/Light.js +29 -0
  234. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/LightMap.js +77 -0
  235. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/PointLight.js +395 -0
  236. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/ReflectionMap.js +79 -0
  237. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/Shadow.js +138 -0
  238. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/lights/index.js +5 -0
  239. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/marker/Marker.js +382 -0
  240. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/marker/index.js +1 -0
  241. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/EdgeMaterial.js +359 -0
  242. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/EmphasisMaterial.js +577 -0
  243. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Fresnel.js +222 -0
  244. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/LambertMaterial.js +378 -0
  245. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/LinesMaterial.js +169 -0
  246. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Material.js +39 -0
  247. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/MetallicMaterial.js +820 -0
  248. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/PhongMaterial.js +860 -0
  249. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/PointsMaterial.js +320 -0
  250. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/SpecularMaterial.js +807 -0
  251. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/Texture.js +522 -0
  252. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/materials/index.js +8 -0
  253. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/Frustum.js +118 -0
  254. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/buildEdgeIndices.js +162 -0
  255. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/geometryCompressionUtils.js +353 -0
  256. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/index.js +1 -0
  257. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/math.js +5302 -0
  258. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/math/rtcCoords.js +132 -0
  259. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/CameraMemento.js +200 -0
  260. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/ModelMemento.js +272 -0
  261. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/ObjectsMemento.js +259 -0
  262. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mementos/index.js +3 -0
  263. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/Mesh.js +2165 -0
  264. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/draw/DrawRenderer.js +978 -0
  265. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/draw/DrawShaderSource.js +1566 -0
  266. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +249 -0
  267. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +163 -0
  268. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +276 -0
  269. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +269 -0
  270. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/index.js +1 -0
  271. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +207 -0
  272. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +156 -0
  273. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickMeshRenderer.js +210 -0
  274. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +146 -0
  275. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +186 -0
  276. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +120 -0
  277. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/shadow/ShadowRenderer.js +214 -0
  278. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +96 -0
  279. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/metriqs/Metriqs.js +259 -0
  280. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/nodes/Node.js +1356 -0
  281. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/nodes/index.js +1 -0
  282. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/CubicBezierCurve.js +194 -0
  283. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/Curve.js +183 -0
  284. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/Path.js +239 -0
  285. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/QuadraticBezierCurve.js +161 -0
  286. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/SplineCurve.js +133 -0
  287. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/paths/index.js +5 -0
  288. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/postfx/SAO.js +547 -0
  289. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/scene/Scene.js +2481 -0
  290. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/sectionPlane/SectionPlane.js +194 -0
  291. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/sectionPlane/index.js +1 -0
  292. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/skybox/Skybox.js +119 -0
  293. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/skybox/index.js +1 -0
  294. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/stats.js +45 -0
  295. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/Map.js +45 -0
  296. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/Queue.js +56 -0
  297. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils/index.js +2 -0
  298. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/utils.js +452 -0
  299. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/viewport/Viewport.js +212 -0
  300. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/ArrayBuf.js +121 -0
  301. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Attribute.js +23 -0
  302. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Drawable.js +270 -0
  303. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/FrameContext.js +259 -0
  304. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/PickResult.js +317 -0
  305. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Pickable.js +69 -0
  306. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Program.js +179 -0
  307. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderBuffer.js +315 -0
  308. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderFlags.js +203 -0
  309. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/RenderState.js +40 -0
  310. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Renderer.js +1300 -0
  311. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Sampler.js +18 -0
  312. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Shader.js +49 -0
  313. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/Texture2D.js +217 -0
  314. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +214 -0
  315. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/occlusion/OcclusionTester.js +432 -0
  316. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/sao/SAODepthLimitedBlurRenderer.js +326 -0
  317. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +375 -0
  318. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webgl/webglEnums.js +61 -0
  319. package/src/lib/gltf/assets/yjkkit-sdk/src/viewer/scene/webglInfo.js +48 -0
  320. package/src/lib/gltf/gltf.css +392 -0
  321. package/src/lib/gltf/gltf.js +2241 -0
  322. package/webpack.config.js +70 -0
  323. package/app.js +0 -43
@@ -0,0 +1,1017 @@
1
+ import {WEBGL_INFO} from "../../../../webglInfo.js";
2
+ import {ENTITY_FLAGS} from '../../ENTITY_FLAGS.js';
3
+ import {RENDER_PASSES} from '../../RENDER_PASSES.js';
4
+
5
+ import {math} from "../../../../math/math.js";
6
+ import {RenderState} from "../../../../webgl/RenderState.js";
7
+ import {ArrayBuf} from "../../../../webgl/ArrayBuf.js";
8
+ import {geometryCompressionUtils} from "../../../../math/geometryCompressionUtils.js";
9
+ import {getBatchingRenderers} from "./TrianglesBatchingRenderers.js";
10
+ import {TrianglesBatchingBuffer} from "./TrianglesBatchingBuffer.js";
11
+ import {quantizePositions, transformAndOctEncodeNormals} from "../../compression.js";
12
+
13
+ const tempMat4 = math.mat4();
14
+ const tempMat4b = math.mat4();
15
+ const tempVec4a = math.vec4([0, 0, 0, 1]);
16
+ const tempVec4b = math.vec4([0, 0, 0, 1]);
17
+ const tempVec4c = math.vec4([0, 0, 0, 1]);
18
+ const tempOBB3 = math.OBB3();
19
+
20
+ /**
21
+ * @private
22
+ */
23
+ class TrianglesBatchingLayer {
24
+
25
+ /**
26
+ * @param model
27
+ * @param cfg
28
+ * @param cfg.layerIndex
29
+ * @param cfg.positionsDecodeMatrix
30
+ * @param cfg.maxGeometryBatchSize
31
+ * @param cfg.rtcCenter
32
+ * @param cfg.scratchMemory
33
+ * @param cfg.solid
34
+ */
35
+ constructor(model, cfg) {
36
+
37
+ /**
38
+ * State sorting key.
39
+ * @type {string}
40
+ */
41
+ this.sortId = "TrianglesBatchingLayer" + cfg.solid ? "-solid" : "-surface";
42
+
43
+ /**
44
+ * Index of this TrianglesBatchingLayer in {@link PerformanceModel#_layerList}.
45
+ * @type {Number}
46
+ */
47
+ this.layerIndex = cfg.layerIndex;
48
+
49
+ this._batchingRenderers = getBatchingRenderers(model.scene);
50
+ this.model = model;
51
+ this._buffer = new TrianglesBatchingBuffer(cfg.maxGeometryBatchSize);
52
+ this._scratchMemory = cfg.scratchMemory;
53
+
54
+ this._state = new RenderState({
55
+ positionsBuf: null,
56
+ offsetsBuf: null,
57
+ normalsBuf: null,
58
+ colorsBuf: null,
59
+ metallicRoughnessBuf: null,
60
+ flagsBuf: null,
61
+ flags2Buf: null,
62
+ indicesBuf: null,
63
+ edgeIndicesBuf: null,
64
+ positionsDecodeMatrix: math.mat4(),
65
+ rtcCenter: null
66
+ });
67
+
68
+ // These counts are used to avoid unnecessary render passes
69
+ this._numPortions = 0;
70
+ this._numVisibleLayerPortions = 0;
71
+ this._numTransparentLayerPortions = 0;
72
+ this._numXRayedLayerPortions = 0;
73
+ this._numSelectedLayerPortions = 0;
74
+ this._numHighlightedLayerPortions = 0;
75
+ this._numClippableLayerPortions = 0;
76
+ this._numEdgesLayerPortions = 0;
77
+ this._numPickableLayerPortions = 0;
78
+ this._numCulledLayerPortions = 0;
79
+
80
+ this._modelAABB = math.collapseAABB3(); // Model-space AABB
81
+ this._portions = [];
82
+
83
+ this._finalized = false;
84
+ this._positionsDecodeMatrix = cfg.positionsDecodeMatrix;
85
+ this._preCompressed = (!!this._positionsDecodeMatrix);
86
+
87
+ if (cfg.rtcCenter) {
88
+ this._state.rtcCenter = math.vec3(cfg.rtcCenter);
89
+ }
90
+
91
+ /**
92
+ * The axis-aligned World-space boundary of this TrianglesBatchingLayer's positions.
93
+ * @type {*|Float64Array}
94
+ */
95
+ this.aabb = math.collapseAABB3();
96
+
97
+ /**
98
+ * When true, this layer contains solid triangle meshes, otherwise this layer contains surface triangle meshes
99
+ * @type {boolean}
100
+ */
101
+ this.solid = !!cfg.solid;
102
+ }
103
+
104
+ /**
105
+ * Tests if there is room for another portion in this TrianglesBatchingLayer.
106
+ *
107
+ * @param lenPositions Number of positions we'd like to create in the portion.
108
+ * @param lenIndices Number of indices we'd like to create in this portion.
109
+ * @returns {boolean} True if OK to create another portion.
110
+ */
111
+ canCreatePortion(lenPositions, lenIndices) {
112
+ if (this._finalized) {
113
+ throw "Already finalized";
114
+ }
115
+ return ((this._buffer.positions.length + lenPositions) < (this._buffer.maxVerts * 3) && (this._buffer.indices.length + lenIndices) < (this._buffer.maxIndices));
116
+ }
117
+
118
+ /**
119
+ * Creates a new portion within this TrianglesBatchingLayer, returns the new portion ID.
120
+ *
121
+ * Gives the portion the specified geometry, color and matrix.
122
+ *
123
+ * @param cfg.positions Flat float Local-space positions array.
124
+ * @param [cfg.normals] Flat float normals array.
125
+ * @param [cfg.colors] Flat float colors array.
126
+ * @param cfg.indices Flat int indices array.
127
+ * @param [cfg.edgeIndices] Flat int edges indices array.
128
+ * @param cfg.color Quantized RGB color [0..255,0..255,0..255,0..255]
129
+ * @param cfg.metallic Metalness factor [0..255]
130
+ * @param cfg.roughness Roughness factor [0..255]
131
+ * @param cfg.opacity Opacity [0..255]
132
+ * @param [cfg.meshMatrix] Flat float 4x4 matrix
133
+ * @param [cfg.worldMatrix] Flat float 4x4 matrix
134
+ * @param cfg.worldAABB Flat float AABB World-space AABB
135
+ * @param cfg.pickColor Quantized pick color
136
+ * @returns {number} Portion ID
137
+ */
138
+ createPortion(cfg) {
139
+
140
+ if (this._finalized) {
141
+ throw "Already finalized";
142
+ }
143
+
144
+ const positions = cfg.positions;
145
+ const normals = cfg.normals;
146
+ const indices = cfg.indices;
147
+ const edgeIndices = cfg.edgeIndices;
148
+ const color = cfg.color;
149
+ const metallic = cfg.metallic;
150
+ const roughness = cfg.roughness;
151
+ const colors = cfg.colors;
152
+ const opacity = cfg.opacity;
153
+ const meshMatrix = cfg.meshMatrix;
154
+ const worldMatrix = cfg.worldMatrix;
155
+ const worldAABB = cfg.worldAABB;
156
+ const pickColor = cfg.pickColor;
157
+
158
+ const buffer = this._buffer;
159
+ const positionsIndex = buffer.positions.length;
160
+ const vertsIndex = positionsIndex / 3;
161
+ const numVerts = positions.length / 3;
162
+ const lenPositions = positions.length;
163
+
164
+ if (this._preCompressed) {
165
+
166
+ for (let i = 0, len = positions.length; i < len; i++) {
167
+ buffer.positions.push(positions[i]);
168
+ }
169
+
170
+ const bounds = geometryCompressionUtils.getPositionsBounds(positions);
171
+
172
+ const min = geometryCompressionUtils.decompressPosition(bounds.min, this._positionsDecodeMatrix, []);
173
+ const max = geometryCompressionUtils.decompressPosition(bounds.max, this._positionsDecodeMatrix, []);
174
+
175
+ worldAABB[0] = min[0];
176
+ worldAABB[1] = min[1];
177
+ worldAABB[2] = min[2];
178
+ worldAABB[3] = max[0];
179
+ worldAABB[4] = max[1];
180
+ worldAABB[5] = max[2];
181
+
182
+ if (worldMatrix) {
183
+ math.AABB3ToOBB3(worldAABB, tempOBB3);
184
+ math.transformOBB3(worldMatrix, tempOBB3);
185
+ math.OBB3ToAABB3(tempOBB3, worldAABB);
186
+ }
187
+
188
+ } else {
189
+
190
+ const positionsBase = buffer.positions.length;
191
+
192
+ for (let i = 0, len = positions.length; i < len; i++) {
193
+ buffer.positions.push(positions[i]);
194
+ }
195
+
196
+ if (meshMatrix) {
197
+
198
+ for (let i = positionsBase, len = positionsBase + lenPositions; i < len; i += 3) {
199
+
200
+ tempVec4a[0] = buffer.positions[i + 0];
201
+ tempVec4a[1] = buffer.positions[i + 1];
202
+ tempVec4a[2] = buffer.positions[i + 2];
203
+
204
+ math.transformPoint4(meshMatrix, tempVec4a, tempVec4b);
205
+
206
+ buffer.positions[i + 0] = tempVec4b[0];
207
+ buffer.positions[i + 1] = tempVec4b[1];
208
+ buffer.positions[i + 2] = tempVec4b[2];
209
+
210
+ math.expandAABB3Point3(this._modelAABB, tempVec4b);
211
+
212
+ if (worldMatrix) {
213
+ math.transformPoint4(worldMatrix, tempVec4b, tempVec4c);
214
+ math.expandAABB3Point3(worldAABB, tempVec4c);
215
+ } else {
216
+ math.expandAABB3Point3(worldAABB, tempVec4b);
217
+ }
218
+ }
219
+
220
+ } else {
221
+
222
+ for (let i = positionsBase, len = positionsBase + lenPositions; i < len; i += 3) {
223
+
224
+ tempVec4a[0] = buffer.positions[i + 0];
225
+ tempVec4a[1] = buffer.positions[i + 1];
226
+ tempVec4a[2] = buffer.positions[i + 2];
227
+
228
+ math.expandAABB3Point3(this._modelAABB, tempVec4a);
229
+
230
+ if (worldMatrix) {
231
+ math.transformPoint4(worldMatrix, tempVec4a, tempVec4b);
232
+ math.expandAABB3Point3(worldAABB, tempVec4b);
233
+ } else {
234
+ math.expandAABB3Point3(worldAABB, tempVec4a);
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ if (this._state.rtcCenter) {
241
+ const rtcCenter = this._state.rtcCenter;
242
+ worldAABB[0] += rtcCenter[0];
243
+ worldAABB[1] += rtcCenter[1];
244
+ worldAABB[2] += rtcCenter[2];
245
+ worldAABB[3] += rtcCenter[0];
246
+ worldAABB[4] += rtcCenter[1];
247
+ worldAABB[5] += rtcCenter[2];
248
+ }
249
+
250
+ math.expandAABB3(this.aabb, worldAABB);
251
+
252
+ if (normals) {
253
+
254
+ if (this._preCompressed) {
255
+
256
+ for (let i = 0, len = normals.length; i < len; i++) {
257
+ buffer.normals.push(normals[i]);
258
+ }
259
+
260
+ } else {
261
+
262
+ const worldNormalMatrix = tempMat4;
263
+
264
+ if (meshMatrix) {
265
+ math.inverseMat4(math.transposeMat4(meshMatrix, tempMat4b), worldNormalMatrix); // Note: order of inverse and transpose doesn't matter
266
+
267
+ } else {
268
+ math.identityMat4(worldNormalMatrix, worldNormalMatrix);
269
+ }
270
+
271
+ transformAndOctEncodeNormals(worldNormalMatrix, normals, normals.length, buffer.normals, buffer.normals.length);
272
+ }
273
+ }
274
+
275
+ if (colors) {
276
+
277
+ for (let i = 0, len = colors.length; i < len; i += 3) {
278
+ buffer.colors.push(colors[i] * 255);
279
+ buffer.colors.push(colors[i + 1] * 255);
280
+ buffer.colors.push(colors[i + 2] * 255);
281
+ buffer.colors.push(255);
282
+ }
283
+
284
+ } else if (color) {
285
+
286
+ const r = color[0]; // Color is pre-quantized by PerformanceModel
287
+ const g = color[1];
288
+ const b = color[2];
289
+ const a = opacity;
290
+
291
+ const metallicValue = (metallic !== null && metallic !== undefined) ? metallic : 0;
292
+ const roughnessValue = (roughness !== null && roughness !== undefined) ? roughness : 255;
293
+
294
+ for (let i = 0; i < numVerts; i++) {
295
+
296
+ buffer.colors.push(r);
297
+ buffer.colors.push(g);
298
+ buffer.colors.push(b);
299
+ buffer.colors.push(a);
300
+
301
+ buffer.metallicRoughness.push(metallicValue);
302
+ buffer.metallicRoughness.push(roughnessValue);
303
+ }
304
+ }
305
+
306
+ if (indices) {
307
+ for (let i = 0, len = indices.length; i < len; i++) {
308
+ buffer.indices.push(indices[i] + vertsIndex);
309
+ }
310
+ }
311
+
312
+ if (edgeIndices) {
313
+ for (let i = 0, len = edgeIndices.length; i < len; i++) {
314
+ buffer.edgeIndices.push(edgeIndices[i] + vertsIndex);
315
+ }
316
+ }
317
+
318
+ {
319
+ const pickColorsBase = buffer.pickColors.length;
320
+ const lenPickColors = numVerts * 4;
321
+ for (let i = pickColorsBase, len = pickColorsBase + lenPickColors; i < len; i += 4) {
322
+ buffer.pickColors.push(pickColor[0]);
323
+ buffer.pickColors.push(pickColor[1]);
324
+ buffer.pickColors.push(pickColor[2]);
325
+ buffer.pickColors.push(pickColor[3]);
326
+ }
327
+ }
328
+
329
+ if (this.model.scene.entityOffsetsEnabled) {
330
+ for (let i = 0; i < numVerts; i++) {
331
+ buffer.offsets.push(0);
332
+ buffer.offsets.push(0);
333
+ buffer.offsets.push(0);
334
+ }
335
+ }
336
+
337
+ const portionId = this._portions.length / 2;
338
+
339
+ this._portions.push(vertsIndex);
340
+ this._portions.push(numVerts);
341
+
342
+ this._numPortions++;
343
+ this.model.numPortions++;
344
+
345
+ return portionId;
346
+ }
347
+
348
+ /**
349
+ * Builds batch VBOs from appended geometries.
350
+ * No more portions can then be created.
351
+ */
352
+ finalize() {
353
+
354
+ if (this._finalized) {
355
+ this.model.error("Already finalized");
356
+ return;
357
+ }
358
+
359
+ const state = this._state;
360
+ const gl = this.model.scene.canvas.gl;
361
+ const buffer = this._buffer;
362
+
363
+ if (buffer.positions.length > 0) {
364
+ if (this._preCompressed) {
365
+ state.positionsDecodeMatrix = this._positionsDecodeMatrix;
366
+ const positions = new Uint16Array(buffer.positions);
367
+ state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, positions, buffer.positions.length, 3, gl.STATIC_DRAW);
368
+ } else {
369
+ const quantizedPositions = quantizePositions(buffer.positions, this._modelAABB, state.positionsDecodeMatrix); // BOTTLENECK
370
+ state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, quantizedPositions, buffer.positions.length, 3, gl.STATIC_DRAW);
371
+ }
372
+ }
373
+
374
+ if (buffer.normals.length > 0) {
375
+ const normals = new Int8Array(buffer.normals);
376
+ let normalized = true; // For oct encoded UInts
377
+ //let normalized = false; // For scaled
378
+ state.normalsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, normals, buffer.normals.length, 3, gl.STATIC_DRAW, normalized);
379
+ }
380
+
381
+ if (buffer.colors.length > 0) {
382
+ const colors = new Uint8Array(buffer.colors);
383
+ let normalized = false;
384
+ state.colorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, colors, buffer.colors.length, 4, gl.DYNAMIC_DRAW, normalized);
385
+ }
386
+
387
+ if (buffer.metallicRoughness.length > 0) {
388
+ const metallicRoughness = new Uint8Array(buffer.metallicRoughness);
389
+ let normalized = false;
390
+ state.metallicRoughnessBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, metallicRoughness, buffer.metallicRoughness.length, 2, gl.STATIC_DRAW, normalized);
391
+ }
392
+
393
+ if (buffer.colors.length > 0) { // Because we build flags arrays here, get their length from the colors array
394
+ const flagsLength = buffer.colors.length;
395
+ const flags = new Uint8Array(flagsLength);
396
+ const flags2 = new Uint8Array(flagsLength);
397
+ let notNormalized = false;
398
+ let normalized = true;
399
+ state.flagsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, flags, flags.length, 4, gl.DYNAMIC_DRAW, notNormalized);
400
+ state.flags2Buf = new ArrayBuf(gl, gl.ARRAY_BUFFER, flags2, flags2.length, 4, gl.DYNAMIC_DRAW, normalized);
401
+ }
402
+
403
+ if (buffer.pickColors.length > 0) {
404
+ const pickColors = new Uint8Array(buffer.pickColors);
405
+ let normalized = false;
406
+ state.pickColorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, pickColors, buffer.pickColors.length, 4, gl.STATIC_DRAW, normalized);
407
+ }
408
+
409
+ if (this.model.scene.entityOffsetsEnabled) {
410
+ if (buffer.offsets.length > 0) {
411
+ const offsets = new Float32Array(buffer.offsets);
412
+ state.offsetsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, offsets, buffer.offsets.length, 3, gl.DYNAMIC_DRAW);
413
+ }
414
+ }
415
+
416
+ const bigIndicesSupported = WEBGL_INFO.SUPPORTED_EXTENSIONS["OES_element_index_uint"];
417
+
418
+ if (buffer.indices.length > 0) {
419
+ const indices = bigIndicesSupported ? new Uint32Array(buffer.indices) : new Uint16Array(buffer.indices);
420
+ state.indicesBuf = new ArrayBuf(gl, gl.ELEMENT_ARRAY_BUFFER, indices, buffer.indices.length, 1, gl.STATIC_DRAW);
421
+ }
422
+ if (buffer.edgeIndices.length > 0) {
423
+ const edgeIndices = bigIndicesSupported ? new Uint32Array(buffer.edgeIndices) : new Uint16Array(buffer.edgeIndices);
424
+ state.edgeIndicesBuf = new ArrayBuf(gl, gl.ELEMENT_ARRAY_BUFFER, edgeIndices, buffer.edgeIndices.length, 1, gl.STATIC_DRAW);
425
+ }
426
+
427
+ this._buffer = null;
428
+ this._finalized = true;
429
+ }
430
+
431
+ initFlags(portionId, flags, meshTransparent) {
432
+ if (flags & ENTITY_FLAGS.VISIBLE) {
433
+ this._numVisibleLayerPortions++;
434
+ this.model.numVisibleLayerPortions++;
435
+ }
436
+ if (flags & ENTITY_FLAGS.HIGHLIGHTED) {
437
+ this._numHighlightedLayerPortions++;
438
+ this.model.numHighlightedLayerPortions++;
439
+ }
440
+ if (flags & ENTITY_FLAGS.XRAYED) {
441
+ this._numXRayedLayerPortions++;
442
+ this.model.numXRayedLayerPortions++;
443
+ }
444
+ if (flags & ENTITY_FLAGS.SELECTED) {
445
+ this._numSelectedLayerPortions++;
446
+ this.model.numSelectedLayerPortions++;
447
+ }
448
+ if (flags & ENTITY_FLAGS.CLIPPABLE) {
449
+ this._numClippableLayerPortions++;
450
+ this.model.numClippableLayerPortions++;
451
+ }
452
+ if (flags & ENTITY_FLAGS.EDGES) {
453
+ this._numEdgesLayerPortions++;
454
+ this.model.numEdgesLayerPortions++;
455
+ }
456
+ if (flags & ENTITY_FLAGS.PICKABLE) {
457
+ this._numPickableLayerPortions++;
458
+ this.model.numPickableLayerPortions++;
459
+ }
460
+ if (flags & ENTITY_FLAGS.CULLED) {
461
+ this._numCulledLayerPortions++;
462
+ this.model.numCulledLayerPortions++;
463
+ }
464
+ if (meshTransparent) {
465
+ this._numTransparentLayerPortions++;
466
+ this.model.numTransparentLayerPortions++;
467
+ }
468
+ this._setFlags(portionId, flags, meshTransparent);
469
+ this._setFlags2(portionId, flags);
470
+ }
471
+
472
+ setVisible(portionId, flags, transparent) {
473
+ if (!this._finalized) {
474
+ throw "Not finalized";
475
+ }
476
+ if (flags & ENTITY_FLAGS.VISIBLE) {
477
+ this._numVisibleLayerPortions++;
478
+ this.model.numVisibleLayerPortions++;
479
+ } else {
480
+ this._numVisibleLayerPortions--;
481
+ this.model.numVisibleLayerPortions--;
482
+ }
483
+ this._setFlags(portionId, flags, transparent);
484
+ }
485
+
486
+ setHighlighted(portionId, flags, transparent) {
487
+ if (!this._finalized) {
488
+ throw "Not finalized";
489
+ }
490
+ if (flags & ENTITY_FLAGS.HIGHLIGHTED) {
491
+ this._numHighlightedLayerPortions++;
492
+ this.model.numHighlightedLayerPortions++;
493
+ } else {
494
+ this._numHighlightedLayerPortions--;
495
+ this.model.numHighlightedLayerPortions--;
496
+ }
497
+ this._setFlags(portionId, flags, transparent);
498
+ }
499
+
500
+ setXRayed(portionId, flags, transparent) {
501
+ if (!this._finalized) {
502
+ throw "Not finalized";
503
+ }
504
+ if (flags & ENTITY_FLAGS.XRAYED) {
505
+ this._numXRayedLayerPortions++;
506
+ this.model.numXRayedLayerPortions++;
507
+ } else {
508
+ this._numXRayedLayerPortions--;
509
+ this.model.numXRayedLayerPortions--;
510
+ }
511
+ this._setFlags(portionId, flags, transparent);
512
+ }
513
+
514
+ setSelected(portionId, flags, transparent) {
515
+ if (!this._finalized) {
516
+ throw "Not finalized";
517
+ }
518
+ if (flags & ENTITY_FLAGS.SELECTED) {
519
+ this._numSelectedLayerPortions++;
520
+ this.model.numSelectedLayerPortions++;
521
+ } else {
522
+ this._numSelectedLayerPortions--;
523
+ this.model.numSelectedLayerPortions--;
524
+ }
525
+ this._setFlags(portionId, flags, transparent);
526
+ }
527
+
528
+ setEdges(portionId, flags, transparent) {
529
+ if (!this._finalized) {
530
+ throw "Not finalized";
531
+ }
532
+ if (flags & ENTITY_FLAGS.EDGES) {
533
+ this._numEdgesLayerPortions++;
534
+ this.model.numEdgesLayerPortions++;
535
+ } else {
536
+ this._numEdgesLayerPortions--;
537
+ this.model.numEdgesLayerPortions--;
538
+ }
539
+ this._setFlags(portionId, flags, transparent);
540
+ }
541
+
542
+ setClippable(portionId, flags) {
543
+ if (!this._finalized) {
544
+ throw "Not finalized";
545
+ }
546
+ if (flags & ENTITY_FLAGS.CLIPPABLE) {
547
+ this._numClippableLayerPortions++;
548
+ this.model.numClippableLayerPortions++;
549
+ } else {
550
+ this._numClippableLayerPortions--;
551
+ this.model.numClippableLayerPortions--;
552
+ }
553
+ this._setFlags2(portionId, flags);
554
+ }
555
+
556
+ setCulled(portionId, flags, transparent) {
557
+ if (!this._finalized) {
558
+ throw "Not finalized";
559
+ }
560
+ if (flags & ENTITY_FLAGS.CULLED) {
561
+ this._numCulledLayerPortions++;
562
+ this.model.numCulledLayerPortions++;
563
+ } else {
564
+ this._numCulledLayerPortions--;
565
+ this.model.numCulledLayerPortions--;
566
+ }
567
+ this._setFlags(portionId, flags, transparent);
568
+ }
569
+
570
+ setCollidable(portionId, flags) {
571
+ if (!this._finalized) {
572
+ throw "Not finalized";
573
+ }
574
+ }
575
+
576
+ setPickable(portionId, flags, transparent) {
577
+ if (!this._finalized) {
578
+ throw "Not finalized";
579
+ }
580
+ if (flags & ENTITY_FLAGS.PICKABLE) {
581
+ this._numPickableLayerPortions++;
582
+ this.model.numPickableLayerPortions++;
583
+ } else {
584
+ this._numPickableLayerPortions--;
585
+ this.model.numPickableLayerPortions--;
586
+ }
587
+ this._setFlags(portionId, flags, transparent);
588
+ }
589
+
590
+ setColor(portionId, color) {
591
+ if (!this._finalized) {
592
+ throw "Not finalized";
593
+ }
594
+ const portionsIdx = portionId * 2;
595
+ const vertexBase = this._portions[portionsIdx];
596
+ const numVerts = this._portions[portionsIdx + 1];
597
+ const firstColor = vertexBase * 4;
598
+ const lenColor = numVerts * 4;
599
+ const tempArray = this._scratchMemory.getUInt8Array(lenColor);
600
+ const r = color[0];
601
+ const g = color[1];
602
+ const b = color[2];
603
+ const a = color[3];
604
+ for (let i = 0; i < lenColor; i += 4) {
605
+ tempArray[i + 0] = r;
606
+ tempArray[i + 1] = g;
607
+ tempArray[i + 2] = b;
608
+ tempArray[i + 3] = a;
609
+ }
610
+ this._state.colorsBuf.setData(tempArray, firstColor, lenColor);
611
+ }
612
+
613
+ setTransparent(portionId, flags, transparent) {
614
+ if (transparent) {
615
+ this._numTransparentLayerPortions++;
616
+ this.model.numTransparentLayerPortions++;
617
+ } else {
618
+ this._numTransparentLayerPortions--;
619
+ this.model.numTransparentLayerPortions--;
620
+ }
621
+ this._setFlags(portionId, flags, transparent);
622
+ }
623
+
624
+ _setFlags(portionId, flags, transparent) {
625
+
626
+ if (!this._finalized) {
627
+ throw "Not finalized";
628
+ }
629
+
630
+ const portionsIdx = portionId * 2;
631
+ const vertexBase = this._portions[portionsIdx];
632
+ const numVerts = this._portions[portionsIdx + 1];
633
+ const firstFlag = vertexBase * 4;
634
+ const lenFlags = numVerts * 4;
635
+ const tempArray = this._scratchMemory.getUInt8Array(lenFlags);
636
+
637
+ const visible = !!(flags & ENTITY_FLAGS.VISIBLE);
638
+ const xrayed = !!(flags & ENTITY_FLAGS.XRAYED);
639
+ const highlighted = !!(flags & ENTITY_FLAGS.HIGHLIGHTED);
640
+ const selected = !!(flags & ENTITY_FLAGS.SELECTED);
641
+ const edges = !!(flags & ENTITY_FLAGS.EDGES);
642
+ const pickable = !!(flags & ENTITY_FLAGS.PICKABLE);
643
+ const culled = !!(flags & ENTITY_FLAGS.CULLED);
644
+
645
+ // Color
646
+
647
+ let f0;
648
+ if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
649
+ f0 = RENDER_PASSES.NOT_RENDERED;
650
+ } else {
651
+ if (transparent) {
652
+ f0 = RENDER_PASSES.COLOR_TRANSPARENT;
653
+ } else {
654
+ f0 = RENDER_PASSES.COLOR_OPAQUE;
655
+ }
656
+ }
657
+
658
+ // Silhouette
659
+
660
+ let f1;
661
+ if (!visible || culled) {
662
+ f1 = RENDER_PASSES.NOT_RENDERED;
663
+ } else if (selected) {
664
+ f1 = RENDER_PASSES.SILHOUETTE_SELECTED;
665
+ } else if (highlighted) {
666
+ f1 = RENDER_PASSES.SILHOUETTE_HIGHLIGHTED;
667
+ } else if (xrayed) {
668
+ f1 = RENDER_PASSES.SILHOUETTE_XRAYED;
669
+ } else {
670
+ f1 = RENDER_PASSES.NOT_RENDERED;
671
+ }
672
+
673
+ // Edges
674
+
675
+ let f2 = 0;
676
+ if (!visible || culled) {
677
+ f2 = RENDER_PASSES.NOT_RENDERED;
678
+ } else if (selected) {
679
+ f2 = RENDER_PASSES.EDGES_SELECTED;
680
+ } else if (highlighted) {
681
+ f2 = RENDER_PASSES.EDGES_HIGHLIGHTED;
682
+ } else if (xrayed) {
683
+ f2 = RENDER_PASSES.EDGES_XRAYED;
684
+ } else if (edges) {
685
+ if (transparent) {
686
+ f2 = RENDER_PASSES.EDGES_COLOR_TRANSPARENT;
687
+ } else {
688
+ f2 = RENDER_PASSES.EDGES_COLOR_OPAQUE;
689
+ }
690
+ } else {
691
+ f2 = RENDER_PASSES.NOT_RENDERED;
692
+ }
693
+
694
+ // Pick
695
+
696
+ let f3 = (visible && !culled && pickable) ? RENDER_PASSES.PICK : RENDER_PASSES.NOT_RENDERED;
697
+
698
+ for (let i = 0; i < lenFlags; i += 4) {
699
+ tempArray[i + 0] = f0; // x - normal fill
700
+ tempArray[i + 1] = f1; // y - emphasis fill
701
+ tempArray[i + 2] = f2; // z - edges
702
+ tempArray[i + 3] = f3; // w - pick
703
+ }
704
+
705
+ this._state.flagsBuf.setData(tempArray, firstFlag, lenFlags);
706
+ }
707
+
708
+ _setFlags2(portionId, flags) {
709
+
710
+ if (!this._finalized) {
711
+ throw "Not finalized";
712
+ }
713
+
714
+ const portionsIdx = portionId * 2;
715
+ const vertexBase = this._portions[portionsIdx];
716
+ const numVerts = this._portions[portionsIdx + 1];
717
+ const firstFlag = vertexBase * 4;
718
+ const lenFlags = numVerts * 4;
719
+ const tempArray = this._scratchMemory.getUInt8Array(lenFlags);
720
+
721
+ const clippable = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 255 : 0;
722
+
723
+ for (let i = 0; i < lenFlags; i += 4) {
724
+ tempArray[i + 0] = clippable;
725
+ }
726
+
727
+ this._state.flags2Buf.setData(tempArray, firstFlag, lenFlags);
728
+ }
729
+
730
+ setOffset(portionId, offset) {
731
+ if (!this._finalized) {
732
+ throw "Not finalized";
733
+ }
734
+ if (!this.model.scene.entityOffsetsEnabled) {
735
+ this.model.error("Entity#offset not enabled for this Viewer"); // See Viewer entityOffsetsEnabled
736
+ return;
737
+ }
738
+ const portionsIdx = portionId * 2;
739
+ const vertexBase = this._portions[portionsIdx];
740
+ const numVerts = this._portions[portionsIdx + 1];
741
+ const firstOffset = vertexBase * 3;
742
+ const lenOffsets = numVerts * 3;
743
+ const tempArray = this._scratchMemory.getFloat32Array(lenOffsets);
744
+ const x = offset[0];
745
+ const y = offset[1];
746
+ const z = offset[2];
747
+ for (let i = 0; i < lenOffsets; i += 3) {
748
+ tempArray[i + 0] = x;
749
+ tempArray[i + 1] = y;
750
+ tempArray[i + 2] = z;
751
+ }
752
+ this._state.offsetsBuf.setData(tempArray, firstOffset, lenOffsets);
753
+ }
754
+
755
+ // ---------------------- COLOR RENDERING -----------------------------------
756
+
757
+ drawColorOpaque(renderFlags, frameCtx) {
758
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === this._numPortions || this._numXRayedLayerPortions === this._numPortions) {
759
+ return;
760
+ }
761
+ this._updateBackfaceCull(renderFlags, frameCtx);
762
+ if (frameCtx.withSAO && this.model.saoEnabled) {
763
+ if (frameCtx.pbrEnabled && this.model.pbrEnabled) {
764
+ if (this._batchingRenderers.colorQualityRendererWithSAO) {
765
+ this._batchingRenderers.colorQualityRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
766
+ }
767
+ } else {
768
+ if (this._batchingRenderers.colorRendererWithSAO) {
769
+ this._batchingRenderers.colorRendererWithSAO.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
770
+ }
771
+ }
772
+ } else {
773
+ if (frameCtx.pbrEnabled && this.model.pbrEnabled) {
774
+ if (this._batchingRenderers.colorQualityRenderer) {
775
+ this._batchingRenderers.colorQualityRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
776
+ }
777
+ } else {
778
+ if (this._batchingRenderers.colorRenderer) {
779
+ this._batchingRenderers.colorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
780
+ }
781
+ }
782
+ }
783
+ }
784
+
785
+ _updateBackfaceCull(renderFlags, frameCtx) {
786
+ const backfaces = this.model.backfaces || (!this.solid) || renderFlags.sectioned;
787
+ if (frameCtx.backfaces !== backfaces) {
788
+ const gl = frameCtx.gl;
789
+ if (backfaces) {
790
+ gl.disable(gl.CULL_FACE);
791
+ } else {
792
+ gl.enable(gl.CULL_FACE);
793
+ }
794
+ frameCtx.backfaces = backfaces;
795
+ }
796
+ }
797
+
798
+ drawColorTransparent(renderFlags, frameCtx) {
799
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === 0 || this._numXRayedLayerPortions === this._numPortions) {
800
+ return;
801
+ }
802
+ this._updateBackfaceCull(renderFlags, frameCtx);
803
+ if (frameCtx.pbrEnabled && this.model.pbrEnabled) {
804
+ if (this._batchingRenderers.colorQualityRenderer) {
805
+ this._batchingRenderers.colorQualityRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_TRANSPARENT);
806
+ }
807
+ } else {
808
+ if (this._batchingRenderers.colorRenderer) {
809
+ this._batchingRenderers.colorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_TRANSPARENT);
810
+ }
811
+ }
812
+ }
813
+
814
+ // ---------------------- RENDERING SAO POST EFFECT TARGETS --------------
815
+
816
+ drawDepth(renderFlags, frameCtx) {
817
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === this._numPortions || this._numXRayedLayerPortions === this._numPortions) {
818
+ return;
819
+ }
820
+ this._updateBackfaceCull(renderFlags, frameCtx);
821
+ if (this._batchingRenderers.depthRenderer) {
822
+ this._batchingRenderers.depthRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE); // Assume whatever post-effect uses depth (eg SAO) does not apply to transparent objects
823
+ }
824
+ }
825
+
826
+ drawNormals(renderFlags, frameCtx) {
827
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numTransparentLayerPortions === this._numPortions || this._numXRayedLayerPortions === this._numPortions) {
828
+ return;
829
+ }
830
+ this._updateBackfaceCull(renderFlags, frameCtx);
831
+ if (this._batchingRenderers.normalsRenderer) {
832
+ this._batchingRenderers.normalsRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE); // Assume whatever post-effect uses normals (eg SAO) does not apply to transparent objects
833
+ }
834
+ }
835
+
836
+ // ---------------------- SILHOUETTE RENDERING -----------------------------------
837
+
838
+ drawSilhouetteXRayed(renderFlags, frameCtx) {
839
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numXRayedLayerPortions === 0) {
840
+ return;
841
+ }
842
+ this._updateBackfaceCull(renderFlags, frameCtx);
843
+ if (this._batchingRenderers.silhouetteRenderer) {
844
+ this._batchingRenderers.silhouetteRenderer.drawLayer(frameCtx, this, RENDER_PASSES.SILHOUETTE_XRAYED);
845
+ }
846
+ }
847
+
848
+ drawSilhouetteHighlighted(renderFlags, frameCtx) {
849
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numHighlightedLayerPortions === 0) {
850
+ return;
851
+ }
852
+ this._updateBackfaceCull(renderFlags, frameCtx);
853
+ if (this._batchingRenderers.silhouetteRenderer) {
854
+ this._batchingRenderers.silhouetteRenderer.drawLayer(frameCtx, this, RENDER_PASSES.SILHOUETTE_HIGHLIGHTED);
855
+ }
856
+ }
857
+
858
+ drawSilhouetteSelected(renderFlags, frameCtx) {
859
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numSelectedLayerPortions === 0) {
860
+ return;
861
+ }
862
+ this._updateBackfaceCull(renderFlags, frameCtx);
863
+ if (this._batchingRenderers.silhouetteRenderer) {
864
+ this._batchingRenderers.silhouetteRenderer.drawLayer(frameCtx, this, RENDER_PASSES.SILHOUETTE_SELECTED);
865
+ }
866
+ }
867
+
868
+ // ---------------------- EDGES RENDERING -----------------------------------
869
+
870
+ drawEdgesColorOpaque(renderFlags, frameCtx) {
871
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numEdgesLayerPortions === 0) {
872
+ return;
873
+ }
874
+ if (this._batchingRenderers.edgesColorRenderer) {
875
+ this._batchingRenderers.edgesColorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_COLOR_OPAQUE);
876
+ }
877
+ }
878
+
879
+ drawEdgesColorTransparent(renderFlags, frameCtx) {
880
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numEdgesLayerPortions === 0 || this._numTransparentLayerPortions === 0) {
881
+ return;
882
+ }
883
+ if (this._batchingRenderers.edgesColorRenderer) {
884
+ this._batchingRenderers.edgesColorRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_COLOR_TRANSPARENT);
885
+ }
886
+ }
887
+
888
+ drawEdgesHighlighted(renderFlags, frameCtx) {
889
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numHighlightedLayerPortions === 0) {
890
+ return;
891
+ }
892
+ if (this._batchingRenderers.edgesRenderer) {
893
+ this._batchingRenderers.edgesRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_HIGHLIGHTED);
894
+ }
895
+ }
896
+
897
+ drawEdgesSelected(renderFlags, frameCtx) {
898
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numSelectedLayerPortions === 0) {
899
+ return;
900
+ }
901
+ if (this._batchingRenderers.edgesRenderer) {
902
+ this._batchingRenderers.edgesRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_SELECTED);
903
+ }
904
+ }
905
+
906
+ drawEdgesXRayed(renderFlags, frameCtx) {
907
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0 || this._numXRayedLayerPortions === 0) {
908
+ return;
909
+ }
910
+ if (this._batchingRenderers.edgesRenderer) {
911
+ this._batchingRenderers.edgesRenderer.drawLayer(frameCtx, this, RENDER_PASSES.EDGES_XRAYED);
912
+ }
913
+ }
914
+
915
+ // ---------------------- OCCLUSION CULL RENDERING -----------------------------------
916
+
917
+ drawOcclusion(renderFlags, frameCtx) {
918
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
919
+ return;
920
+ }
921
+ this._updateBackfaceCull(renderFlags, frameCtx);
922
+ if (this._batchingRenderers.occlusionRenderer) {
923
+ this._batchingRenderers.occlusionRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
924
+ }
925
+ }
926
+
927
+ // ---------------------- SHADOW BUFFER RENDERING -----------------------------------
928
+
929
+ drawShadow(renderFlags, frameCtx) {
930
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
931
+ return;
932
+ }
933
+ this._updateBackfaceCull(renderFlags, frameCtx);
934
+ if (this._batchingRenderers.shadowRenderer) {
935
+ this._batchingRenderers.shadowRenderer.drawLayer(frameCtx, this, RENDER_PASSES.COLOR_OPAQUE);
936
+ }
937
+ }
938
+
939
+ //---- PICKING ----------------------------------------------------------------------------------------------------
940
+
941
+ drawPickMesh(renderFlags, frameCtx) {
942
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
943
+ return;
944
+ }
945
+ this._updateBackfaceCull(renderFlags, frameCtx);
946
+ if (this._batchingRenderers.pickMeshRenderer) {
947
+ this._batchingRenderers.pickMeshRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
948
+ }
949
+ }
950
+
951
+ drawPickDepths(renderFlags, frameCtx) {
952
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
953
+ return;
954
+ }
955
+ this._updateBackfaceCull(renderFlags, frameCtx);
956
+ if (this._batchingRenderers.pickDepthRenderer) {
957
+ this._batchingRenderers.pickDepthRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
958
+ }
959
+ }
960
+
961
+ drawPickNormals(renderFlags, frameCtx) {
962
+ if (this._numCulledLayerPortions === this._numPortions || this._numVisibleLayerPortions === 0) {
963
+ return;
964
+ }
965
+ this._updateBackfaceCull(renderFlags, frameCtx);
966
+ if (this._batchingRenderers.pickNormalsRenderer) {
967
+ this._batchingRenderers.pickNormalsRenderer.drawLayer(frameCtx, this, RENDER_PASSES.PICK);
968
+ }
969
+ }
970
+
971
+ destroy() {
972
+ const state = this._state;
973
+ if (state.positionsBuf) {
974
+ state.positionsBuf.destroy();
975
+ state.positionsBuf = null;
976
+ }
977
+ if (state.offsetsBuf) {
978
+ state.offsetsBuf.destroy();
979
+ state.offsetsBuf = null;
980
+ }
981
+ if (state.normalsBuf) {
982
+ state.normalsBuf.destroy();
983
+ state.normalsBuf = null;
984
+ }
985
+ if (state.colorsBuf) {
986
+ state.colorsBuf.destroy();
987
+ state.colorsBuf = null;
988
+ }
989
+ if (state.metallicRoughnessBuf) {
990
+ state.metallicRoughnessBuf.destroy();
991
+ state.metallicRoughnessBuf = null;
992
+ }
993
+ if (state.flagsBuf) {
994
+ state.flagsBuf.destroy();
995
+ state.flagsBuf = null;
996
+ }
997
+ if (state.flags2Buf) {
998
+ state.flags2Buf.destroy();
999
+ state.flags2Buf = null;
1000
+ }
1001
+ if (state.pickColorsBuf) {
1002
+ state.pickColorsBuf.destroy();
1003
+ state.pickColorsBuf = null;
1004
+ }
1005
+ if (state.indicesBuf) {
1006
+ state.indicesBuf.destroy();
1007
+ state.indicessBuf = null;
1008
+ }
1009
+ if (state.edgeIndicesBuf) {
1010
+ state.edgeIndicesBuf.destroy();
1011
+ state.edgeIndicessBuf = null;
1012
+ }
1013
+ state.destroy();
1014
+ }
1015
+ }
1016
+
1017
+ export {TrianglesBatchingLayer};