@needle-tools/three 0.145.2 → 0.146.1

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 (394) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +3559 -6924
  3. package/build/three.js +3559 -6924
  4. package/build/three.min.js +1 -2
  5. package/build/three.module.js +732 -339
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +49 -66
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +70 -134
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +138 -405
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -54
  14. package/examples/js/controls/FlyControls.js +29 -55
  15. package/examples/js/controls/OrbitControls.js +85 -95
  16. package/examples/js/controls/PointerLockControls.js +5 -14
  17. package/examples/js/controls/TrackballControls.js +33 -86
  18. package/examples/js/controls/TransformControls.js +84 -169
  19. package/examples/js/csm/CSM.js +4 -39
  20. package/examples/js/csm/CSMFrustum.js +3 -9
  21. package/examples/js/csm/CSMHelper.js +24 -4
  22. package/examples/js/csm/CSMShader.js +2 -6
  23. package/examples/js/curves/CurveExtras.js +27 -27
  24. package/examples/js/curves/NURBSCurve.js +4 -16
  25. package/examples/js/curves/NURBSSurface.js +3 -9
  26. package/examples/js/curves/NURBSUtils.js +8 -45
  27. package/examples/js/effects/AnaglyphEffect.js +4 -18
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +26 -30
  30. package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
  31. package/examples/js/effects/PeppersGhostEffect.js +12 -39
  32. package/examples/js/effects/StereoEffect.js +0 -4
  33. package/examples/js/environments/RoomEnvironment.js +12 -10
  34. package/examples/js/exporters/ColladaExporter.js +48 -65
  35. package/examples/js/exporters/DRACOExporter.js +22 -22
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +143 -261
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +42 -33
  40. package/examples/js/exporters/PLYExporter.js +38 -33
  41. package/examples/js/exporters/STLExporter.js +5 -7
  42. package/examples/js/exporters/USDZExporter.js +110 -25
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +11 -6
  45. package/examples/js/geometries/DecalGeometry.js +53 -20
  46. package/examples/js/geometries/LightningStrike.js +54 -67
  47. package/examples/js/geometries/ParametricGeometries.js +8 -7
  48. package/examples/js/geometries/ParametricGeometry.js +25 -12
  49. package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
  50. package/examples/js/geometries/TeapotGeometry.js +54 -50
  51. package/examples/js/geometries/TextGeometry.js +6 -4
  52. package/examples/js/helpers/LightProbeHelper.js +1 -2
  53. package/examples/js/helpers/OctreeHelper.js +22 -20
  54. package/examples/js/helpers/PositionalAudioHelper.js +8 -6
  55. package/examples/js/helpers/RectAreaLightHelper.js +6 -7
  56. package/examples/js/helpers/VertexNormalsHelper.js +15 -13
  57. package/examples/js/helpers/VertexTangentsHelper.js +15 -9
  58. package/examples/js/helpers/ViewHelper.js +31 -16
  59. package/examples/js/interactive/HTMLMesh.js +22 -33
  60. package/examples/js/interactive/InteractiveGroup.js +6 -12
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +0 -8
  63. package/examples/js/lights/LightProbeGenerator.js +32 -39
  64. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  65. package/examples/js/lines/LineGeometry.js +3 -5
  66. package/examples/js/lines/LineMaterial.js +4 -11
  67. package/examples/js/lines/LineSegments2.js +38 -89
  68. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  69. package/examples/js/lines/Wireframe.js +2 -7
  70. package/examples/js/lines/WireframeGeometry2.js +3 -1
  71. package/examples/js/loaders/3DMLoader.js +58 -155
  72. package/examples/js/loaders/3MFLoader.js +72 -106
  73. package/examples/js/loaders/AMFLoader.js +0 -25
  74. package/examples/js/loaders/BVHLoader.js +44 -43
  75. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  76. package/examples/js/loaders/ColladaLoader.js +201 -359
  77. package/examples/js/loaders/DDSLoader.js +24 -25
  78. package/examples/js/loaders/DRACOLoader.js +29 -66
  79. package/examples/js/loaders/EXRLoader.js +67 -164
  80. package/examples/js/loaders/FBXLoader.js +286 -441
  81. package/examples/js/loaders/FontLoader.js +6 -15
  82. package/examples/js/loaders/GCodeLoader.js +15 -16
  83. package/examples/js/loaders/GLTFLoader.js +354 -405
  84. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
  85. package/examples/js/loaders/KMZLoader.js +3 -7
  86. package/examples/js/loaders/KTXLoader.js +12 -30
  87. package/examples/js/loaders/LDrawLoader.js +178 -289
  88. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  89. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  90. package/examples/js/loaders/LWOLoader.js +59 -124
  91. package/examples/js/loaders/LogLuvLoader.js +27 -77
  92. package/examples/js/loaders/LottieLoader.js +4 -4
  93. package/examples/js/loaders/MD2Loader.js +26 -27
  94. package/examples/js/loaders/MDDLoader.js +6 -10
  95. package/examples/js/loaders/MMDLoader.js +180 -189
  96. package/examples/js/loaders/MTLLoader.js +18 -47
  97. package/examples/js/loaders/MaterialXLoader.js +392 -0
  98. package/examples/js/loaders/NRRDLoader.js +44 -84
  99. package/examples/js/loaders/OBJLoader.js +50 -65
  100. package/examples/js/loaders/PCDLoader.js +34 -29
  101. package/examples/js/loaders/PDBLoader.js +17 -13
  102. package/examples/js/loaders/PLYLoader.js +9 -39
  103. package/examples/js/loaders/PRWMLoader.js +11 -22
  104. package/examples/js/loaders/PVRLoader.js +7 -16
  105. package/examples/js/loaders/RGBELoader.js +36 -61
  106. package/examples/js/loaders/RGBMLoader.js +26 -87
  107. package/examples/js/loaders/STLLoader.js +20 -27
  108. package/examples/js/loaders/SVGLoader.js +361 -233
  109. package/examples/js/loaders/TDSLoader.js +81 -118
  110. package/examples/js/loaders/TGALoader.js +39 -41
  111. package/examples/js/loaders/TIFFLoader.js +0 -1
  112. package/examples/js/loaders/TTFLoader.js +0 -8
  113. package/examples/js/loaders/TiltLoader.js +14 -15
  114. package/examples/js/loaders/VOXLoader.js +8 -16
  115. package/examples/js/loaders/VRMLLoader.js +243 -340
  116. package/examples/js/loaders/VTKLoader.js +101 -118
  117. package/examples/js/loaders/XYZLoader.js +2 -4
  118. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  119. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  120. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  121. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  122. package/examples/js/math/Capsule.js +0 -17
  123. package/examples/js/math/ColorConverter.js +3 -3
  124. package/examples/js/math/ConvexHull.js +183 -139
  125. package/examples/js/math/ImprovedNoise.js +1 -1
  126. package/examples/js/math/Lut.js +8 -15
  127. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  128. package/examples/js/math/OBB.js +90 -49
  129. package/examples/js/math/Octree.js +2 -57
  130. package/examples/js/math/SimplexNoise.js +74 -88
  131. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  132. package/examples/js/misc/GPUComputationRenderer.js +14 -18
  133. package/examples/js/misc/Gyroscope.js +5 -9
  134. package/examples/js/misc/MD2Character.js +14 -23
  135. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  136. package/examples/js/misc/MorphAnimMesh.js +0 -6
  137. package/examples/js/misc/MorphBlendMesh.js +3 -30
  138. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  139. package/examples/js/misc/RollerCoaster.js +17 -24
  140. package/examples/js/misc/TubePainter.js +18 -12
  141. package/examples/js/misc/Volume.js +16 -45
  142. package/examples/js/misc/VolumeSlice.js +14 -24
  143. package/examples/js/modifiers/CurveModifier.js +19 -21
  144. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  145. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  146. package/examples/js/modifiers/TessellateModifier.js +2 -9
  147. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  148. package/examples/js/objects/Lensflare.js +47 -38
  149. package/examples/js/objects/LightningStorm.js +10 -13
  150. package/examples/js/objects/MarchingCubes.js +80 -59
  151. package/examples/js/objects/Reflector.js +22 -20
  152. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  153. package/examples/js/objects/Refractor.js +52 -30
  154. package/examples/js/objects/ShadowMesh.js +1 -2
  155. package/examples/js/objects/Sky.js +2 -7
  156. package/examples/js/objects/Water.js +23 -18
  157. package/examples/js/objects/Water2.js +20 -19
  158. package/examples/js/physics/AmmoPhysics.js +23 -20
  159. package/examples/js/physics/OimoPhysics.js +19 -17
  160. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  161. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  162. package/examples/js/postprocessing/BloomPass.js +38 -17
  163. package/examples/js/postprocessing/BokehPass.js +29 -12
  164. package/examples/js/postprocessing/ClearPass.js +1 -6
  165. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  166. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  167. package/examples/js/postprocessing/EffectComposer.js +25 -32
  168. package/examples/js/postprocessing/FilmPass.js +7 -5
  169. package/examples/js/postprocessing/GlitchPass.js +10 -11
  170. package/examples/js/postprocessing/HalftonePass.js +9 -9
  171. package/examples/js/postprocessing/LUTPass.js +2 -15
  172. package/examples/js/postprocessing/MaskPass.js +20 -17
  173. package/examples/js/postprocessing/OutlinePass.js +45 -36
  174. package/examples/js/postprocessing/Pass.js +11 -14
  175. package/examples/js/postprocessing/RenderPass.js +3 -7
  176. package/examples/js/postprocessing/SAOPass.js +40 -32
  177. package/examples/js/postprocessing/SMAAPass.js +34 -17
  178. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  179. package/examples/js/postprocessing/SSAOPass.js +56 -42
  180. package/examples/js/postprocessing/SSRPass.js +78 -61
  181. package/examples/js/postprocessing/SavePass.js +14 -6
  182. package/examples/js/postprocessing/ShaderPass.js +9 -8
  183. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  184. package/examples/js/postprocessing/TexturePass.js +7 -4
  185. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  186. package/examples/js/renderers/CSS2DRenderer.js +2 -21
  187. package/examples/js/renderers/CSS3DRenderer.js +3 -24
  188. package/examples/js/renderers/Projector.js +29 -85
  189. package/examples/js/renderers/SVGRenderer.js +4 -50
  190. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  191. package/examples/js/shaders/AfterimageShader.js +3 -6
  192. package/examples/js/shaders/BasicShader.js +3 -6
  193. package/examples/js/shaders/BleachBypassShader.js +3 -6
  194. package/examples/js/shaders/BlendShader.js +3 -6
  195. package/examples/js/shaders/BokehShader.js +3 -6
  196. package/examples/js/shaders/BokehShader2.js +4 -13
  197. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  198. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  199. package/examples/js/shaders/ColorifyShader.js +2 -6
  200. package/examples/js/shaders/ConvolutionShader.js +5 -10
  201. package/examples/js/shaders/CopyShader.js +3 -6
  202. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  203. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  204. package/examples/js/shaders/DigitalGlitch.js +3 -6
  205. package/examples/js/shaders/DotScreenShader.js +2 -6
  206. package/examples/js/shaders/FXAAShader.js +1 -3
  207. package/examples/js/shaders/FilmShader.js +3 -6
  208. package/examples/js/shaders/FocusShader.js +3 -6
  209. package/examples/js/shaders/FreiChenShader.js +2 -6
  210. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  211. package/examples/js/shaders/GodRaysShader.js +11 -24
  212. package/examples/js/shaders/HalftoneShader.js +3 -6
  213. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  214. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  215. package/examples/js/shaders/HueSaturationShader.js +3 -6
  216. package/examples/js/shaders/KaleidoShader.js +3 -6
  217. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  218. package/examples/js/shaders/LuminosityShader.js +3 -6
  219. package/examples/js/shaders/MMDToonShader.js +2 -6
  220. package/examples/js/shaders/MirrorShader.js +3 -6
  221. package/examples/js/shaders/NormalMapShader.js +2 -6
  222. package/examples/js/shaders/RGBShiftShader.js +3 -6
  223. package/examples/js/shaders/SAOShader.js +2 -6
  224. package/examples/js/shaders/SMAAShader.js +6 -18
  225. package/examples/js/shaders/SSAOShader.js +2 -6
  226. package/examples/js/shaders/SSRShader.js +6 -18
  227. package/examples/js/shaders/SepiaShader.js +3 -6
  228. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  229. package/examples/js/shaders/TechnicolorShader.js +3 -6
  230. package/examples/js/shaders/ToneMapShader.js +3 -6
  231. package/examples/js/shaders/ToonShader.js +8 -24
  232. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  233. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  234. package/examples/js/shaders/VelocityShader.js +126 -0
  235. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  236. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  237. package/examples/js/shaders/VignetteShader.js +3 -6
  238. package/examples/js/shaders/VolumeShader.js +2 -6
  239. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  240. package/examples/js/textures/FlakesTexture.js +0 -1
  241. package/examples/js/utils/BufferGeometryUtils.js +234 -168
  242. package/examples/js/utils/CameraUtils.js +5 -20
  243. package/examples/js/utils/GPUStatsPanel.js +3 -12
  244. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  245. package/examples/js/utils/GeometryUtils.js +13 -18
  246. package/examples/js/utils/LDrawUtils.js +8 -11
  247. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  248. package/examples/js/utils/SceneUtils.js +117 -6
  249. package/examples/js/utils/ShadowMapViewer.js +17 -14
  250. package/examples/js/utils/SkeletonUtils.js +13 -27
  251. package/examples/js/utils/UVsDebug.js +20 -12
  252. package/examples/js/utils/WorkerPool.js +1 -11
  253. package/examples/jsm/animation/CCDIKSolver.js +1 -1
  254. package/examples/jsm/capabilities/WebGPU.js +3 -1
  255. package/examples/jsm/controls/OrbitControls.js +44 -4
  256. package/examples/jsm/exporters/GLTFExporter.js +17 -131
  257. package/examples/jsm/exporters/USDZExporter.js +94 -28
  258. package/examples/jsm/interactive/HTMLMesh.js +2 -0
  259. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  260. package/examples/jsm/loaders/3DMLoader.js +1 -2
  261. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  262. package/examples/jsm/loaders/FBXLoader.js +16 -2
  263. package/examples/jsm/loaders/GLTFLoader.js +204 -377
  264. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  265. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  266. package/examples/jsm/loaders/LottieLoader.js +4 -2
  267. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  268. package/examples/jsm/loaders/PCDLoader.js +1 -1
  269. package/examples/jsm/loaders/PLYLoader.js +68 -16
  270. package/examples/jsm/loaders/SVGLoader.js +227 -14
  271. package/examples/jsm/loaders/USDZLoader.js +31 -16
  272. package/examples/jsm/nodes/Nodes.js +14 -2
  273. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  274. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  275. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  276. package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
  277. package/examples/jsm/nodes/core/Node.js +1 -1
  278. package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
  279. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  280. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  281. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  282. package/examples/jsm/nodes/core/constants.js +13 -13
  283. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  284. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  285. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  286. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  287. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  288. package/examples/jsm/nodes/materials/Materials.js +9 -7
  289. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  290. package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
  291. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  292. package/examples/jsm/nodes/math/MathNode.js +5 -0
  293. package/examples/jsm/nodes/math/OperatorNode.js +6 -1
  294. package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
  295. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
  296. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
  297. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  298. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  299. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  300. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  301. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  302. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  303. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  304. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  305. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  306. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  307. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  308. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  309. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  310. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  311. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  312. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  313. package/examples/jsm/postprocessing/OutlinePass.js +10 -0
  314. package/examples/jsm/postprocessing/Pass.js +2 -0
  315. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  316. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  317. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  318. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  319. package/examples/jsm/postprocessing/SavePass.js +17 -1
  320. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  321. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  322. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  323. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  324. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
  325. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  326. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  327. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  328. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  329. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
  330. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  331. package/examples/jsm/shaders/VelocityShader.js +128 -0
  332. package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
  333. package/examples/jsm/utils/SceneUtils.js +129 -4
  334. package/examples/jsm/utils/TextureUtils.js +85 -0
  335. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  336. package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
  337. package/package.json +11 -12
  338. package/src/Three.js +1 -0
  339. package/src/audio/AudioContext.js +5 -5
  340. package/src/cameras/CubeCamera.js +14 -14
  341. package/src/constants.js +1 -1
  342. package/src/core/InstancedBufferGeometry.js +1 -7
  343. package/src/extras/Earcut.js +67 -67
  344. package/src/helpers/DirectionalLightHelper.js +5 -1
  345. package/src/helpers/HemisphereLightHelper.js +4 -1
  346. package/src/helpers/PointLightHelper.js +2 -1
  347. package/src/helpers/SpotLightHelper.js +4 -2
  348. package/src/lights/PointLight.js +2 -2
  349. package/src/lights/SpotLight.js +2 -2
  350. package/src/loaders/FileLoader.js +4 -1
  351. package/src/loaders/ObjectLoader.js +5 -1
  352. package/src/materials/Material.js +1 -1
  353. package/src/math/Color.js +5 -5
  354. package/src/math/Matrix3.js +53 -18
  355. package/src/math/Ray.js +2 -5
  356. package/src/math/Sphere.js +19 -26
  357. package/src/objects/InstancedMesh.js +7 -0
  358. package/src/objects/LOD.js +25 -6
  359. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  360. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  361. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  362. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  363. package/src/renderers/WebGLRenderTarget.js +1 -1
  364. package/src/renderers/WebGLRenderer.js +36 -62
  365. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  367. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  369. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  370. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  371. package/src/renderers/shaders/ShaderChunk.js +3 -0
  372. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  373. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  374. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  375. package/src/renderers/shaders/ShaderLib.js +20 -6
  376. package/src/renderers/shaders/UniformsLib.js +1 -1
  377. package/src/renderers/shaders/UniformsUtils.js +15 -0
  378. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  379. package/src/renderers/webgl/WebGLBackground.js +15 -7
  380. package/src/renderers/webgl/WebGLCubeUVMaps.js +1 -1
  381. package/src/renderers/webgl/WebGLLights.js +0 -4
  382. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  383. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  384. package/src/renderers/webgl/WebGLState.js +31 -1
  385. package/src/renderers/webgl/WebGLTextures.js +71 -18
  386. package/src/renderers/webgl/WebGLUniforms.js +116 -20
  387. package/src/renderers/webgl/WebGLUtils.js +1 -1
  388. package/src/renderers/webxr/WebXRController.js +46 -13
  389. package/src/renderers/webxr/WebXRManager.js +85 -3
  390. package/src/scenes/Scene.js +8 -0
  391. package/src/textures/CompressedArrayTexture.js +18 -0
  392. package/examples/js/libs/lottie_canvas.js +0 -12751
  393. package/examples/js/shaders/PixelShader.js +0 -51
  394. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -19,76 +19,68 @@
