@xeokit/xeokit-sdk 2.5.2-beta-11 → 2.5.2-beta-16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (463) hide show
  1. package/dist/xeokit-sdk.cjs.js +176 -141
  2. package/dist/xeokit-sdk.es.js +176 -141
  3. package/dist/xeokit-sdk.es5.js +151 -149
  4. package/dist/xeokit-sdk.min.cjs.js +2 -2
  5. package/dist/xeokit-sdk.min.es.js +2 -2
  6. package/dist/xeokit-sdk.min.es5.js +2 -2
  7. package/package.json +1 -1
  8. package/src/viewer/metadata/MetaModel.js +15 -0
  9. package/src/viewer/metadata/MetaScene.js +15 -9
  10. package/src/viewer/scene/model/SceneModel.js +1 -1
  11. package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
  12. package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
  13. package/src/viewer/scene/webgl/Renderer.js +20 -19
  14. package/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +0 -663
  15. package/src/src/extras/ContextMenu/ContextMenu.js +0 -907
  16. package/src/src/extras/ContextMenu/index.js +0 -1
  17. package/src/src/extras/MarqueePicker/MarqueePicker.js +0 -352
  18. package/src/src/extras/MarqueePicker/MarqueePickerMouseControl.js +0 -174
  19. package/src/src/extras/MarqueePicker/index.js +0 -2
  20. package/src/src/extras/PointerLens/PointerLens.js +0 -312
  21. package/src/src/extras/PointerLens/index.js +0 -1
  22. package/src/src/extras/collision/ObjectsKdTree3.js +0 -149
  23. package/src/src/extras/collision/index.js +0 -1
  24. package/src/src/extras/index.js +0 -4
  25. package/src/src/index.js +0 -3
  26. package/src/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +0 -731
  27. package/src/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.js +0 -84
  28. package/src/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +0 -435
  29. package/src/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.js +0 -406
  30. package/src/src/plugins/AngleMeasurementsPlugin/index.js +0 -3
  31. package/src/src/plugins/AnnotationsPlugin/Annotation.js +0 -368
  32. package/src/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +0 -583
  33. package/src/src/plugins/AnnotationsPlugin/index.js +0 -1
  34. package/src/src/plugins/AxisGizmoPlugin/AxisGizmoPlugin.js +0 -333
  35. package/src/src/plugins/AxisGizmoPlugin/index.js +0 -1
  36. package/src/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js +0 -977
  37. package/src/src/plugins/BCFViewpointsPlugin/index.js +0 -1
  38. package/src/src/plugins/CityJSONLoaderPlugin/CityJSONDefaultDataSource.js +0 -29
  39. package/src/src/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.js +0 -751
  40. package/src/src/plugins/CityJSONLoaderPlugin/index.js +0 -1
  41. package/src/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +0 -963
  42. package/src/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.js +0 -84
  43. package/src/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +0 -399
  44. package/src/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +0 -505
  45. package/src/src/plugins/DistanceMeasurementsPlugin/index.js +0 -3
  46. package/src/src/plugins/FaceAlignedSectionPlanesPlugin/FaceAlignedSectionPlanesControl.js +0 -639
  47. package/src/src/plugins/FaceAlignedSectionPlanesPlugin/FaceAlignedSectionPlanesPlugin.js +0 -436
  48. package/src/src/plugins/FaceAlignedSectionPlanesPlugin/Overview.js +0 -247
  49. package/src/src/plugins/FaceAlignedSectionPlanesPlugin/Plane.js +0 -167
  50. package/src/src/plugins/FaceAlignedSectionPlanesPlugin/index.js +0 -1
  51. package/src/src/plugins/FastNavPlugin/FastNavPlugin.js +0 -429
  52. package/src/src/plugins/FastNavPlugin/index.js +0 -1
  53. package/src/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +0 -140
  54. package/src/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +0 -421
  55. package/src/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +0 -669
  56. package/src/src/plugins/GLTFLoaderPlugin/index.js +0 -2
  57. package/src/src/plugins/LASLoaderPlugin/LASDefaultDataSource.js +0 -58
  58. package/src/src/plugins/LASLoaderPlugin/LASLoaderPlugin.js +0 -563
  59. package/src/src/plugins/LASLoaderPlugin/index.js +0 -1
  60. package/src/src/plugins/LASLoaderPlugin/loadLASHeader.js +0 -183
  61. package/src/src/plugins/NavCubePlugin/CubeTextureCanvas.js +0 -290
  62. package/src/src/plugins/NavCubePlugin/NavCubePlugin.js +0 -753
  63. package/src/src/plugins/NavCubePlugin/index.js +0 -1
  64. package/src/src/plugins/OBJLoaderPlugin/OBJLoaderPlugin.js +0 -145
  65. package/src/src/plugins/OBJLoaderPlugin/OBJSceneGraphLoader.js +0 -777
  66. package/src/src/plugins/OBJLoaderPlugin/index.js +0 -1
  67. package/src/src/plugins/STLLoaderPlugin/STLDefaultDataSource.js +0 -33
  68. package/src/src/plugins/STLLoaderPlugin/STLLoaderPlugin.js +0 -274
  69. package/src/src/plugins/STLLoaderPlugin/STLSceneGraphLoader.js +0 -313
  70. package/src/src/plugins/STLLoaderPlugin/index.js +0 -2
  71. package/src/src/plugins/SectionPlanesPlugin/Control.js +0 -1328
  72. package/src/src/plugins/SectionPlanesPlugin/Overview.js +0 -249
  73. package/src/src/plugins/SectionPlanesPlugin/Plane.js +0 -169
  74. package/src/src/plugins/SectionPlanesPlugin/SectionPlanesPlugin.js +0 -404
  75. package/src/src/plugins/SectionPlanesPlugin/index.js +0 -1
  76. package/src/src/plugins/SkyboxesPlugin/SkyboxesPlugin.js +0 -134
  77. package/src/src/plugins/SkyboxesPlugin/index.js +0 -1
  78. package/src/src/plugins/StoreyViewsPlugin/Storey.js +0 -84
  79. package/src/src/plugins/StoreyViewsPlugin/StoreyMap.js +0 -57
  80. package/src/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +0 -773
  81. package/src/src/plugins/StoreyViewsPlugin/index.js +0 -1
  82. package/src/src/plugins/TreeViewPlugin/RenderService.js +0 -169
  83. package/src/src/plugins/TreeViewPlugin/TreeViewNode.js +0 -101
  84. package/src/src/plugins/TreeViewPlugin/TreeViewPlugin.js +0 -1370
  85. package/src/src/plugins/TreeViewPlugin/index.js +0 -1
  86. package/src/src/plugins/ViewCullPlugin/ViewCullPlugin.js +0 -295
  87. package/src/src/plugins/ViewCullPlugin/index.js +0 -1
  88. package/src/src/plugins/WebIFCLoaderPlugin/WebIFCDefaultDataSource.js +0 -58
  89. package/src/src/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.js +0 -942
  90. package/src/src/plugins/WebIFCLoaderPlugin/index.js +0 -1
  91. package/src/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +0 -95
  92. package/src/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +0 -1194
  93. package/src/src/plugins/XKTLoaderPlugin/index.js +0 -2
  94. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV1.js +0 -169
  95. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV10.js +0 -660
  96. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +0 -663
  97. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV2.js +0 -230
  98. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV3.js +0 -223
  99. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV4.js +0 -283
  100. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV5.js +0 -246
  101. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +0 -301
  102. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +0 -439
  103. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +0 -563
  104. package/src/src/plugins/XKTLoaderPlugin/parsers/ParserV9.js +0 -518
  105. package/src/src/plugins/XKTLoaderPlugin/parsers/lib/pako.js +0 -2
  106. package/src/src/plugins/XML3DLoaderPlugin/XML3DLoaderPlugin.js +0 -238
  107. package/src/src/plugins/XML3DLoaderPlugin/XML3DSceneGraphLoader.js +0 -1279
  108. package/src/src/plugins/XML3DLoaderPlugin/index.js +0 -1
  109. package/src/src/plugins/XML3DLoaderPlugin/zipjs/.jshintrc +0 -11
  110. package/src/src/plugins/XML3DLoaderPlugin/zipjs/deflate.js +0 -2060
  111. package/src/src/plugins/XML3DLoaderPlugin/zipjs/inflate.js +0 -2155
  112. package/src/src/plugins/XML3DLoaderPlugin/zipjs/mime-types.js +0 -1002
  113. package/src/src/plugins/XML3DLoaderPlugin/zipjs/pako/codecs.js +0 -64
  114. package/src/src/plugins/XML3DLoaderPlugin/zipjs/z-worker.js +0 -153
  115. package/src/src/plugins/XML3DLoaderPlugin/zipjs/zip-ext.js +0 -267
  116. package/src/src/plugins/XML3DLoaderPlugin/zipjs/zip-fs.js +0 -553
  117. package/src/src/plugins/XML3DLoaderPlugin/zipjs/zip.js +0 -991
  118. package/src/src/plugins/XML3DLoaderPlugin/zipjs/zlib-asm/codecs.js +0 -49
  119. package/src/src/plugins/index.js +0 -21
  120. package/src/src/plugins/lib/culling/ObjectCullStates.js +0 -208
  121. package/src/src/plugins/lib/earcut.js +0 -677
  122. package/src/src/plugins/lib/html/Dot.js +0 -179
  123. package/src/src/plugins/lib/html/Label.js +0 -174
  124. package/src/src/plugins/lib/html/Wire.js +0 -220
  125. package/src/src/viewer/Configs.js +0 -127
  126. package/src/src/viewer/Plugin.js +0 -233
  127. package/src/src/viewer/Viewer.js +0 -542
  128. package/src/src/viewer/index.js +0 -5
  129. package/src/src/viewer/localization/LocaleService.js +0 -475
  130. package/src/src/viewer/metadata/IFCObjectDefaultColors.js +0 -163
  131. package/src/src/viewer/metadata/IFCObjectDefaults.js +0 -17
  132. package/src/src/viewer/metadata/MetaModel.js +0 -414
  133. package/src/src/viewer/metadata/MetaObject.js +0 -223
  134. package/src/src/viewer/metadata/MetaScene.js +0 -336
  135. package/src/src/viewer/metadata/Property.js +0 -55
  136. package/src/src/viewer/metadata/PropertySet.js +0 -77
  137. package/src/src/viewer/scene/Bitmap/Bitmap.js +0 -473
  138. package/src/src/viewer/scene/Bitmap/index.js +0 -1
  139. package/src/src/viewer/scene/CameraControl/CameraControl.js +0 -1750
  140. package/src/src/viewer/scene/CameraControl/lib/CameraUpdater.js +0 -312
  141. package/src/src/viewer/scene/CameraControl/lib/controllers/PanController.js +0 -112
  142. package/src/src/viewer/scene/CameraControl/lib/controllers/PickController.js +0 -265
  143. package/src/src/viewer/scene/CameraControl/lib/controllers/PivotController.js +0 -384
  144. package/src/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +0 -122
  145. package/src/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +0 -183
  146. package/src/src/viewer/scene/CameraControl/lib/handlers/MouseMiscHandler.js +0 -68
  147. package/src/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +0 -345
  148. package/src/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +0 -376
  149. package/src/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +0 -288
  150. package/src/src/viewer/scene/CameraControl/lib/handlers/TouchPickHandler.js +0 -235
  151. package/src/src/viewer/scene/Component.js +0 -915
  152. package/src/src/viewer/scene/Entity.js +0 -502
  153. package/src/src/viewer/scene/ImagePlane/ImagePlane.js +0 -570
  154. package/src/src/viewer/scene/ImagePlane/index.js +0 -1
  155. package/src/src/viewer/scene/LineSet/LineSet.js +0 -163
  156. package/src/src/viewer/scene/LineSet/index.js +0 -1
  157. package/src/src/viewer/scene/camera/Camera.js +0 -912
  158. package/src/src/viewer/scene/camera/CameraFlightAnimation.js +0 -669
  159. package/src/src/viewer/scene/camera/CameraPath.js +0 -194
  160. package/src/src/viewer/scene/camera/CameraPathAnimation.js +0 -326
  161. package/src/src/viewer/scene/camera/CustomProjection.js +0 -149
  162. package/src/src/viewer/scene/camera/Frustum.js +0 -316
  163. package/src/src/viewer/scene/camera/Ortho.js +0 -286
  164. package/src/src/viewer/scene/camera/Perspective.js +0 -304
  165. package/src/src/viewer/scene/camera/index.js +0 -2
  166. package/src/src/viewer/scene/canvas/Canvas.js +0 -490
  167. package/src/src/viewer/scene/canvas/Spinner.js +0 -323
  168. package/src/src/viewer/scene/constants/constants.js +0 -371
  169. package/src/src/viewer/scene/core.js +0 -268
  170. package/src/src/viewer/scene/geometry/Geometry.js +0 -33
  171. package/src/src/viewer/scene/geometry/ReadableGeometry.js +0 -682
  172. package/src/src/viewer/scene/geometry/VBOGeometry.js +0 -319
  173. package/src/src/viewer/scene/geometry/builders/buildBoxGeometry.js +0 -238
  174. package/src/src/viewer/scene/geometry/builders/buildBoxLinesGeometry.js +0 -106
  175. package/src/src/viewer/scene/geometry/builders/buildCylinderGeometry.js +0 -271
  176. package/src/src/viewer/scene/geometry/builders/buildGridGeometry.js +0 -102
  177. package/src/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +0 -168
  178. package/src/src/viewer/scene/geometry/builders/buildSphereGeometry.js +0 -161
  179. package/src/src/viewer/scene/geometry/builders/buildTorusGeometry.js +0 -172
  180. package/src/src/viewer/scene/geometry/builders/buildVectorTextGeometry.js +0 -1721
  181. package/src/src/viewer/scene/geometry/builders/index.js +0 -8
  182. package/src/src/viewer/scene/geometry/index.js +0 -4
  183. package/src/src/viewer/scene/geometry/loaders/index.js +0 -2
  184. package/src/src/viewer/scene/geometry/loaders/load3DSGeometry.js +0 -103
  185. package/src/src/viewer/scene/geometry/loaders/loadOBJGeometry.js +0 -130
  186. package/src/src/viewer/scene/index.js +0 -21
  187. package/src/src/viewer/scene/input/Input.js +0 -1333
  188. package/src/src/viewer/scene/libs/k3d.js +0 -1032
  189. package/src/src/viewer/scene/lights/AmbientLight.js +0 -175
  190. package/src/src/viewer/scene/lights/CubeTexture.js +0 -156
  191. package/src/src/viewer/scene/lights/DirLight.js +0 -314
  192. package/src/src/viewer/scene/lights/Light.js +0 -29
  193. package/src/src/viewer/scene/lights/LightMap.js +0 -77
  194. package/src/src/viewer/scene/lights/PointLight.js +0 -395
  195. package/src/src/viewer/scene/lights/ReflectionMap.js +0 -79
  196. package/src/src/viewer/scene/lights/Shadow.js +0 -138
  197. package/src/src/viewer/scene/lights/index.js +0 -5
  198. package/src/src/viewer/scene/marker/Marker.js +0 -383
  199. package/src/src/viewer/scene/marker/SpriteMarker.js +0 -356
  200. package/src/src/viewer/scene/marker/index.js +0 -2
  201. package/src/src/viewer/scene/materials/EdgeMaterial.js +0 -359
  202. package/src/src/viewer/scene/materials/EmphasisMaterial.js +0 -613
  203. package/src/src/viewer/scene/materials/Fresnel.js +0 -222
  204. package/src/src/viewer/scene/materials/LambertMaterial.js +0 -378
  205. package/src/src/viewer/scene/materials/LinesMaterial.js +0 -169
  206. package/src/src/viewer/scene/materials/Material.js +0 -39
  207. package/src/src/viewer/scene/materials/MetallicMaterial.js +0 -820
  208. package/src/src/viewer/scene/materials/PhongMaterial.js +0 -860
  209. package/src/src/viewer/scene/materials/PointsMaterial.js +0 -409
  210. package/src/src/viewer/scene/materials/SpecularMaterial.js +0 -807
  211. package/src/src/viewer/scene/materials/Texture.js +0 -513
  212. package/src/src/viewer/scene/materials/index.js +0 -8
  213. package/src/src/viewer/scene/math/Frustum.js +0 -118
  214. package/src/src/viewer/scene/math/buildEdgeIndices.js +0 -162
  215. package/src/src/viewer/scene/math/geometryCompressionUtils.js +0 -365
  216. package/src/src/viewer/scene/math/index.js +0 -3
  217. package/src/src/viewer/scene/math/math.js +0 -5386
  218. package/src/src/viewer/scene/math/rtcCoords.js +0 -139
  219. package/src/src/viewer/scene/mementos/CameraMemento.js +0 -200
  220. package/src/src/viewer/scene/mementos/ModelMemento.js +0 -263
  221. package/src/src/viewer/scene/mementos/ObjectsMemento.js +0 -259
  222. package/src/src/viewer/scene/mementos/index.js +0 -3
  223. package/src/src/viewer/scene/mesh/Mesh.js +0 -2202
  224. package/src/src/viewer/scene/mesh/draw/DrawRenderer.js +0 -996
  225. package/src/src/viewer/scene/mesh/draw/DrawShaderSource.js +0 -1570
  226. package/src/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +0 -259
  227. package/src/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +0 -159
  228. package/src/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +0 -286
  229. package/src/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +0 -262
  230. package/src/src/viewer/scene/mesh/index.js +0 -1
  231. package/src/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +0 -217
  232. package/src/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +0 -157
  233. package/src/src/viewer/scene/mesh/pick/PickMeshRenderer.js +0 -223
  234. package/src/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +0 -151
  235. package/src/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +0 -200
  236. package/src/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +0 -124
  237. package/src/src/viewer/scene/mesh/shadow/ShadowRenderer.js +0 -214
  238. package/src/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +0 -98
  239. package/src/src/viewer/scene/metriqs/Metriqs.js +0 -259
  240. package/src/src/viewer/scene/model/ENTITY_FLAGS.js +0 -21
  241. package/src/src/viewer/scene/model/PerformanceModel.js +0 -26
  242. package/src/src/viewer/scene/model/RENDER_PASSES.js +0 -34
  243. package/src/src/viewer/scene/model/SceneModel.js +0 -4018
  244. package/src/src/viewer/scene/model/SceneModelEntity.js +0 -715
  245. package/src/src/viewer/scene/model/SceneModelMesh.js +0 -341
  246. package/src/src/viewer/scene/model/SceneModelTexture.js +0 -38
  247. package/src/src/viewer/scene/model/SceneModelTextureSet.js +0 -59
  248. package/src/src/viewer/scene/model/SceneModelTransform.js +0 -404
  249. package/src/src/viewer/scene/model/VBOSceneModel.js +0 -26
  250. package/src/src/viewer/scene/model/calculateUniquePositions.js +0 -126
  251. package/src/src/viewer/scene/model/compression.js +0 -227
  252. package/src/src/viewer/scene/model/dtx/BindableDataTexture.js +0 -31
  253. package/src/src/viewer/scene/model/dtx/lines/DTXLinesBuffer.js +0 -27
  254. package/src/src/viewer/scene/model/dtx/lines/DTXLinesLayer.js +0 -891
  255. package/src/src/viewer/scene/model/dtx/lines/DTXLinesState.js +0 -46
  256. package/src/src/viewer/scene/model/dtx/lines/DTXLinesTextureFactory.js +0 -411
  257. package/src/src/viewer/scene/model/dtx/lines/dataTextureRamStats.js +0 -49
  258. package/src/src/viewer/scene/model/dtx/lines/rebucketPositions.js +0 -208
  259. package/src/src/viewer/scene/model/dtx/lines/renderers/DTXLinesColorRenderer.js +0 -389
  260. package/src/src/viewer/scene/model/dtx/lines/renderers/DTXLinesRenderers.js +0 -65
  261. package/src/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +0 -1322
  262. package/src/src/viewer/scene/model/dtx/triangles/lib/DTXTrianglesBuffer.js +0 -46
  263. package/src/src/viewer/scene/model/dtx/triangles/lib/DTXTrianglesState.js +0 -250
  264. package/src/src/viewer/scene/model/dtx/triangles/lib/DTXTrianglesTextureFactory.js +0 -518
  265. package/src/src/viewer/scene/model/dtx/triangles/lib/dataTextureRamStats.js +0 -54
  266. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js +0 -619
  267. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesDepthRenderer.js +0 -464
  268. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js +0 -414
  269. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js +0 -422
  270. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesNormalsRenderer.js +0 -345
  271. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesOcclusionRenderer.js +0 -436
  272. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickDepthRenderer.js +0 -462
  273. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickMeshRenderer.js +0 -436
  274. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsFlatRenderer.js +0 -455
  275. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsRenderer.js +0 -440
  276. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesRenderers.js +0 -307
  277. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js +0 -465
  278. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapInitRenderer.js +0 -466
  279. package/src/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSnapRenderer.js +0 -427
  280. package/src/src/viewer/scene/model/index.js +0 -5
  281. package/src/src/viewer/scene/model/rebucketPositions.js +0 -354
  282. package/src/src/viewer/scene/model/vbo/ScratchMemory.js +0 -63
  283. package/src/src/viewer/scene/model/vbo/VBORenderer.js +0 -646
  284. package/src/src/viewer/scene/model/vbo/batching/lines/VBOBatchingLinesLayer.js +0 -699
  285. package/src/src/viewer/scene/model/vbo/batching/lines/lib/VBOBatchingLinesBuffer.js +0 -19
  286. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLineSnapInitRenderer.js +0 -316
  287. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesColorRenderer.js +0 -114
  288. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesRenderers.js +0 -99
  289. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSilhouetteRenderer.js +0 -124
  290. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapInitRenderer.js +0 -311
  291. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOBatchingLinesSnapRenderer.js +0 -309
  292. package/src/src/viewer/scene/model/vbo/batching/lines/renderers/VBOSceneModelLineBatchingRenderer.js +0 -24
  293. package/src/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsBuffer.js +0 -20
  294. package/src/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsLayer.js +0 -718
  295. package/src/src/viewer/scene/model/vbo/batching/points/VBOBatchingPointsRenderer.js +0 -24
  296. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsColorRenderer.js +0 -168
  297. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsOcclusionRenderer.js +0 -136
  298. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsPickDepthRenderer.js +0 -156
  299. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsPickMeshRenderer.js +0 -148
  300. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsRenderers.js +0 -144
  301. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsShadowRenderer.js +0 -107
  302. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSilhouetteRenderer.js +0 -146
  303. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapInitRenderer.js +0 -309
  304. package/src/src/viewer/scene/model/vbo/batching/points/renderers/VBOBatchingPointsSnapRenderer.js +0 -303
  305. package/src/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesBuffer.js +0 -24
  306. package/src/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +0 -1257
  307. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesColorRenderer.js +0 -131
  308. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesEmphasisRenderer.js +0 -135
  309. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesRenderer.js +0 -12
  310. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/Renderers.js +0 -375
  311. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js +0 -34
  312. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +0 -238
  313. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorTextureRenderer.js +0 -270
  314. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesDepthRenderer.js +0 -126
  315. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesFlatColorRenderer.js +0 -235
  316. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesNormalsRenderer.js +0 -139
  317. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesOcclusionRenderer.js +0 -125
  318. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPBRRenderer.js +0 -561
  319. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickDepthRenderer.js +0 -144
  320. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickMeshRenderer.js +0 -130
  321. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickNormalsFlatRenderer.js +0 -121
  322. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesPickNormalsRenderer.js +0 -131
  323. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesShadowRenderer.js +0 -107
  324. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSilhouetteRenderer.js +0 -136
  325. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapInitRenderer.js +0 -311
  326. package/src/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +0 -308
  327. package/src/src/viewer/scene/model/vbo/float16.js +0 -760
  328. package/src/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +0 -704
  329. package/src/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesColorRenderer.js +0 -148
  330. package/src/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesRenderer.js +0 -26
  331. package/src/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesRenderers.js +0 -139
  332. package/src/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSilhouetteRenderer.js +0 -127
  333. package/src/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapInitRenderer.js +0 -331
  334. package/src/src/viewer/scene/model/vbo/instancing/lines/renderers/VBOInstancingLinesSnapRenderer.js +0 -316
  335. package/src/src/viewer/scene/model/vbo/instancing/points/VBOInstancingPointsLayer.js +0 -728
  336. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsColorRenderer.js +0 -174
  337. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsDepthRenderer.js +0 -156
  338. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsOcclusionRenderer.js +0 -149
  339. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsPickDepthRenderer.js +0 -170
  340. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsPickMeshRenderer.js +0 -152
  341. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsRenderer.js +0 -26
  342. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsRenderers.js +0 -174
  343. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsShadowRenderer.js +0 -119
  344. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSilhouetteRenderer.js +0 -154
  345. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapInitRenderer.js +0 -330
  346. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingPointsSnapRenderer.js +0 -311
  347. package/src/src/viewer/scene/model/vbo/instancing/points/renderers/VBOInstancingTrianglesRenderer.js +0 -150
  348. package/src/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +0 -1190
  349. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesColorRenderer.js +0 -136
  350. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesEmphasisRenderer.js +0 -137
  351. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesRenderer.js +0 -12
  352. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/Renderers.js +0 -376
  353. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +0 -253
  354. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorTextureRenderer.js +0 -278
  355. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesDepthRenderer.js +0 -126
  356. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatColorRenderer.js +0 -244
  357. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatNormalsRenderer.js +0 -130
  358. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js +0 -29
  359. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesNormalsRenderer.js +0 -138
  360. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesOcclusionRenderer.js +0 -128
  361. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPBRRenderer.js +0 -561
  362. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickDepthRenderer.js +0 -149
  363. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickMeshRenderer.js +0 -136
  364. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickNormalsFlatRenderer.js +0 -130
  365. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesPickNormalsRenderer.js +0 -145
  366. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesShadowRenderer.js +0 -113
  367. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSilhouetteRenderer.js +0 -139
  368. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapInitRenderer.js +0 -342
  369. package/src/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +0 -325
  370. package/src/src/viewer/scene/nodes/Node.js +0 -1383
  371. package/src/src/viewer/scene/nodes/index.js +0 -1
  372. package/src/src/viewer/scene/paths/CubicBezierCurve.js +0 -194
  373. package/src/src/viewer/scene/paths/Curve.js +0 -183
  374. package/src/src/viewer/scene/paths/Path.js +0 -239
  375. package/src/src/viewer/scene/paths/QuadraticBezierCurve.js +0 -161
  376. package/src/src/viewer/scene/paths/SplineCurve.js +0 -133
  377. package/src/src/viewer/scene/paths/index.js +0 -5
  378. package/src/src/viewer/scene/postfx/SAO.js +0 -543
  379. package/src/src/viewer/scene/scene/Scene.js +0 -2802
  380. package/src/src/viewer/scene/sectionPlane/SectionPlane.js +0 -198
  381. package/src/src/viewer/scene/sectionPlane/SectionPlaneCache.js +0 -101
  382. package/src/src/viewer/scene/sectionPlane/index.js +0 -1
  383. package/src/src/viewer/scene/skybox/Skybox.js +0 -123
  384. package/src/src/viewer/scene/skybox/index.js +0 -1
  385. package/src/src/viewer/scene/stats.js +0 -44
  386. package/src/src/viewer/scene/utils/Cache.js +0 -29
  387. package/src/src/viewer/scene/utils/FileLoader.js +0 -161
  388. package/src/src/viewer/scene/utils/Loader.js +0 -55
  389. package/src/src/viewer/scene/utils/LoadingManager.js +0 -86
  390. package/src/src/viewer/scene/utils/Map.js +0 -45
  391. package/src/src/viewer/scene/utils/Queue.js +0 -56
  392. package/src/src/viewer/scene/utils/WorkerPool.js +0 -73
  393. package/src/src/viewer/scene/utils/index.js +0 -6
  394. package/src/src/viewer/scene/utils/textureTranscoders/KTX2TextureTranscoder/KTX2TextureTranscoder.js +0 -650
  395. package/src/src/viewer/scene/utils/textureTranscoders/KTX2TextureTranscoder/index.js +0 -1
  396. package/src/src/viewer/scene/utils/textureTranscoders/TextureTranscoder.js +0 -31
  397. package/src/src/viewer/scene/utils/textureTranscoders/index.js +0 -2
  398. package/src/src/viewer/scene/utils.js +0 -453
  399. package/src/src/viewer/scene/viewport/Viewport.js +0 -212
  400. package/src/src/viewer/scene/webgl/ArrayBuf.js +0 -121
  401. package/src/src/viewer/scene/webgl/Attribute.js +0 -23
  402. package/src/src/viewer/scene/webgl/Drawable.js +0 -270
  403. package/src/src/viewer/scene/webgl/FrameContext.js +0 -313
  404. package/src/src/viewer/scene/webgl/PickResult.js +0 -364
  405. package/src/src/viewer/scene/webgl/Pickable.js +0 -69
  406. package/src/src/viewer/scene/webgl/Program.js +0 -181
  407. package/src/src/viewer/scene/webgl/RenderBuffer.js +0 -378
  408. package/src/src/viewer/scene/webgl/RenderBufferManager.js +0 -34
  409. package/src/src/viewer/scene/webgl/RenderFlags.js +0 -203
  410. package/src/src/viewer/scene/webgl/RenderState.js +0 -40
  411. package/src/src/viewer/scene/webgl/Renderer.js +0 -1781
  412. package/src/src/viewer/scene/webgl/Sampler.js +0 -18
  413. package/src/src/viewer/scene/webgl/Shader.js +0 -49
  414. package/src/src/viewer/scene/webgl/Texture2D.js +0 -442
  415. package/src/src/viewer/scene/webgl/convertConstant.js +0 -244
  416. package/src/src/viewer/scene/webgl/getExtension.js +0 -32
  417. package/src/src/viewer/scene/webgl/occlusion/OcclusionLayer.js +0 -214
  418. package/src/src/viewer/scene/webgl/occlusion/OcclusionTester.js +0 -426
  419. package/src/src/viewer/scene/webgl/sao/SAODepthLimitedBlurRenderer.js +0 -324
  420. package/src/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +0 -376
  421. package/src/src/viewer/scene/webgl/webglEnums.js +0 -61
  422. package/src/src/viewer/scene/webglInfo.js +0 -47
  423. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorRenderer.js +0 -238
  424. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesColorTextureRenderer.js +0 -270
  425. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesDepthRenderer.js +0 -126
  426. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesColorRenderer.js +0 -127
  427. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesEdgesRenderer.js +0 -133
  428. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesFlatColorRenderer.js +0 -235
  429. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesNormalsRenderer.js +0 -139
  430. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesOcclusionRenderer.js +0 -125
  431. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPBRRenderer.js +0 -561
  432. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickDepthRenderer.js +0 -144
  433. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickMeshRenderer.js +0 -130
  434. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsFlatRenderer.js +0 -121
  435. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesPickNormalsRenderer.js +0 -131
  436. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderer.js +0 -33
  437. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesRenderers.js +0 -375
  438. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesShadowRenderer.js +0 -107
  439. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSilhouetteRenderer.js +0 -136
  440. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapInitRenderer.js +0 -311
  441. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOBatchingTrianglesSnapRenderer.js +0 -308
  442. package/src/viewer/scene/model/vbo/batching/triangles/renderers/VBOSceneModelTriangleBatchingEdgesRenderer.js +0 -12
  443. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorRenderer.js +0 -253
  444. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesColorTextureRenderer.js +0 -278
  445. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesDepthRenderer.js +0 -126
  446. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesColorRenderer.js +0 -132
  447. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesEdgesRenderer.js +0 -134
  448. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatColorRenderer.js +0 -244
  449. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesFlatNormalsRenderer.js +0 -130
  450. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesNormalsRenderer.js +0 -138
  451. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesOcclusionRenderer.js +0 -128
  452. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPBRRenderer.js +0 -561
  453. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickDepthRenderer.js +0 -149
  454. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickMeshRenderer.js +0 -136
  455. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsFlatRenderer.js +0 -130
  456. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesPickNormalsRenderer.js +0 -145
  457. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesRenderers.js +0 -376
  458. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesShadowRenderer.js +0 -113
  459. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSilhouetteRenderer.js +0 -139
  460. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapInitRenderer.js +0 -342
  461. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOInstancingTrianglesSnapRenderer.js +0 -325
  462. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingEdgesRenderer.js +0 -12
  463. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/VBOSceneModelTriangleInstancingRenderer.js +0 -29
