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,354 @@
1
+ import {Program} from "../../../../../webgl/Program.js";
2
+ import {createRTCViewMat, getPlaneRTCPos} from "../../../../../math/rtcCoords.js";
3
+ import {math} from "../../../../../math/math.js";
4
+ import {WEBGL_INFO} from "../../../../../webglInfo.js";
5
+
6
+ const tempVec3a = math.vec3();
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ class TrianglesInstancingNormalsRenderer {
12
+
13
+ constructor(scene) {
14
+ this._scene = scene;
15
+ this._hash = this._getHash();
16
+ this._allocate();
17
+ }
18
+
19
+ getValid() {
20
+ return this._hash === this._getHash();
21
+ };
22
+
23
+ _getHash() {
24
+ return this._scene._sectionPlanesState.getHash();
25
+ }
26
+
27
+ drawLayer(frameCtx, instancingLayer, renderPass) {
28
+
29
+ const model = instancingLayer.model;
30
+ const scene = model.scene;
31
+ const camera = scene.camera;
32
+ const gl = scene.canvas.gl;
33
+ const state = instancingLayer._state;
34
+ const instanceExt = this._instanceExt;
35
+ const rtcCenter = instancingLayer._state.rtcCenter;
36
+
37
+ if (!this._program) {
38
+ this._allocate(instancingLayer);
39
+ if (this.errors) {
40
+ return;
41
+ }
42
+ }
43
+
44
+ if (frameCtx.lastProgramId !== this._program.id) {
45
+ frameCtx.lastProgramId = this._program.id;
46
+ this._bindProgram();
47
+ }
48
+
49
+ gl.uniform1i(this._uRenderPass, renderPass);
50
+
51
+ gl.uniformMatrix4fv(this._uViewMatrix, false, (rtcCenter) ? createRTCViewMat(camera.viewMatrix, rtcCenter) : camera.viewMatrix);
52
+ gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
53
+
54
+ gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
55
+ gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
56
+
57
+ const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
58
+ if (numSectionPlanes > 0) {
59
+ const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
60
+ const baseIndex = instancingLayer.layerIndex * numSectionPlanes;
61
+ const renderFlags = model.renderFlags;
62
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
63
+ const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
64
+ if (sectionPlaneUniforms) {
65
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
66
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
67
+ if (active) {
68
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
69
+ if (rtcCenter) {
70
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, rtcCenter, tempVec3a);
71
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
72
+ } else {
73
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
74
+ }
75
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ gl.uniformMatrix4fv(this._uPositionsDecodeMatrix, false, instancingLayer._state.positionsDecodeMatrix);
82
+
83
+ this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
84
+ this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
85
+ this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
86
+
87
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol0.location, 1);
88
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol1.location, 1);
89
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol2.location, 1);
90
+
91
+ this._aPosition.bindArrayBuffer(state.positionsBuf);
92
+ this._aNormal.bindArrayBuffer(state.normalsBuf);
93
+
94
+ if (this._aOffset) {
95
+ this._aOffset.bindArrayBuffer(state.offsetsBuf);
96
+ instanceExt.vertexAttribDivisorANGLE(this._aOffset.location, 1);
97
+ }
98
+
99
+ this._aColor.bindArrayBuffer(state.colorsBuf);
100
+ instanceExt.vertexAttribDivisorANGLE(this._aColor.location, 1);
101
+
102
+ this._aFlags.bindArrayBuffer(state.flagsBuf);
103
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags.location, 1);
104
+
105
+ if (this._aFlags2) {
106
+ this._aFlags2.bindArrayBuffer(state.flags2Buf);
107
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags2.location, 1);
108
+ }
109
+
110
+ state.indicesBuf.bind();
111
+
112
+ instanceExt.drawElementsInstancedANGLE(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
113
+
114
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol0.location, 0);
115
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol1.location, 0);
116
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol2.location, 0);
117
+ instanceExt.vertexAttribDivisorANGLE(this._aColor.location, 0);
118
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags.location, 0);
119
+
120
+ if (this._aFlags2) { // Won't be in shader when not clipping
121
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags2.location, 0);
122
+ }
123
+
124
+ if (this._aOffset) {
125
+ instanceExt.vertexAttribDivisorANGLE(this._aOffset.location, 0);
126
+ }
127
+ }
128
+
129
+ _allocate() {
130
+
131
+ const scene = this._scene;
132
+ const gl = scene.canvas.gl;
133
+ const sectionPlanesState = scene._sectionPlanesState;
134
+
135
+ this._program = new Program(gl, this._buildShader());
136
+
137
+ if (this._program.errors) {
138
+ this.errors = this._program.errors;
139
+ return;
140
+ }
141
+
142
+ this._instanceExt = gl.getExtension("ANGLE_instanced_arrays");
143
+
144
+ const program = this._program;
145
+
146
+ this._uRenderPass = program.getLocation("renderPass");
147
+ this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
148
+ this._uWorldMatrix = program.getLocation("worldMatrix");
149
+ this._uWorldNormalMatrix = program.getLocation("worldNormalMatrix");
150
+ this._uViewMatrix = program.getLocation("viewMatrix");
151
+ this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
152
+ this._uProjMatrix = program.getLocation("projMatrix");
153
+ this._uSectionPlanes = [];
154
+
155
+ const clips = sectionPlanesState.sectionPlanes;
156
+ for (let i = 0, len = clips.length; i < len; i++) {
157
+ this._uSectionPlanes.push({
158
+ active: program.getLocation("sectionPlaneActive" + i),
159
+ pos: program.getLocation("sectionPlanePos" + i),
160
+ dir: program.getLocation("sectionPlaneDir" + i)
161
+ });
162
+ }
163
+
164
+ this._aPosition = program.getAttribute("position");
165
+ this._aOffset = program.getAttribute("offset");
166
+ this._aNormal = program.getAttribute("normal");
167
+ this._aColor = program.getAttribute("color");
168
+ this._aFlags = program.getAttribute("flags");
169
+
170
+ if (this._aFlags2) {
171
+ this._aFlags2 = program.getAttribute("flags2");
172
+ }
173
+
174
+ this._aModelMatrixCol0 = program.getAttribute("modelMatrixCol0");
175
+ this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
176
+ this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
177
+
178
+ if ( scene.logarithmicDepthBufferEnabled) {
179
+ this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
180
+ }
181
+ }
182
+
183
+ _bindProgram() {
184
+
185
+ const scene = this._scene;
186
+ const gl = scene.canvas.gl;
187
+ const project = scene.camera.project;
188
+
189
+ this._program.bind();
190
+
191
+ gl.uniformMatrix4fv(this._uProjMatrix, false, project.matrix);
192
+
193
+ if ( scene.logarithmicDepthBufferEnabled) {
194
+ const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
195
+ gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
196
+ }
197
+ }
198
+
199
+ _buildShader() {
200
+ return {
201
+ vertex: this._buildVertexShader(),
202
+ fragment: this._buildFragmentShader()
203
+ };
204
+ }
205
+
206
+ _buildVertexShader() {
207
+ const scene = this._scene;
208
+ const sectionPlanesState = scene._sectionPlanesState;
209
+ const clipping = sectionPlanesState.sectionPlanes.length > 0;
210
+ const src = [];
211
+ src.push("// Instancing geometry normals drawing vertex shader");
212
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
213
+ src.push("#extension GL_EXT_frag_depth : enable");
214
+ }
215
+ src.push("uniform int renderPass;");
216
+ src.push("attribute vec3 position;");
217
+ if (scene.entityOffsetsEnabled) {
218
+ src.push("attribute vec3 offset;");
219
+ }
220
+ src.push("attribute vec3 normal;");
221
+ src.push("attribute vec4 color;");
222
+ src.push("attribute vec4 flags;");
223
+ src.push("attribute vec4 flags2;");
224
+ src.push("attribute vec4 modelMatrixCol0;");
225
+ src.push("attribute vec4 modelMatrixCol1;");
226
+ src.push("attribute vec4 modelMatrixCol2;");
227
+ src.push("uniform mat4 worldMatrix;");
228
+ src.push("uniform mat4 worldNormalMatrix;");
229
+ src.push("uniform mat4 viewMatrix;");
230
+ src.push("uniform mat4 projMatrix;");
231
+ src.push("uniform mat4 viewNormalMatrix;");
232
+ src.push("uniform mat4 positionsDecodeMatrix;");
233
+ if (scene.logarithmicDepthBufferEnabled) {
234
+ src.push("uniform float logDepthBufFC;");
235
+ if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
236
+ src.push("varying float vFragDepth;");
237
+ }
238
+ }
239
+ src.push("vec3 octDecode(vec2 oct) {");
240
+ src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
241
+ src.push(" if (v.z < 0.0) {");
242
+ src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");
243
+ src.push(" }");
244
+ src.push(" return normalize(v);");
245
+ src.push("}");
246
+ if (clipping) {
247
+ src.push("varying vec4 vWorldPosition;");
248
+ src.push("varying vec4 vFlags2;");
249
+ }
250
+ src.push("varying vec3 vViewNormal;");
251
+ src.push("void main(void) {");
252
+
253
+ // flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
254
+ // renderPass = COLOR_OPAQUE
255
+
256
+ src.push(`if (int(flags.x) != renderPass) {`);
257
+ src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");
258
+ src.push("} else {");
259
+ src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
260
+ src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
261
+ if (scene.entityOffsetsEnabled) {
262
+ src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
263
+ }
264
+ src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
265
+ src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");
266
+ src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");
267
+
268
+ if (clipping) {
269
+ src.push("vWorldPosition = worldPosition;");
270
+ src.push("vFlags2 = flags2;");
271
+ }
272
+ src.push(" vViewNormal = viewNormal;");
273
+ src.push("vec4 clipPos = projMatrix * viewPosition;");
274
+ if (scene.logarithmicDepthBufferEnabled) {
275
+ if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
276
+ src.push("vFragDepth = 1.0 + clipPos.w;");
277
+ } else {
278
+ src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
279
+ src.push("clipPos.z *= clipPos.w;");
280
+ }
281
+ }
282
+ src.push("gl_Position = clipPos;");
283
+ src.push("}");
284
+ src.push("}");
285
+ return src;
286
+ }
287
+
288
+ _buildFragmentShader() {
289
+ const scene = this._scene;
290
+ const sectionPlanesState = scene._sectionPlanesState;
291
+ const clipping = sectionPlanesState.sectionPlanes.length > 0;
292
+ const src = [];
293
+ src.push("// Instancing geometry depth drawing fragment shader");
294
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
295
+ src.push("#extension GL_EXT_frag_depth : enable");
296
+ }
297
+ src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
298
+ src.push("precision highp float;");
299
+ src.push("precision highp int;");
300
+ src.push("#else");
301
+ src.push("precision mediump float;");
302
+ src.push("precision mediump int;");
303
+ src.push("#endif");
304
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
305
+ src.push("uniform float logDepthBufFC;");
306
+ src.push("varying float vFragDepth;");
307
+ }
308
+ if (clipping) {
309
+ src.push("varying vec4 vWorldPosition;");
310
+ src.push("varying vec4 vFlags2;");
311
+ for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
312
+ src.push("uniform bool sectionPlaneActive" + i + ";");
313
+ src.push("uniform vec3 sectionPlanePos" + i + ";");
314
+ src.push("uniform vec3 sectionPlaneDir" + i + ";");
315
+ }
316
+ }
317
+ src.push("varying vec3 vViewNormal;");
318
+ src.push("vec3 packNormalToRGB( const in vec3 normal ) {");
319
+ src.push(" return normalize( normal ) * 0.5 + 0.5;");
320
+ src.push("}");
321
+ src.push("void main(void) {");
322
+ if (clipping) {
323
+ src.push(" bool clippable = (float(vFlags2.x) > 0.0);");
324
+ src.push(" if (clippable) {");
325
+ src.push(" float dist = 0.0;");
326
+ for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
327
+ src.push("if (sectionPlaneActive" + i + ") {");
328
+ src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
329
+ src.push("}");
330
+ }
331
+ src.push("if (dist > 0.0) { discard; }");
332
+ src.push("}");
333
+ }
334
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
335
+ src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
336
+ }
337
+ src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");
338
+ src.push("}");
339
+ return src;
340
+ }
341
+
342
+ webglContextRestored() {
343
+ this._program = null;
344
+ }
345
+
346
+ destroy() {
347
+ if (this._program) {
348
+ this._program.destroy();
349
+ }
350
+ this._program = null;
351
+ }
352
+ }
353
+
354
+ export {TrianglesInstancingNormalsRenderer};
@@ -0,0 +1,329 @@
1
+ import {Program} from "../../../../../webgl/Program.js";
2
+ import {createRTCViewMat, getPlaneRTCPos} from "../../../../../math/rtcCoords.js";
3
+ import {math} from "../../../../../math/math.js";
4
+ import {WEBGL_INFO} from "../../../../../webglInfo.js";
5
+
6
+ const tempVec3a = math.vec3();
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ class TrianglesInstancingOcclusionRenderer {
12
+
13
+ constructor(scene) {
14
+ this._scene = scene;
15
+ this._hash = this._getHash();
16
+ this._allocate();
17
+ }
18
+
19
+ getValid() {
20
+ return this._hash === this._getHash();
21
+ };
22
+
23
+ _getHash() {
24
+ return this._scene._sectionPlanesState.getHash();
25
+ }
26
+
27
+ drawLayer(frameCtx, instancingLayer, renderPass) {
28
+
29
+ const model = instancingLayer.model;
30
+ const scene = model.scene;
31
+ const camera = scene.camera;
32
+ const gl = scene.canvas.gl;
33
+ const state = instancingLayer._state;
34
+ const instanceExt = this._instanceExt;
35
+ const rtcCenter = instancingLayer._state.rtcCenter;
36
+
37
+ if (!this._program) {
38
+ this._allocate();
39
+ if (this.errors) {
40
+ return;
41
+ }
42
+ }
43
+
44
+ if (frameCtx.lastProgramId !== this._program.id) {
45
+ frameCtx.lastProgramId = this._program.id;
46
+ this._bindProgram();
47
+ }
48
+
49
+ gl.uniform1i(this._uRenderPass, renderPass);
50
+
51
+ gl.uniformMatrix4fv(this._uViewMatrix, false, (rtcCenter) ? createRTCViewMat(camera.viewMatrix, rtcCenter) : camera.viewMatrix);
52
+ gl.uniformMatrix4fv(this._uWorldMatrix, false, model.worldMatrix);
53
+
54
+ const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
55
+ if (numSectionPlanes > 0) {
56
+ const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
57
+ const baseIndex = instancingLayer.layerIndex * numSectionPlanes;
58
+ const renderFlags = model.renderFlags;
59
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
60
+ const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
61
+ if (sectionPlaneUniforms) {
62
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
63
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
64
+ if (active) {
65
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
66
+ if (rtcCenter) {
67
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, rtcCenter, tempVec3a);
68
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
69
+ } else {
70
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
71
+ }
72
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ gl.uniformMatrix4fv(this._uPositionsDecodeMatrix, false, instancingLayer._state.positionsDecodeMatrix);
79
+
80
+ this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);
81
+ this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);
82
+ this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);
83
+
84
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol0.location, 1);
85
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol1.location, 1);
86
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol2.location, 1);
87
+
88
+ if (this._aColor) {
89
+ this._aColor.bindArrayBuffer(state.colorsBuf);
90
+ instanceExt.vertexAttribDivisorANGLE(this._aColor.location, 1);
91
+ }
92
+
93
+ this._aPosition.bindArrayBuffer(state.positionsBuf);
94
+
95
+ if (this._aOffset) {
96
+ this._aOffset.bindArrayBuffer(state.offsetsBuf);
97
+ instanceExt.vertexAttribDivisorANGLE(this._aOffset.location, 1);
98
+ }
99
+
100
+ this._aFlags.bindArrayBuffer(state.flagsBuf);
101
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags.location, 1);
102
+
103
+ if (this._aFlags2) {
104
+ this._aFlags2.bindArrayBuffer(state.flags2Buf);
105
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags2.location, 1);
106
+ }
107
+
108
+ state.indicesBuf.bind();
109
+
110
+ instanceExt.drawElementsInstancedANGLE(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
111
+
112
+ // Cleanup
113
+
114
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol0.location, 0);
115
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol1.location, 0);
116
+ instanceExt.vertexAttribDivisorANGLE(this._aModelMatrixCol2.location, 0);
117
+ if (this._aColor) {
118
+ instanceExt.vertexAttribDivisorANGLE(this._aColor.location, 0);
119
+ }
120
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags.location, 0);
121
+ if (this._aFlags2) { // Won't be in shader when not clipping
122
+ instanceExt.vertexAttribDivisorANGLE(this._aFlags2.location, 0);
123
+ }
124
+ if (this._aOffset) {
125
+ instanceExt.vertexAttribDivisorANGLE(this._aOffset.location, 0);
126
+ }
127
+ }
128
+
129
+ _allocate() {
130
+
131
+ const scene = this._scene;
132
+ const gl = scene.canvas.gl;
133
+ const sectionPlanesState = scene._sectionPlanesState;
134
+
135
+ this._program = new Program(gl, this._buildShader());
136
+
137
+ if (this._program.errors) {
138
+ this.errors = this._program.errors;
139
+ return;
140
+ }
141
+
142
+ this._instanceExt = gl.getExtension("ANGLE_instanced_arrays");
143
+
144
+ const program = this._program;
145
+
146
+ this._uRenderPass = program.getLocation("renderPass");
147
+ this._uPositionsDecodeMatrix = program.getLocation("positionsDecodeMatrix");
148
+ this._uWorldMatrix = program.getLocation("worldMatrix");
149
+ this._uViewMatrix = program.getLocation("viewMatrix");
150
+ this._uProjMatrix = program.getLocation("projMatrix");
151
+ this._uSectionPlanes = [];
152
+
153
+ const clips = sectionPlanesState.sectionPlanes;
154
+ for (let i = 0, len = clips.length; i < len; i++) {
155
+ this._uSectionPlanes.push({
156
+ active: program.getLocation("sectionPlaneActive" + i),
157
+ pos: program.getLocation("sectionPlanePos" + i),
158
+ dir: program.getLocation("sectionPlaneDir" + i)
159
+ });
160
+ }
161
+
162
+ this._aPosition = program.getAttribute("position");
163
+ this._aOffset = program.getAttribute("offset");
164
+ this._aColor = program.getAttribute("color");
165
+ this._aFlags = program.getAttribute("flags");
166
+ this._aFlags2 = program.getAttribute("flags2");
167
+
168
+ this._aModelMatrixCol0 = program.getAttribute("modelMatrixCol0");
169
+ this._aModelMatrixCol1 = program.getAttribute("modelMatrixCol1");
170
+ this._aModelMatrixCol2 = program.getAttribute("modelMatrixCol2");
171
+
172
+ if (scene.logarithmicDepthBufferEnabled) {
173
+ this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
174
+ }
175
+ }
176
+
177
+ _bindProgram() {
178
+
179
+ const scene = this._scene;
180
+ const gl = scene.canvas.gl;
181
+ const project = scene.camera.project;
182
+
183
+ this._program.bind();
184
+
185
+ gl.uniformMatrix4fv(this._uProjMatrix, false, project.matrix);
186
+
187
+ if (scene.logarithmicDepthBufferEnabled) {
188
+ const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
189
+ gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
190
+ }
191
+ }
192
+
193
+ _buildShader() {
194
+ return {
195
+ vertex: this._buildVertexShader(),
196
+ fragment: this._buildFragmentShader()
197
+ };
198
+ }
199
+
200
+ _buildVertexShader() {
201
+ const scene = this._scene;
202
+ const sectionPlanesState = scene._sectionPlanesState;
203
+ const clipping = sectionPlanesState.sectionPlanes.length > 0;
204
+ const src = [];
205
+ src.push("// Instancing occlusion vertex shader");
206
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
207
+ src.push("#extension GL_EXT_frag_depth : enable");
208
+ }
209
+ src.push("uniform int renderPass;");
210
+ src.push("attribute vec3 position;");
211
+ if (scene.entityOffsetsEnabled) {
212
+ src.push("attribute vec3 offset;");
213
+ }
214
+ src.push("attribute vec4 color;");
215
+ src.push("attribute vec4 flags;");
216
+ src.push("attribute vec4 flags2;");
217
+ src.push("attribute vec4 modelMatrixCol0;"); // Modeling matrix
218
+ src.push("attribute vec4 modelMatrixCol1;");
219
+ src.push("attribute vec4 modelMatrixCol2;");
220
+ src.push("uniform mat4 worldMatrix;");
221
+ src.push("uniform mat4 viewMatrix;");
222
+ src.push("uniform mat4 projMatrix;");
223
+ src.push("uniform mat4 positionsDecodeMatrix;");
224
+ if (scene.logarithmicDepthBufferEnabled) {
225
+ src.push("uniform float logDepthBufFC;");
226
+ if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
227
+ src.push("varying float vFragDepth;");
228
+ }
229
+ }
230
+ if (clipping) {
231
+ src.push("varying vec4 vWorldPosition;");
232
+ src.push("varying vec4 vFlags2;");
233
+ }
234
+ src.push("void main(void) {");
235
+
236
+ // flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
237
+ // renderPass = COLOR_OPAQUE
238
+
239
+ src.push(`if (int(flags.x) != renderPass) {`);
240
+ src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");
241
+
242
+ src.push("} else {");
243
+ src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");
244
+ src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");
245
+ if (scene.entityOffsetsEnabled) {
246
+ src.push(" worldPosition.xyz = worldPosition.xyz + offset;");
247
+ }
248
+ src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");
249
+ if (clipping) {
250
+ src.push(" vWorldPosition = worldPosition;");
251
+ }
252
+ src.push("vec4 clipPos = projMatrix * viewPosition;");
253
+ if (scene.logarithmicDepthBufferEnabled) {
254
+ if (WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
255
+ src.push("vFragDepth = 1.0 + clipPos.w;");
256
+ } else {
257
+ src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
258
+ src.push("clipPos.z *= clipPos.w;");
259
+ }
260
+ }
261
+ src.push("gl_Position = clipPos;");
262
+ src.push("}");
263
+ src.push("}");
264
+ return src;
265
+ }
266
+
267
+ _buildFragmentShader() {
268
+ const scene = this._scene;
269
+ const sectionPlanesState = scene._sectionPlanesState;
270
+ const clipping = sectionPlanesState.sectionPlanes.length > 0;
271
+ const src = [];
272
+ src.push("// Instancing occlusion fragment shader");
273
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
274
+ src.push("#extension GL_EXT_frag_depth : enable");
275
+ }
276
+ src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
277
+ src.push("precision highp float;");
278
+ src.push("precision highp int;");
279
+ src.push("#else");
280
+ src.push("precision mediump float;");
281
+ src.push("precision mediump int;");
282
+ src.push("#endif");
283
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
284
+ src.push("uniform float logDepthBufFC;");
285
+ src.push("varying float vFragDepth;");
286
+ }
287
+ if (clipping) {
288
+ src.push("varying vec4 vWorldPosition;");
289
+ src.push("varying vec4 vFlags2;");
290
+ for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
291
+ src.push("uniform bool sectionPlaneActive" + i + ";");
292
+ src.push("uniform vec3 sectionPlanePos" + i + ";");
293
+ src.push("uniform vec3 sectionPlaneDir" + i + ";");
294
+ }
295
+ }
296
+ src.push("void main(void) {");
297
+ if (clipping) {
298
+ src.push(" bool clippable = (float(vFlags2.x) > 0.0);");
299
+ src.push(" if (clippable) {");
300
+ src.push(" float dist = 0.0;");
301
+ for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
302
+ src.push("if (sectionPlaneActive" + i + ") {");
303
+ src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
304
+ src.push("}");
305
+ }
306
+ src.push("if (dist > 0.0) { discard; }");
307
+ src.push("}");
308
+ }
309
+ src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); "); // Occluders are blue
310
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
311
+ src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
312
+ }
313
+ src.push("}");
314
+ return src;
315
+ }
316
+
317
+ webglContextRestored() {
318
+ this._program = null;
319
+ }
320
+
321
+ destroy() {
322
+ if (this._program) {
323
+ this._program.destroy();
324
+ }
325
+ this._program = null;
326
+ }
327
+ }
328
+
329
+ export {TrianglesInstancingOcclusionRenderer};