19
19
  this.grad3 = [[ 1, 1, 0 ], [ - 1, 1, 0 ], [ 1, - 1, 0 ], [ - 1, - 1, 0 ], [ 1, 0, 1 ], [ - 1, 0, 1 ], [ 1, 0, - 1 ], [ - 1, 0, - 1 ], [ 0, 1, 1 ], [ 0, - 1, 1 ], [ 0, 1, - 1 ], [ 0, - 1, - 1 ]];
20
20
  this.grad4 = [[ 0, 1, 1, 1 ], [ 0, 1, 1, - 1 ], [ 0, 1, - 1, 1 ], [ 0, 1, - 1, - 1 ], [ 0, - 1, 1, 1 ], [ 0, - 1, 1, - 1 ], [ 0, - 1, - 1, 1 ], [ 0, - 1, - 1, - 1 ], [ 1, 0, 1, 1 ], [ 1, 0, 1, - 1 ], [ 1, 0, - 1, 1 ], [ 1, 0, - 1, - 1 ], [ - 1, 0, 1, 1 ], [ - 1, 0, 1, - 1 ], [ - 1, 0, - 1, 1 ], [ - 1, 0, - 1, - 1 ], [ 1, 1, 0, 1 ], [ 1, 1, 0, - 1 ], [ 1, - 1, 0, 1 ], [ 1, - 1, 0, - 1 ], [ - 1, 1, 0, 1 ], [ - 1, 1, 0, - 1 ], [ - 1, - 1, 0, 1 ], [ - 1, - 1, 0, - 1 ], [ 1, 1, 1, 0 ], [ 1, 1, - 1, 0 ], [ 1, - 1, 1, 0 ], [ 1, - 1, - 1, 0 ], [ - 1, 1, 1, 0 ], [ - 1, 1, - 1, 0 ], [ - 1, - 1, 1, 0 ], [ - 1, - 1, - 1, 0 ]];
