@needle-tools/three 0.154.2 → 0.160.2

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 (957) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +86 -84
  3. package/build/three.cjs +53679 -51654
  4. package/build/three.module.js +53263 -51253
  5. package/build/three.module.min.js +6 -6
  6. package/examples/fonts/LICENSE +13 -13
  7. package/examples/fonts/README.md +11 -11
  8. package/examples/fonts/droid/NOTICE +190 -190
  9. package/examples/fonts/droid/README.txt +18 -18
  10. package/examples/fonts/ttf/README.md +9 -9
  11. package/examples/jsm/Addons.js +294 -0
  12. package/examples/jsm/animation/AnimationClipCreator.js +116 -116
  13. package/examples/jsm/animation/CCDIKSolver.js +482 -482
  14. package/examples/jsm/animation/MMDAnimationHelper.js +1207 -1207
  15. package/examples/jsm/animation/MMDPhysics.js +1406 -1406
  16. package/examples/jsm/cameras/CinematicCamera.js +208 -208
  17. package/examples/jsm/capabilities/WebGL.js +108 -91
  18. package/examples/jsm/capabilities/WebGPU.js +57 -53
  19. package/examples/jsm/controls/ArcballControls.js +3224 -3224
  20. package/examples/jsm/controls/DragControls.js +221 -220
  21. package/examples/jsm/controls/FirstPersonControls.js +325 -325
  22. package/examples/jsm/controls/FlyControls.js +326 -300
  23. package/examples/jsm/controls/MapControls.js +28 -28
  24. package/examples/jsm/controls/OrbitControls.js +1521 -1279
  25. package/examples/jsm/controls/PointerLockControls.js +162 -162
  26. package/examples/jsm/controls/TrackballControls.js +828 -828
  27. package/examples/jsm/controls/TransformControls.js +1573 -1557
  28. package/examples/jsm/csm/CSM.js +384 -384
  29. package/examples/jsm/csm/CSMFrustum.js +152 -152
  30. package/examples/jsm/csm/CSMHelper.js +193 -193
  31. package/examples/jsm/csm/CSMShader.js +295 -252
  32. package/examples/jsm/curves/CurveExtras.js +422 -422
  33. package/examples/jsm/curves/NURBSCurve.js +80 -80
  34. package/examples/jsm/curves/NURBSSurface.js +52 -52
  35. package/examples/jsm/curves/NURBSUtils.js +487 -487
  36. package/examples/jsm/effects/AnaglyphEffect.js +154 -154
  37. package/examples/jsm/effects/AsciiEffect.js +263 -263
  38. package/examples/jsm/effects/OutlineEffect.js +539 -539
  39. package/examples/jsm/effects/ParallaxBarrierEffect.js +119 -119
  40. package/examples/jsm/effects/PeppersGhostEffect.js +153 -153
  41. package/examples/jsm/effects/StereoEffect.js +55 -55
  42. package/examples/jsm/environments/DebugEnvironment.js +52 -52
  43. package/examples/jsm/environments/RoomEnvironment.js +148 -148
  44. package/examples/jsm/exporters/DRACOExporter.js +267 -267
  45. package/examples/jsm/exporters/EXRExporter.js +579 -501
  46. package/examples/jsm/exporters/GLTFExporter.js +3311 -3163
  47. package/examples/jsm/exporters/KTX2Exporter.js +292 -292
  48. package/examples/jsm/exporters/MMDExporter.js +217 -217
  49. package/examples/jsm/exporters/OBJExporter.js +284 -284
  50. package/examples/jsm/exporters/PLYExporter.js +528 -528
  51. package/examples/jsm/exporters/STLExporter.js +199 -199
  52. package/examples/jsm/exporters/USDZExporter.js +720 -710
  53. package/examples/jsm/geometries/BoxLineGeometry.js +69 -69
  54. package/examples/jsm/geometries/ConvexGeometry.js +53 -53
  55. package/examples/jsm/geometries/DecalGeometry.js +356 -356
  56. package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
  57. package/examples/jsm/geometries/ParametricGeometries.js +254 -254
  58. package/examples/jsm/geometries/ParametricGeometry.js +139 -139
  59. package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -155
  60. package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
  61. package/examples/jsm/geometries/TeapotGeometry.js +704 -704
  62. package/examples/jsm/geometries/TextGeometry.js +57 -57
  63. package/examples/jsm/helpers/LightProbeHelper.js +130 -130
  64. package/examples/jsm/helpers/OctreeHelper.js +73 -73
  65. package/examples/jsm/helpers/PositionalAudioHelper.js +109 -109
  66. package/examples/jsm/helpers/RectAreaLightHelper.js +85 -85
  67. package/examples/jsm/helpers/TextureHelper.js +237 -0
  68. package/examples/jsm/helpers/VertexNormalsHelper.js +96 -96
  69. package/examples/jsm/helpers/VertexTangentsHelper.js +88 -88
  70. package/examples/jsm/helpers/ViewHelper.js +333 -333
  71. package/examples/jsm/interactive/HTMLMesh.js +572 -565
  72. package/examples/jsm/interactive/InteractiveGroup.js +116 -116
  73. package/examples/jsm/interactive/SelectionBox.js +227 -227
  74. package/examples/jsm/interactive/SelectionHelper.js +104 -97
  75. package/examples/jsm/libs/ammo.wasm.js +822 -822
  76. package/examples/jsm/libs/basis/README.md +46 -46
  77. package/examples/jsm/libs/basis/basis_transcoder.js +21 -21
  78. package/examples/jsm/libs/chevrotain.module.min.js +141 -141
  79. package/examples/jsm/libs/draco/README.md +32 -32
  80. package/examples/jsm/libs/draco/draco_decoder.js +34 -34
  81. package/examples/jsm/libs/draco/draco_encoder.js +33 -33
  82. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -117
  83. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -33
  84. package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -33
  85. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -116
  86. package/examples/jsm/libs/ecsy.module.js +1792 -1792
  87. package/examples/jsm/libs/fflate.module.js +2474 -2474
  88. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  89. package/examples/jsm/libs/lil-gui.module.min.js +8 -8
  90. package/examples/jsm/libs/lottie_canvas.module.js +14849 -14844
  91. package/examples/jsm/libs/meshopt_decoder.module.js +178 -178
  92. package/examples/jsm/libs/mikktspace.module.js +128 -128
  93. package/examples/jsm/libs/mmdparser.module.js +11530 -11530
  94. package/examples/jsm/libs/motion-controllers.module.js +397 -397
  95. package/examples/jsm/libs/opentype.module.js +14506 -14568
  96. package/examples/jsm/libs/potpack.module.js +124 -124
  97. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8743 -21
  98. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8748 -15
  99. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  100. package/examples/jsm/libs/stats.module.js +167 -167
  101. package/examples/jsm/libs/surfaceNet.js +201 -0
  102. package/examples/jsm/libs/tween.module.js +858 -803
  103. package/examples/jsm/libs/utif.module.js +1664 -1578
  104. package/examples/jsm/libs/zstddec.module.js +1 -1
  105. package/examples/jsm/lights/IESSpotLight.js +25 -25
  106. package/examples/jsm/lights/LightProbeGenerator.js +286 -252
  107. package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -79
  108. package/examples/jsm/lines/Line2.js +19 -19
  109. package/examples/jsm/lines/LineGeometry.js +79 -79
  110. package/examples/jsm/lines/LineMaterial.js +619 -702
  111. package/examples/jsm/lines/LineSegments2.js +361 -361
  112. package/examples/jsm/lines/LineSegmentsGeometry.js +241 -241
  113. package/examples/jsm/lines/Wireframe.js +56 -56
  114. package/examples/jsm/lines/WireframeGeometry2.js +24 -24
  115. package/examples/jsm/loaders/3DMLoader.js +1772 -1497
  116. package/examples/jsm/loaders/3MFLoader.js +1478 -1478
  117. package/examples/jsm/loaders/AMFLoader.js +521 -521
  118. package/examples/jsm/loaders/BVHLoader.js +437 -437
  119. package/examples/jsm/loaders/ColladaLoader.js +4116 -4122
  120. package/examples/jsm/loaders/DDSLoader.js +318 -274
  121. package/examples/jsm/loaders/DRACOLoader.js +613 -612
  122. package/examples/jsm/loaders/EXRLoader.js +2309 -2309
  123. package/examples/jsm/loaders/FBXLoader.js +4314 -4142
  124. package/examples/jsm/loaders/FontLoader.js +183 -183
  125. package/examples/jsm/loaders/GCodeLoader.js +261 -261
  126. package/examples/jsm/loaders/GLTFLoader.js +4666 -4579
  127. package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +719 -683
  128. package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -115
  129. package/examples/jsm/loaders/IESLoader.js +337 -337
  130. package/examples/jsm/loaders/KMZLoader.js +130 -130
  131. package/examples/jsm/loaders/KTX2Loader.js +932 -868
  132. package/examples/jsm/loaders/KTXLoader.js +176 -176
  133. package/examples/jsm/loaders/LDrawLoader.js +2470 -2464
  134. package/examples/jsm/loaders/LUT3dlLoader.js +183 -151
  135. package/examples/jsm/loaders/LUTCubeLoader.js +167 -153
  136. package/examples/jsm/loaders/LUTImageLoader.js +163 -0
  137. package/examples/jsm/loaders/LWOLoader.js +1052 -1052
  138. package/examples/jsm/loaders/LogLuvLoader.js +606 -606
  139. package/examples/jsm/loaders/LottieLoader.js +77 -77
  140. package/examples/jsm/loaders/MD2Loader.js +399 -399
  141. package/examples/jsm/loaders/MDDLoader.js +102 -102
  142. package/examples/jsm/loaders/MMDLoader.js +2276 -2273
  143. package/examples/jsm/loaders/MTLLoader.js +567 -567
  144. package/examples/jsm/loaders/MaterialXLoader.js +852 -734
  145. package/examples/jsm/loaders/NRRDLoader.js +686 -699
  146. package/examples/jsm/loaders/OBJLoader.js +905 -905
  147. package/examples/jsm/loaders/PCDLoader.js +467 -467
  148. package/examples/jsm/loaders/PDBLoader.js +232 -232
  149. package/examples/jsm/loaders/PLYLoader.js +771 -771
  150. package/examples/jsm/loaders/PVRLoader.js +251 -251
  151. package/examples/jsm/loaders/RGBELoader.js +450 -468
  152. package/examples/jsm/loaders/RGBMLoader.js +1065 -1065
  153. package/examples/jsm/loaders/STLLoader.js +410 -403
  154. package/examples/jsm/loaders/SVGLoader.js +3173 -3172
  155. package/examples/jsm/loaders/TDSLoader.js +1124 -1124
  156. package/examples/jsm/loaders/TGALoader.js +517 -517
  157. package/examples/jsm/loaders/TIFFLoader.js +36 -36
  158. package/examples/jsm/loaders/TTFLoader.js +214 -214
  159. package/examples/jsm/loaders/TiltLoader.js +520 -520
  160. package/examples/jsm/loaders/USDZLoader.js +822 -633
  161. package/examples/jsm/loaders/VOXLoader.js +311 -311
  162. package/examples/jsm/loaders/VRMLLoader.js +3533 -3533
  163. package/examples/jsm/loaders/VTKLoader.js +1163 -1163
  164. package/examples/jsm/loaders/XYZLoader.js +106 -106
  165. package/examples/jsm/loaders/lwo/IFFParser.js +1214 -1218
  166. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -414
  167. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -373
  168. package/examples/jsm/materials/MeshGouraudMaterial.js +426 -420
  169. package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
  170. package/examples/jsm/math/Capsule.js +82 -137
  171. package/examples/jsm/math/ColorConverter.js +36 -36
  172. package/examples/jsm/math/ConvexHull.js +1271 -1271
  173. package/examples/jsm/math/ImprovedNoise.js +71 -71
  174. package/examples/jsm/math/Lut.js +204 -204
  175. package/examples/jsm/math/MeshSurfaceSampler.js +250 -250
  176. package/examples/jsm/math/OBB.js +423 -423
  177. package/examples/jsm/math/Octree.js +540 -462
  178. package/examples/jsm/math/SimplexNoise.js +444 -444
  179. package/examples/jsm/misc/ConvexObjectBreaker.js +519 -519
  180. package/examples/jsm/misc/GPUComputationRenderer.js +446 -455
  181. package/examples/jsm/misc/Gyroscope.js +66 -66
  182. package/examples/jsm/misc/MD2Character.js +276 -276
  183. package/examples/jsm/misc/MD2CharacterComplex.js +576 -576
  184. package/examples/jsm/misc/MorphAnimMesh.js +75 -75
  185. package/examples/jsm/misc/MorphBlendMesh.js +322 -322
  186. package/examples/jsm/misc/ProgressiveLightMap.js +323 -323
  187. package/examples/jsm/misc/RollerCoaster.js +566 -566
  188. package/examples/jsm/misc/Timer.js +119 -0
  189. package/examples/jsm/misc/TubePainter.js +202 -205
  190. package/examples/jsm/misc/Volume.js +473 -475
  191. package/examples/jsm/misc/VolumeSlice.js +229 -229
  192. package/examples/jsm/modifiers/CurveModifier.js +344 -326
  193. package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -279
  194. package/examples/jsm/modifiers/SimplifyModifier.js +617 -525
  195. package/examples/jsm/modifiers/TessellateModifier.js +307 -307
  196. package/examples/jsm/nodes/Nodes.js +189 -172
  197. package/examples/jsm/nodes/accessors/BitangentNode.js +89 -89
  198. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +127 -99
  199. package/examples/jsm/nodes/accessors/BufferNode.js +30 -30
  200. package/examples/jsm/nodes/accessors/CameraNode.js +120 -98
  201. package/examples/jsm/nodes/accessors/CubeTextureNode.js +61 -101
  202. package/examples/jsm/nodes/accessors/InstanceNode.js +71 -71
  203. package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
  204. package/examples/jsm/nodes/accessors/MaterialNode.js +314 -277
  205. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +51 -39
  206. package/examples/jsm/nodes/accessors/ModelNode.js +33 -34
  207. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +39 -29
  208. package/examples/jsm/nodes/accessors/MorphNode.js +245 -70
  209. package/examples/jsm/nodes/accessors/NormalNode.js +96 -96
  210. package/examples/jsm/nodes/accessors/Object3DNode.js +150 -150
  211. package/examples/jsm/nodes/accessors/PointUVNode.js +26 -26
  212. package/examples/jsm/nodes/accessors/PositionNode.js +104 -104
  213. package/examples/jsm/nodes/accessors/ReferenceNode.js +102 -72
  214. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +35 -35
  215. package/examples/jsm/nodes/accessors/SceneNode.js +52 -46
  216. package/examples/jsm/nodes/accessors/SkinningNode.js +103 -93
  217. package/examples/jsm/nodes/accessors/StorageBufferNode.js +54 -27
  218. package/examples/jsm/nodes/accessors/TangentNode.js +103 -103
  219. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -94
  220. package/examples/jsm/nodes/accessors/TextureNode.js +367 -230
  221. package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -35
  222. package/examples/jsm/nodes/accessors/TextureStoreNode.js +82 -0
  223. package/examples/jsm/nodes/accessors/UVNode.js +47 -47
  224. package/examples/jsm/nodes/accessors/UserDataNode.js +29 -29
  225. package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
  226. package/examples/jsm/nodes/code/CodeNode.js +78 -78
  227. package/examples/jsm/nodes/code/ExpressionNode.js +37 -37
  228. package/examples/jsm/nodes/code/FunctionCallNode.js +96 -96
  229. package/examples/jsm/nodes/code/FunctionNode.js +138 -127
  230. package/examples/jsm/nodes/code/ScriptableNode.js +488 -488
  231. package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -167
  232. package/examples/jsm/nodes/core/ArrayUniformNode.js +26 -26
  233. package/examples/jsm/nodes/core/AssignNode.js +72 -0
  234. package/examples/jsm/nodes/core/AttributeNode.js +108 -102
  235. package/examples/jsm/nodes/core/BypassNode.js +45 -45
  236. package/examples/jsm/nodes/core/CacheNode.js +49 -46
  237. package/examples/jsm/nodes/core/ConstNode.js +32 -32
  238. package/examples/jsm/nodes/core/ContextNode.js +61 -61
  239. package/examples/jsm/nodes/core/IndexNode.js +66 -66
  240. package/examples/jsm/nodes/core/InputNode.js +83 -83
  241. package/examples/jsm/nodes/core/LightingModel.js +17 -17
  242. package/examples/jsm/nodes/core/Node.js +483 -445
  243. package/examples/jsm/nodes/core/NodeAttribute.js +15 -15
  244. package/examples/jsm/nodes/core/NodeBuilder.js +1267 -1016
  245. package/examples/jsm/nodes/core/NodeCache.js +26 -26
  246. package/examples/jsm/nodes/core/NodeCode.js +15 -15
  247. package/examples/jsm/nodes/core/NodeFrame.js +135 -110
  248. package/examples/jsm/nodes/core/NodeFunction.js +22 -22
  249. package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -17
  250. package/examples/jsm/nodes/core/NodeKeywords.js +80 -80
  251. package/examples/jsm/nodes/core/NodeParser.js +11 -11
  252. package/examples/jsm/nodes/core/NodeUniform.js +40 -28
  253. package/examples/jsm/nodes/core/NodeUtils.js +210 -212
  254. package/examples/jsm/nodes/core/NodeVar.js +14 -14
  255. package/examples/jsm/nodes/core/NodeVarying.js +17 -17
  256. package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
  257. package/examples/jsm/nodes/core/ParameterNode.js +33 -0
  258. package/examples/jsm/nodes/core/PropertyNode.js +72 -57
  259. package/examples/jsm/nodes/core/StackNode.js +89 -99
  260. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  261. package/examples/jsm/nodes/core/TempNode.js +58 -58
  262. package/examples/jsm/nodes/core/UniformGroup.js +13 -0
  263. package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
  264. package/examples/jsm/nodes/core/UniformNode.js +80 -61
  265. package/examples/jsm/nodes/core/VarNode.js +60 -87
  266. package/examples/jsm/nodes/core/VaryingNode.js +65 -69
  267. package/examples/jsm/nodes/core/constants.js +27 -27
  268. package/examples/jsm/nodes/display/AfterImageNode.js +134 -0
  269. package/examples/jsm/nodes/display/BlendModeNode.js +99 -99
  270. package/examples/jsm/nodes/display/BumpMapNode.js +99 -0
  271. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +96 -100
  272. package/examples/jsm/nodes/display/ColorSpaceNode.js +108 -108
  273. package/examples/jsm/nodes/display/FrontFacingNode.js +27 -27
  274. package/examples/jsm/nodes/display/GaussianBlurNode.js +177 -0
  275. package/examples/jsm/nodes/display/NormalMapNode.js +108 -106
  276. package/examples/jsm/nodes/display/PassNode.js +182 -0
  277. package/examples/jsm/nodes/display/PosterizeNode.js +32 -32
  278. package/examples/jsm/nodes/display/ToneMappingNode.js +184 -141
  279. package/examples/jsm/nodes/display/ViewportDepthNode.js +97 -69
  280. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +31 -34
  281. package/examples/jsm/nodes/display/ViewportNode.js +134 -115
  282. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +31 -31
  283. package/examples/jsm/nodes/display/ViewportTextureNode.js +75 -75
  284. package/examples/jsm/nodes/fog/FogExp2Node.js +35 -35
  285. package/examples/jsm/nodes/fog/FogNode.js +38 -37
  286. package/examples/jsm/nodes/fog/FogRangeNode.js +34 -34
  287. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +40 -32
  288. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -9
  289. package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +57 -43
  290. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +30 -29
  291. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +23 -18
  292. package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -13
  293. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +16 -16
  294. package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
  295. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +28 -20
  296. package/examples/jsm/nodes/functions/PhongLightingModel.js +67 -28
  297. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +393 -204
  298. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +13 -13
  299. package/examples/jsm/nodes/functions/material/getRoughness.js +18 -18
  300. package/examples/jsm/nodes/geometry/RangeNode.js +104 -104
  301. package/examples/jsm/nodes/gpgpu/ComputeNode.js +85 -72
  302. package/examples/jsm/nodes/lighting/AONode.js +27 -27
  303. package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -27
  304. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +238 -146
  305. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +40 -43
  306. package/examples/jsm/nodes/lighting/EnvironmentNode.js +181 -181
  307. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +55 -55
  308. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -39
  309. package/examples/jsm/nodes/lighting/LightNode.js +57 -57
  310. package/examples/jsm/nodes/lighting/LightUtils.js +17 -17
  311. package/examples/jsm/nodes/lighting/LightingContextNode.js +66 -99
  312. package/examples/jsm/nodes/lighting/LightingNode.js +21 -21
  313. package/examples/jsm/nodes/lighting/LightsNode.js +188 -128
  314. package/examples/jsm/nodes/lighting/PointLightNode.js +68 -71
  315. package/examples/jsm/nodes/lighting/SpotLightNode.js +89 -92
  316. package/examples/jsm/nodes/loaders/NodeLoader.js +108 -108
  317. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +59 -59
  318. package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -70
  319. package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
  320. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +436 -0
  321. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +28 -28
  322. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  323. package/examples/jsm/nodes/materials/Materials.js +16 -11
  324. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +28 -27
  325. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
  326. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +40 -38
  327. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +65 -65
  328. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +155 -111
  329. package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
  330. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +80 -80
  331. package/examples/jsm/nodes/materials/NodeMaterial.js +568 -510
  332. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +39 -49
  333. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +96 -103
  334. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -199
  335. package/examples/jsm/nodes/materialx/MaterialXNodes.js +68 -68
  336. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +130 -56
  337. package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
  338. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +29 -19
  339. package/examples/jsm/nodes/math/CondNode.js +86 -86
  340. package/examples/jsm/nodes/math/HashNode.js +34 -0
  341. package/examples/jsm/nodes/math/MathNode.js +382 -359
  342. package/examples/jsm/nodes/math/OperatorNode.js +266 -269
  343. package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
  344. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -152
  345. package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -14
  346. package/examples/jsm/nodes/procedural/CheckerNode.js +42 -42
  347. package/examples/jsm/nodes/shadernode/ShaderNode.js +625 -420
  348. package/examples/jsm/nodes/utils/ArrayElementNode.js +41 -33
  349. package/examples/jsm/nodes/utils/ConvertNode.js +65 -65
  350. package/examples/jsm/nodes/utils/DiscardNode.js +27 -26
  351. package/examples/jsm/nodes/utils/EquirectUVNode.js +33 -33
  352. package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
  353. package/examples/jsm/nodes/utils/JoinNode.js +61 -51
  354. package/examples/jsm/nodes/utils/LoopNode.js +198 -186
  355. package/examples/jsm/nodes/utils/MatcapUVNode.js +30 -30
  356. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +46 -46
  357. package/examples/jsm/nodes/utils/OscNode.js +81 -81
  358. package/examples/jsm/nodes/utils/PackingNode.js +55 -55
  359. package/examples/jsm/nodes/utils/RemapNode.js +42 -42
  360. package/examples/jsm/nodes/utils/RotateNode.js +43 -0
  361. package/examples/jsm/nodes/utils/RotateUVNode.js +43 -43
  362. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  363. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -37
  364. package/examples/jsm/nodes/utils/SplitNode.js +112 -104
  365. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +41 -41
  366. package/examples/jsm/nodes/utils/TimerNode.js +94 -94
  367. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +62 -62
  368. package/examples/jsm/objects/GroundedSkybox.js +50 -0
  369. package/examples/jsm/objects/InstancedPoints.js +21 -0
  370. package/examples/jsm/objects/Lensflare.js +397 -377
  371. package/examples/jsm/objects/MarchingCubes.js +1176 -1176
  372. package/examples/jsm/objects/QuadMesh.js +66 -0
  373. package/examples/jsm/objects/Reflector.js +264 -272
  374. package/examples/jsm/objects/ReflectorForSSRPass.js +352 -349
  375. package/examples/jsm/objects/Refractor.js +327 -332
  376. package/examples/jsm/objects/ShadowMesh.js +80 -80
  377. package/examples/jsm/objects/Sky.js +219 -219
  378. package/examples/jsm/objects/Water.js +333 -330
  379. package/examples/jsm/objects/Water2.js +361 -358
  380. package/examples/jsm/offscreen/jank.js +45 -45
  381. package/examples/jsm/offscreen/offscreen.js +8 -8
  382. package/examples/jsm/offscreen/scene.js +86 -87
  383. package/examples/jsm/physics/AmmoPhysics.js +306 -285
  384. package/examples/jsm/physics/RapierPhysics.js +220 -199
  385. package/examples/jsm/postprocessing/AfterimagePass.js +104 -104
  386. package/examples/jsm/postprocessing/BloomPass.js +172 -172
  387. package/examples/jsm/postprocessing/BokehPass.js +141 -140
  388. package/examples/jsm/postprocessing/ClearPass.js +46 -46
  389. package/examples/jsm/postprocessing/CubeTexturePass.js +85 -85
  390. package/examples/jsm/postprocessing/DotScreenPass.js +65 -65
  391. package/examples/jsm/postprocessing/EffectComposer.js +231 -231
  392. package/examples/jsm/postprocessing/FilmPass.js +64 -66
  393. package/examples/jsm/postprocessing/GTAOPass.js +582 -0
  394. package/examples/jsm/postprocessing/GlitchPass.js +128 -128
  395. package/examples/jsm/postprocessing/HalftonePass.js +79 -79
  396. package/examples/jsm/postprocessing/LUTPass.js +174 -173
  397. package/examples/jsm/postprocessing/MaskPass.js +104 -101
  398. package/examples/jsm/postprocessing/OutlinePass.js +654 -654
  399. package/examples/jsm/postprocessing/OutputPass.js +95 -72
  400. package/examples/jsm/postprocessing/Pass.js +95 -84
  401. package/examples/jsm/postprocessing/RenderPass.js +99 -81
  402. package/examples/jsm/postprocessing/RenderPixelatedPass.js +235 -235
  403. package/examples/jsm/postprocessing/SAOPass.js +335 -411
  404. package/examples/jsm/postprocessing/SMAAPass.js +199 -201
  405. package/examples/jsm/postprocessing/SSAARenderPass.js +228 -228
  406. package/examples/jsm/postprocessing/SSAOPass.js +420 -440
  407. package/examples/jsm/postprocessing/SSRPass.js +641 -641
  408. package/examples/jsm/postprocessing/SavePass.js +79 -79
  409. package/examples/jsm/postprocessing/ShaderPass.js +77 -77
  410. package/examples/jsm/postprocessing/TAARenderPass.js +188 -189
  411. package/examples/jsm/postprocessing/TexturePass.js +67 -67
  412. package/examples/jsm/postprocessing/UnrealBloomPass.js +415 -411
  413. package/examples/jsm/renderers/CSS2DRenderer.js +215 -215
  414. package/examples/jsm/renderers/CSS3DRenderer.js +329 -335
  415. package/examples/jsm/renderers/Projector.js +918 -918
  416. package/examples/jsm/renderers/SVGRenderer.js +556 -553
  417. package/examples/jsm/renderers/common/Animation.js +47 -58
  418. package/examples/jsm/renderers/common/Attributes.js +75 -75
  419. package/examples/jsm/renderers/common/Backend.js +193 -162
  420. package/examples/jsm/renderers/common/Background.js +134 -134
  421. package/examples/jsm/renderers/common/Binding.js +25 -11
  422. package/examples/jsm/renderers/common/Bindings.js +173 -169
  423. package/examples/jsm/renderers/common/Buffer.js +38 -38
  424. package/examples/jsm/renderers/common/BufferUtils.js +33 -33
  425. package/examples/jsm/renderers/common/ChainMap.js +89 -89
  426. package/examples/jsm/renderers/common/Color4.js +37 -0
  427. package/examples/jsm/renderers/common/ComputePipeline.js +17 -17
  428. package/examples/jsm/renderers/common/Constants.js +14 -14
  429. package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -65
  430. package/examples/jsm/renderers/common/DataMap.js +54 -54
  431. package/examples/jsm/renderers/common/Geometries.js +215 -215
  432. package/examples/jsm/renderers/common/Info.js +107 -73
  433. package/examples/jsm/renderers/common/Pipeline.js +13 -13
  434. package/examples/jsm/renderers/common/Pipelines.js +322 -321
  435. package/examples/jsm/renderers/common/PostProcessing.js +25 -0
  436. package/examples/jsm/renderers/common/ProgrammableStage.js +20 -18
  437. package/examples/jsm/renderers/common/RenderContext.js +41 -37
  438. package/examples/jsm/renderers/common/RenderContexts.js +74 -38
  439. package/examples/jsm/renderers/common/RenderList.js +186 -178
  440. package/examples/jsm/renderers/common/RenderLists.js +38 -38
  441. package/examples/jsm/renderers/common/RenderObject.js +178 -113
  442. package/examples/jsm/renderers/common/RenderObjects.js +91 -92
  443. package/examples/jsm/renderers/common/RenderPipeline.js +16 -16
  444. package/examples/jsm/renderers/common/Renderer.js +1062 -864
  445. package/examples/jsm/renderers/common/SampledTexture.js +83 -80
  446. package/examples/jsm/renderers/common/Sampler.js +18 -18
  447. package/examples/jsm/renderers/common/StorageBuffer.js +17 -17
  448. package/examples/jsm/renderers/common/StorageBufferAttribute.js +21 -0
  449. package/examples/jsm/renderers/common/StorageTexture.js +20 -0
  450. package/examples/jsm/renderers/common/Textures.js +354 -206
  451. package/examples/jsm/renderers/common/Uniform.js +140 -140
  452. package/examples/jsm/renderers/common/UniformBuffer.js +15 -15
  453. package/examples/jsm/renderers/common/UniformsGroup.js +299 -299
  454. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +44 -0
  455. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +49 -39
  456. package/examples/jsm/renderers/common/nodes/NodeSampler.js +15 -21
  457. package/examples/jsm/renderers/common/nodes/NodeUniform.js +135 -135
  458. package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
  459. package/examples/jsm/renderers/common/nodes/Nodes.js +495 -319
  460. package/examples/jsm/renderers/webgl/WebGLBackend.js +1290 -0
  461. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +679 -340
  462. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +252 -0
  463. package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
  464. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
  465. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +36 -0
  466. package/examples/jsm/renderers/webgl/utils/WebGLState.js +738 -0
  467. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +647 -0
  468. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +284 -0
  469. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +320 -0
  470. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +26 -26
  471. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +794 -764
  472. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +51 -49
  473. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +1321 -847
  474. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +53 -32
  475. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +1098 -878
  476. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +104 -104
  477. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeParser.js +14 -14
  478. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +287 -255
  479. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +244 -145
  480. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +324 -322
  481. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +570 -580
  482. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  483. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +1040 -937
  484. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +93 -92
  485. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +89 -87
  486. package/examples/jsm/shaders/AfterimageShader.js +58 -56
  487. package/examples/jsm/shaders/BasicShader.js +29 -27
  488. package/examples/jsm/shaders/BleachBypassShader.js +62 -62
  489. package/examples/jsm/shaders/BlendShader.js +49 -47
  490. package/examples/jsm/shaders/BokehShader.js +145 -143
  491. package/examples/jsm/shaders/BokehShader2.js +397 -393
  492. package/examples/jsm/shaders/BrightnessContrastShader.js +56 -54
  493. package/examples/jsm/shaders/ColorCorrectionShader.js +52 -50
  494. package/examples/jsm/shaders/ColorifyShader.js +51 -51
  495. package/examples/jsm/shaders/ConvolutionShader.js +103 -103
  496. package/examples/jsm/shaders/CopyShader.js +45 -45
  497. package/examples/jsm/shaders/DOFMipMapShader.js +56 -54
  498. package/examples/jsm/shaders/DepthLimitedBlurShader.js +171 -166
  499. package/examples/jsm/shaders/DigitalGlitch.js +101 -101
  500. package/examples/jsm/shaders/DotScreenShader.js +70 -70
  501. package/examples/jsm/shaders/ExposureShader.js +44 -44
  502. package/examples/jsm/shaders/FXAAShader.js +288 -286
  503. package/examples/jsm/shaders/FilmShader.js +59 -102
  504. package/examples/jsm/shaders/FocusShader.js +89 -87
  505. package/examples/jsm/shaders/FreiChenShader.js +96 -94
  506. package/examples/jsm/shaders/GTAOShader.js +424 -0
  507. package/examples/jsm/shaders/GammaCorrectionShader.js +43 -43
  508. package/examples/jsm/shaders/GodRaysShader.js +321 -313
  509. package/examples/jsm/shaders/HalftoneShader.js +312 -310
  510. package/examples/jsm/shaders/HorizontalBlurShader.js +59 -59
  511. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +63 -61
  512. package/examples/jsm/shaders/HueSaturationShader.js +67 -65
  513. package/examples/jsm/shaders/KaleidoShader.js +58 -56
  514. package/examples/jsm/shaders/LuminosityHighPassShader.js +66 -64
  515. package/examples/jsm/shaders/LuminosityShader.js +48 -46
  516. package/examples/jsm/shaders/MMDToonShader.js +134 -132
  517. package/examples/jsm/shaders/MirrorShader.js +56 -54
  518. package/examples/jsm/shaders/NormalMapShader.js +55 -53
  519. package/examples/jsm/shaders/OutputShader.js +81 -61
  520. package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
  521. package/examples/jsm/shaders/RGBShiftShader.js +54 -54
  522. package/examples/jsm/shaders/SAOShader.js +179 -188
  523. package/examples/jsm/shaders/SMAAShader.js +466 -460
  524. package/examples/jsm/shaders/SSAOShader.js +300 -288
  525. package/examples/jsm/shaders/SSRShader.js +370 -364
  526. package/examples/jsm/shaders/SepiaShader.js +52 -52
  527. package/examples/jsm/shaders/SobelOperatorShader.js +92 -90
  528. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +90 -88
  529. package/examples/jsm/shaders/TechnicolorShader.js +45 -43
  530. package/examples/jsm/shaders/ToonShader.js +326 -326
  531. package/examples/jsm/shaders/TriangleBlurShader.js +74 -72
  532. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +47 -45
  533. package/examples/jsm/shaders/VelocityShader.js +130 -128
  534. package/examples/jsm/shaders/VerticalBlurShader.js +59 -59
  535. package/examples/jsm/shaders/VerticalTiltShiftShader.js +63 -61
  536. package/examples/jsm/shaders/VignetteShader.js +51 -51
  537. package/examples/jsm/shaders/VolumeShader.js +289 -289
  538. package/examples/jsm/shaders/WaterRefractionShader.js +95 -93
  539. package/examples/jsm/textures/FlakesTexture.js +40 -40
  540. package/examples/jsm/transpiler/AST.js +270 -0
  541. package/examples/jsm/transpiler/GLSLDecoder.js +941 -0
  542. package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
  543. package/examples/jsm/transpiler/TSLEncoder.js +715 -0
  544. package/examples/jsm/transpiler/Transpiler.js +18 -0
  545. package/examples/jsm/utils/BufferGeometryUtils.js +1371 -1364
  546. package/examples/jsm/utils/CameraUtils.js +73 -73
  547. package/examples/jsm/utils/GPUStatsPanel.js +128 -128
  548. package/examples/jsm/utils/GeometryCompressionUtils.js +639 -639
  549. package/examples/jsm/utils/GeometryUtils.js +221 -221
  550. package/examples/jsm/utils/LDrawUtils.js +202 -202
  551. package/examples/jsm/utils/PackedPhongMaterial.js +178 -178
  552. package/examples/jsm/utils/SceneUtils.js +254 -254
  553. package/examples/jsm/utils/ShadowMapViewer.js +210 -210
  554. package/examples/jsm/utils/SkeletonUtils.js +413 -413
  555. package/examples/jsm/utils/SortUtils.js +160 -0
  556. package/examples/jsm/utils/TextureUtils.js +98 -86
  557. package/examples/jsm/utils/UVsDebug.js +165 -165
  558. package/examples/jsm/utils/WorkerPool.js +102 -102
  559. package/examples/jsm/webxr/ARButton.js +232 -208
  560. package/examples/jsm/webxr/OculusHandModel.js +109 -109
  561. package/examples/jsm/webxr/OculusHandPointerModel.js +416 -415
  562. package/examples/jsm/webxr/Text2D.js +38 -38
  563. package/examples/jsm/webxr/VRButton.js +225 -200
  564. package/examples/jsm/webxr/XRButton.js +224 -198
  565. package/examples/jsm/webxr/XRControllerModelFactory.js +315 -310
  566. package/examples/jsm/webxr/XREstimatedLight.js +223 -223
  567. package/examples/jsm/webxr/XRHandMeshModel.js +116 -113
  568. package/examples/jsm/webxr/XRHandModelFactory.js +105 -105
  569. package/examples/jsm/webxr/XRHandPrimitiveModel.js +105 -104
  570. package/examples/jsm/webxr/XRPlanes.js +100 -100
  571. package/package.json +129 -126
  572. package/src/Three.Legacy.js +1 -1
  573. package/src/Three.js +184 -182
  574. package/src/animation/AnimationAction.js +700 -700
  575. package/src/animation/AnimationClip.js +473 -473
  576. package/src/animation/AnimationMixer.js +770 -770
  577. package/src/animation/AnimationObjectGroup.js +387 -387
  578. package/src/animation/AnimationUtils.js +356 -373
  579. package/src/animation/KeyframeTrack.js +462 -462
  580. package/src/animation/PropertyBinding.js +719 -719
  581. package/src/animation/PropertyMixer.js +318 -318
  582. package/src/animation/tracks/BooleanKeyframeTrack.js +19 -19
  583. package/src/animation/tracks/ColorKeyframeTrack.js +15 -15
  584. package/src/animation/tracks/NumberKeyframeTrack.js +12 -12
  585. package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -23
  586. package/src/animation/tracks/StringKeyframeTrack.js +15 -15
  587. package/src/animation/tracks/VectorKeyframeTrack.js +12 -12
  588. package/src/audio/Audio.js +400 -396
  589. package/src/audio/AudioAnalyser.js +40 -40
  590. package/src/audio/AudioContext.js +25 -25
  591. package/src/audio/AudioListener.js +140 -137
  592. package/src/audio/PositionalAudio.js +146 -146
  593. package/src/cameras/ArrayCamera.js +17 -17
  594. package/src/cameras/Camera.js +69 -73
  595. package/src/cameras/CubeCamera.js +173 -170
  596. package/src/cameras/OrthographicCamera.js +136 -136
  597. package/src/cameras/PerspectiveCamera.js +268 -233
  598. package/src/cameras/StereoCamera.js +100 -100
  599. package/src/constants.js +216 -201
  600. package/src/core/BufferAttribute.js +650 -610
  601. package/src/core/BufferGeometry.js +1079 -1079
  602. package/src/core/Clock.js +74 -74
  603. package/src/core/EventDispatcher.js +87 -87
  604. package/src/core/GLBufferAttribute.js +60 -60
  605. package/src/core/InstancedBufferAttribute.js +39 -39
  606. package/src/core/InstancedBufferGeometry.js +40 -40
  607. package/src/core/InstancedInterleavedBuffer.js +48 -48
  608. package/src/core/InterleavedBuffer.js +166 -145
  609. package/src/core/InterleavedBufferAttribute.js +351 -331
  610. package/src/core/Layers.js +60 -60
  611. package/src/core/Object3D.js +1008 -973
  612. package/src/core/Raycaster.js +110 -110
  613. package/src/core/RenderTarget.js +131 -0
  614. package/src/core/Uniform.js +17 -17
  615. package/src/core/UniformsGroup.js +98 -92
  616. package/src/extras/DataUtils.js +176 -176
  617. package/src/extras/Earcut.js +789 -789
  618. package/src/extras/ImageUtils.js +129 -129
  619. package/src/extras/PMREMGenerator.js +910 -903
  620. package/src/extras/ShapeUtils.js +92 -92
  621. package/src/extras/core/Curve.js +416 -416
  622. package/src/extras/core/CurvePath.js +255 -252
  623. package/src/extras/core/Interpolations.js +79 -79
  624. package/src/extras/core/Path.js +196 -196
  625. package/src/extras/core/Shape.js +102 -102
  626. package/src/extras/core/ShapePath.js +291 -291
  627. package/src/extras/curves/ArcCurve.js +17 -17
  628. package/src/extras/curves/CatmullRomCurve3.js +255 -255
  629. package/src/extras/curves/CubicBezierCurve.js +78 -78
  630. package/src/extras/curves/CubicBezierCurve3.js +79 -79
  631. package/src/extras/curves/Curves.js +10 -10
  632. package/src/extras/curves/EllipseCurve.js +156 -156
  633. package/src/extras/curves/LineCurve.js +92 -92
  634. package/src/extras/curves/LineCurve3.js +92 -88
  635. package/src/extras/curves/QuadraticBezierCurve.js +74 -74
  636. package/src/extras/curves/QuadraticBezierCurve3.js +75 -75
  637. package/src/extras/curves/SplineCurve.js +97 -97
  638. package/src/geometries/BoxGeometry.js +180 -180
  639. package/src/geometries/CapsuleGeometry.js +33 -33
  640. package/src/geometries/CircleGeometry.js +101 -101
  641. package/src/geometries/ConeGeometry.js +31 -31
  642. package/src/geometries/CylinderGeometry.js +286 -286
  643. package/src/geometries/DodecahedronGeometry.js +66 -66
  644. package/src/geometries/EdgesGeometry.js +152 -152
  645. package/src/geometries/ExtrudeGeometry.js +814 -814
  646. package/src/geometries/Geometries.js +21 -21
  647. package/src/geometries/IcosahedronGeometry.js +42 -42
  648. package/src/geometries/LatheGeometry.js +189 -189
  649. package/src/geometries/OctahedronGeometry.js +37 -37
  650. package/src/geometries/PlaneGeometry.js +98 -98
  651. package/src/geometries/PolyhedronGeometry.js +319 -319
  652. package/src/geometries/RingGeometry.js +128 -128
  653. package/src/geometries/ShapeGeometry.js +195 -195
  654. package/src/geometries/SphereGeometry.js +137 -137
  655. package/src/geometries/TetrahedronGeometry.js +34 -34
  656. package/src/geometries/TorusGeometry.js +120 -120
  657. package/src/geometries/TorusKnotGeometry.js +167 -167
  658. package/src/geometries/TubeGeometry.js +203 -203
  659. package/src/geometries/WireframeGeometry.js +147 -147
  660. package/src/helpers/ArrowHelper.js +114 -114
  661. package/src/helpers/AxesHelper.js +68 -68
  662. package/src/helpers/Box3Helper.js +55 -55
  663. package/src/helpers/BoxHelper.js +113 -113
  664. package/src/helpers/CameraHelper.js +269 -269
  665. package/src/helpers/DirectionalLightHelper.js +93 -93
  666. package/src/helpers/GridHelper.js +56 -56
  667. package/src/helpers/HemisphereLightHelper.js +88 -88
  668. package/src/helpers/PlaneHelper.js +63 -63
  669. package/src/helpers/PointLightHelper.js +92 -92
  670. package/src/helpers/PolarGridHelper.js +96 -96
  671. package/src/helpers/SkeletonHelper.js +128 -128
  672. package/src/helpers/SpotLightHelper.js +94 -94
  673. package/src/lights/AmbientLight.js +17 -17
  674. package/src/lights/DirectionalLight.js +43 -43
  675. package/src/lights/DirectionalLightShadow.js +16 -16
  676. package/src/lights/HemisphereLight.js +34 -34
  677. package/src/lights/Light.js +58 -58
  678. package/src/lights/LightProbe.js +47 -47
  679. package/src/lights/LightShadow.js +147 -147
  680. package/src/lights/PointLight.js +57 -57
  681. package/src/lights/PointLightShadow.js +96 -96
  682. package/src/lights/RectAreaLight.js +56 -56
  683. package/src/lights/SpotLight.js +71 -71
  684. package/src/lights/SpotLightShadow.js +50 -50
  685. package/src/loaders/AnimationLoader.js +66 -66
  686. package/src/loaders/AudioLoader.js +66 -66
  687. package/src/loaders/BufferGeometryLoader.js +217 -224
  688. package/src/loaders/Cache.js +42 -42
  689. package/src/loaders/CompressedTextureLoader.js +134 -134
  690. package/src/loaders/CubeTextureLoader.js +58 -58
  691. package/src/loaders/DataTextureLoader.js +135 -118
  692. package/src/loaders/FileLoader.js +284 -284
  693. package/src/loaders/ImageBitmapLoader.js +123 -99
  694. package/src/loaders/ImageLoader.js +91 -91
  695. package/src/loaders/Loader.js +72 -72
  696. package/src/loaders/LoaderUtils.js +75 -75
  697. package/src/loaders/LoadingManager.js +142 -142
  698. package/src/loaders/MaterialLoader.js +372 -364
  699. package/src/loaders/ObjectLoader.js +1148 -1093
  700. package/src/loaders/TextureLoader.js +41 -41
  701. package/src/materials/LineBasicMaterial.js +53 -49
  702. package/src/materials/LineDashedMaterial.js +35 -35
  703. package/src/materials/Material.js +522 -508
  704. package/src/materials/Materials.js +39 -39
  705. package/src/materials/MeshBasicMaterial.js +85 -81
  706. package/src/materials/MeshDepthMaterial.js +54 -54
  707. package/src/materials/MeshDistanceMaterial.js +43 -43
  708. package/src/materials/MeshLambertMaterial.js +120 -116
  709. package/src/materials/MeshMatcapMaterial.js +85 -81
  710. package/src/materials/MeshNormalMaterial.js +61 -61
  711. package/src/materials/MeshPhongMaterial.js +124 -120
  712. package/src/materials/MeshPhysicalMaterial.js +224 -224
  713. package/src/materials/MeshStandardMaterial.js +128 -124
  714. package/src/materials/MeshToonMaterial.js +106 -102
  715. package/src/materials/PointsMaterial.js +54 -50
  716. package/src/materials/RawShaderMaterial.js +17 -17
  717. package/src/materials/ShaderMaterial.js +190 -187
  718. package/src/materials/ShadowMaterial.js +37 -37
  719. package/src/materials/SpriteMaterial.js +54 -54
  720. package/src/math/Box2.js +204 -204
  721. package/src/math/Box3.js +534 -517
  722. package/src/math/Color.js +623 -627
  723. package/src/math/ColorManagement.js +139 -133
  724. package/src/math/Cylindrical.js +61 -61
  725. package/src/math/Euler.js +315 -315
  726. package/src/math/Frustum.js +186 -186
  727. package/src/math/Interpolant.js +241 -241
  728. package/src/math/Line3.js +115 -115
  729. package/src/math/MathUtils.js +363 -363
  730. package/src/math/Matrix3.js +388 -388
  731. package/src/math/Matrix4.js +915 -915
  732. package/src/math/Plane.js +205 -205
  733. package/src/math/Quaternion.js +685 -684
  734. package/src/math/Ray.js +493 -493
  735. package/src/math/Sphere.js +245 -243
  736. package/src/math/Spherical.js +86 -86
  737. package/src/math/SphericalHarmonics3.js +243 -243
  738. package/src/math/Triangle.js +311 -329
  739. package/src/math/Vector2.js +480 -480
  740. package/src/math/Vector3.js +724 -725
  741. package/src/math/Vector4.js +644 -644
  742. package/src/math/interpolants/CubicInterpolant.js +150 -150
  743. package/src/math/interpolants/DiscreteInterpolant.js +26 -26
  744. package/src/math/interpolants/LinearInterpolant.js +38 -38
  745. package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -39
  746. package/src/objects/BatchedMesh.js +1019 -0
  747. package/src/objects/Bone.js +17 -17
  748. package/src/objects/Group.js +17 -17
  749. package/src/objects/InstancedMesh.js +214 -214
  750. package/src/objects/LOD.js +214 -214
  751. package/src/objects/Line.js +222 -222
  752. package/src/objects/LineLoop.js +17 -17
  753. package/src/objects/LineSegments.js +55 -55
  754. package/src/objects/Mesh.js +429 -429
  755. package/src/objects/Points.js +166 -166
  756. package/src/objects/Skeleton.js +277 -279
  757. package/src/objects/SkinnedMesh.js +257 -266
  758. package/src/objects/Sprite.js +181 -181
  759. package/src/renderers/WebGL1Renderer.js +7 -7
  760. package/src/renderers/WebGL3DRenderTarget.js +22 -22
  761. package/src/renderers/WebGLArrayRenderTarget.js +22 -22
  762. package/src/renderers/WebGLCubeRenderTarget.js +155 -155
  763. package/src/renderers/WebGLMultipleRenderTargets.js +82 -84
  764. package/src/renderers/WebGLRenderTarget.js +15 -122
  765. package/src/renderers/WebGLRenderer.js +2631 -2439
  766. package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -7
  767. package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -68
  768. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -7
  769. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -7
  770. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -7
  771. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -5
  772. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -18
  773. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -8
  774. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
  775. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
  776. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -9
  777. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -9
  778. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -33
  779. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -42
  780. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -7
  781. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -10
  782. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -21
  783. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -33
  784. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -9
  785. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -7
  786. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -7
  787. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -11
  788. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -11
  789. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -11
  790. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -23
  791. package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -3
  792. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +44 -11
  793. package/src/renderers/shaders/ShaderChunk/common.glsl.js +147 -156
  794. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -191
  795. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -5
  796. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -5
  797. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -36
  798. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -9
  799. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -7
  800. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -7
  801. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -20
  802. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -9
  803. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -7
  804. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -14
  805. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +62 -62
  806. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -21
  807. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -22
  808. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -69
  809. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -37
  810. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -17
  811. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -19
  812. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -7
  813. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -7
  814. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -27
  815. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -121
  816. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -14
  817. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -10
  818. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -8
  819. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +202 -198
  820. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -13
  821. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +40 -40
  822. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -5
  823. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -28
  824. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +228 -223
  825. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -7
  826. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -32
  827. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +151 -146
  828. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +562 -560
  829. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -4
  830. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -26
  831. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -9
  832. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -9
  833. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -16
  834. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -22
  835. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +21 -13
  836. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +11 -11
  837. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -27
  838. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -27
  839. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -12
  840. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -7
  841. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -24
  842. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -27
  843. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -38
  844. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -36
  845. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -76
  846. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +33 -33
  847. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -14
  848. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -14
  849. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -14
  850. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -43
  851. package/src/renderers/shaders/ShaderChunk/occlusion_fragment.glsl.js +20 -0
  852. package/src/renderers/shaders/ShaderChunk/occlusion_pars_fragment.glsl.js +97 -0
  853. package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -11
  854. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +68 -68
  855. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -8
  856. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -13
  857. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -12
  858. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -7
  859. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +314 -314
  860. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -68
  861. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +68 -68
  862. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -66
  863. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -10
  864. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -33
  865. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -15
  866. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -20
  867. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -14
  868. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -7
  869. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -7
  870. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +169 -77
  871. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -36
  872. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +201 -201
  873. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -119
  874. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -145
  875. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -122
  876. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -15
  877. package/src/renderers/shaders/ShaderChunk.js +274 -266
  878. package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -32
  879. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -62
  880. package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -36
  881. package/src/renderers/shaders/ShaderLib/depth.glsl.js +95 -94
  882. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +76 -75
  883. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -35
  884. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +77 -75
  885. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +117 -114
  886. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +126 -122
  887. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +113 -109
  888. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +89 -82
  889. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +128 -124
  890. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +226 -222
  891. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +120 -116
  892. package/src/renderers/shaders/ShaderLib/points.glsl.js +88 -86
  893. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +57 -54
  894. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +81 -81
  895. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -53
  896. package/src/renderers/shaders/ShaderLib.js +367 -359
  897. package/src/renderers/shaders/UniformsLib.js +236 -230
  898. package/src/renderers/shaders/UniformsUtils.js +104 -104
  899. package/src/renderers/webgl/WebGLAnimation.js +53 -53
  900. package/src/renderers/webgl/WebGLAttributes.js +229 -195
  901. package/src/renderers/webgl/WebGLBackground.js +239 -247
  902. package/src/renderers/webgl/WebGLBindingStates.js +631 -631
  903. package/src/renderers/webgl/WebGLBufferRenderer.js +92 -61
  904. package/src/renderers/webgl/WebGLCapabilities.js +120 -120
  905. package/src/renderers/webgl/WebGLClipping.js +171 -171
  906. package/src/renderers/webgl/WebGLCubeMaps.js +99 -99
  907. package/src/renderers/webgl/WebGLCubeUVMaps.js +132 -130
  908. package/src/renderers/webgl/WebGLExtensions.js +97 -96
  909. package/src/renderers/webgl/WebGLGeometries.js +211 -207
  910. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +102 -71
  911. package/src/renderers/webgl/WebGLInfo.js +71 -71
  912. package/src/renderers/webgl/WebGLLights.js +590 -570
  913. package/src/renderers/webgl/WebGLMaterials.js +576 -567
  914. package/src/renderers/webgl/WebGLMorphtargets.js +300 -300
  915. package/src/renderers/webgl/WebGLObjects.js +92 -92
  916. package/src/renderers/webgl/WebGLProgram.js +1112 -1002
  917. package/src/renderers/webgl/WebGLPrograms.js +663 -625
  918. package/src/renderers/webgl/WebGLProperties.js +48 -48
  919. package/src/renderers/webgl/WebGLRenderLists.js +238 -238
  920. package/src/renderers/webgl/WebGLRenderStates.js +107 -107
  921. package/src/renderers/webgl/WebGLShader.js +12 -12
  922. package/src/renderers/webgl/WebGLShaderCache.js +124 -124
  923. package/src/renderers/webgl/WebGLShadowMap.js +424 -389
  924. package/src/renderers/webgl/WebGLState.js +1328 -1307
  925. package/src/renderers/webgl/WebGLTextures.js +2117 -2017
  926. package/src/renderers/webgl/WebGLUniforms.js +1156 -1146
  927. package/src/renderers/webgl/WebGLUniformsGroups.js +392 -413
  928. package/src/renderers/webgl/WebGLUtils.js +283 -278
  929. package/src/renderers/webxr/WebXRController.js +343 -343
  930. package/src/renderers/webxr/WebXRManager.js +840 -770
  931. package/src/scenes/Fog.js +38 -37
  932. package/src/scenes/FogExp2.js +35 -34
  933. package/src/scenes/Scene.js +63 -63
  934. package/src/textures/CanvasTexture.js +17 -17
  935. package/src/textures/CompressedArrayTexture.js +18 -18
  936. package/src/textures/CompressedCubeTexture.js +19 -0
  937. package/src/textures/CompressedTexture.js +28 -28
  938. package/src/textures/CubeTexture.js +33 -33
  939. package/src/textures/Data3DTexture.js +35 -35
  940. package/src/textures/DataArrayTexture.js +27 -27
  941. package/src/textures/DataTexture.js +22 -22
  942. package/src/textures/DepthTexture.js +58 -58
  943. package/src/textures/FramebufferTexture.js +23 -23
  944. package/src/textures/Source.js +127 -127
  945. package/src/textures/Texture.js +338 -338
  946. package/src/textures/VideoTexture.js +55 -55
  947. package/src/utils.js +91 -83
  948. package/build/three.js +0 -51661
  949. package/build/three.min.js +0 -7
  950. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -64
  951. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
  952. package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
  953. package/examples/jsm/renderers/common/RenderTarget.js +0 -15
  954. package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
  955. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  956. package/src/lights/AmbientLightProbe.js +0 -21
  957. package/src/lights/HemisphereLightProbe.js +0 -30