@@ -1,1570 +0,0 @@
1
- /**
2
- * @private
3
- */
4
-
5
- import {LinearEncoding, sRGBEncoding} from "../../constants/constants.js";
6
-
7
- const DrawShaderSource = function (mesh) {
8
- if (mesh._material._state.type === "LambertMaterial") {
9
- this.vertex = buildVertexLambert(mesh);
10
- this.fragment = buildFragmentLambert(mesh);
11
- } else {
12
- this.vertex = buildVertexDraw(mesh);
13
- this.fragment = buildFragmentDraw(mesh);
14
- }
15
- };
16
-
17
- const TEXTURE_DECODE_FUNCS = {};
18
- TEXTURE_DECODE_FUNCS[LinearEncoding] = "linearToLinear";
19
- TEXTURE_DECODE_FUNCS[sRGBEncoding] = "sRGBToLinear";
20
-
21
- function getReceivesShadow(mesh) {
22
- if (!mesh.receivesShadow) {
23
- return false;
24
- }
25
- const lights = mesh.scene._lightsState.lights;
26
- if (!lights || lights.length === 0) {
27
- return false;
28
- }
29
- for (let i = 0, len = lights.length; i < len; i++) {
30
- if (lights[i].castsShadow) {
31
- return true;
32
- }
33
- }
34
- return false;
35
- }
36
-
37
- function hasTextures(mesh) {
38
- if (!mesh._geometry._state.uvBuf) {
39
- return false;
40
- }
41
- const material = mesh._material;
42
- return !!(material._ambientMap ||
43
- material._occlusionMap ||
44
- material._baseColorMap ||
45
- material._diffuseMap ||
46
- material._alphaMap ||
47
- material._specularMap ||
48
- material._glossinessMap ||
49
- material._specularGlossinessMap ||
50
- material._emissiveMap ||
51
- material._metallicMap ||
52
- material._roughnessMap ||
53
- material._metallicRoughnessMap ||
54
- material._reflectivityMap ||
55
- material._normalMap);
56
- }
57
-
58
- function hasNormals(mesh) {
59
- const primitive = mesh._geometry._state.primitiveName;
60
- if ((mesh._geometry._state.autoVertexNormals || mesh._geometry._state.normalsBuf) && (primitive === "triangles" || primitive === "triangle-strip" || primitive === "triangle-fan")) {
61
- return true;
62
- }
63
- return false;
64
- }
65
-
66
- function buildVertexLambert(mesh) {
67
-
68
- const scene = mesh.scene;
69
- const sectionPlanesState = mesh.scene._sectionPlanesState;
70
- const lightsState = mesh.scene._lightsState;
71
- const geometryState = mesh._geometry._state;
72
- const billboard = mesh._state.billboard;
73
- const stationary = mesh._state.stationary;
74
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
75
- const quantizedGeometry = !!geometryState.compressGeometry;
76
-
77
- const src = [];
78
- src.push("#version 300 es");
79
- src.push("// Lambertian drawing vertex shader");
80
- src.push("in vec3 position;");
81
- src.push("uniform mat4 modelMatrix;");
82
- src.push("uniform mat4 viewMatrix;");
83
- src.push("uniform mat4 projMatrix;");
84
- src.push("uniform vec4 colorize;");
85
- src.push("uniform vec3 offset;");
86
- if (quantizedGeometry) {
87
- src.push("uniform mat4 positionsDecodeMatrix;");
88
- }
89
- if (scene.logarithmicDepthBufferEnabled) {
90
- src.push("uniform float logDepthBufFC;");
91
- src.push("out float vFragDepth;");
92
- src.push("bool isPerspectiveMatrix(mat4 m) {");
93
- src.push(" return (m[2][3] == - 1.0);");
94
- src.push("}");
95
- src.push("out float isPerspective;");
96
- }
97
- if (clipping) {
98
- src.push("out vec4 vWorldPosition;");
99
- }
100
- src.push("uniform vec4 lightAmbient;");
101
- src.push("uniform vec4 materialColor;");
102
- src.push("uniform vec3 materialEmissive;");
103
- if (geometryState.normalsBuf) {
104
- src.push("in vec3 normal;");
105
- src.push("uniform mat4 modelNormalMatrix;");
106
- src.push("uniform mat4 viewNormalMatrix;");
107
- for (let i = 0, len = lightsState.lights.length; i < len; i++) {
108
- const light = lightsState.lights[i];
109
- if (light.type === "ambient") {
110
- continue;
111
- }
112
- src.push("uniform vec4 lightColor" + i + ";");
113
- if (light.type === "dir") {
114
- src.push("uniform vec3 lightDir" + i + ";");
115
- }
116
- if (light.type === "point") {
117
- src.push("uniform vec3 lightPos" + i + ";");
118
- }
119
- if (light.type === "spot") {
120
- src.push("uniform vec3 lightPos" + i + ";");
121
- src.push("uniform vec3 lightDir" + i + ";");
122
- }
123
- }
124
- if (quantizedGeometry) {
125
- src.push("vec3 octDecode(vec2 oct) {");
126
- src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
127
- src.push(" if (v.z < 0.0) {");
128
- 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);");
129
- src.push(" }");
130
- src.push(" return normalize(v);");
131
- src.push("}");
132
- }
133
- }
134
- src.push("out vec4 vColor;");
135
- if (geometryState.primitiveName === "points") {
136
- src.push("uniform float pointSize;");
137
- }
138
- if (billboard === "spherical" || billboard === "cylindrical") {
139
- src.push("void billboard(inout mat4 mat) {");
140
- src.push(" mat[0][0] = 1.0;");
141
- src.push(" mat[0][1] = 0.0;");
142
- src.push(" mat[0][2] = 0.0;");
143
- if (billboard === "spherical") {
144
- src.push(" mat[1][0] = 0.0;");
145
- src.push(" mat[1][1] = 1.0;");
146
- src.push(" mat[1][2] = 0.0;");
147
- }
148
- src.push(" mat[2][0] = 0.0;");
149
- src.push(" mat[2][1] = 0.0;");
150
- src.push(" mat[2][2] =1.0;");
151
- src.push("}");
152
- }
153
- src.push("void main(void) {");
154
- src.push("vec4 localPosition = vec4(position, 1.0); ");
155
- src.push("vec4 worldPosition;");
156
- if (quantizedGeometry) {
157
- src.push("localPosition = positionsDecodeMatrix * localPosition;");
158
- }
159
- if (geometryState.normalsBuf) {
160
- if (quantizedGeometry) {
161
- src.push("vec4 localNormal = vec4(octDecode(normal.xy), 0.0); ");
162
- } else {
163
- src.push("vec4 localNormal = vec4(normal, 0.0); ");
164
- }
165
- src.push("mat4 modelNormalMatrix2 = modelNormalMatrix;");
166
- src.push("mat4 viewNormalMatrix2 = viewNormalMatrix;");
167
- }
168
- src.push("mat4 viewMatrix2 = viewMatrix;");
169
- src.push("mat4 modelMatrix2 = modelMatrix;");
170
- if (stationary) {
171
- src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;")
172
- }
173
- if (billboard === "spherical" || billboard === "cylindrical") {
174
- src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");
175
- src.push("billboard(modelMatrix2);");
176
- src.push("billboard(viewMatrix2);");
177
- src.push("billboard(modelViewMatrix);");
178
- if (geometryState.normalsBuf) {
179
- src.push("mat4 modelViewNormalMatrix = viewNormalMatrix2 * modelNormalMatrix2;");
180
- src.push("billboard(modelNormalMatrix2);");
181
- src.push("billboard(viewNormalMatrix2);");
182
- src.push("billboard(modelViewNormalMatrix);");
183
- }
184
- src.push("worldPosition = modelMatrix2 * localPosition;");
185
- src.push("worldPosition.xyz = worldPosition.xyz + offset;");
186
- src.push("vec4 viewPosition = modelViewMatrix * localPosition;");
187
- } else {
188
- src.push("worldPosition = modelMatrix2 * localPosition;");
189
- src.push("worldPosition.xyz = worldPosition.xyz + offset;");
190
- src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");
191
- }
192
- if (geometryState.normalsBuf) {
193
- src.push("vec3 viewNormal = normalize((viewNormalMatrix2 * modelNormalMatrix2 * localNormal).xyz);");
194
- }
195
- src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");
196
- src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");
197
- src.push("float lambertian = 1.0;");
198
- if (geometryState.normalsBuf) {
199
- for (let i = 0, len = lightsState.lights.length; i < len; i++) {
200
- const light = lightsState.lights[i];
201
- if (light.type === "ambient") {
202
- continue;
203
- }
204
- if (light.type === "dir") {
205
- if (light.space === "view") {
206
- src.push("viewLightDir = normalize(lightDir" + i + ");");
207
- } else {
208
- src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir" + i + ", 0.0)).xyz);");
209
- }
210
- } else if (light.type === "point") {
211
- if (light.space === "view") {
212
- src.push("viewLightDir = -normalize(lightPos" + i + " - viewPosition.xyz);");
213
- } else {
214
- src.push("viewLightDir = -normalize((viewMatrix2 * vec4(lightPos" + i + ", 0.0)).xyz);");
215
- }
216
- } else if (light.type === "spot") {
217
- if (light.space === "view") {
218
- src.push("viewLightDir = normalize(lightDir" + i + ");");
219
- } else {
220
- src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir" + i + ", 0.0)).xyz);");
221
- }
222
- } else {
223
- continue;
224
- }
225
- src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");
226
- src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
227
- }
228
- }
229
- src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * materialColor.rgb) + materialEmissive.rgb + (reflectedColor * materialColor.rgb), materialColor.a) * colorize;"); // TODO: How to have ambient bright enough for canvas BG but not too bright for scene?
230
- if (clipping) {
231
- src.push("vWorldPosition = worldPosition;");
232
- }
233
- if (geometryState.primitiveName === "points") {
234
- src.push("gl_PointSize = pointSize;");
235
- }
236
- src.push("vec4 clipPos = projMatrix * viewPosition;");
237
- if (scene.logarithmicDepthBufferEnabled) {
238
- src.push("vFragDepth = 1.0 + clipPos.w;");
239
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
240
- }
241
- src.push("gl_Position = clipPos;");
242
- src.push("}");
243
- return src;
244
- }
245
-
246
- function buildFragmentLambert(mesh) {
247
- const scene = mesh.scene;
248
- const sectionPlanesState = scene._sectionPlanesState;
249
- const materialState = mesh._material._state;
250
- const geometryState = mesh._geometry._state;
251
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
252
- const solid = false && materialState.backfaces;
253
- const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
254
- const src = [];
255
- src.push("#version 300 es");
256
- src.push("// Lambertian drawing fragment shader");
257
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
258
- src.push("precision highp float;");
259
- src.push("precision highp int;");
260
- src.push("#else");
261
- src.push("precision mediump float;");
262
- src.push("precision mediump int;");
263
- src.push("#endif");
264
- if (scene.logarithmicDepthBufferEnabled) {
265
- src.push("in float isPerspective;");
266
- src.push("uniform float logDepthBufFC;");
267
- src.push("in float vFragDepth;");
268
- }
269
- if (clipping) {
270
- src.push("in vec4 vWorldPosition;");
271
- src.push("uniform bool clippable;");
272
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
273
- src.push("uniform bool sectionPlaneActive" + i + ";");
274
- src.push("uniform vec3 sectionPlanePos" + i + ";");
275
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
276
- }
277
- }
278
- src.push("in vec4 vColor;");
279
- if (gammaOutput) {
280
- src.push("uniform float gammaFactor;");
281
- src.push(" vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
282
- src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
283
- src.push("}");
284
- }
285
- src.push("out vec4 outColor;");
286
- src.push("void main(void) {");
287
- if (clipping) {
288
- src.push("if (clippable) {");
289
- src.push(" float dist = 0.0;");
290
- for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
291
- src.push("if (sectionPlaneActive" + i + ") {");
292
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
293
- src.push("}");
294
- }
295
- src.push(" if (dist > 0.0) { discard; }");
296
- if (solid) {
297
- src.push(" if (gl_FrontFacing == false) {");
298
- src.push(" outColor = vec4(1.0, 0.0, 0.0, 1.0);");
299
- src.push(" return;");
300
- src.push(" }");
301
- }
302
- src.push("}");
303
- }
304
- if (geometryState.primitiveName === "points") {
305
- src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");
306
- src.push("float r = dot(cxy, cxy);");
307
- src.push("if (r > 1.0) {");
308
- src.push(" discard;");
309
- src.push("}");
310
-
311
- }
312
- if (scene.logarithmicDepthBufferEnabled) {
313
- src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
314
- }
315
- if (gammaOutput) {
316
- src.push("outColor = linearToGamma(vColor, gammaFactor);");
317
- } else {
318
- src.push("outColor = vColor;");
319
- }
320
- src.push("}");
321
- return src;
322
- }
323
-
324
- function buildVertexDraw(mesh) {
325
- const scene = mesh.scene;
326
- const material = mesh._material;
327
- const meshState = mesh._state;
328
- const sectionPlanesState = scene._sectionPlanesState;
329
- const geometryState = mesh._geometry._state;
330
- const lightsState = scene._lightsState;
331
- let i;
332
- let len;
333
- let light;
334
- const billboard = meshState.billboard;
335
- const background = meshState.background;
336
- const stationary = meshState.stationary;
337
- const texturing = hasTextures(mesh);
338
- const normals = hasNormals(mesh);
339
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
340
- const receivesShadow = getReceivesShadow(mesh);
341
- const quantizedGeometry = !!geometryState.compressGeometry;
342
- const src = [];
343
- src.push("#version 300 es");
344
- src.push("// Drawing vertex shader");
345
- src.push("in vec3 position;");
346
- if (quantizedGeometry) {
347
- src.push("uniform mat4 positionsDecodeMatrix;");
348
- }
349
- src.push("uniform mat4 modelMatrix;");
350
- src.push("uniform mat4 viewMatrix;");
351
- src.push("uniform mat4 projMatrix;");
352
- src.push("out vec3 vViewPosition;");
353
- src.push("uniform vec3 offset;");
354
- if (clipping) {
355
- src.push("out vec4 vWorldPosition;");
356
- }
357
- if (scene.logarithmicDepthBufferEnabled) {
358
- src.push("uniform float logDepthBufFC;");
359
- src.push("out float vFragDepth;");
360
- src.push("bool isPerspectiveMatrix(mat4 m) {");
361
- src.push(" return (m[2][3] == - 1.0);");
362
- src.push("}");
363
- src.push("out float isPerspective;");
364
- }
365
- if (lightsState.lightMaps.length > 0) {
366
- src.push("out vec3 vWorldNormal;");
367
- }
368
- if (normals) {
369
- src.push("in vec3 normal;");
370
- src.push("uniform mat4 modelNormalMatrix;");
371
- src.push("uniform mat4 viewNormalMatrix;");
372
- src.push("out vec3 vViewNormal;");
373
- for (let i = 0, len = lightsState.lights.length; i < len; i++) {
374
- light = lightsState.lights[i];
375
- if (light.type === "ambient") {
376
- continue;
377
- }
378
- if (light.type === "dir") {
379
- src.push("uniform vec3 lightDir" + i + ";");
380
- }
381
- if (light.type === "point") {
382
- src.push("uniform vec3 lightPos" + i + ";");
383
- }
384
- if (light.type === "spot") {
385
- src.push("uniform vec3 lightPos" + i + ";");
386
- src.push("uniform vec3 lightDir" + i + ";");
387
- }
388
- if (!(light.type === "dir" && light.space === "view")) {
389
- src.push("out vec4 vViewLightReverseDirAndDist" + i + ";");
390
- }
391
- }
392
- if (quantizedGeometry) {
393
- src.push("vec3 octDecode(vec2 oct) {");
394
- src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
395
- src.push(" if (v.z < 0.0) {");
396
- 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);");
397
- src.push(" }");
398
- src.push(" return normalize(v);");
399
- src.push("}");
400
- }
401
- }
402
- if (texturing) {
403
- src.push("in vec2 uv;");
404
- src.push("out vec2 vUV;");
405
- if (quantizedGeometry) {
406
- src.push("uniform mat3 uvDecodeMatrix;")
407
- }
408
- }
409
- if (geometryState.colors) {
410
- src.push("in vec4 color;");
411
- src.push("out vec4 vColor;");
412
- }
413
- if (geometryState.primitiveName === "points") {
414
- src.push("uniform float pointSize;");
415
- }
416
- if (billboard === "spherical" || billboard === "cylindrical") {
417
- src.push("void billboard(inout mat4 mat) {");
418
- src.push(" mat[0][0] = 1.0;");
419
- src.push(" mat[0][1] = 0.0;");
420
- src.push(" mat[0][2] = 0.0;");
421
- if (billboard === "spherical") {
422
- src.push(" mat[1][0] = 0.0;");
423
- src.push(" mat[1][1] = 1.0;");
424
- src.push(" mat[1][2] = 0.0;");
425
- }
426
- src.push(" mat[2][0] = 0.0;");
427
- src.push(" mat[2][1] = 0.0;");
428
- src.push(" mat[2][2] =1.0;");
429
- src.push("}");
430
- }
431
- if (receivesShadow) {
432
- src.push("const mat4 texUnitConverter = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);");
433
- for (let i = 0, len = lightsState.lights.length; i < len; i++) { // Light sources
434
- if (lightsState.lights[i].castsShadow) {
435
- src.push("uniform mat4 shadowViewMatrix" + i + ";");
436
- src.push("uniform mat4 shadowProjMatrix" + i + ";");
437
- src.push("out vec4 vShadowPosFromLight" + i + ";");
438
- }
439
- }
440
- }
441
- src.push("void main(void) {");
442
- src.push("vec4 localPosition = vec4(position, 1.0); ");
443
- src.push("vec4 worldPosition;");
444
- if (quantizedGeometry) {
445
- src.push("localPosition = positionsDecodeMatrix * localPosition;");
446
- }
447
- if (normals) {
448
- if (quantizedGeometry) {
449
- src.push("vec4 localNormal = vec4(octDecode(normal.xy), 0.0); ");
450
- } else {
451
- src.push("vec4 localNormal = vec4(normal, 0.0); ");
452
- }
453
- src.push("mat4 modelNormalMatrix2 = modelNormalMatrix;");
454
- src.push("mat4 viewNormalMatrix2 = viewNormalMatrix;");
455
- }
456
- src.push("mat4 viewMatrix2 = viewMatrix;");
457
- src.push("mat4 modelMatrix2 = modelMatrix;");
458
- if (stationary) {
459
- src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;")
460
- } else if (background) {
461
- src.push("viewMatrix2[3] = vec4(0.0, 0.0, 0.0 ,1.0);");
462
- }
463
- if (billboard === "spherical" || billboard === "cylindrical") {
464
- src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");
465
- src.push("billboard(modelMatrix2);");
466
- src.push("billboard(viewMatrix2);");
467
- src.push("billboard(modelViewMatrix);");
468
- if (normals) {
469
- src.push("mat4 modelViewNormalMatrix = viewNormalMatrix2 * modelNormalMatrix2;");
470
- src.push("billboard(modelNormalMatrix2);");
471
- src.push("billboard(viewNormalMatrix2);");
472
- src.push("billboard(modelViewNormalMatrix);");
473
- }
474
- src.push("worldPosition = modelMatrix2 * localPosition;");
475
- src.push("worldPosition.xyz = worldPosition.xyz + offset;");
476
- src.push("vec4 viewPosition = modelViewMatrix * localPosition;");
477
- } else {
478
- src.push("worldPosition = modelMatrix2 * localPosition;");
479
- src.push("worldPosition.xyz = worldPosition.xyz + offset;");
480
- src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");
481
- }
482
- if (normals) {
483
- src.push("vec3 worldNormal = (modelNormalMatrix2 * localNormal).xyz; ");
484
- if (lightsState.lightMaps.length > 0) {
485
- src.push("vWorldNormal = worldNormal;");
486
- }
487
- src.push("vViewNormal = normalize((viewNormalMatrix2 * vec4(worldNormal, 1.0)).xyz);");
488
- src.push("vec3 tmpVec3;");
489
- src.push("float lightDist;");
490
- for (let i = 0, len = lightsState.lights.length; i < len; i++) { // Lights
491
- light = lightsState.lights[i];
492
- if (light.type === "ambient") {
493
- continue;
494
- }
495
- if (light.type === "dir") {
496
- if (light.space === "world") {
497
- src.push("tmpVec3 = vec3(viewMatrix2 * vec4(lightDir" + i + ", 0.0) ).xyz;");
498
- src.push("vViewLightReverseDirAndDist" + i + " = vec4(-tmpVec3, 0.0);");
499
- }
500
- }
501
- if (light.type === "point") {
502
- if (light.space === "world") {
503
- src.push("tmpVec3 = (viewMatrix2 * vec4(lightPos" + i + ", 1.0)).xyz - viewPosition.xyz;");
504
- src.push("lightDist = abs(length(tmpVec3));");
505
- } else {
506
- src.push("tmpVec3 = lightPos" + i + ".xyz - viewPosition.xyz;");
507
- src.push("lightDist = abs(length(tmpVec3));");
508
- }
509
- src.push("vViewLightReverseDirAndDist" + i + " = vec4(tmpVec3, lightDist);");
510
- }
511
- }
512
- }
513
- if (texturing) {
514
- if (quantizedGeometry) {
515
- src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");
516
- } else {
517
- src.push("vUV = uv;");
518
- }
519
- }
520
- if (geometryState.colors) {
521
- src.push("vColor = color;");
522
- }
523
- if (geometryState.primitiveName === "points") {
524
- src.push("gl_PointSize = pointSize;");
525
- }
526
- if (clipping) {
527
- src.push("vWorldPosition = worldPosition;");
528
- }
529
- src.push(" vViewPosition = viewPosition.xyz;");
530
- src.push("vec4 clipPos = projMatrix * viewPosition;");
531
- if (scene.logarithmicDepthBufferEnabled) {
532
- src.push("vFragDepth = 1.0 + clipPos.w;");
533
- src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
534
- }
535
- if (background) {
536
- src.push("clipPos.z = clipPos.w;");
537
- }
538
- src.push("gl_Position = clipPos;");
539
- if (receivesShadow) {
540
- src.push("const mat4 texUnitConverter = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);");
541
- src.push("vec4 tempx; ");
542
- for (let i = 0, len = lightsState.lights.length; i < len; i++) { // Light sources
543
- if (lightsState.lights[i].castsShadow) {
544
- src.push("vShadowPosFromLight" + i + " = texUnitConverter * shadowProjMatrix" + i + " * (shadowViewMatrix" + i + " * worldPosition); ");
545
- }
546
- }
547
- }
548
- src.push("}");
549
- return src;
550
- }
551
-
552
- function buildFragmentDraw(mesh) {
553
-
554
- const scene = mesh.scene;
555
- const gl = scene.canvas.gl;
556
- const material = mesh._material;
557
- const geometryState = mesh._geometry._state;
558
- const sectionPlanesState = mesh.scene._sectionPlanesState;
559
- const lightsState = mesh.scene._lightsState;
560
- const materialState = mesh._material._state;
561
- const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
562
- const normals = hasNormals(mesh);
563
- const uvs = geometryState.uvBuf;
564
- const solid = false && materialState.backfaces;
565
- const phongMaterial = (materialState.type === "PhongMaterial");
566
- const metallicMaterial = (materialState.type === "MetallicMaterial");
567
- const specularMaterial = (materialState.type === "SpecularMaterial");
568
- const receivesShadow = getReceivesShadow(mesh);
569
- const gammaInput = scene.gammaInput; // If set, then it expects that all textures and colors are premultiplied gamma. Default is false.
570
- const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
571
-
572
- let light;
573
- const src = [];
574
- src.push("#version 300 es");
575
- src.push("// Drawing fragment shader");
576
-
577
- src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
578
- src.push("precision highp float;");
579
- src.push("precision highp int;");
580
- src.push("#else");
581
- src.push("precision mediump float;");
582
- src.push("precision mediump int;");
583
- src.push("#endif");
584
-
585
- if (scene.logarithmicDepthBufferEnabled) {
586
- src.push("in float isPerspective;");
587
- src.push("uniform float logDepthBufFC;");
588
- src.push("in float vFragDepth;");
589
- }
590
-
591
- if (receivesShadow) {
592
- src.push("float unpackDepth (vec4 color) {");
593
- src.push(" const vec4 bitShift = vec4(1.0, 1.0/256.0, 1.0/(256.0 * 256.0), 1.0/(256.0*256.0*256.0));");
594
- src.push(" return dot(color, bitShift);");
595
- src.push("}");
596
- }
597
-
598
- //--------------------------------------------------------------------------------
599
- // GAMMA CORRECTION
600
- //--------------------------------------------------------------------------------
601
-
602
- src.push("uniform float gammaFactor;");
603
- src.push("vec4 linearToLinear( in vec4 value ) {");
604
- src.push(" return value;");
605
- src.push("}");
606
- src.push("vec4 sRGBToLinear( in vec4 value ) {");
607
- src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
608
- src.push("}");
609
- src.push("vec4 gammaToLinear( in vec4 value) {");
610
- src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
611
- src.push("}");
612
- if (gammaOutput) {
613
- src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
614
- src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
615
- src.push("}");
616
- }
617
-
618
- //--------------------------------------------------------------------------------
619
- // USER CLIP PLANES
620
- //--------------------------------------------------------------------------------
621
-
622
- if (clipping) {
623
- src.push("in vec4 vWorldPosition;");
624
- src.push("uniform bool clippable;");
625
- for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
626
- src.push("uniform bool sectionPlaneActive" + i + ";");
627
- src.push("uniform vec3 sectionPlanePos" + i + ";");
628
- src.push("uniform vec3 sectionPlaneDir" + i + ";");
629
- }
630
- }
631
-
632
- if (normals) {
633
-
634
- //--------------------------------------------------------------------------------
635
- // LIGHT AND REFLECTION MAP INPUTS
636
- // Define here so available globally to shader functions
637
- //--------------------------------------------------------------------------------
638
-
639
- if (lightsState.lightMaps.length > 0) {
640
- src.push("uniform samplerCube lightMap;");
641
- src.push("uniform mat4 viewNormalMatrix;");
642
- }
643
- if (lightsState.reflectionMaps.length > 0) {
644
- src.push("uniform samplerCube reflectionMap;");
645
- }
646
- if (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0) {
647
- src.push("uniform mat4 viewMatrix;");
648
- }
649
-
650
- //--------------------------------------------------------------------------------
651
- // SHADING FUNCTIONS
652
- //--------------------------------------------------------------------------------
653
-
654
- // CONSTANT DEFINITIONS
655
-
656
- src.push("#define PI 3.14159265359");
657
- src.push("#define RECIPROCAL_PI 0.31830988618");
658
- src.push("#define RECIPROCAL_PI2 0.15915494");
659
- src.push("#define EPSILON 1e-6");
660
-
661
- src.push("#define saturate(a) clamp( a, 0.0, 1.0 )");
662
-
663
- // UTILITY DEFINITIONS
664
-
665
- src.push("vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {");
666
- src.push(" return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );");
667
- src.push("}");
668
-
669
- // STRUCTURES
670
-
671
- src.push("struct IncidentLight {");
672
- src.push(" vec3 color;");
673
- src.push(" vec3 direction;");
674
- src.push("};");
675
-
676
- src.push("struct ReflectedLight {");
677
- src.push(" vec3 diffuse;");
678
- src.push(" vec3 specular;");
679
- src.push("};");
680
-
681
- src.push("struct Geometry {");
682
- src.push(" vec3 position;");
683
- src.push(" vec3 viewNormal;");
684
- src.push(" vec3 worldNormal;");
685
- src.push(" vec3 viewEyeDir;");
686
- src.push("};");
687
-
688
- src.push("struct Material {");
689
- src.push(" vec3 diffuseColor;");
690
- src.push(" float specularRoughness;");
691
- src.push(" vec3 specularColor;");
692
- src.push(" float shine;"); // Only used for Phong
693
- src.push("};");
694
-
695
- // COMMON UTILS
696
-
697
- if (phongMaterial) {
698
-
699
- if (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0) {
700
-
701
- src.push("void computePhongLightMapping(const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");
702
-
703
- if (lightsState.lightMaps.length > 0) {
704
- src.push(" vec3 irradiance = " + TEXTURE_DECODE_FUNCS[lightsState.lightMaps[0].encoding] + "(texture(lightMap, geometry.worldNormal)).rgb;");
705
- src.push(" irradiance *= PI;");
706
- src.push(" vec3 diffuseBRDFContrib = (RECIPROCAL_PI * material.diffuseColor);");
707
- src.push(" reflectedLight.diffuse += irradiance * diffuseBRDFContrib;");
708
- }
709
- if (lightsState.reflectionMaps.length > 0) {
710
- src.push(" vec3 reflectVec = reflect(-geometry.viewEyeDir, geometry.viewNormal);");
711
- src.push(" vec3 radiance = texture(reflectionMap, reflectVec).rgb * 0.2;");
712
- src.push(" radiance *= PI;");
713
- src.push(" reflectedLight.specular += radiance;");
714
- }
715
- src.push("}");
716
- }
717
-
718
- src.push("void computePhongLighting(const in IncidentLight directLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");
719
- src.push(" float dotNL = saturate(dot(geometry.viewNormal, directLight.direction));");
720
- src.push(" vec3 irradiance = dotNL * directLight.color * PI;");
721
- src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");
722
- src.push(" reflectedLight.specular += directLight.color * material.specularColor * pow(max(dot(reflect(-directLight.direction, -geometry.viewNormal), geometry.viewEyeDir), 0.0), material.shine);");
723
- src.push("}");
724
- }
725
-
726
- if (metallicMaterial || specularMaterial) {
727
-
728
- // IRRADIANCE EVALUATION
729
-
730
- src.push("float GGXRoughnessToBlinnExponent(const in float ggxRoughness) {");
731
- src.push(" float r = ggxRoughness + 0.0001;");
732
- src.push(" return (2.0 / (r * r) - 2.0);");
733
- src.push("}");
734
-
735
- src.push("float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {");
736
- src.push(" float maxMIPLevelScalar = float( maxMIPLevel );");
737
- src.push(" float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( ( blinnShininessExponent * blinnShininessExponent ) + 1.0 );");
738
- src.push(" return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );");
739
- src.push("}");
740
-
741
- if (lightsState.reflectionMaps.length > 0) {
742
- src.push("vec3 getLightProbeIndirectRadiance(const in vec3 reflectVec, const in float blinnShininessExponent, const in int maxMIPLevel) {");
743
- src.push(" float mipLevel = 0.5 * getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);"); //TODO: a random factor - fix this
744
- src.push(" vec3 envMapColor = " + TEXTURE_DECODE_FUNCS[lightsState.reflectionMaps[0].encoding] + "(texture(reflectionMap, reflectVec, mipLevel)).rgb;");
745
- src.push(" return envMapColor;");
746
- src.push("}");
747
- }
748
-
749
- // SPECULAR BRDF EVALUATION
750
-
751
- src.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {");
752
- src.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );");
753
- src.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;");
754
- src.push("}");
755
-
756
- src.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {");
757
- src.push(" float a2 = ( alpha * alpha );");
758
- src.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");
759
- src.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");
760
- src.push(" return 1.0 / ( gl * gv );");
761
- src.push("}");
762
-
763
- src.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {");
764
- src.push(" float a2 = ( alpha * alpha );");
765
- src.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");
766
- src.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");
767
- src.push(" return 0.5 / max( gv + gl, EPSILON );");
768
- src.push("}");
769
-
770
- src.push("float D_GGX(const in float alpha, const in float dotNH) {");
771
- src.push(" float a2 = ( alpha * alpha );");
772
- src.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;");
773
- src.push(" return RECIPROCAL_PI * a2 / ( denom * denom);");
774
- src.push("}");
775
-
776
- src.push("vec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");
777
- src.push(" float alpha = ( roughness * roughness );");
778
- src.push(" vec3 halfDir = normalize( incidentLight.direction + geometry.viewEyeDir );");
779
- src.push(" float dotNL = saturate( dot( geometry.viewNormal, incidentLight.direction ) );");
780
- src.push(" float dotNV = saturate( dot( geometry.viewNormal, geometry.viewEyeDir ) );");
781
- src.push(" float dotNH = saturate( dot( geometry.viewNormal, halfDir ) );");
782
- src.push(" float dotLH = saturate( dot( incidentLight.direction, halfDir ) );");
783
- src.push(" vec3 F = F_Schlick( specularColor, dotLH );");
784
- src.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );");
785
- src.push(" float D = D_GGX( alpha, dotNH );");
786
- src.push(" return F * (G * D);");
787
- src.push("}");
788
-
789
- src.push("vec3 BRDF_Specular_GGX_Environment(const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");
790
- src.push(" float dotNV = saturate(dot(geometry.viewNormal, geometry.viewEyeDir));");
791
- src.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);");
792
- src.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);");
793
- src.push(" vec4 r = roughness * c0 + c1;");
794
- src.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;");
795
- src.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;");
796
- src.push(" return specularColor * AB.x + AB.y;");
797
- src.push("}");
798
-
799
- if (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0) {
800
-
801
- src.push("void computePBRLightMapping(const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");
802
- if (lightsState.lightMaps.length > 0) {
803
- src.push(" vec3 irradiance = sRGBToLinear(texture(lightMap, geometry.worldNormal)).rgb;");
804
- src.push(" irradiance *= PI;");
805
- src.push(" vec3 diffuseBRDFContrib = (RECIPROCAL_PI * material.diffuseColor);");
806
- src.push(" reflectedLight.diffuse += irradiance * diffuseBRDFContrib;");
807
- // src.push(" reflectedLight.diffuse = vec3(1.0, 0.0, 0.0);");
808
- }
809
- if (lightsState.reflectionMaps.length > 0) {
810
- src.push(" vec3 reflectVec = reflect(-geometry.viewEyeDir, geometry.viewNormal);");
811
- src.push(" reflectVec = inverseTransformDirection(reflectVec, viewMatrix);");
812
- src.push(" float blinnExpFromRoughness = GGXRoughnessToBlinnExponent(material.specularRoughness);");
813
- src.push(" vec3 radiance = getLightProbeIndirectRadiance(reflectVec, blinnExpFromRoughness, 8);");
814
- src.push(" vec3 specularBRDFContrib = BRDF_Specular_GGX_Environment(geometry, material.specularColor, material.specularRoughness);");
815
- src.push(" reflectedLight.specular += radiance * specularBRDFContrib;");
816
- }
817
- src.push("}");
818
- }
819
-
820
- // MAIN LIGHTING COMPUTATION FUNCTION
821
-
822
- src.push("void computePBRLighting(const in IncidentLight incidentLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");
823
- src.push(" float dotNL = saturate(dot(geometry.viewNormal, incidentLight.direction));");
824
- src.push(" vec3 irradiance = dotNL * incidentLight.color * PI;");
825
- src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");
826
- src.push(" reflectedLight.specular += irradiance * BRDF_Specular_GGX(incidentLight, geometry, material.specularColor, material.specularRoughness);");
827
- src.push("}");
828
-
829
- } // (metallicMaterial || specularMaterial)
830
-
831
- } // geometry.normals
832
-
833
- //--------------------------------------------------------------------------------
834
- // GEOMETRY INPUTS
835
- //--------------------------------------------------------------------------------
836
-
837
- src.push("in vec3 vViewPosition;");
838
-
839
- if (geometryState.colors) {
840
- src.push("in vec4 vColor;");
841
- }
842
-
843
- if (uvs &&
844
- ((normals && material._normalMap)
845
- || material._ambientMap
846
- || material._baseColorMap
847
- || material._diffuseMap
848
- || material._emissiveMap
849
- || material._metallicMap
850
- || material._roughnessMap
851
- || material._metallicRoughnessMap
852
- || material._specularMap
853
- || material._glossinessMap
854
- || material._specularGlossinessMap
855
- || material._occlusionMap
856
- || material._alphaMap)) {
857
- src.push("in vec2 vUV;");
858
- }
859
-
860
- if (normals) {
861
- if (lightsState.lightMaps.length > 0) {
862
- src.push("in vec3 vWorldNormal;");
863
- }
864
- src.push("in vec3 vViewNormal;");
865
- }
866
-
867
- //--------------------------------------------------------------------------------
868
- // MATERIAL CHANNEL INPUTS
869
- //--------------------------------------------------------------------------------
870
-
871
- if (materialState.ambient) {
872
- src.push("uniform vec3 materialAmbient;");
873
- }
874
- if (materialState.baseColor) {
875
- src.push("uniform vec3 materialBaseColor;");
876
- }
877
- if (materialState.alpha !== undefined && materialState.alpha !== null) {
878
- src.push("uniform vec4 materialAlphaModeCutoff;"); // [alpha, alphaMode, alphaCutoff]
879
- }
880
- if (materialState.emissive) {
881
- src.push("uniform vec3 materialEmissive;");
882
- }
883
- if (materialState.diffuse) {
884
- src.push("uniform vec3 materialDiffuse;");
885
- }
886
- if (materialState.glossiness !== undefined && materialState.glossiness !== null) {
887
- src.push("uniform float materialGlossiness;");
888
- }
889
- if (materialState.shininess !== undefined && materialState.shininess !== null) {
890
- src.push("uniform float materialShininess;"); // Phong channel
891
- }
892
- if (materialState.specular) {
893
- src.push("uniform vec3 materialSpecular;");
894
- }
895
- if (materialState.metallic !== undefined && materialState.metallic !== null) {
896
- src.push("uniform float materialMetallic;");
897
- }
898
- if (materialState.roughness !== undefined && materialState.roughness !== null) {
899
- src.push("uniform float materialRoughness;");
900
- }
901
- if (materialState.specularF0 !== undefined && materialState.specularF0 !== null) {
902
- src.push("uniform float materialSpecularF0;");
903
- }
904
-
905
- //--------------------------------------------------------------------------------
906
- // MATERIAL TEXTURE INPUTS
907
- //--------------------------------------------------------------------------------
908
-
909
- if (uvs && material._ambientMap) {
910
- src.push("uniform sampler2D ambientMap;");
911
- if (material._ambientMap._state.matrix) {
912
- src.push("uniform mat4 ambientMapMatrix;");
913
- }
914
- }
915
- if (uvs && material._baseColorMap) {
916
- src.push("uniform sampler2D baseColorMap;");
917
- if (material._baseColorMap._state.matrix) {
918
- src.push("uniform mat4 baseColorMapMatrix;");
919
- }
920
- }
921
- if (uvs && material._diffuseMap) {
922
- src.push("uniform sampler2D diffuseMap;");
923
- if (material._diffuseMap._state.matrix) {
924
- src.push("uniform mat4 diffuseMapMatrix;");
925
- }
926
- }
927
- if (uvs && material._emissiveMap) {
928
- src.push("uniform sampler2D emissiveMap;");
929
- if (material._emissiveMap._state.matrix) {
930
- src.push("uniform mat4 emissiveMapMatrix;");
931
- }
932
- }
933
- if (normals && uvs && material._metallicMap) {
934
- src.push("uniform sampler2D metallicMap;");
935
- if (material._metallicMap._state.matrix) {
936
- src.push("uniform mat4 metallicMapMatrix;");
937
- }
938
- }
939
- if (normals && uvs && material._roughnessMap) {
940
- src.push("uniform sampler2D roughnessMap;");
941
- if (material._roughnessMap._state.matrix) {
942
- src.push("uniform mat4 roughnessMapMatrix;");
943
- }
944
- }
945
- if (normals && uvs && material._metallicRoughnessMap) {
946
- src.push("uniform sampler2D metallicRoughnessMap;");
947
- if (material._metallicRoughnessMap._state.matrix) {
948
- src.push("uniform mat4 metallicRoughnessMapMatrix;");
949
- }
950
- }
951
- if (normals && material._normalMap) {
952
- src.push("uniform sampler2D normalMap;");
953
- if (material._normalMap._state.matrix) {
954
- src.push("uniform mat4 normalMapMatrix;");
955
- }
956
- src.push("vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {");
957
- src.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );");
958
- src.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );");
959
- src.push(" vec2 st0 = dFdx( uv.st );");
960
- src.push(" vec2 st1 = dFdy( uv.st );");
961
- src.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );");
962
- src.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );");
963
- src.push(" vec3 N = normalize( surf_norm );");
964
- src.push(" vec3 mapN = texture( normalMap, uv ).xyz * 2.0 - 1.0;");
965
- src.push(" mat3 tsn = mat3( S, T, N );");
966
- // src.push(" mapN *= 3.0;");
967
- src.push(" return normalize( tsn * mapN );");
968
- src.push("}");
969
- }
970
- if (uvs && material._occlusionMap) {
971
- src.push("uniform sampler2D occlusionMap;");
972
- if (material._occlusionMap._state.matrix) {
973
- src.push("uniform mat4 occlusionMapMatrix;");
974
- }
975
- }
976
- if (uvs && material._alphaMap) {
977
- src.push("uniform sampler2D alphaMap;");
978
- if (material._alphaMap._state.matrix) {
979
- src.push("uniform mat4 alphaMapMatrix;");
980
- }
981
- }
982
- if (normals && uvs && material._specularMap) {
983
- src.push("uniform sampler2D specularMap;");
984
- if (material._specularMap._state.matrix) {
985
- src.push("uniform mat4 specularMapMatrix;");
986
- }
987
- }
988
- if (normals && uvs && material._glossinessMap) {
989
- src.push("uniform sampler2D glossinessMap;");
990
- if (material._glossinessMap._state.matrix) {
991
- src.push("uniform mat4 glossinessMapMatrix;");
992
- }
993
- }
994
- if (normals && uvs && material._specularGlossinessMap) {
995
- src.push("uniform sampler2D materialSpecularGlossinessMap;");
996
- if (material._specularGlossinessMap._state.matrix) {
997
- src.push("uniform mat4 materialSpecularGlossinessMapMatrix;");
998
- }
999
- }
1000
-
1001
- //--------------------------------------------------------------------------------
1002
- // MATERIAL FRESNEL INPUTS
1003
- //--------------------------------------------------------------------------------
1004
-
1005
- if (normals && (material._diffuseFresnel ||
1006
- material._specularFresnel ||
1007
- material._alphaFresnel ||
1008
- material._emissiveFresnel ||
1009
- material._reflectivityFresnel)) {
1010
- src.push("float fresnel(vec3 eyeDir, vec3 normal, float edgeBias, float centerBias, float power) {");
1011
- src.push(" float fr = abs(dot(eyeDir, normal));");
1012
- src.push(" float finalFr = clamp((fr - edgeBias) / (centerBias - edgeBias), 0.0, 1.0);");
1013
- src.push(" return pow(finalFr, power);");
1014
- src.push("}");
1015
- if (material._diffuseFresnel) {
1016
- src.push("uniform float diffuseFresnelCenterBias;");
1017
- src.push("uniform float diffuseFresnelEdgeBias;");
1018
- src.push("uniform float diffuseFresnelPower;");
1019
- src.push("uniform vec3 diffuseFresnelCenterColor;");
1020
- src.push("uniform vec3 diffuseFresnelEdgeColor;");
1021
- }
1022
- if (material._specularFresnel) {
1023
- src.push("uniform float specularFresnelCenterBias;");
1024
- src.push("uniform float specularFresnelEdgeBias;");
1025
- src.push("uniform float specularFresnelPower;");
1026
- src.push("uniform vec3 specularFresnelCenterColor;");
1027
- src.push("uniform vec3 specularFresnelEdgeColor;");
1028
- }
1029
- if (material._alphaFresnel) {
1030
- src.push("uniform float alphaFresnelCenterBias;");
1031
- src.push("uniform float alphaFresnelEdgeBias;");
1032
- src.push("uniform float alphaFresnelPower;");
1033
- src.push("uniform vec3 alphaFresnelCenterColor;");
1034
- src.push("uniform vec3 alphaFresnelEdgeColor;");
1035
- }
1036
- if (material._reflectivityFresnel) {
1037
- src.push("uniform float materialSpecularF0FresnelCenterBias;");
1038
- src.push("uniform float materialSpecularF0FresnelEdgeBias;");
1039
- src.push("uniform float materialSpecularF0FresnelPower;");
1040
- src.push("uniform vec3 materialSpecularF0FresnelCenterColor;");
1041
- src.push("uniform vec3 materialSpecularF0FresnelEdgeColor;");
1042
- }
1043
- if (material._emissiveFresnel) {
1044
- src.push("uniform float emissiveFresnelCenterBias;");
1045
- src.push("uniform float emissiveFresnelEdgeBias;");
1046
- src.push("uniform float emissiveFresnelPower;");
1047
- src.push("uniform vec3 emissiveFresnelCenterColor;");
1048
- src.push("uniform vec3 emissiveFresnelEdgeColor;");
1049
- }
1050
- }
1051
-
1052
- //--------------------------------------------------------------------------------
1053
- // LIGHT SOURCES
1054
- //--------------------------------------------------------------------------------
1055
-
1056
- src.push("uniform vec4 lightAmbient;");
1057
-
1058
- if (normals) {
1059
- for (let i = 0, len = lightsState.lights.length; i < len; i++) { // Light sources
1060
- const light = lightsState.lights[i];
1061
- if (light.type === "ambient") {
1062
- continue;
1063
- }
1064
- src.push("uniform vec4 lightColor" + i + ";");
1065
- if (light.type === "point") {
1066
- src.push("uniform vec3 lightAttenuation" + i + ";");
1067
- }
1068
- if (light.type === "dir" && light.space === "view") {
1069
- src.push("uniform vec3 lightDir" + i + ";");
1070
- }
1071
- if (light.type === "point" && light.space === "view") {
1072
- src.push("uniform vec3 lightPos" + i + ";");
1073
- } else {
1074
- src.push("in vec4 vViewLightReverseDirAndDist" + i + ";");
1075
- }
1076
- }
1077
- }
1078
-
1079
- if (receivesShadow) {
1080
-
1081
- // Variance castsShadow mapping filter
1082
-
1083
- // src.push("float linstep(float low, float high, float v){");
1084
- // src.push(" return clamp((v-low)/(high-low), 0.0, 1.0);");
1085
- // src.push("}");
1086
- //
1087
- // src.push("float VSM(sampler2D depths, vec2 uv, float compare){");
1088
- // src.push(" vec2 moments = texture(depths, uv).xy;");
1089
- // src.push(" float p = smoothstep(compare-0.02, compare, moments.x);");
1090
- // src.push(" float variance = max(moments.y - moments.x*moments.x, -0.001);");
1091
- // src.push(" float d = compare - moments.x;");
1092
- // src.push(" float p_max = linstep(0.2, 1.0, variance / (variance + d*d));");
1093
- // src.push(" return clamp(max(p, p_max), 0.0, 1.0);");
1094
- // src.push("}");
1095
-
1096
- for (let i = 0, len = lightsState.lights.length; i < len; i++) { // Light sources
1097
- if (lightsState.lights[i].castsShadow) {
1098
- src.push("in vec4 vShadowPosFromLight" + i + ";");
1099
- src.push("uniform sampler2D shadowMap" + i + ";");
1100
- }
1101
- }
1102
- }
1103
-
1104
- src.push("uniform vec4 colorize;");
1105
-
1106
- //================================================================================
1107
- // MAIN
1108
- //================================================================================
1109
- src.push("out vec4 outColor;");
1110
- src.push("void main(void) {");
1111
-
1112
- if (clipping) {
1113
- src.push("if (clippable) {");
1114
- src.push(" float dist = 0.0;");
1115
- for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
1116
- src.push("if (sectionPlaneActive" + i + ") {");
1117
- src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
1118
- src.push("}");
1119
- }
1120
- src.push(" if (dist > 0.0) { discard; }");
1121
- if (solid) {
1122
- src.push(" if (gl_FrontFacing == false) {");
1123
- src.push(" outColor = vec4(1.0, 0.0, 0.0, 1.0);");
1124
- src.push(" return;");
1125
- src.push(" }");
1126
- }
1127
- src.push("}");
1128
- }
1129
-
1130
- if (geometryState.primitiveName === "points") {
1131
- src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");
1132
- src.push("float r = dot(cxy, cxy);");
1133
- src.push("if (r > 1.0) {");
1134
- src.push(" discard;");
1135
- src.push("}");
1136
- }
1137
-
1138
- src.push("float occlusion = 1.0;");
1139
-
1140
- if (materialState.ambient) {
1141
- src.push("vec3 ambientColor = materialAmbient;");
1142
- } else {
1143
- src.push("vec3 ambientColor = vec3(1.0, 1.0, 1.0);");
1144
- }
1145
-
1146
- if (materialState.diffuse) {
1147
- src.push("vec3 diffuseColor = materialDiffuse;");
1148
- } else if (materialState.baseColor) {
1149
- src.push("vec3 diffuseColor = materialBaseColor;");
1150
- } else {
1151
- src.push("vec3 diffuseColor = vec3(1.0, 1.0, 1.0);");
1152
- }
1153
-
1154
- if (geometryState.colors) {
1155
- src.push("diffuseColor *= vColor.rgb;");
1156
- }
1157
-
1158
- if (materialState.emissive) {
1159
- src.push("vec3 emissiveColor = materialEmissive;"); // Emissive default is (0,0,0), so initializing here
1160
- } else {
1161
- src.push("vec3 emissiveColor = vec3(0.0, 0.0, 0.0);");
1162
- }
1163
-
1164
- if (materialState.specular) {
1165
- src.push("vec3 specular = materialSpecular;");
1166
- } else {
1167
- src.push("vec3 specular = vec3(1.0, 1.0, 1.0);");
1168
- }
1169
-
1170
- if (materialState.alpha !== undefined) {
1171
- src.push("float alpha = materialAlphaModeCutoff[0];");
1172
- } else {
1173
- src.push("float alpha = 1.0;");
1174
- }
1175
-
1176
- if (geometryState.colors) {
1177
- src.push("alpha *= vColor.a;");
1178
- }
1179
-
1180
- if (materialState.glossiness !== undefined) {
1181
- src.push("float glossiness = materialGlossiness;");
1182
- } else {
1183
- src.push("float glossiness = 1.0;");
1184
- }
1185
-
1186
- if (materialState.metallic !== undefined) {
1187
- src.push("float metallic = materialMetallic;");
1188
- } else {
1189
- src.push("float metallic = 1.0;");
1190
- }
1191
-
1192
- if (materialState.roughness !== undefined) {
1193
- src.push("float roughness = materialRoughness;");
1194
- } else {
1195
- src.push("float roughness = 1.0;");
1196
- }
1197
-
1198
- if (materialState.specularF0 !== undefined) {
1199
- src.push("float specularF0 = materialSpecularF0;");
1200
- } else {
1201
- src.push("float specularF0 = 1.0;");
1202
- }
1203
-
1204
- //--------------------------------------------------------------------------------
1205
- // TEXTURING
1206
- //--------------------------------------------------------------------------------
1207
-
1208
- if (uvs && ((normals && material._normalMap)
1209
- || material._ambientMap
1210
- || material._baseColorMap
1211
- || material._diffuseMap
1212
- || material._occlusionMap
1213
- || material._emissiveMap
1214
- || material._metallicMap
1215
- || material._roughnessMap
1216
- || material._metallicRoughnessMap
1217
- || material._specularMap
1218
- || material._glossinessMap
1219
- || material._specularGlossinessMap
1220
- || material._alphaMap)) {
1221
- src.push("vec4 texturePos = vec4(vUV.s, vUV.t, 1.0, 1.0);");
1222
- src.push("vec2 textureCoord;");
1223
- }
1224
-
1225
- if (uvs && material._ambientMap) {
1226
- if (material._ambientMap._state.matrix) {
1227
- src.push("textureCoord = (ambientMapMatrix * texturePos).xy;");
1228
- } else {
1229
- src.push("textureCoord = texturePos.xy;");
1230
- }
1231
- src.push("vec4 ambientTexel = texture(ambientMap, textureCoord).rgb;");
1232
- src.push("ambientTexel = " + TEXTURE_DECODE_FUNCS[material._ambientMap._state.encoding] + "(ambientTexel);");
1233
- src.push("ambientColor *= ambientTexel.rgb;");
1234
- }
1235
-
1236
- if (uvs && material._diffuseMap) {
1237
- if (material._diffuseMap._state.matrix) {
1238
- src.push("textureCoord = (diffuseMapMatrix * texturePos).xy;");
1239
- } else {
1240
- src.push("textureCoord = texturePos.xy;");
1241
- }
1242
- src.push("vec4 diffuseTexel = texture(diffuseMap, textureCoord);");
1243
- src.push("diffuseTexel = " + TEXTURE_DECODE_FUNCS[material._diffuseMap._state.encoding] + "(diffuseTexel);");
1244
- src.push("diffuseColor *= diffuseTexel.rgb;");
1245
- src.push("alpha *= diffuseTexel.a;");
1246
- }
1247
-
1248
- if (uvs && material._baseColorMap) {
1249
- if (material._baseColorMap._state.matrix) {
1250
- src.push("textureCoord = (baseColorMapMatrix * texturePos).xy;");
1251
- } else {
1252
- src.push("textureCoord = texturePos.xy;");
1253
- }
1254
- src.push("vec4 baseColorTexel = texture(baseColorMap, textureCoord);");
1255
- src.push("baseColorTexel = " + TEXTURE_DECODE_FUNCS[material._baseColorMap._state.encoding] + "(baseColorTexel);");
1256
- src.push("diffuseColor *= baseColorTexel.rgb;");
1257
- src.push("alpha *= baseColorTexel.a;");
1258
- }
1259
-
1260
- if (uvs && material._emissiveMap) {
1261
- if (material._emissiveMap._state.matrix) {
1262
- src.push("textureCoord = (emissiveMapMatrix * texturePos).xy;");
1263
- } else {
1264
- src.push("textureCoord = texturePos.xy;");
1265
- }
1266
- src.push("vec4 emissiveTexel = texture(emissiveMap, textureCoord);");
1267
- src.push("emissiveTexel = " + TEXTURE_DECODE_FUNCS[material._emissiveMap._state.encoding] + "(emissiveTexel);");
1268
- src.push("emissiveColor = emissiveTexel.rgb;");
1269
- }
1270
-
1271
- if (uvs && material._alphaMap) {
1272
- if (material._alphaMap._state.matrix) {
1273
- src.push("textureCoord = (alphaMapMatrix * texturePos).xy;");
1274
- } else {
1275
- src.push("textureCoord = texturePos.xy;");
1276
- }
1277
- src.push("alpha *= texture(alphaMap, textureCoord).r;");
1278
- }
1279
-
1280
- if (uvs && material._occlusionMap) {
1281
- if (material._occlusionMap._state.matrix) {
1282
- src.push("textureCoord = (occlusionMapMatrix * texturePos).xy;");
1283
- } else {
1284
- src.push("textureCoord = texturePos.xy;");
1285
- }
1286
- src.push("occlusion *= texture(occlusionMap, textureCoord).r;");
1287
- }
1288
-
1289
- if (normals && ((lightsState.lights.length > 0) || lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0)) {
1290
-
1291
- //--------------------------------------------------------------------------------
1292
- // SHADING
1293
- //--------------------------------------------------------------------------------
1294
-
1295
- if (uvs && material._normalMap) {
1296
- if (material._normalMap._state.matrix) {
1297
- src.push("textureCoord = (normalMapMatrix * texturePos).xy;");
1298
- } else {
1299
- src.push("textureCoord = texturePos.xy;");
1300
- }
1301
- src.push("vec3 viewNormal = perturbNormal2Arb( vViewPosition, normalize(vViewNormal), textureCoord );");
1302
- } else {
1303
- src.push("vec3 viewNormal = normalize(vViewNormal);");
1304
- }
1305
-
1306
- if (uvs && material._specularMap) {
1307
- if (material._specularMap._state.matrix) {
1308
- src.push("textureCoord = (specularMapMatrix * texturePos).xy;");
1309
- } else {
1310
- src.push("textureCoord = texturePos.xy;");
1311
- }
1312
- src.push("specular *= texture(specularMap, textureCoord).rgb;");
1313
- }
1314
-
1315
- if (uvs && material._glossinessMap) {
1316
- if (material._glossinessMap._state.matrix) {
1317
- src.push("textureCoord = (glossinessMapMatrix * texturePos).xy;");
1318
- } else {
1319
- src.push("textureCoord = texturePos.xy;");
1320
- }
1321
- src.push("glossiness *= texture(glossinessMap, textureCoord).r;");
1322
- }
1323
-
1324
- if (uvs && material._specularGlossinessMap) {
1325
- if (material._specularGlossinessMap._state.matrix) {
1326
- src.push("textureCoord = (materialSpecularGlossinessMapMatrix * texturePos).xy;");
1327
- } else {
1328
- src.push("textureCoord = texturePos.xy;");
1329
- }
1330
- src.push("vec4 specGlossRGB = texture(materialSpecularGlossinessMap, textureCoord).rgba;"); // TODO: what if only RGB texture?
1331
- src.push("specular *= specGlossRGB.rgb;");
1332
- src.push("glossiness *= specGlossRGB.a;");
1333
- }
1334
-
1335
- if (uvs && material._metallicMap) {
1336
- if (material._metallicMap._state.matrix) {
1337
- src.push("textureCoord = (metallicMapMatrix * texturePos).xy;");
1338
- } else {
1339
- src.push("textureCoord = texturePos.xy;");
1340
- }
1341
- src.push("metallic *= texture(metallicMap, textureCoord).r;");
1342
- }
1343
-
1344
- if (uvs && material._roughnessMap) {
1345
- if (material._roughnessMap._state.matrix) {
1346
- src.push("textureCoord = (roughnessMapMatrix * texturePos).xy;");
1347
- } else {
1348
- src.push("textureCoord = texturePos.xy;");
1349
- }
1350
- src.push("roughness *= texture(roughnessMap, textureCoord).r;");
1351
- }
1352
-
1353
- if (uvs && material._metallicRoughnessMap) {
1354
- if (material._metallicRoughnessMap._state.matrix) {
1355
- src.push("textureCoord = (metallicRoughnessMapMatrix * texturePos).xy;");
1356
- } else {
1357
- src.push("textureCoord = texturePos.xy;");
1358
- }
1359
- src.push("vec3 metalRoughRGB = texture(metallicRoughnessMap, textureCoord).rgb;");
1360
- src.push("metallic *= metalRoughRGB.b;");
1361
- src.push("roughness *= metalRoughRGB.g;");
1362
- }
1363
-
1364
- src.push("vec3 viewEyeDir = normalize(-vViewPosition);");
1365
-
1366
- if (material._diffuseFresnel) {
1367
- src.push("float diffuseFresnel = fresnel(viewEyeDir, viewNormal, diffuseFresnelEdgeBias, diffuseFresnelCenterBias, diffuseFresnelPower);");
1368
- src.push("diffuseColor *= mix(diffuseFresnelEdgeColor, diffuseFresnelCenterColor, diffuseFresnel);");
1369
- }
1370
- if (material._specularFresnel) {
1371
- src.push("float specularFresnel = fresnel(viewEyeDir, viewNormal, specularFresnelEdgeBias, specularFresnelCenterBias, specularFresnelPower);");
1372
- src.push("specular *= mix(specularFresnelEdgeColor, specularFresnelCenterColor, specularFresnel);");
1373
- }
1374
- if (material._alphaFresnel) {
1375
- src.push("float alphaFresnel = fresnel(viewEyeDir, viewNormal, alphaFresnelEdgeBias, alphaFresnelCenterBias, alphaFresnelPower);");
1376
- src.push("alpha *= mix(alphaFresnelEdgeColor.r, alphaFresnelCenterColor.r, alphaFresnel);");
1377
- }
1378
- if (material._emissiveFresnel) {
1379
- src.push("float emissiveFresnel = fresnel(viewEyeDir, viewNormal, emissiveFresnelEdgeBias, emissiveFresnelCenterBias, emissiveFresnelPower);");
1380
- src.push("emissiveColor *= mix(emissiveFresnelEdgeColor, emissiveFresnelCenterColor, emissiveFresnel);");
1381
- }
1382
-
1383
- src.push("if (materialAlphaModeCutoff[1] == 1.0 && alpha < materialAlphaModeCutoff[2]) {"); // ie. (alphaMode == "mask" && alpha < alphaCutoff)
1384
- src.push(" discard;"); // TODO: Discard earlier within this shader?
1385
- src.push("}");
1386
-
1387
- // PREPARE INPUTS FOR SHADER FUNCTIONS
1388
-
1389
- src.push("IncidentLight light;");
1390
- src.push("Material material;");
1391
- src.push("Geometry geometry;");
1392
- src.push("ReflectedLight reflectedLight = ReflectedLight(vec3(0.0,0.0,0.0), vec3(0.0,0.0,0.0));");
1393
- src.push("vec3 viewLightDir;");
1394
-
1395
- if (phongMaterial) {
1396
- src.push("material.diffuseColor = diffuseColor;");
1397
- src.push("material.specularColor = specular;");
1398
- src.push("material.shine = materialShininess;");
1399
- }
1400
-
1401
- if (specularMaterial) {
1402
- src.push("float oneMinusSpecularStrength = 1.0 - max(max(specular.r, specular.g ),specular.b);"); // Energy conservation
1403
- src.push("material.diffuseColor = diffuseColor * oneMinusSpecularStrength;");
1404
- src.push("material.specularRoughness = clamp( 1.0 - glossiness, 0.04, 1.0 );");
1405
- src.push("material.specularColor = specular;");
1406
- }
1407
-
1408
- if (metallicMaterial) {
1409
- src.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;");
1410
- src.push("material.diffuseColor = diffuseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);");
1411
- src.push("material.specularRoughness = clamp(roughness, 0.04, 1.0);");
1412
- src.push("material.specularColor = mix(vec3(dielectricSpecular), diffuseColor, metallic);");
1413
- }
1414
-
1415
- src.push("geometry.position = vViewPosition;");
1416
- if (lightsState.lightMaps.length > 0) {
1417
- src.push("geometry.worldNormal = normalize(vWorldNormal);");
1418
- }
1419
- src.push("geometry.viewNormal = viewNormal;");
1420
- src.push("geometry.viewEyeDir = viewEyeDir;");
1421
-
1422
- // ENVIRONMENT AND REFLECTION MAP SHADING
1423
-
1424
- if ((phongMaterial) && (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0)) {
1425
- src.push("computePhongLightMapping(geometry, material, reflectedLight);");
1426
- }
1427
-
1428
- if ((specularMaterial || metallicMaterial) && (lightsState.lightMaps.length > 0 || lightsState.reflectionMaps.length > 0)) {
1429
- src.push("computePBRLightMapping(geometry, material, reflectedLight);");
1430
- }
1431
-
1432
- // LIGHT SOURCE SHADING
1433
-
1434
- src.push("float shadow = 1.0;");
1435
-
1436
- // if (receivesShadow) {
1437
- //
1438
- // src.push("float lightDepth2 = clamp(length(lightPos)/40.0, 0.0, 1.0);");
1439
- // src.push("float illuminated = VSM(sLightDepth, lightUV, lightDepth2);");
1440
- //
1441
- src.push("float shadowAcneRemover = 0.007;");
1442
- src.push("vec3 fragmentDepth;");
1443
- src.push("float texelSize = 1.0 / 1024.0;");
1444
- src.push("float amountInLight = 0.0;");
1445
- src.push("vec3 shadowCoord;");
1446
- src.push('vec4 rgbaDepth;');
1447
- src.push("float depth;");
1448
- // }
1449
-
1450
- const numShadows = 0;
1451
- for (let i = 0, len = lightsState.lights.length; i < len; i++) {
1452
-
1453
- const light = lightsState.lights[i];
1454
-
1455
- if (light.type === "ambient") {
1456
- continue;
1457
- }
1458
- if (light.type === "dir" && light.space === "view") {
1459
- src.push("viewLightDir = -normalize(lightDir" + i + ");");
1460
- } else if (light.type === "point" && light.space === "view") {
1461
- src.push("viewLightDir = normalize(lightPos" + i + " - vViewPosition);");
1462
- //src.push("tmpVec3 = lightPos" + i + ".xyz - viewPosition.xyz;");
1463
- //src.push("lightDist = abs(length(tmpVec3));");
1464
- } else {
1465
- src.push("viewLightDir = normalize(vViewLightReverseDirAndDist" + i + ".xyz);"); // If normal mapping, the fragment->light vector will be in tangent space
1466
- }
1467
-
1468
- if (receivesShadow && light.castsShadow) {
1469
-
1470
- // if (true) {
1471
- // src.push('shadowCoord = (vShadowPosFromLight' + i + '.xyz/vShadowPosFromLight' + i + '.w)/2.0 + 0.5;');
1472
- // src.push("lightDepth2 = clamp(length(vec3[0.0, 20.0, 20.0])/40.0, 0.0, 1.0);");
1473
- // src.push("castsShadow *= VSM(shadowMap' + i + ', shadowCoord, lightDepth2);");
1474
- // }
1475
- //
1476
- // if (false) {
1477
- //
1478
- // PCF
1479
-
1480
- src.push("shadow = 0.0;");
1481
-
1482
- src.push("fragmentDepth = vShadowPosFromLight" + i + ".xyz;");
1483
- src.push("fragmentDepth.z -= shadowAcneRemover;");
1484
- src.push("for (int x = -3; x <= 3; x++) {");
1485
- src.push(" for (int y = -3; y <= 3; y++) {");
1486
- src.push(" float texelDepth = unpackDepth(texture(shadowMap" + i + ", fragmentDepth.xy + vec2(x, y) * texelSize));");
1487
- src.push(" if (fragmentDepth.z < texelDepth) {");
1488
- src.push(" shadow += 1.0;");
1489
- src.push(" }");
1490
- src.push(" }");
1491
- src.push("}");
1492
-
1493
- src.push("shadow = shadow / 9.0;");
1494
-
1495
- src.push("light.color = lightColor" + i + ".rgb * (lightColor" + i + ".a * shadow);"); // a is intensity
1496
- //
1497
- // }
1498
- //
1499
- // if (false){
1500
- //
1501
- // src.push("shadow = 1.0;");
1502
- //
1503
- // src.push('shadowCoord = (vShadowPosFromLight' + i + '.xyz/vShadowPosFromLight' + i + '.w)/2.0 + 0.5;');
1504
- //
1505
- // src.push('shadow -= (shadowCoord.z > unpackDepth(texture(shadowMap' + i + ', shadowCoord.xy + vec2( -0.94201624, -0.39906216 ) / 700.0)) + 0.0015) ? 0.2 : 0.0;');
1506
- // src.push('shadow -= (shadowCoord.z > unpackDepth(texture(shadowMap' + i + ', shadowCoord.xy + vec2( 0.94558609, -0.76890725 ) / 700.0)) + 0.0015) ? 0.2 : 0.0;');
1507
- // src.push('shadow -= (shadowCoord.z > unpackDepth(texture(shadowMap' + i + ', shadowCoord.xy + vec2( -0.094184101, -0.92938870 ) / 700.0)) + 0.0015) ? 0.2 : 0.0;');
1508
- // src.push('shadow -= (shadowCoord.z > unpackDepth(texture(shadowMap' + i + ', shadowCoord.xy + vec2( 0.34495938, 0.29387760 ) / 700.0)) + 0.0015) ? 0.2 : 0.0;');
1509
- //
1510
- // src.push("light.color = lightColor" + i + ".rgb * (lightColor" + i + ".a * shadow);");
1511
- // }
1512
- } else {
1513
- src.push("light.color = lightColor" + i + ".rgb * (lightColor" + i + ".a );"); // a is intensity
1514
- }
1515
-
1516
- src.push("light.direction = viewLightDir;");
1517
-
1518
- if (phongMaterial) {
1519
- src.push("computePhongLighting(light, geometry, material, reflectedLight);");
1520
- }
1521
-
1522
- if (specularMaterial || metallicMaterial) {
1523
- src.push("computePBRLighting(light, geometry, material, reflectedLight);");
1524
- }
1525
- }
1526
-
1527
- if (numShadows > 0) {
1528
- //src.push("shadow /= " + (9 * numShadows) + ".0;");
1529
- }
1530
-
1531
- //src.push("reflectedLight.diffuse *= shadow;");
1532
-
1533
- // COMBINE TERMS
1534
-
1535
- if (phongMaterial) {
1536
- src.push("vec3 outgoingLight = (lightAmbient.rgb * lightAmbient.a * diffuseColor) + ((occlusion * (( reflectedLight.diffuse + reflectedLight.specular)))) + emissiveColor;");
1537
-
1538
- } else {
1539
- src.push("vec3 outgoingLight = (occlusion * (reflectedLight.diffuse)) + (occlusion * reflectedLight.specular) + emissiveColor;");
1540
- }
1541
-
1542
- } else {
1543
-
1544
- //--------------------------------------------------------------------------------
1545
- // NO SHADING - EMISSIVE and AMBIENT ONLY
1546
- //--------------------------------------------------------------------------------
1547
-
1548
- src.push("ambientColor *= (lightAmbient.rgb * lightAmbient.a);");
1549
-
1550
- src.push("vec3 outgoingLight = emissiveColor + ambientColor;");
1551
- }
1552
-
1553
- src.push("vec4 fragColor = vec4(outgoingLight, alpha) * colorize;");
1554
-
1555
- if (gammaOutput) {
1556
- src.push("fragColor = linearToGamma(fragColor, gammaFactor);");
1557
- }
1558
-
1559
- src.push("outColor = fragColor;");
1560
-
1561
- if (scene.logarithmicDepthBufferEnabled) {
1562
- src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
1563
- }
1564
-
1565
- src.push("}");
1566
-
1567
- return src;
1568
- }
1569
-
1570
- export {DrawShaderSource};