21
21
  this.p = [];
22
-
23
22
  for ( let i = 0; i < 256; i ++ ) {
24
23
 
25
24
  this.p[ i ] = Math.floor( r.random() * 256 );
26
25
 
27
- } // To remove the need for index wrapping, double the permutation table length
28
-
26
+ }
29
27
 
28
+ // To remove the need for index wrapping, double the permutation table length
30
29
  this.perm = [];
31
-
32
30
  for ( let i = 0; i < 512; i ++ ) {
33
31
 
34
32
  this.perm[ i ] = this.p[ i & 255 ];
35
33
 
36
- } // A lookup table to traverse the simplex around a given point in 4D.
37
- // Details can be found where this table is used, in the 4D noise method.
38
-
34
+ }
39
35
 
36
+ // A lookup table to traverse the simplex around a given point in 4D.
37
+ // Details can be found where this table is used, in the 4D noise method.
40
38
  this.simplex = [[ 0, 1, 2, 3 ], [ 0, 1, 3, 2 ], [ 0, 0, 0, 0 ], [ 0, 2, 3, 1 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 2, 1, 3 ], [ 0, 0, 0, 0 ], [ 0, 3, 1, 2 ], [ 0, 3, 2, 1 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 1, 3, 2, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 1, 2, 0, 3 ], [ 0, 0, 0, 0 ], [ 1, 3, 0, 2 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 2, 3, 0, 1 ], [ 2, 3, 1, 0 ], [ 1, 0, 2, 3 ], [ 1, 0, 3, 2 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 2, 0, 3, 1 ], [ 0, 0, 0, 0 ], [ 2, 1, 3, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 2, 0, 1, 3 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 3, 0, 1, 2 ], [ 3, 0, 2, 1 ], [ 0, 0, 0, 0 ], [ 3, 1, 2, 0 ], [ 2, 1, 0, 3 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 3, 1, 0, 2 ], [ 0, 0, 0, 0 ], [ 3, 2, 0, 1 ], [ 3, 2, 1, 0 ]];