@@ -1,1146 +1,1156 @@
1
- /**
2
- * Uniforms of a program.
3
- * Those form a tree structure with a special top-level container for the root,
4
- * which you get by calling 'new WebGLUniforms( gl, program )'.
5
- *
6
- *
7
- * Properties of inner nodes including the top-level container:
8
- *
9
- * .seq - array of nested uniforms
10
- * .map - nested uniforms by name
11
- *
12
- *
13
- * Methods of all nodes except the top-level container:
14
- *
15
- * .setValue( gl, value, [textures] )
16
- *
17
- * uploads a uniform value(s)
18
- * the 'textures' parameter is needed for sampler uniforms
19
- *
20
- *
21
- * Static methods of the top-level container (textures factorizations):
22
- *
23
- * .upload( gl, seq, values, textures )
24
- *
25
- * sets uniforms in 'seq' to 'values[id].value'
26
- *
27
- * .seqWithValue( seq, values ) : filteredSeq
28
- *
29
- * filters 'seq' entries with corresponding entry in values
30
- *
31
- *
32
- * Methods of the top-level container (textures factorizations):
33
- *
34
- * .setValue( gl, name, value, textures )
35
- *
36
- * sets uniform with name 'name' to 'value'
37
- *
38
- * .setOptional( gl, obj, prop )
39
- *
40
- * like .set for an optional property of the object
41
- *
42
- */
43
-
44
- import { CubeTexture } from '../../textures/CubeTexture.js';
45
- import { Texture } from '../../textures/Texture.js';
46
- import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
47
- import { Data3DTexture } from '../../textures/Data3DTexture.js';
48
-
49
- const emptyTexture = /*@__PURE__*/ new Texture();
50
- const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
51
- const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
52
- const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
53
-
54
- // --- Utilities ---
55
-
56
- // Array Caches (provide typed arrays for temporary by size)
57
-
58
- const arrayCacheF32 = [];
59
- const arrayCacheI32 = [];
60
-
61
- // Float32Array caches used for uploading Matrix uniforms
62
-
63
- const mat4array = new Float32Array( 16 );
64
- const mat3array = new Float32Array( 9 );
65
- const mat2array = new Float32Array( 4 );
66
-
67
- // Flattening for arrays of vectors and matrices
68
-
69
- function flatten( array, nBlocks, blockSize ) {
70
-
71
- const firstElem = array[ 0 ];
72
-
73
- if ( firstElem <= 0 || firstElem > 0 ) return array;
74
- // unoptimized: ! isNaN( firstElem )
75
- // see http://jacksondunstan.com/articles/983
76
-
77
- const n = nBlocks * blockSize;
78
- let r = arrayCacheF32[ n ];
79
-
80
- if ( r === undefined ) {
81
-
82
- r = new Float32Array( n );
83
- arrayCacheF32[ n ] = r;
84
-
85
- }
86
-
87
- if ( nBlocks !== 0 ) {
88
-
89
- firstElem.toArray( r, 0 );
90
-
91
- for ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {
92
-
93
- offset += blockSize;
94
- array[ i ].toArray( r, offset );
95
-
96
- }
97
-
98
- }
99
-
100
- return r;
101
-
102
- }
103
-
104
- function arraysEqual( a, b ) {
105
-
106
- if ( a.length !== b.length ) return false;
107
-
108
- for ( let i = 0, l = a.length; i < l; i ++ ) {
109
-
110
- if ( a[ i ] !== b[ i ] ) return false;
111
-
112
- }
113
-
114
- return true;
115
-
116
- }
117
-
118
- function copyArray( a, b ) {
119
-
120
- for ( let i = 0, l = b.length; i < l; i ++ ) {
121
-
122
- a[ i ] = b[ i ];
123
-
124
- }
125
-
126
- }
127
-
128
- // Texture unit allocation
129
-
130
- function allocTexUnits( textures, n ) {
131
-
132
- let r = arrayCacheI32[ n ];
133
-
134
- if ( r === undefined ) {
135
-
136
- r = new Int32Array( n );
137
- arrayCacheI32[ n ] = r;
138
-
139
- }
140
-
141
- for ( let i = 0; i !== n; ++ i ) {
142
-
143
- r[ i ] = textures.allocateTextureUnit();
144
-
145
- }
146
-
147
- return r;
148
-
149
- }
150
-
151
- // --- Setters ---
152
-
153
- // Note: Defining these methods externally, because they come in a bunch
154
- // and this way their names minify.
155
-
156
- // Single scalar
157
-
158
- function setValueV1f( gl, v ) {
159
-
160
- const cache = this.cache;
161
-
162
- if ( cache[ 0 ] === v ) return;
163
-
164
- gl.uniform1f( this.addr, v );
165
-
166
- cache[ 0 ] = v;
167
-
168
- }
169
-
170
- // Single float vector (from flat array or THREE.VectorN)
171
-
172
- function setValueV2f( gl, v ) {
173
-
174
- const cache = this.cache;
175
-
176
- if ( v.x !== undefined ) {
177
-
178
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
179
-
180
- gl.uniform2f( this.addr, v.x, v.y );
181
-
182
- cache[ 0 ] = v.x;
183
- cache[ 1 ] = v.y;
184
-
185
- }
186
-
187
- } else {
188
-
189
- if ( arraysEqual( cache, v ) ) return;
190
-
191
- gl.uniform2fv( this.addr, v );
192
-
193
- copyArray( cache, v );
194
-
195
- }
196
-
197
- }
198
-
199
- function setValueV3f( gl, v ) {
200
-
201
- const cache = this.cache;
202
-
203
- if ( v.x !== undefined ) {
204
-
205
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
206
-
207
- gl.uniform3f( this.addr, v.x, v.y, v.z );
208
-
209
- cache[ 0 ] = v.x;
210
- cache[ 1 ] = v.y;
211
- cache[ 2 ] = v.z;
212
-
213
- }
214
-
215
- } else if ( v.r !== undefined ) {
216
-
217
- if ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {
218
-
219
- gl.uniform3f( this.addr, v.r, v.g, v.b );
220
-
221
- cache[ 0 ] = v.r;
222
- cache[ 1 ] = v.g;
223
- cache[ 2 ] = v.b;
224
-
225
- }
226
-
227
- } else {
228
-
229
- if ( arraysEqual( cache, v ) ) return;
230
-
231
- gl.uniform3fv( this.addr, v );
232
-
233
- copyArray( cache, v );
234
-
235
- }
236
-
237
- }
238
-
239
- function setValueV4f( gl, v ) {
240
-
241
- const cache = this.cache;
242
-
243
- if ( v.x !== undefined ) {
244
-
245
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
246
-
247
- gl.uniform4f( this.addr, v.x, v.y, v.z, v.w );
248
-
249
- cache[ 0 ] = v.x;
250
- cache[ 1 ] = v.y;
251
- cache[ 2 ] = v.z;
252
- cache[ 3 ] = v.w;
253
-
254
- }
255
-
256
- } else {
257
-
258
- if ( arraysEqual( cache, v ) ) return;
259
-
260
- gl.uniform4fv( this.addr, v );
261
-
262
- copyArray( cache, v );
263
-
264
- }
265
-
266
- }
267
-
268
- // Single matrix (from flat array or THREE.MatrixN)
269
-
270
- function setValueM2( gl, v ) {
271
-
272
- const cache = this.cache;
273
- const elements = v.elements;
274
-
275
- if ( elements === undefined ) {
276
-
277
- if ( arraysEqual( cache, v ) ) return;
278
-
279
- gl.uniformMatrix2fv( this.addr, false, v );
280
-
281
- copyArray( cache, v );
282
-
283
- } else {
284
-
285
- if ( arraysEqual( cache, elements ) ) return;
286
-
287
- mat2array.set( elements );
288
-
289
- gl.uniformMatrix2fv( this.addr, false, mat2array );
290
-
291
- copyArray( cache, elements );
292
-
293
- }
294
-
295
- }
296
-
297
- function setValueM3( gl, v ) {
298
-
299
- const cache = this.cache;
300
- const elements = v.elements;
301
-
302
- if ( elements === undefined ) {
303
-
304
- if ( arraysEqual( cache, v ) ) return;
305
-
306
- gl.uniformMatrix3fv( this.addr, false, v );
307
-
308
- copyArray( cache, v );
309
-
310
- } else {
311
-
312
- if ( arraysEqual( cache, elements ) ) return;
313
-
314
- mat3array.set( elements );
315
-
316
- gl.uniformMatrix3fv( this.addr, false, mat3array );
317
-
318
- copyArray( cache, elements );
319
-
320
- }
321
-
322
- }
323
-
324
- function setValueM4( gl, v ) {
325
-
326
- const cache = this.cache;
327
- const elements = v.elements;
328
-
329
- if ( elements === undefined ) {
330
-
331
- if ( arraysEqual( cache, v ) ) return;
332
-
333
- gl.uniformMatrix4fv( this.addr, false, v );
334
-
335
- copyArray( cache, v );
336
-
337
- } else {
338
-
339
- if ( arraysEqual( cache, elements ) ) return;
340
-
341
- mat4array.set( elements );
342
-
343
- gl.uniformMatrix4fv( this.addr, false, mat4array );
344
-
345
- copyArray( cache, elements );
346
-
347
- }
348
-
349
- }
350
-
351
- // Single integer / boolean
352
-
353
- function setValueV1i( gl, v ) {
354
-
355
- const cache = this.cache;
356
-
357
- if ( cache[ 0 ] === v ) return;
358
-
359
- gl.uniform1i( this.addr, v );
360
-
361
- cache[ 0 ] = v;
362
-
363
- }
364
-
365
- // Single integer / boolean vector (from flat array or THREE.VectorN)
366
-
367
- function setValueV2i( gl, v ) {
368
-
369
- const cache = this.cache;
370
-
371
- if ( v.x !== undefined ) {
372
-
373
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
374
-
375
- gl.uniform2i( this.addr, v.x, v.y );
376
-
377
- cache[ 0 ] = v.x;
378
- cache[ 1 ] = v.y;
379
-
380
- }
381
-
382
- } else {
383
-
384
- if ( arraysEqual( cache, v ) ) return;
385
-
386
- gl.uniform2iv( this.addr, v );
387
-
388
- copyArray( cache, v );
389
-
390
- }
391
-
392
- }
393
-
394
- function setValueV3i( gl, v ) {
395
-
396
- const cache = this.cache;
397
-
398
- if ( v.x !== undefined ) {
399
-
400
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
401
-
402
- gl.uniform3i( this.addr, v.x, v.y, v.z );
403
-
404
- cache[ 0 ] = v.x;
405
- cache[ 1 ] = v.y;
406
- cache[ 2 ] = v.z;
407
-
408
- }
409
-
410
- } else {
411
-
412
- if ( arraysEqual( cache, v ) ) return;
413
-
414
- gl.uniform3iv( this.addr, v );
415
-
416
- copyArray( cache, v );
417
-
418
- }
419
-
420
- }
421
-
422
- function setValueV4i( gl, v ) {
423
-
424
- const cache = this.cache;
425
-
426
- if ( v.x !== undefined ) {
427
-
428
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
429
-
430
- gl.uniform4i( this.addr, v.x, v.y, v.z, v.w );
431
-
432
- cache[ 0 ] = v.x;
433
- cache[ 1 ] = v.y;
434
- cache[ 2 ] = v.z;
435
- cache[ 3 ] = v.w;
436
-
437
- }
438
-
439
- } else {
440
-
441
- if ( arraysEqual( cache, v ) ) return;
442
-
443
- gl.uniform4iv( this.addr, v );
444
-
445
- copyArray( cache, v );
446
-
447
- }
448
-
449
- }
450
-
451
- // Single unsigned integer
452
-
453
- function setValueV1ui( gl, v ) {
454
-
455
- const cache = this.cache;
456
-
457
- if ( cache[ 0 ] === v ) return;
458
-
459
- gl.uniform1ui( this.addr, v );
460
-
461
- cache[ 0 ] = v;
462
-
463
- }
464
-
465
- // Single unsigned integer vector (from flat array or THREE.VectorN)
466
-
467
- function setValueV2ui( gl, v ) {
468
-
469
- const cache = this.cache;
470
-
471
- if ( v.x !== undefined ) {
472
-
473
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
474
-
475
- gl.uniform2ui( this.addr, v.x, v.y );
476
-
477
- cache[ 0 ] = v.x;
478
- cache[ 1 ] = v.y;
479
-
480
- }
481
-
482
- } else {
483
-
484
- if ( arraysEqual( cache, v ) ) return;
485
-
486
- gl.uniform2uiv( this.addr, v );
487
-
488
- copyArray( cache, v );
489
-
490
- }
491
-
492
- }
493
-
494
- function setValueV3ui( gl, v ) {
495
-
496
- const cache = this.cache;
497
-
498
- if ( v.x !== undefined ) {
499
-
500
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
501
-
502
- gl.uniform3ui( this.addr, v.x, v.y, v.z );
503
-
504
- cache[ 0 ] = v.x;
505
- cache[ 1 ] = v.y;
506
- cache[ 2 ] = v.z;
507
-
508
- }
509
-
510
- } else {
511
-
512
- if ( arraysEqual( cache, v ) ) return;
513
-
514
- gl.uniform3uiv( this.addr, v );
515
-
516
- copyArray( cache, v );
517
-
518
- }
519
-
520
- }
521
-
522
- function setValueV4ui( gl, v ) {
523
-
524
- const cache = this.cache;
525
-
526
- if ( v.x !== undefined ) {
527
-
528
- if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
529
-
530
- gl.uniform4ui( this.addr, v.x, v.y, v.z, v.w );
531
-
532
- cache[ 0 ] = v.x;
533
- cache[ 1 ] = v.y;
534
- cache[ 2 ] = v.z;
535
- cache[ 3 ] = v.w;
536
-
537
- }
538
-
539
- } else {
540
-
541
- if ( arraysEqual( cache, v ) ) return;
542
-
543
- gl.uniform4uiv( this.addr, v );
544
-
545
- copyArray( cache, v );
546
-
547
- }
548
-
549
- }
550
-
551
-
552
- // Single texture (2D / Cube)
553
-
554
- function setValueT1( gl, v, textures ) {
555
-
556
- const cache = this.cache;
557
- const unit = textures.allocateTextureUnit();
558
-
559
- if ( cache[ 0 ] !== unit ) {
560
-
561
- gl.uniform1i( this.addr, unit );
562
- cache[ 0 ] = unit;
563
-
564
- }
565
-
566
- textures.setTexture2D( v || emptyTexture, unit );
567
-
568
- }
569
-
570
- function setValueT3D1( gl, v, textures ) {
571
-
572
- const cache = this.cache;
573
- const unit = textures.allocateTextureUnit();
574
-
575
- if ( cache[ 0 ] !== unit ) {
576
-
577
- gl.uniform1i( this.addr, unit );
578
- cache[ 0 ] = unit;
579
-
580
- }
581
-
582
- textures.setTexture3D( v || empty3dTexture, unit );
583
-
584
- }
585
-
586
- function setValueT6( gl, v, textures ) {
587
-
588
- const cache = this.cache;
589
- const unit = textures.allocateTextureUnit();
590
-
591
- if ( cache[ 0 ] !== unit ) {
592
-
593
- gl.uniform1i( this.addr, unit );
594
- cache[ 0 ] = unit;
595
-
596
- }
597
-
598
- textures.setTextureCube( v || emptyCubeTexture, unit );
599
-
600
- }
601
-
602
- function setValueT2DArray1( gl, v, textures ) {
603
-
604
- const cache = this.cache;
605
- const unit = textures.allocateTextureUnit();
606
-
607
- if ( cache[ 0 ] !== unit ) {
608
-
609
- gl.uniform1i( this.addr, unit );
610
- cache[ 0 ] = unit;
611
-
612
- }
613
-
614
- textures.setTexture2DArray( v || emptyArrayTexture, unit );
615
-
616
- }
617
-
618
- // Helper to pick the right setter for the singular case
619
-
620
- function getSingularSetter( type ) {
621
-
622
- switch ( type ) {
623
-
624
- case 0x1406: return setValueV1f; // FLOAT
625
- case 0x8b50: return setValueV2f; // _VEC2
626
- case 0x8b51: return setValueV3f; // _VEC3
627
- case 0x8b52: return setValueV4f; // _VEC4
628
-
629
- case 0x8b5a: return setValueM2; // _MAT2
630
- case 0x8b5b: return setValueM3; // _MAT3
631
- case 0x8b5c: return setValueM4; // _MAT4
632
-
633
- case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL
634
- case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2
635
- case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3
636
- case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4
637
-
638
- case 0x1405: return setValueV1ui; // UINT
639
- case 0x8dc6: return setValueV2ui; // _VEC2
640
- case 0x8dc7: return setValueV3ui; // _VEC3
641
- case 0x8dc8: return setValueV4ui; // _VEC4
642
-
643
- case 0x8b5e: // SAMPLER_2D
644
- case 0x8d66: // SAMPLER_EXTERNAL_OES
645
- case 0x8dca: // INT_SAMPLER_2D
646
- case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
647
- case 0x8b62: // SAMPLER_2D_SHADOW
648
- return setValueT1;
649
-
650
- case 0x8b5f: // SAMPLER_3D
651
- case 0x8dcb: // INT_SAMPLER_3D
652
- case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
653
- return setValueT3D1;
654
-
655
- case 0x8b60: // SAMPLER_CUBE
656
- case 0x8dcc: // INT_SAMPLER_CUBE
657
- case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
658
- case 0x8dc5: // SAMPLER_CUBE_SHADOW
659
- return setValueT6;
660
-
661
- case 0x8dc1: // SAMPLER_2D_ARRAY
662
- case 0x8dcf: // INT_SAMPLER_2D_ARRAY
663
- case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
664
- case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
665
- return setValueT2DArray1;
666
-
667
- }
668
-
669
- }
670
-
671
-
672
- // Array of scalars
673
-
674
- function setValueV1fArray( gl, v ) {
675
-
676
- gl.uniform1fv( this.addr, v );
677
-
678
- }
679
-
680
- // Array of vectors (from flat array or array of THREE.VectorN)
681
-
682
- function setValueV2fArray( gl, v ) {
683
-
684
- const data = flatten( v, this.size, 2 );
685
-
686
- gl.uniform2fv( this.addr, data );
687
-
688
- }
689
-
690
- function setValueV3fArray( gl, v ) {
691
-
692
- const data = flatten( v, this.size, 3 );
693
-
694
- gl.uniform3fv( this.addr, data );
695
-
696
- }
697
-
698
- function setValueV4fArray( gl, v ) {
699
-
700
- const data = flatten( v, this.size, 4 );
701
-
702
- gl.uniform4fv( this.addr, data );
703
-
704
- }
705
-
706
- // Array of matrices (from flat array or array of THREE.MatrixN)
707
-
708
- function setValueM2Array( gl, v ) {
709
-
710
- const data = flatten( v, this.size, 4 );
711
-
712
- gl.uniformMatrix2fv( this.addr, false, data );
713
-
714
- }
715
-
716
- function setValueM3Array( gl, v ) {
717
-
718
- const data = flatten( v, this.size, 9 );
719
-
720
- gl.uniformMatrix3fv( this.addr, false, data );
721
-
722
- }
723
-
724
- function setValueM4Array( gl, v ) {
725
-
726
- const data = flatten( v, this.size, 16 );
727
-
728
- gl.uniformMatrix4fv( this.addr, false, data );
729
-
730
- }
731
-
732
- // Array of integer / boolean
733
-
734
- function setValueV1iArray( gl, v ) {
735
-
736
- gl.uniform1iv( this.addr, v );
737
-
738
- }
739
-
740
- // Array of integer / boolean vectors (from flat array)
741
-
742
- function setValueV2iArray( gl, v ) {
743
-
744
- gl.uniform2iv( this.addr, v );
745
-
746
- }
747
-
748
- function setValueV3iArray( gl, v ) {
749
-
750
- gl.uniform3iv( this.addr, v );
751
-
752
- }
753
-
754
- function setValueV4iArray( gl, v ) {
755
-
756
- gl.uniform4iv( this.addr, v );
757
-
758
- }
759
-
760
- // Array of unsigned integer
761
-
762
- function setValueV1uiArray( gl, v ) {
763
-
764
- gl.uniform1uiv( this.addr, v );
765
-
766
- }
767
-
768
- // Array of unsigned integer vectors (from flat array)
769
-
770
- function setValueV2uiArray( gl, v ) {
771
-
772
- gl.uniform2uiv( this.addr, v );
773
-
774
- }
775
-
776
- function setValueV3uiArray( gl, v ) {
777
-
778
- gl.uniform3uiv( this.addr, v );
779
-
780
- }
781
-
782
- function setValueV4uiArray( gl, v ) {
783
-
784
- gl.uniform4uiv( this.addr, v );
785
-
786
- }
787
-
788
-
789
- // Array of textures (2D / 3D / Cube / 2DArray)
790
-
791
- function setValueT1Array( gl, v, textures ) {
792
-
793
- const cache = this.cache;
794
-
795
- const n = v.length;
796
-
797
- const units = allocTexUnits( textures, n );
798
-
799
- if ( ! arraysEqual( cache, units ) ) {
800
-
801
- gl.uniform1iv( this.addr, units );
802
-
803
- copyArray( cache, units );
804
-
805
- }
806
-
807
- for ( let i = 0; i !== n; ++ i ) {
808
-
809
- textures.setTexture2D( v[ i ] || emptyTexture, units[ i ] );
810
-
811
- }
812
-
813
- }
814
-
815
- function setValueT3DArray( gl, v, textures ) {
816
-
817
- const cache = this.cache;
818
-
819
- const n = v.length;
820
-
821
- const units = allocTexUnits( textures, n );
822
-
823
- if ( ! arraysEqual( cache, units ) ) {
824
-
825
- gl.uniform1iv( this.addr, units );
826
-
827
- copyArray( cache, units );
828
-
829
- }
830
-
831
- for ( let i = 0; i !== n; ++ i ) {
832
-
833
- textures.setTexture3D( v[ i ] || empty3dTexture, units[ i ] );
834
-
835
- }
836
-
837
- }
838
-
839
- function setValueT6Array( gl, v, textures ) {
840
-
841
- const cache = this.cache;
842
-
843
- const n = v.length;
844
-
845
- const units = allocTexUnits( textures, n );
846
-
847
- if ( ! arraysEqual( cache, units ) ) {
848
-
849
- gl.uniform1iv( this.addr, units );
850
-
851
- copyArray( cache, units );
852
-
853
- }
854
-
855
- for ( let i = 0; i !== n; ++ i ) {
856
-
857
- textures.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );
858
-
859
- }
860
-
861
- }
862
-
863
- function setValueT2DArrayArray( gl, v, textures ) {
864
-
865
- const cache = this.cache;
866
-
867
- const n = v.length;
868
-
869
- const units = allocTexUnits( textures, n );
870
-
871
- if ( ! arraysEqual( cache, units ) ) {
872
-
873
- gl.uniform1iv( this.addr, units );
874
-
875
- copyArray( cache, units );
876
-
877
- }
878
-
879
- for ( let i = 0; i !== n; ++ i ) {
880
-
881
- textures.setTexture2DArray( v[ i ] || emptyArrayTexture, units[ i ] );
882
-
883
- }
884
-
885
- }
886
-
887
-
888
- // Helper to pick the right setter for a pure (bottom-level) array
889
-
890
- function getPureArraySetter( type ) {
891
-
892
- switch ( type ) {
893
-
894
- case 0x1406: return setValueV1fArray; // FLOAT
895
- case 0x8b50: return setValueV2fArray; // _VEC2
896
- case 0x8b51: return setValueV3fArray; // _VEC3
897
- case 0x8b52: return setValueV4fArray; // _VEC4
898
-
899
- case 0x8b5a: return setValueM2Array; // _MAT2
900
- case 0x8b5b: return setValueM3Array; // _MAT3
901
- case 0x8b5c: return setValueM4Array; // _MAT4
902
-
903
- case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL
904
- case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2
905
- case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3
906
- case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4
907
-
908
- case 0x1405: return setValueV1uiArray; // UINT
909
- case 0x8dc6: return setValueV2uiArray; // _VEC2
910
- case 0x8dc7: return setValueV3uiArray; // _VEC3
911
- case 0x8dc8: return setValueV4uiArray; // _VEC4
912
-
913
- case 0x8b5e: // SAMPLER_2D
914
- case 0x8d66: // SAMPLER_EXTERNAL_OES
915
- case 0x8dca: // INT_SAMPLER_2D
916
- case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
917
- case 0x8b62: // SAMPLER_2D_SHADOW
918
- return setValueT1Array;
919
-
920
- case 0x8b5f: // SAMPLER_3D
921
- case 0x8dcb: // INT_SAMPLER_3D
922
- case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
923
- return setValueT3DArray;
924
-
925
- case 0x8b60: // SAMPLER_CUBE
926
- case 0x8dcc: // INT_SAMPLER_CUBE
927
- case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
928
- case 0x8dc5: // SAMPLER_CUBE_SHADOW
929
- return setValueT6Array;
930
-
931
- case 0x8dc1: // SAMPLER_2D_ARRAY
932
- case 0x8dcf: // INT_SAMPLER_2D_ARRAY
933
- case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
934
- case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
935
- return setValueT2DArrayArray;
936
-
937
- }
938
-
939
- }
940
-
941
- // --- Uniform Classes ---
942
-
943
- class SingleUniform {
944
-
945
- constructor( id, activeInfo, addr ) {
946
-
947
- this.id = id;
948
- this.addr = addr;
949
- this.cache = [];
950
- this.setValue = getSingularSetter( activeInfo.type );
951
-
952
- // this.path = activeInfo.name; // DEBUG
953
-
954
- }
955
-
956
- }
957
-
958
- class PureArrayUniform {
959
-
960
- constructor( id, activeInfo, addr ) {
961
-
962
- this.id = id;
963
- this.addr = addr;
964
- this.cache = [];
965
- this.size = activeInfo.size;
966
- this.setValue = getPureArraySetter( activeInfo.type );
967
-
968
- // this.path = activeInfo.name; // DEBUG
969
-
970
- }
971
-
972
- }
973
-
974
- class StructuredUniform {
975
-
976
- constructor( id ) {
977
-
978
- this.id = id;
979
-
980
- this.seq = [];
981
- this.map = {};
982
-
983
- }
984
-
985
- setValue( gl, value, textures ) {
986
-
987
- const seq = this.seq;
988
-
989
- for ( let i = 0, n = seq.length; i !== n; ++ i ) {
990
-
991
- const u = seq[ i ];
992
- u.setValue( gl, value[ u.id ], textures );
993
-
994
- }
995
-
996
- }
997
-
998
- }
999
-
1000
- // --- Top-level ---
1001
-
1002
- // Parser - builds up the property tree from the path strings
1003
-
1004
- const RePathPart = /(\w+)(\])?(\[|\.)?/g;
1005
-
1006
- // extracts
1007
- // - the identifier (member name or array index)
1008
- // - followed by an optional right bracket (found when array index)
1009
- // - followed by an optional left bracket or dot (type of subscript)
1010
- //
1011
- // Note: These portions can be read in a non-overlapping fashion and
1012
- // allow straightforward parsing of the hierarchy that WebGL encodes
1013
- // in the uniform names.
1014
-
1015
- function addUniform( container, uniformObject ) {
1016
-
1017
- container.seq.push( uniformObject );
1018
- container.map[ uniformObject.id ] = uniformObject;
1019
-
1020
- }
1021
-
1022
- function parseUniform( activeInfo, addr, container ) {
1023
-
1024
- const path = activeInfo.name,
1025
- pathLength = path.length;
1026
-
1027
- // reset RegExp object, because of the early exit of a previous run
1028
- RePathPart.lastIndex = 0;
1029
-
1030
- while ( true ) {
1031
-
1032
- const match = RePathPart.exec( path ),
1033
- matchEnd = RePathPart.lastIndex;
1034
-
1035
- let id = match[ 1 ];
1036
- const idIsIndex = match[ 2 ] === ']',
1037
- subscript = match[ 3 ];
1038
-
1039
- if ( idIsIndex ) id = id | 0; // convert to integer
1040
-
1041
- if ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {
1042
-
1043
- // bare name or "pure" bottom-level array "[0]" suffix
1044
-
1045
- addUniform( container, subscript === undefined ?
1046
- new SingleUniform( id, activeInfo, addr ) :
1047
- new PureArrayUniform( id, activeInfo, addr ) );
1048
-
1049
- break;
1050
-
1051
- } else {
1052
-
1053
- // step into inner node / create it in case it doesn't exist
1054
-
1055
- const map = container.map;
1056
- let next = map[ id ];
1057
-
1058
- if ( next === undefined ) {
1059
-
1060
- next = new StructuredUniform( id );
1061
- addUniform( container, next );
1062
-
1063
- }
1064
-
1065
- container = next;
1066
-
1067
- }
1068
-
1069
- }
1070
-
1071
- }
1072
-
1073
- // Root Container
1074
-
1075
- class WebGLUniforms {
1076
-
1077
- constructor( gl, program ) {
1078
-
1079
- this.seq = [];
1080
- this.map = {};
1081
-
1082
- const n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );
1083
-
1084
- for ( let i = 0; i < n; ++ i ) {
1085
-
1086
- const info = gl.getActiveUniform( program, i ),
1087
- addr = gl.getUniformLocation( program, info.name );
1088
-
1089
- parseUniform( info, addr, this );
1090
-
1091
- }
1092
-
1093
- }
1094
-
1095
- setValue( gl, name, value, textures ) {
1096
-
1097
- const u = this.map[ name ];
1098
-
1099
- if ( u !== undefined ) u.setValue( gl, value, textures );
1100
-
1101
- }
1102
-
1103
- setOptional( gl, object, name ) {
1104
-
1105
- const v = object[ name ];
1106
-
1107
- if ( v !== undefined ) this.setValue( gl, name, v );
1108
-
1109
- }
1110
-
1111
- static upload( gl, seq, values, textures ) {
1112
-
1113
- for ( let i = 0, n = seq.length; i !== n; ++ i ) {
1114
-
1115
- const u = seq[ i ],
1116
- v = values[ u.id ];
1117
-
1118
- if ( v.needsUpdate !== false ) {
1119
-
1120
- // note: always updating when .needsUpdate is undefined
1121
- u.setValue( gl, v.value, textures );
1122
-
1123
- }
1124
-
1125
- }
1126
-
1127
- }
1128
-
1129
- static seqWithValue( seq, values ) {
1130
-
1131
- const r = [];
1132
-
1133
- for ( let i = 0, n = seq.length; i !== n; ++ i ) {
1134
-
1135
- const u = seq[ i ];
1136
- if ( u.id in values ) r.push( u );
1137
-
1138
- }
1139
-
1140
- return r;
1141
-
1142
- }
1143
-
1144
- }
1145
-
1146
- export { WebGLUniforms };
1
+ /**
2
+ * Uniforms of a program.
3
+ * Those form a tree structure with a special top-level container for the root,
4
+ * which you get by calling 'new WebGLUniforms( gl, program )'.
5
+ *
6
+ *
7
+ * Properties of inner nodes including the top-level container:
8
+ *
9
+ * .seq - array of nested uniforms
10
+ * .map - nested uniforms by name
11
+ *
12
+ *
13
+ * Methods of all nodes except the top-level container:
14
+ *
15
+ * .setValue( gl, value, [textures] )
16
+ *
17
+ * uploads a uniform value(s)
18
+ * the 'textures' parameter is needed for sampler uniforms
19
+ *
20
+ *
21
+ * Static methods of the top-level container (textures factorizations):
22
+ *
23
+ * .upload( gl, seq, values, textures )
24
+ *
25
+ * sets uniforms in 'seq' to 'values[id].value'
26
+ *
27
+ * .seqWithValue( seq, values ) : filteredSeq
28
+ *
29
+ * filters 'seq' entries with corresponding entry in values
30
+ *
31
+ *
32
+ * Methods of the top-level container (textures factorizations):
33
+ *
34
+ * .setValue( gl, name, value, textures )
35
+ *
36
+ * sets uniform with name 'name' to 'value'
37
+ *
38
+ * .setOptional( gl, obj, prop )
39
+ *
40
+ * like .set for an optional property of the object
41
+ *
42
+ */
43
+
44
+ import { CubeTexture } from '../../textures/CubeTexture.js';
45
+ import { Texture } from '../../textures/Texture.js';
46
+ import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
47
+ import { Data3DTexture } from '../../textures/Data3DTexture.js';
48
+ import { DepthTexture } from '../../textures/DepthTexture.js';
49
+ import { LessEqualCompare } from '../../constants.js';
50
+
51
+ const emptyTexture = /*@__PURE__*/ new Texture();
52
+
53
+ const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
54
+ emptyShadowTexture.compareFunction = LessEqualCompare;
55
+
56
+ const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
57
+ const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
58
+ const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
59
+
60
+ // --- Utilities ---
61
+
62
+ // Array Caches (provide typed arrays for temporary by size)
63
+
64
+ const arrayCacheF32 = [];
65
+ const arrayCacheI32 = [];
66
+
67
+ // Float32Array caches used for uploading Matrix uniforms
68
+
69
+ const mat4array = new Float32Array( 16 );
70
+ const mat3array = new Float32Array( 9 );
71
+ const mat2array = new Float32Array( 4 );
72
+
73
+ // Flattening for arrays of vectors and matrices
74
+
75
+ function flatten( array, nBlocks, blockSize ) {
76
+
77
+ const firstElem = array[ 0 ];
78
+
79
+ if ( firstElem <= 0 || firstElem > 0 ) return array;
80
+ // unoptimized: ! isNaN( firstElem )
81
+ // see http://jacksondunstan.com/articles/983
82
+
83
+ const n = nBlocks * blockSize;
84
+ let r = arrayCacheF32[ n ];
85
+
86
+ if ( r === undefined ) {
87
+
88
+ r = new Float32Array( n );
89
+ arrayCacheF32[ n ] = r;
90
+
91
+ }
92
+
93
+ if ( nBlocks !== 0 ) {
94
+
95
+ firstElem.toArray( r, 0 );
96
+
97
+ for ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {
98
+
99
+ offset += blockSize;
100
+ array[ i ].toArray( r, offset );
101
+
102
+ }
103
+
104
+ }
105
+
106
+ return r;
107
+
108
+ }
109
+
110
+ function arraysEqual( a, b ) {
111
+
112
+ if ( a.length !== b.length ) return false;
113
+
114
+ for ( let i = 0, l = a.length; i < l; i ++ ) {
115
+
116
+ if ( a[ i ] !== b[ i ] ) return false;
117
+
118
+ }
119
+
120
+ return true;
121
+
122
+ }
123
+
124
+ function copyArray( a, b ) {
125
+
126
+ for ( let i = 0, l = b.length; i < l; i ++ ) {
127
+
128
+ a[ i ] = b[ i ];
129
+
130
+ }
131
+
132
+ }
133
+
134
+ // Texture unit allocation
135
+
136
+ function allocTexUnits( textures, n ) {
137
+
138
+ let r = arrayCacheI32[ n ];
139
+
140
+ if ( r === undefined ) {
141
+
142
+ r = new Int32Array( n );
143
+ arrayCacheI32[ n ] = r;
144
+
145
+ }
146
+
147
+ for ( let i = 0; i !== n; ++ i ) {
148
+
149
+ r[ i ] = textures.allocateTextureUnit();
150
+
151
+ }
152
+
153
+ return r;
154
+
155
+ }
156
+
157
+ // --- Setters ---
158
+
159
+ // Note: Defining these methods externally, because they come in a bunch
160
+ // and this way their names minify.
161
+
162
+ // Single scalar
163
+
164
+ function setValueV1f( gl, v ) {
165
+
166
+ const cache = this.cache;
167
+
168
+ if ( cache[ 0 ] === v ) return;
169
+
170
+ gl.uniform1f( this.addr, v );
171
+
172
+ cache[ 0 ] = v;
173
+
174
+ }
175
+
176
+ // Single float vector (from flat array or THREE.VectorN)
177
+
178
+ function setValueV2f( gl, v ) {
179
+
180
+ const cache = this.cache;
181
+
182
+ if ( v.x !== undefined ) {
183
+
184
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
185
+
186
+ gl.uniform2f( this.addr, v.x, v.y );
187
+
188
+ cache[ 0 ] = v.x;
189
+ cache[ 1 ] = v.y;
190
+
191
+ }
192
+
193
+ } else {
194
+
195
+ if ( arraysEqual( cache, v ) ) return;
196
+
197
+ gl.uniform2fv( this.addr, v );
198
+
199
+ copyArray( cache, v );
200
+
201
+ }
202
+
203
+ }
204
+
205
+ function setValueV3f( gl, v ) {
206
+
207
+ const cache = this.cache;
208
+
209
+ if ( v.x !== undefined ) {
210
+
211
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
212
+
213
+ gl.uniform3f( this.addr, v.x, v.y, v.z );
214
+
215
+ cache[ 0 ] = v.x;
216
+ cache[ 1 ] = v.y;
217
+ cache[ 2 ] = v.z;
218
+
219
+ }
220
+
221
+ } else if ( v.r !== undefined ) {
222
+
223
+ if ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {
224
+
225
+ gl.uniform3f( this.addr, v.r, v.g, v.b );
226
+
227
+ cache[ 0 ] = v.r;
228
+ cache[ 1 ] = v.g;
229
+ cache[ 2 ] = v.b;
230
+
231
+ }
232
+
233
+ } else {
234
+
235
+ if ( arraysEqual( cache, v ) ) return;
236
+
237
+ gl.uniform3fv( this.addr, v );
238
+
239
+ copyArray( cache, v );
240
+
241
+ }
242
+
243
+ }
244
+
245
+ function setValueV4f( gl, v ) {
246
+
247
+ const cache = this.cache;
248
+
249
+ if ( v.x !== undefined ) {
250
+
251
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
252
+
253
+ gl.uniform4f( this.addr, v.x, v.y, v.z, v.w );
254
+
255
+ cache[ 0 ] = v.x;
256
+ cache[ 1 ] = v.y;
257
+ cache[ 2 ] = v.z;
258
+ cache[ 3 ] = v.w;
259
+
260
+ }
261
+
262
+ } else {
263
+
264
+ if ( arraysEqual( cache, v ) ) return;
265
+
266
+ gl.uniform4fv( this.addr, v );
267
+
268
+ copyArray( cache, v );
269
+
270
+ }
271
+
272
+ }
273
+
274
+ // Single matrix (from flat array or THREE.MatrixN)
275
+
276
+ function setValueM2( gl, v ) {
277
+
278
+ const cache = this.cache;
279
+ const elements = v.elements;
280
+
281
+ if ( elements === undefined ) {
282
+
283
+ if ( arraysEqual( cache, v ) ) return;
284
+
285
+ gl.uniformMatrix2fv( this.addr, false, v );
286
+
287
+ copyArray( cache, v );
288
+
289
+ } else {
290
+
291
+ if ( arraysEqual( cache, elements ) ) return;
292
+
293
+ mat2array.set( elements );
294
+
295
+ gl.uniformMatrix2fv( this.addr, false, mat2array );
296
+
297
+ copyArray( cache, elements );
298
+
299
+ }
300
+
301
+ }
302
+
303
+ function setValueM3( gl, v ) {
304
+
305
+ const cache = this.cache;
306
+ const elements = v.elements;
307
+
308
+ if ( elements === undefined ) {
309
+
310
+ if ( arraysEqual( cache, v ) ) return;
311
+
312
+ gl.uniformMatrix3fv( this.addr, false, v );
313
+
314
+ copyArray( cache, v );
315
+
316
+ } else {
317
+
318
+ if ( arraysEqual( cache, elements ) ) return;
319
+
320
+ mat3array.set( elements );
321
+
322
+ gl.uniformMatrix3fv( this.addr, false, mat3array );
323
+
324
+ copyArray( cache, elements );
325
+
326
+ }
327
+
328
+ }
329
+
330
+ function setValueM4( gl, v ) {
331
+
332
+ const cache = this.cache;
333
+ const elements = v.elements;
334
+
335
+ if ( elements === undefined ) {
336
+
337
+ if ( arraysEqual( cache, v ) ) return;
338
+
339
+ gl.uniformMatrix4fv( this.addr, false, v );
340
+
341
+ copyArray( cache, v );
342
+
343
+ } else {
344
+
345
+ if ( arraysEqual( cache, elements ) ) return;
346
+
347
+ mat4array.set( elements );
348
+
349
+ gl.uniformMatrix4fv( this.addr, false, mat4array );
350
+
351
+ copyArray( cache, elements );
352
+
353
+ }
354
+
355
+ }
356
+
357
+ // Single integer / boolean
358
+
359
+ function setValueV1i( gl, v ) {
360
+
361
+ const cache = this.cache;
362
+
363
+ if ( cache[ 0 ] === v ) return;
364
+
365
+ gl.uniform1i( this.addr, v );
366
+
367
+ cache[ 0 ] = v;
368
+
369
+ }
370
+
371
+ // Single integer / boolean vector (from flat array or THREE.VectorN)
372
+
373
+ function setValueV2i( gl, v ) {
374
+
375
+ const cache = this.cache;
376
+
377
+ if ( v.x !== undefined ) {
378
+
379
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
380
+
381
+ gl.uniform2i( this.addr, v.x, v.y );
382
+
383
+ cache[ 0 ] = v.x;
384
+ cache[ 1 ] = v.y;
385
+
386
+ }
387
+
388
+ } else {
389
+
390
+ if ( arraysEqual( cache, v ) ) return;
391
+
392
+ gl.uniform2iv( this.addr, v );
393
+
394
+ copyArray( cache, v );
395
+
396
+ }
397
+
398
+ }
399
+
400
+ function setValueV3i( gl, v ) {
401
+
402
+ const cache = this.cache;
403
+
404
+ if ( v.x !== undefined ) {
405
+
406
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
407
+
408
+ gl.uniform3i( this.addr, v.x, v.y, v.z );
409
+
410
+ cache[ 0 ] = v.x;
411
+ cache[ 1 ] = v.y;
412
+ cache[ 2 ] = v.z;
413
+
414
+ }
415
+
416
+ } else {
417
+
418
+ if ( arraysEqual( cache, v ) ) return;
419
+
420
+ gl.uniform3iv( this.addr, v );
421
+
422
+ copyArray( cache, v );
423
+
424
+ }
425
+
426
+ }
427
+
428
+ function setValueV4i( gl, v ) {
429
+
430
+ const cache = this.cache;
431
+
432
+ if ( v.x !== undefined ) {
433
+
434
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
435
+
436
+ gl.uniform4i( this.addr, v.x, v.y, v.z, v.w );
437
+
438
+ cache[ 0 ] = v.x;
439
+ cache[ 1 ] = v.y;
440
+ cache[ 2 ] = v.z;
441
+ cache[ 3 ] = v.w;
442
+
443
+ }
444
+
445
+ } else {
446
+
447
+ if ( arraysEqual( cache, v ) ) return;
448
+
449
+ gl.uniform4iv( this.addr, v );
450
+
451
+ copyArray( cache, v );
452
+
453
+ }
454
+
455
+ }
456
+
457
+ // Single unsigned integer
458
+
459
+ function setValueV1ui( gl, v ) {
460
+
461
+ const cache = this.cache;
462
+
463
+ if ( cache[ 0 ] === v ) return;
464
+
465
+ gl.uniform1ui( this.addr, v );
466
+
467
+ cache[ 0 ] = v;
468
+
469
+ }
470
+
471
+ // Single unsigned integer vector (from flat array or THREE.VectorN)
472
+
473
+ function setValueV2ui( gl, v ) {
474
+
475
+ const cache = this.cache;
476
+
477
+ if ( v.x !== undefined ) {
478
+
479
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
480
+
481
+ gl.uniform2ui( this.addr, v.x, v.y );
482
+
483
+ cache[ 0 ] = v.x;
484
+ cache[ 1 ] = v.y;
485
+
486
+ }
487
+
488
+ } else {
489
+
490
+ if ( arraysEqual( cache, v ) ) return;
491
+
492
+ gl.uniform2uiv( this.addr, v );
493
+
494
+ copyArray( cache, v );
495
+
496
+ }
497
+
498
+ }
499
+
500
+ function setValueV3ui( gl, v ) {
501
+
502
+ const cache = this.cache;
503
+
504
+ if ( v.x !== undefined ) {
505
+
506
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
507
+
508
+ gl.uniform3ui( this.addr, v.x, v.y, v.z );
509
+
510
+ cache[ 0 ] = v.x;
511
+ cache[ 1 ] = v.y;
512
+ cache[ 2 ] = v.z;
513
+
514
+ }
515
+
516
+ } else {
517
+
518
+ if ( arraysEqual( cache, v ) ) return;
519
+
520
+ gl.uniform3uiv( this.addr, v );
521
+
522
+ copyArray( cache, v );
523
+
524
+ }
525
+
526
+ }
527
+
528
+ function setValueV4ui( gl, v ) {
529
+
530
+ const cache = this.cache;
531
+
532
+ if ( v.x !== undefined ) {
533
+
534
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
535
+
536
+ gl.uniform4ui( this.addr, v.x, v.y, v.z, v.w );
537
+
538
+ cache[ 0 ] = v.x;
539
+ cache[ 1 ] = v.y;
540
+ cache[ 2 ] = v.z;
541
+ cache[ 3 ] = v.w;
542
+
543
+ }
544
+
545
+ } else {
546
+
547
+ if ( arraysEqual( cache, v ) ) return;
548
+
549
+ gl.uniform4uiv( this.addr, v );
550
+
551
+ copyArray( cache, v );
552
+
553
+ }
554
+
555
+ }
556
+
557
+
558
+ // Single texture (2D / Cube)
559
+
560
+ function setValueT1( gl, v, textures ) {
561
+
562
+ const cache = this.cache;
563
+ const unit = textures.allocateTextureUnit();
564
+
565
+ if ( cache[ 0 ] !== unit ) {
566
+
567
+ gl.uniform1i( this.addr, unit );
568
+ cache[ 0 ] = unit;
569
+
570
+ }
571
+
572
+ const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
573
+
574
+ textures.setTexture2D( v || emptyTexture2D, unit );
575
+
576
+ }
577
+
578
+ function setValueT3D1( gl, v, textures ) {
579
+
580
+ const cache = this.cache;
581
+ const unit = textures.allocateTextureUnit();
582
+
583
+ if ( cache[ 0 ] !== unit ) {
584
+
585
+ gl.uniform1i( this.addr, unit );
586
+ cache[ 0 ] = unit;
587
+
588
+ }
589
+
590
+ textures.setTexture3D( v || empty3dTexture, unit );
591
+
592
+ }
593
+
594
+ function setValueT6( gl, v, textures ) {
595
+
596
+ const cache = this.cache;
597
+ const unit = textures.allocateTextureUnit();
598
+
599
+ if ( cache[ 0 ] !== unit ) {
600
+
601
+ gl.uniform1i( this.addr, unit );
602
+ cache[ 0 ] = unit;
603
+
604
+ }
605
+
606
+ textures.setTextureCube( v || emptyCubeTexture, unit );
607
+
608
+ }
609
+
610
+ function setValueT2DArray1( gl, v, textures ) {
611
+
612
+ const cache = this.cache;
613
+ const unit = textures.allocateTextureUnit();
614
+
615
+ if ( cache[ 0 ] !== unit ) {
616
+
617
+ gl.uniform1i( this.addr, unit );
618
+ cache[ 0 ] = unit;
619
+
620
+ }
621
+
622
+ textures.setTexture2DArray( v || emptyArrayTexture, unit );
623
+
624
+ }
625
+
626
+ // Helper to pick the right setter for the singular case
627
+
628
+ function getSingularSetter( type ) {
629
+
630
+ switch ( type ) {
631
+
632
+ case 0x1406: return setValueV1f; // FLOAT
633
+ case 0x8b50: return setValueV2f; // _VEC2
634
+ case 0x8b51: return setValueV3f; // _VEC3
635
+ case 0x8b52: return setValueV4f; // _VEC4
636
+
637
+ case 0x8b5a: return setValueM2; // _MAT2
638
+ case 0x8b5b: return setValueM3; // _MAT3
639
+ case 0x8b5c: return setValueM4; // _MAT4
640
+
641
+ case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL
642
+ case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2
643
+ case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3
644
+ case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4
645
+
646
+ case 0x1405: return setValueV1ui; // UINT
647
+ case 0x8dc6: return setValueV2ui; // _VEC2
648
+ case 0x8dc7: return setValueV3ui; // _VEC3
649
+ case 0x8dc8: return setValueV4ui; // _VEC4
650
+
651
+ case 0x8b5e: // SAMPLER_2D
652
+ case 0x8d66: // SAMPLER_EXTERNAL_OES
653
+ case 0x8dca: // INT_SAMPLER_2D
654
+ case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
655
+ case 0x8b62: // SAMPLER_2D_SHADOW
656
+ return setValueT1;
657
+
658
+ case 0x8b5f: // SAMPLER_3D
659
+ case 0x8dcb: // INT_SAMPLER_3D
660
+ case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
661
+ return setValueT3D1;
662
+
663
+ case 0x8b60: // SAMPLER_CUBE
664
+ case 0x8dcc: // INT_SAMPLER_CUBE
665
+ case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
666
+ case 0x8dc5: // SAMPLER_CUBE_SHADOW
667
+ return setValueT6;
668
+
669
+ case 0x8dc1: // SAMPLER_2D_ARRAY
670
+ case 0x8dcf: // INT_SAMPLER_2D_ARRAY
671
+ case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
672
+ case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
673
+ return setValueT2DArray1;
674
+
675
+ }
676
+
677
+ }
678
+
679
+
680
+ // Array of scalars
681
+
682
+ function setValueV1fArray( gl, v ) {
683
+
684
+ gl.uniform1fv( this.addr, v );
685
+
686
+ }
687
+
688
+ // Array of vectors (from flat array or array of THREE.VectorN)
689
+
690
+ function setValueV2fArray( gl, v ) {
691
+
692
+ const data = flatten( v, this.size, 2 );
693
+
694
+ gl.uniform2fv( this.addr, data );
695
+
696
+ }
697
+
698
+ function setValueV3fArray( gl, v ) {
699
+
700
+ const data = flatten( v, this.size, 3 );
701
+
702
+ gl.uniform3fv( this.addr, data );
703
+
704
+ }
705
+
706
+ function setValueV4fArray( gl, v ) {
707
+
708
+ const data = flatten( v, this.size, 4 );
709
+
710
+ gl.uniform4fv( this.addr, data );
711
+
712
+ }
713
+
714
+ // Array of matrices (from flat array or array of THREE.MatrixN)
715
+
716
+ function setValueM2Array( gl, v ) {
717
+
718
+ const data = flatten( v, this.size, 4 );
719
+
720
+ gl.uniformMatrix2fv( this.addr, false, data );
721
+
722
+ }
723
+
724
+ function setValueM3Array( gl, v ) {
725
+
726
+ const data = flatten( v, this.size, 9 );
727
+
728
+ gl.uniformMatrix3fv( this.addr, false, data );
729
+
730
+ }
731
+
732
+ function setValueM4Array( gl, v ) {
733
+
734
+ const data = flatten( v, this.size, 16 );
735
+
736
+ gl.uniformMatrix4fv( this.addr, false, data );
737
+
738
+ }
739
+
740
+ // Array of integer / boolean
741
+
742
+ function setValueV1iArray( gl, v ) {
743
+
744
+ gl.uniform1iv( this.addr, v );
745
+
746
+ }
747
+
748
+ // Array of integer / boolean vectors (from flat array)
749
+
750
+ function setValueV2iArray( gl, v ) {
751
+
752
+ gl.uniform2iv( this.addr, v );
753
+
754
+ }
755
+
756
+ function setValueV3iArray( gl, v ) {
757
+
758
+ gl.uniform3iv( this.addr, v );
759
+
760
+ }
761
+
762
+ function setValueV4iArray( gl, v ) {
763
+
764
+ gl.uniform4iv( this.addr, v );
765
+
766
+ }
767
+
768
+ // Array of unsigned integer
769
+
770
+ function setValueV1uiArray( gl, v ) {
771
+
772
+ gl.uniform1uiv( this.addr, v );
773
+
774
+ }
775
+
776
+ // Array of unsigned integer vectors (from flat array)
777
+
778
+ function setValueV2uiArray( gl, v ) {
779
+
780
+ gl.uniform2uiv( this.addr, v );
781
+
782
+ }
783
+
784
+ function setValueV3uiArray( gl, v ) {
785
+
786
+ gl.uniform3uiv( this.addr, v );
787
+
788
+ }
789
+
790
+ function setValueV4uiArray( gl, v ) {
791
+
792
+ gl.uniform4uiv( this.addr, v );
793
+
794
+ }
795
+
796
+
797
+ // Array of textures (2D / 3D / Cube / 2DArray)
798
+
799
+ function setValueT1Array( gl, v, textures ) {
800
+
801
+ const cache = this.cache;
802
+
803
+ const n = v.length;
804
+
805
+ const units = allocTexUnits( textures, n );
806
+
807
+ if ( ! arraysEqual( cache, units ) ) {
808
+
809
+ gl.uniform1iv( this.addr, units );
810
+
811
+ copyArray( cache, units );
812
+
813
+ }
814
+
815
+ for ( let i = 0; i !== n; ++ i ) {
816
+
817
+ textures.setTexture2D( v[ i ] || emptyTexture, units[ i ] );
818
+
819
+ }
820
+
821
+ }
822
+
823
+ function setValueT3DArray( gl, v, textures ) {
824
+
825
+ const cache = this.cache;
826
+
827
+ const n = v.length;
828
+
829
+ const units = allocTexUnits( textures, n );
830
+
831
+ if ( ! arraysEqual( cache, units ) ) {
832
+
833
+ gl.uniform1iv( this.addr, units );
834
+
835
+ copyArray( cache, units );
836
+
837
+ }
838
+
839
+ for ( let i = 0; i !== n; ++ i ) {
840
+
841
+ textures.setTexture3D( v[ i ] || empty3dTexture, units[ i ] );
842
+
843
+ }
844
+
845
+ }
846
+
847
+ function setValueT6Array( gl, v, textures ) {
848
+
849
+ const cache = this.cache;
850
+
851
+ const n = v.length;
852
+
853
+ const units = allocTexUnits( textures, n );
854
+
855
+ if ( ! arraysEqual( cache, units ) ) {
856
+
857
+ gl.uniform1iv( this.addr, units );
858
+
859
+ copyArray( cache, units );
860
+
861
+ }
862
+
863
+ for ( let i = 0; i !== n; ++ i ) {
864
+
865
+ textures.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );
866
+
867
+ }
868
+
869
+ }
870
+
871
+ function setValueT2DArrayArray( gl, v, textures ) {
872
+
873
+ const cache = this.cache;
874
+
875
+ const n = v.length;
876
+
877
+ const units = allocTexUnits( textures, n );
878
+
879
+ if ( ! arraysEqual( cache, units ) ) {
880
+
881
+ gl.uniform1iv( this.addr, units );
882
+
883
+ copyArray( cache, units );
884
+
885
+ }
886
+
887
+ for ( let i = 0; i !== n; ++ i ) {
888
+
889
+ textures.setTexture2DArray( v[ i ] || emptyArrayTexture, units[ i ] );
890
+
891
+ }
892
+
893
+ }
894
+
895
+
896
+ // Helper to pick the right setter for a pure (bottom-level) array
897
+
898
+ function getPureArraySetter( type ) {
899
+
900
+ switch ( type ) {
901
+
902
+ case 0x1406: return setValueV1fArray; // FLOAT
903
+ case 0x8b50: return setValueV2fArray; // _VEC2
904
+ case 0x8b51: return setValueV3fArray; // _VEC3
905
+ case 0x8b52: return setValueV4fArray; // _VEC4
906
+
907
+ case 0x8b5a: return setValueM2Array; // _MAT2
908
+ case 0x8b5b: return setValueM3Array; // _MAT3
909
+ case 0x8b5c: return setValueM4Array; // _MAT4
910
+
911
+ case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL
912
+ case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2
913
+ case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3
914
+ case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4
915
+
916
+ case 0x1405: return setValueV1uiArray; // UINT
917
+ case 0x8dc6: return setValueV2uiArray; // _VEC2
918
+ case 0x8dc7: return setValueV3uiArray; // _VEC3
919
+ case 0x8dc8: return setValueV4uiArray; // _VEC4
920
+
921
+ case 0x8b5e: // SAMPLER_2D
922
+ case 0x8d66: // SAMPLER_EXTERNAL_OES
923
+ case 0x8dca: // INT_SAMPLER_2D
924
+ case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
925
+ case 0x8b62: // SAMPLER_2D_SHADOW
926
+ return setValueT1Array;
927
+
928
+ case 0x8b5f: // SAMPLER_3D
929
+ case 0x8dcb: // INT_SAMPLER_3D
930
+ case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
931
+ return setValueT3DArray;
932
+
933
+ case 0x8b60: // SAMPLER_CUBE
934
+ case 0x8dcc: // INT_SAMPLER_CUBE
935
+ case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
936
+ case 0x8dc5: // SAMPLER_CUBE_SHADOW
937
+ return setValueT6Array;
938
+
939
+ case 0x8dc1: // SAMPLER_2D_ARRAY
940
+ case 0x8dcf: // INT_SAMPLER_2D_ARRAY
941
+ case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
942
+ case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
943
+ return setValueT2DArrayArray;
944
+
945
+ }
946
+
947
+ }
948
+
949
+ // --- Uniform Classes ---
950
+
951
+ class SingleUniform {
952
+
953
+ constructor( id, activeInfo, addr ) {
954
+
955
+ this.id = id;
956
+ this.addr = addr;
957
+ this.cache = [];
958
+ this.type = activeInfo.type;
959
+ this.setValue = getSingularSetter( activeInfo.type );
960
+
961
+ // this.path = activeInfo.name; // DEBUG
962
+
963
+ }
964
+
965
+ }
966
+
967
+ class PureArrayUniform {
968
+
969
+ constructor( id, activeInfo, addr ) {
970
+
971
+ this.id = id;
972
+ this.addr = addr;
973
+ this.cache = [];
974
+ this.type = activeInfo.type;
975
+ this.size = activeInfo.size;
976
+ this.setValue = getPureArraySetter( activeInfo.type );
977
+
978
+ // this.path = activeInfo.name; // DEBUG
979
+
980
+ }
981
+
982
+ }
983
+
984
+ class StructuredUniform {
985
+
986
+ constructor( id ) {
987
+
988
+ this.id = id;
989
+
990
+ this.seq = [];
991
+ this.map = {};
992
+
993
+ }
994
+
995
+ setValue( gl, value, textures ) {
996
+
997
+ const seq = this.seq;
998
+
999
+ for ( let i = 0, n = seq.length; i !== n; ++ i ) {
1000
+
1001
+ const u = seq[ i ];
1002
+ u.setValue( gl, value[ u.id ], textures );
1003
+
1004
+ }
1005
+
1006
+ }
1007
+
1008
+ }
1009
+
1010
+ // --- Top-level ---
1011
+
1012
+ // Parser - builds up the property tree from the path strings
1013
+
1014
+ const RePathPart = /(\w+)(\])?(\[|\.)?/g;
1015
+
1016
+ // extracts
1017
+ // - the identifier (member name or array index)
1018
+ // - followed by an optional right bracket (found when array index)
1019
+ // - followed by an optional left bracket or dot (type of subscript)
1020
+ //
1021
+ // Note: These portions can be read in a non-overlapping fashion and
1022
+ // allow straightforward parsing of the hierarchy that WebGL encodes
1023
+ // in the uniform names.
1024
+
1025
+ function addUniform( container, uniformObject ) {
1026
+
1027
+ container.seq.push( uniformObject );
1028
+ container.map[ uniformObject.id ] = uniformObject;
1029
+
1030
+ }
1031
+
1032
+ function parseUniform( activeInfo, addr, container ) {
1033
+
1034
+ const path = activeInfo.name,
1035
+ pathLength = path.length;
1036
+
1037
+ // reset RegExp object, because of the early exit of a previous run
1038
+ RePathPart.lastIndex = 0;
1039
+
1040
+ while ( true ) {
1041
+
1042
+ const match = RePathPart.exec( path ),
1043
+ matchEnd = RePathPart.lastIndex;
1044
+
1045
+ let id = match[ 1 ];
1046
+ const idIsIndex = match[ 2 ] === ']',
1047
+ subscript = match[ 3 ];
1048
+
1049
+ if ( idIsIndex ) id = id | 0; // convert to integer
1050
+
1051
+ if ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {
1052
+
1053
+ // bare name or "pure" bottom-level array "[0]" suffix
1054
+
1055
+ addUniform( container, subscript === undefined ?
1056
+ new SingleUniform( id, activeInfo, addr ) :
1057
+ new PureArrayUniform( id, activeInfo, addr ) );
1058
+
1059
+ break;
1060
+
1061
+ } else {
1062
+
1063
+ // step into inner node / create it in case it doesn't exist
1064
+
1065
+ const map = container.map;
1066
+ let next = map[ id ];
1067
+
1068
+ if ( next === undefined ) {
1069
+
1070
+ next = new StructuredUniform( id );
1071
+ addUniform( container, next );
1072
+
1073
+ }
1074
+
1075
+ container = next;
1076
+
1077
+ }
1078
+
1079
+ }
1080
+
1081
+ }
1082
+
1083
+ // Root Container
1084
+
1085
+ class WebGLUniforms {
1086
+
1087
+ constructor( gl, program ) {
1088
+
1089
+ this.seq = [];
1090
+ this.map = {};
1091
+
1092
+ const n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );
1093
+
1094
+ for ( let i = 0; i < n; ++ i ) {
1095
+
1096
+ const info = gl.getActiveUniform( program, i ),
1097
+ addr = gl.getUniformLocation( program, info.name );
1098
+
1099
+ parseUniform( info, addr, this );
1100
+
1101
+ }
1102
+
1103
+ }
1104
+
1105
+ setValue( gl, name, value, textures ) {
1106
+
1107
+ const u = this.map[ name ];
1108
+
1109
+ if ( u !== undefined ) u.setValue( gl, value, textures );
1110
+
1111
+ }
1112
+
1113
+ setOptional( gl, object, name ) {
1114
+
1115
+ const v = object[ name ];
1116
+
1117
+ if ( v !== undefined ) this.setValue( gl, name, v );
1118
+
1119
+ }
1120
+
1121
+ static upload( gl, seq, values, textures ) {
1122
+
1123
+ for ( let i = 0, n = seq.length; i !== n; ++ i ) {
1124
+
1125
+ const u = seq[ i ],
1126
+ v = values[ u.id ];
1127
+
1128
+ if ( v.needsUpdate !== false ) {
1129
+
1130
+ // note: always updating when .needsUpdate is undefined
1131
+ u.setValue( gl, v.value, textures );
1132
+
1133
+ }
1134
+
1135
+ }
1136
+
1137
+ }
1138
+
1139
+ static seqWithValue( seq, values ) {
1140
+
1141
+ const r = [];
1142
+
1143
+ for ( let i = 0, n = seq.length; i !== n; ++ i ) {
1144
+
1145
+ const u = seq[ i ];
1146
+ if ( u.id in values ) r.push( u );
1147
+
1148
+ }
1149
+
1150
+ return r;
1151
+
1152
+ }
1153
+
1154
+ }
1155
+
1156
+ export { WebGLUniforms };