41
39
 
42
40
  }
43
-
44
41
  dot( g, x, y ) {
45
42
 
46
43
  return g[ 0 ] * x + g[ 1 ] * y;
47
44
 
48
45
  }
49
-
50
46
  dot3( g, x, y, z ) {
51
47
 
52
48
  return g[ 0 ] * x + g[ 1 ] * y + g[ 2 ] * z;
53
49
 
54
50
  }
55
-
56
51
  dot4( g, x, y, z, w ) {
57
52
 
58
53
  return g[ 0 ] * x + g[ 1 ] * y + g[ 2 ] * z + g[ 3 ] * w;
59
54
 
60
55
  }
61
-
62
56
  noise( xin, yin ) {
63
57
 
64
58
  let n0; // Noise contributions from the three corners
65
-
66
59
  let n1;
67
- let n2; // Skew the input space to determine which simplex cell we're in
68
-
60
+ let n2;
61
+ // Skew the input space to determine which simplex cell we're in
69
62
  const F2 = 0.5 * ( Math.sqrt( 3.0 ) - 1.0 );
70
63
  const s = ( xin + yin ) * F2; // Hairy factor for 2D
71
-
72
64
  const i = Math.floor( xin + s );
73
65
  const j = Math.floor( yin + s );
74
66
  const G2 = ( 3.0 - Math.sqrt( 3.0 ) ) / 6.0;
75
67
  const t = ( i + j ) * G2;
76
68
  const X0 = i - t; // Unskew the cell origin back to (x,y) space
77
-
78
69
  const Y0 = j - t;
79
70
  const x0 = xin - X0; // The x,y distances from the cell origin
71
+ const y0 = yin - Y0;
80
72
 
81
- const y0 = yin - Y0; // For the 2D case, the simplex shape is an equilateral triangle.
73
+ // For the 2D case, the simplex shape is an equilateral triangle.
82
74
  // Determine which simplex we are in.
83
-
84
75
  let i1; // Offsets for second (middle) corner of simplex in (i,j) coords
85
76
 
86
77
  let j1;
87
-
88
78
  if ( x0 > y0 ) {
89
79
 
90
80
  i1 = 1;
91
- j1 = 0; // lower triangle, XY order: (0,0)->(1,0)->(1,1)
81
+ j1 = 0;
82
+
83
+ // lower triangle, XY order: (0,0)->(1,0)->(1,1)
92
84
 
93
85
  } else {
94
86
 
@@ -96,24 +88,21 @@
96
88
  j1 = 1;
97
89
 
98
90
  } // upper triangle, YX order: (0,0)->(0,1)->(1,1)
91
+
99
92
  // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
100
93
  // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
101
94
  // c = (3-sqrt(3))/6
102
-
103
-
104
95
  const x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
105
-
106
96
  const y1 = y0 - j1 + G2;
107
97
  const x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords
108
-
109
- const y2 = y0 - 1.0 + 2.0 * G2; // Work out the hashed gradient indices of the three simplex corners
110
-
98
+ const y2 = y0 - 1.0 + 2.0 * G2;
99
+ // Work out the hashed gradient indices of the three simplex corners
111
100
  const ii = i & 255;
112
101
  const jj = j & 255;
113
102
  const gi0 = this.perm[ ii + this.perm[ jj ] ] % 12;
114
103
  const gi1 = this.perm[ ii + i1 + this.perm[ jj + j1 ] ] % 12;
115
- const gi2 = this.perm[ ii + 1 + this.perm[ jj + 1 ] ] % 12; // Calculate the contribution from the three corners
116
-
104
+ const gi2 = this.perm[ ii + 1 + this.perm[ jj + 1 ] ] % 12;
105
+ // Calculate the contribution from the three corners
117
106
  let t0 = 0.5 - x0 * x0 - y0 * y0;
118
107
  if ( t0 < 0 ) n0 = 0.0; else {
119
108
 
@@ -136,50 +125,45 @@
136
125
  t2 *= t2;
137
126
  n2 = t2 * t2 * this.dot( this.grad3[ gi2 ], x2, y2 );
138
127
 
139
- } // Add contributions from each corner to get the final noise value.
140
- // The result is scaled to return values in the interval [-1,1].
128
+ }
141
129
 
130
+ // Add contributions from each corner to get the final noise value.
131
+ // The result is scaled to return values in the interval [-1,1].
142
132
  return 70.0 * ( n0 + n1 + n2 );
143
133
 
144
- } // 3D simplex noise
145
-
134
+ }
146
135
 
136
+ // 3D simplex noise
147
137
  noise3d( xin, yin, zin ) {
148
138
 
149
139
  let n0; // Noise contributions from the four corners
150
-
151
140
  let n1;
152
141
  let n2;
153
- let n3; // Skew the input space to determine which simplex cell we're in
154
-
142
+ let n3;
143
+ // Skew the input space to determine which simplex cell we're in
155
144
  const F3 = 1.0 / 3.0;
156
145
  const s = ( xin + yin + zin ) * F3; // Very nice and simple skew factor for 3D
157
-
158
146
  const i = Math.floor( xin + s );
159
147
  const j = Math.floor( yin + s );
160
148
  const k = Math.floor( zin + s );
161
149
  const G3 = 1.0 / 6.0; // Very nice and simple unskew factor, too
162
-
163
150
  const t = ( i + j + k ) * G3;
164
151
  const X0 = i - t; // Unskew the cell origin back to (x,y,z) space
165
-
166
152
  const Y0 = j - t;
167
153
  const Z0 = k - t;
168
154
  const x0 = xin - X0; // The x,y,z distances from the cell origin
169
-
170
155
  const y0 = yin - Y0;
171
- const z0 = zin - Z0; // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
172
- // Determine which simplex we are in.
156
+ const z0 = zin - Z0;
173
157
 
158
+ // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
159
+ // Determine which simplex we are in.
174
160
  let i1; // Offsets for second corner of simplex in (i,j,k) coords
175
161
 
176
162
  let j1;
177
163
  let k1;
178
164
  let i2; // Offsets for third corner of simplex in (i,j,k) coords
179
-
180
165
  let j2;
181
166
  let k2;
182
-
183
167
  if ( x0 >= y0 ) {
184
168
 
185
169
  if ( y0 >= z0 ) {
@@ -189,7 +173,9 @@
189
173
  k1 = 0;
190
174
  i2 = 1;
191
175
  j2 = 1;
192
- k2 = 0; // X Y Z order
176
+ k2 = 0;
177
+
178
+ // X Y Z order
193
179
 
194
180
  } else if ( x0 >= z0 ) {
195
181
 
@@ -198,7 +184,9 @@
198
184
  k1 = 0;
199
185
  i2 = 1;
200
186
  j2 = 0;
201
- k2 = 1; // X Z Y order
187
+ k2 = 1;
188
+
189
+ // X Z Y order
202
190
 
203
191
  } else {
204
192
 
@@ -214,6 +202,7 @@
214
202
  } else {
215
203
 
216
204
  // x0<y0
205
+
217
206
  if ( y0 < z0 ) {
218
207
 
219
208
  i1 = 0;
@@ -221,7 +210,9 @@
221
210
  k1 = 1;
222
211
  i2 = 0;
223
212
  j2 = 1;
224
- k2 = 1; // Z Y X order
213
+ k2 = 1;
214
+
215
+ // Z Y X order
225
216
 
226
217
  } else if ( x0 < z0 ) {
227
218
 
@@ -230,7 +221,9 @@
230
221
  k1 = 0;
231
222
  i2 = 0;
232
223
  j2 = 1;
233
- k2 = 1; // Y Z X order
224
+ k2 = 1;
225
+
226
+ // Y Z X order
234
227
 
235
228
  } else {
236
229
 
@@ -243,33 +236,30 @@
243
236
 
244
237
  } // Y X Z order
245
238
 
246
- } // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
239
+ }
240
+
241
+ // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
247
242
  // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and
248
243
  // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where
249
244
  // c = 1/6.
250
-
251
-
252
245
  const x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
253
-
254
246
  const y1 = y0 - j1 + G3;
255
247
  const z1 = z0 - k1 + G3;
256
248
  const x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
257
-
258
249
  const y2 = y0 - j2 + 2.0 * G3;
259
250
  const z2 = z0 - k2 + 2.0 * G3;
260
251
  const x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
261
-
262
252
  const y3 = y0 - 1.0 + 3.0 * G3;
263
- const z3 = z0 - 1.0 + 3.0 * G3; // Work out the hashed gradient indices of the four simplex corners
264
-
253
+ const z3 = z0 - 1.0 + 3.0 * G3;
254
+ // Work out the hashed gradient indices of the four simplex corners
265
255
  const ii = i & 255;
266
256
  const jj = j & 255;
267
257
  const kk = k & 255;
268
258
  const gi0 = this.perm[ ii + this.perm[ jj + this.perm[ kk ] ] ] % 12;
269
259
  const gi1 = this.perm[ ii + i1 + this.perm[ jj + j1 + this.perm[ kk + k1 ] ] ] % 12;
270
260
  const gi2 = this.perm[ ii + i2 + this.perm[ jj + j2 + this.perm[ kk + k2 ] ] ] % 12;
271
- const gi3 = this.perm[ ii + 1 + this.perm[ jj + 1 + this.perm[ kk + 1 ] ] ] % 12; // Calculate the contribution from the four corners
272
-
261
+ const gi3 = this.perm[ ii + 1 + this.perm[ jj + 1 + this.perm[ kk + 1 ] ] ] % 12;
262
+ // Calculate the contribution from the four corners
273
263
  let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
274
264
  if ( t0 < 0 ) n0 = 0.0; else {
275
265
 
@@ -300,48 +290,47 @@
300
290
  t3 *= t3;
301
291
  n3 = t3 * t3 * this.dot3( this.grad3[ gi3 ], x3, y3, z3 );
302
292
 
303
- } // Add contributions from each corner to get the final noise value.
304
- // The result is scaled to stay just inside [-1,1]
293
+ }
305
294
 
295
+ // Add contributions from each corner to get the final noise value.
296
+ // The result is scaled to stay just inside [-1,1]
306
297
  return 32.0 * ( n0 + n1 + n2 + n3 );
307
298
 
308
- } // 4D simplex noise
309
-
299
+ }
310
300
 
301
+ // 4D simplex noise
311
302
  noise4d( x, y, z, w ) {
312
303
 
313
304
  // For faster and easier lookups
314
305
  const grad4 = this.grad4;
315
306
  const simplex = this.simplex;
316
- const perm = this.perm; // The skewing and unskewing factors are hairy again for the 4D case
307
+ const perm = this.perm;
317
308
 
309
+ // The skewing and unskewing factors are hairy again for the 4D case
318
310
  const F4 = ( Math.sqrt( 5.0 ) - 1.0 ) / 4.0;
319
311
  const G4 = ( 5.0 - Math.sqrt( 5.0 ) ) / 20.0;
320
312
  let n0; // Noise contributions from the five corners
321
-
322
313
  let n1;
323
314
  let n2;
324
315
  let n3;
325
- let n4; // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
326
-
316
+ let n4;
317
+ // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in
327
318
  const s = ( x + y + z + w ) * F4; // Factor for 4D skewing
328
-
329
319
  const i = Math.floor( x + s );
330
320
  const j = Math.floor( y + s );
331
321
  const k = Math.floor( z + s );
332
322
  const l = Math.floor( w + s );
333
323
  const t = ( i + j + k + l ) * G4; // Factor for 4D unskewing
334
-
335
324
  const X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space
336
-
337
325
  const Y0 = j - t;
338
326
  const Z0 = k - t;
339
327
  const W0 = l - t;
340
328
  const x0 = x - X0; // The x,y,z,w distances from the cell origin
341
-
342
329
  const y0 = y - Y0;
343
330
  const z0 = z - Z0;
344
- const w0 = w - W0; // For the 4D case, the simplex is a 4D shape I won't even try to describe.
331
+ const w0 = w - W0;
332
+
333
+ // For the 4D case, the simplex is a 4D shape I won't even try to describe.
345
334
  // To find out which of the 24 possible simplices we're in, we need to
346
335
  // determine the magnitude ordering of x0, y0, z0 and w0.
347
336
  // The method below is a good way of finding the ordering of x,y,z,w and
@@ -349,55 +338,51 @@
349
338
  // First, six pair-wise comparisons are performed between each possible pair
350
339
  // of the four coordinates, and the results are used to add up binary bits
351
340
  // for an integer index.
352
-
353
341
  const c1 = x0 > y0 ? 32 : 0;
354
342
  const c2 = x0 > z0 ? 16 : 0;
355
343
  const c3 = y0 > z0 ? 8 : 0;
356
344
  const c4 = x0 > w0 ? 4 : 0;
357
345
  const c5 = y0 > w0 ? 2 : 0;
358
346
  const c6 = z0 > w0 ? 1 : 0;
359
- const c = c1 + c2 + c3 + c4 + c5 + c6; // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
347
+ const c = c1 + c2 + c3 + c4 + c5 + c6;
348
+
349
+ // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order.
360
350
  // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w
361
351
  // impossible. Only the 24 indices which have non-zero entries make any sense.
362
352
  // We use a thresholding to set the coordinates in turn from the largest magnitude.
363
353
  // The number 3 in the "simplex" array is at the position of the largest coordinate.
364
-
365
354
  const i1 = simplex[ c ][ 0 ] >= 3 ? 1 : 0;
366
355
  const j1 = simplex[ c ][ 1 ] >= 3 ? 1 : 0;
367
356
  const k1 = simplex[ c ][ 2 ] >= 3 ? 1 : 0;
368
- const l1 = simplex[ c ][ 3 ] >= 3 ? 1 : 0; // The number 2 in the "simplex" array is at the second largest coordinate.
369
-
357
+ const l1 = simplex[ c ][ 3 ] >= 3 ? 1 : 0;
358
+ // The number 2 in the "simplex" array is at the second largest coordinate.
370
359
  const i2 = simplex[ c ][ 0 ] >= 2 ? 1 : 0;
371
360
  const j2 = simplex[ c ][ 1 ] >= 2 ? 1 : 0;
372
361
  const k2 = simplex[ c ][ 2 ] >= 2 ? 1 : 0;
373
- const l2 = simplex[ c ][ 3 ] >= 2 ? 1 : 0; // The number 1 in the "simplex" array is at the second smallest coordinate.
374
-
362
+ const l2 = simplex[ c ][ 3 ] >= 2 ? 1 : 0;
363
+ // The number 1 in the "simplex" array is at the second smallest coordinate.
375
364
  const i3 = simplex[ c ][ 0 ] >= 1 ? 1 : 0;
376
365
  const j3 = simplex[ c ][ 1 ] >= 1 ? 1 : 0;
377
366
  const k3 = simplex[ c ][ 2 ] >= 1 ? 1 : 0;
378
- const l3 = simplex[ c ][ 3 ] >= 1 ? 1 : 0; // The fifth corner has all coordinate offsets = 1, so no need to look that up.
379
-
367
+ const l3 = simplex[ c ][ 3 ] >= 1 ? 1 : 0;
368
+ // The fifth corner has all coordinate offsets = 1, so no need to look that up.
380
369
  const x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords
381
-
382
370
  const y1 = y0 - j1 + G4;
383
371
  const z1 = z0 - k1 + G4;
384
372
  const w1 = w0 - l1 + G4;
385
373
  const x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords
386
-
387
374
  const y2 = y0 - j2 + 2.0 * G4;
388
375
  const z2 = z0 - k2 + 2.0 * G4;
389
376
  const w2 = w0 - l2 + 2.0 * G4;
390
377
  const x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords
391
-
392
378
  const y3 = y0 - j3 + 3.0 * G4;
393
379
  const z3 = z0 - k3 + 3.0 * G4;
394
380
  const w3 = w0 - l3 + 3.0 * G4;
395
381
  const x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords
396
-
397
382
  const y4 = y0 - 1.0 + 4.0 * G4;
398
383
  const z4 = z0 - 1.0 + 4.0 * G4;
399
- const w4 = w0 - 1.0 + 4.0 * G4; // Work out the hashed gradient indices of the five simplex corners
400
-
384
+ const w4 = w0 - 1.0 + 4.0 * G4;
385
+ // Work out the hashed gradient indices of the five simplex corners
401
386
  const ii = i & 255;
402
387
  const jj = j & 255;
403
388
  const kk = k & 255;
@@ -406,8 +391,8 @@
406
391
  const gi1 = perm[ ii + i1 + perm[ jj + j1 + perm[ kk + k1 + perm[ ll + l1 ] ] ] ] % 32;
407
392
  const gi2 = perm[ ii + i2 + perm[ jj + j2 + perm[ kk + k2 + perm[ ll + l2 ] ] ] ] % 32;
408
393
  const gi3 = perm[ ii + i3 + perm[ jj + j3 + perm[ kk + k3 + perm[ ll + l3 ] ] ] ] % 32;
409
- const gi4 = perm[ ii + 1 + perm[ jj + 1 + perm[ kk + 1 + perm[ ll + 1 ] ] ] ] % 32; // Calculate the contribution from the five corners
410
-
394
+ const gi4 = perm[ ii + 1 + perm[ jj + 1 + perm[ kk + 1 + perm[ ll + 1 ] ] ] ] % 32;
395
+ // Calculate the contribution from the five corners
411
396
  let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
412
397
  if ( t0 < 0 ) n0 = 0.0; else {
413
398
 
@@ -446,8 +431,9 @@
446
431
  t4 *= t4;
447
432
  n4 = t4 * t4 * this.dot4( grad4[ gi4 ], x4, y4, z4, w4 );
448
433
 
449
- } // Sum up and scale the result to cover the range [-1,1]
434
+ }
450
435
 
436
+ // Sum up and scale the result to cover the range [-1,1]
451
437
  return 27.0 * ( n0 + n1 + n2 + n3 + n4 );
452
438
 
453
439
  }