@needle-tools/three 0.145.4 → 0.146.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 (393) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +32586 -35951
  3. package/build/three.js +32600 -35965
  4. package/build/three.min.js +6 -7
  5. package/build/three.module.js +1547 -1154
  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 +75 -19
  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/WebGLLights.js +0 -4
  381. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  382. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  383. package/src/renderers/webgl/WebGLState.js +31 -1
  384. package/src/renderers/webgl/WebGLTextures.js +71 -18
  385. package/src/renderers/webgl/WebGLUniforms.js +116 -20
  386. package/src/renderers/webgl/WebGLUtils.js +1 -1
  387. package/src/renderers/webxr/WebXRController.js +46 -13
  388. package/src/renderers/webxr/WebXRManager.js +85 -3
  389. package/src/scenes/Scene.js +8 -0
  390. package/src/textures/CompressedArrayTexture.js +18 -0
  391. package/examples/js/libs/lottie_canvas.js +0 -12751
  392. package/examples/js/shaders/PixelShader.js +0 -51
  393. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -107,19 +107,19 @@
107
107
 
108
108
  super();
109
109
  this.isLightningStrike = true;
110
- this.type = 'LightningStrike'; // Set parameters, and set undefined parameters to default values
110
+ this.type = 'LightningStrike';
111
111
 
112
- this.init( LightningStrike.copyParameters( rayParameters, rayParameters ) ); // Creates and populates the mesh
112
+ // Set parameters, and set undefined parameters to default values
113
+ this.init( LightningStrike.copyParameters( rayParameters, rayParameters ) );
113
114
 
115
+ // Creates and populates the mesh
114
116
  this.createMesh();
115
117
 
116
118
  }
117
-
118
119
  static createRandomGenerator() {
119
120
 
120
121
  const numSeeds = 2053;
121
122
  const seeds = [];
122
-
123
123
  for ( let i = 0; i < numSeeds; i ++ ) {
124
124
 
125
125
  seeds.push( Math.random() );
@@ -149,7 +149,6 @@
149
149
  return generator;
150
150
 
151
151
  }
152
-
153
152
  static copyParameters( dest = {}, source = {} ) {
154
153
 
155
154
  const vecCopy = function ( v ) {
@@ -167,8 +166,12 @@
167
166
  };
168
167
 
169
168
  dest.sourceOffset = source.sourceOffset !== undefined ? vecCopy( source.sourceOffset ) : new THREE.Vector3( 0, 100, 0 ), dest.destOffset = source.destOffset !== undefined ? vecCopy( source.destOffset ) : new THREE.Vector3( 0, 0, 0 ), dest.timeScale = source.timeScale !== undefined ? source.timeScale : 1, dest.roughness = source.roughness !== undefined ? source.roughness : 0.9, dest.straightness = source.straightness !== undefined ? source.straightness : 0.7, dest.up0 = source.up0 !== undefined ? vecCopy( source.up0 ) : new THREE.Vector3( 0, 0, 1 );
170
- dest.up1 = source.up1 !== undefined ? vecCopy( source.up1 ) : new THREE.Vector3( 0, 0, 1 ), dest.radius0 = source.radius0 !== undefined ? source.radius0 : 1, dest.radius1 = source.radius1 !== undefined ? source.radius1 : 1, dest.radius0Factor = source.radius0Factor !== undefined ? source.radius0Factor : 0.5, dest.radius1Factor = source.radius1Factor !== undefined ? source.radius1Factor : 0.2, dest.minRadius = source.minRadius !== undefined ? source.minRadius : 0.2, // These parameters should not be changed after lightning creation. They can be changed but the ray will change its form abruptly:
171
- dest.isEternal = source.isEternal !== undefined ? source.isEternal : source.birthTime === undefined || source.deathTime === undefined, dest.birthTime = source.birthTime, dest.deathTime = source.deathTime, dest.propagationTimeFactor = source.propagationTimeFactor !== undefined ? source.propagationTimeFactor : 0.1, dest.vanishingTimeFactor = source.vanishingTimeFactor !== undefined ? source.vanishingTimeFactor : 0.9, dest.subrayPeriod = source.subrayPeriod !== undefined ? source.subrayPeriod : 4, dest.subrayDutyCycle = source.subrayDutyCycle !== undefined ? source.subrayDutyCycle : 0.6; // These parameters cannot change after lightning creation:
169
+ dest.up1 = source.up1 !== undefined ? vecCopy( source.up1 ) : new THREE.Vector3( 0, 0, 1 ), dest.radius0 = source.radius0 !== undefined ? source.radius0 : 1, dest.radius1 = source.radius1 !== undefined ? source.radius1 : 1, dest.radius0Factor = source.radius0Factor !== undefined ? source.radius0Factor : 0.5, dest.radius1Factor = source.radius1Factor !== undefined ? source.radius1Factor : 0.2, dest.minRadius = source.minRadius !== undefined ? source.minRadius : 0.2,
170
+ // These parameters should not be changed after lightning creation. They can be changed but the ray will change its form abruptly:
171
+
172
+ dest.isEternal = source.isEternal !== undefined ? source.isEternal : source.birthTime === undefined || source.deathTime === undefined, dest.birthTime = source.birthTime, dest.deathTime = source.deathTime, dest.propagationTimeFactor = source.propagationTimeFactor !== undefined ? source.propagationTimeFactor : 0.1, dest.vanishingTimeFactor = source.vanishingTimeFactor !== undefined ? source.vanishingTimeFactor : 0.9, dest.subrayPeriod = source.subrayPeriod !== undefined ? source.subrayPeriod : 4, dest.subrayDutyCycle = source.subrayDutyCycle !== undefined ? source.subrayDutyCycle : 0.6;
173
+
174
+ // These parameters cannot change after lightning creation:
172
175
 
173
176
  dest.maxIterations = source.maxIterations !== undefined ? source.maxIterations : 9;
174
177
  dest.isStatic = source.isStatic !== undefined ? source.isStatic : false;
@@ -180,15 +183,12 @@
180
183
  return dest;
181
184
 
182
185
  }
183
-
184
186
  update( time ) {
185
187
 
186
188
  if ( this.isStatic ) return;
187
-
188
189
  if ( this.rayParameters.isEternal || this.rayParameters.birthTime <= time && time <= this.rayParameters.deathTime ) {
189
190
 
190
191
  this.updateMesh( time );
191
-
192
192
  if ( time < this.subrays[ 0 ].endPropagationTime ) {
193
193
 
194
194
  this.state = LightningStrike.RAY_PROPAGATING;
@@ -208,7 +208,6 @@
208
208
  } else {
209
209
 
210
210
  this.visible = false;
211
-
212
211
  if ( time < this.rayParameters.birthTime ) {
213
212
 
214
213
  this.state = LightningStrike.RAY_UNBORN;
@@ -222,11 +221,13 @@
222
221
  }
223
222
 
224
223
  }
225
-
226
224
  init( rayParameters ) {
227
225
 
228
226
  // Init all the state from the parameters
229
- this.rayParameters = rayParameters; // These parameters cannot change after lightning creation:
227
+
228
+ this.rayParameters = rayParameters;
229
+
230
+ // These parameters cannot change after lightning creation:
230
231
 
231
232
  this.maxIterations = rayParameters.maxIterations !== undefined ? Math.floor( rayParameters.maxIterations ) : 9;
232
233
  rayParameters.maxIterations = this.maxIterations;
@@ -239,13 +240,13 @@
239
240
  this.recursionProbability = rayParameters.recursionProbability !== undefined ? rayParameters.recursionProbability : 0.6;
240
241
  rayParameters.recursionProbability = this.recursionProbability;
241
242
  this.generateUVs = rayParameters.generateUVs !== undefined ? rayParameters.generateUVs : false;
242
- rayParameters.generateUVs = this.generateUVs; // Random generator
243
+ rayParameters.generateUVs = this.generateUVs;
243
244
 
245
+ // Random generator
244
246
  if ( rayParameters.randomGenerator !== undefined ) {
245
247
 
246
248
  this.randomGenerator = rayParameters.randomGenerator;
247
249
  this.seedGenerator = rayParameters.randomGenerator;
248
-
249
250
  if ( rayParameters.noiseSeed !== undefined ) {
250
251
 
251
252
  this.seedGenerator.setSeed( rayParameters.noiseSeed );
@@ -257,9 +258,9 @@
257
258
  this.randomGenerator = LightningStrike.createRandomGenerator();
258
259
  this.seedGenerator = Math;
259
260
 
260
- } // Ray creation callbacks
261
-
261
+ }
262
262
 
263
+ // Ray creation callbacks
263
264
  if ( rayParameters.onDecideSubrayCreation !== undefined ) {
264
265
 
265
266
  this.onDecideSubrayCreation = rayParameters.onDecideSubrayCreation;
@@ -267,22 +268,21 @@
267
268
  } else {
268
269
 
269
270
  this.createDefaultSubrayCreationCallbacks();
270
-
271
271
  if ( rayParameters.onSubrayCreation !== undefined ) {
272
272
 
273
273
  this.onSubrayCreation = rayParameters.onSubrayCreation;
274
274
 
275
275
  }
276
276
 
277
- } // Internal state
277
+ }
278
278
 
279
+ // Internal state
279
280
 
280
281
  this.state = LightningStrike.RAY_INITIALIZED;
281
282
  this.maxSubrays = Math.ceil( 1 + Math.pow( this.ramification, Math.max( 0, this.maxSubrayRecursion - 1 ) ) );
282
283
  rayParameters.maxSubrays = this.maxSubrays;
283
284
  this.maxRaySegments = 2 * ( 1 << this.maxIterations );
284
285
  this.subrays = [];
285
-
286
286
  for ( let i = 0; i < this.maxSubrays; i ++ ) {
287
287
 
288
288
  this.subrays.push( this.createSubray() );
@@ -290,7 +290,6 @@
290
290
  }
291
291
 
292
292
  this.raySegments = [];
293
-
294
293
  for ( let i = 0; i < this.maxRaySegments; i ++ ) {
295
294
 
296
295
  this.raySegments.push( this.createSegment() );
@@ -317,8 +316,9 @@
317
316
  this.uvsAttribute = null;
318
317
  this.simplexX = new THREE.SimplexNoise( this.seedGenerator );
319
318
  this.simplexY = new THREE.SimplexNoise( this.seedGenerator );
320
- this.simplexZ = new THREE.SimplexNoise( this.seedGenerator ); // Temp vectors
319
+ this.simplexZ = new THREE.SimplexNoise( this.seedGenerator );
321
320
 
321
+ // Temp vectors
322
322
  this.forwards = new THREE.Vector3();
323
323
  this.forwardsFill = new THREE.Vector3();
324
324
  this.side = new THREE.Vector3();
@@ -330,7 +330,6 @@
330
330
  this.cross1 = new THREE.Vector3();
331
331
 
332
332
  }
333
-
334
333
  createMesh() {
335
334
 
336
335
  const maxDrawableSegmentsPerSubRay = 1 << this.maxIterations;
@@ -338,19 +337,17 @@
338
337
  const maxIndices = 18 * maxDrawableSegmentsPerSubRay * this.maxSubrays;
339
338
  this.vertices = new Float32Array( maxVerts * 3 );
340
339
  this.indices = new Uint32Array( maxIndices );
341
-
342
340
  if ( this.generateUVs ) {
343
341
 
344
342
  this.uvs = new Float32Array( maxVerts * 2 );
345
343
 
346
- } // Populate the mesh
347
-
344
+ }
348
345
 
346
+ // Populate the mesh
349
347
  this.fillMesh( 0 );
350
348
  this.setIndex( new THREE.Uint32BufferAttribute( this.indices, 1 ) );
351
349
  this.positionAttribute = new THREE.Float32BufferAttribute( this.vertices, 3 );
352
350
  this.setAttribute( 'position', this.positionAttribute );
353
-
354
351
  if ( this.generateUVs ) {
355
352
 
356
353
  this.uvsAttribute = new THREE.Float32BufferAttribute( new Float32Array( this.uvs ), 2 );
@@ -362,19 +359,17 @@
362
359
 
363
360
  this.index.usage = THREE.DynamicDrawUsage;
364
361
  this.positionAttribute.usage = THREE.DynamicDrawUsage;
365
-
366
362
  if ( this.generateUVs ) {
367
363
 
368
364
  this.uvsAttribute.usage = THREE.DynamicDrawUsage;
369
365
 
370
366
  }
371
367
 
372
- } // Store buffers for later modification
373
-
368
+ }
374
369
 
370
+ // Store buffers for later modification
375
371
  this.vertices = this.positionAttribute.array;
376
372
  this.indices = this.index.array;
377
-
378
373
  if ( this.generateUVs ) {
379
374
 
380
375
  this.uvs = this.uvsAttribute.array;
@@ -382,14 +377,12 @@
382
377
  }
383
378
 
384
379
  }
385
-
386
380
  updateMesh( time ) {
387
381
 
388
382
  this.fillMesh( time );
389
383
  this.drawRange.count = this.currentIndex;
390
384
  this.index.needsUpdate = true;
391
385
  this.positionAttribute.needsUpdate = true;
392
-
393
386
  if ( this.generateUVs ) {
394
387
 
395
388
  this.uvsAttribute.needsUpdate = true;
@@ -397,7 +390,6 @@
397
390
  }
398
391
 
399
392
  }
400
-
401
393
  fillMesh( time ) {
402
394
 
403
395
  const scope = this;
@@ -408,15 +400,16 @@
408
400
  this.fractalRay( time, function fillVertices( segment ) {
409
401
 
410
402
  const subray = scope.currentSubray;
411
-
412
403
  if ( time < subray.birthTime ) {
413
404
 
414
405
  //&& ( ! this.rayParameters.isEternal || scope.currentSubray.recursion > 0 ) ) {
406
+
415
407
  return;
416
408
 
417
409
  } else if ( this.rayParameters.isEternal && scope.currentSubray.recursion == 0 ) {
418
410
 
419
411
  // Eternal rays don't propagate nor vanish, but its subrays do
412
+
420
413
  scope.createPrism( segment );
421
414
  scope.onDecideSubrayCreation( segment, scope );
422
415
 
@@ -425,6 +418,7 @@
425
418
  if ( scope.timeFraction >= segment.fraction0 * subray.propagationTimeFactor ) {
426
419
 
427
420
  // Ray propagation has arrived to this segment
421
+
428
422
  scope.createPrism( segment );
429
423
  scope.onDecideSubrayCreation( segment, scope );
430
424
 
@@ -433,6 +427,7 @@
433
427
  } else if ( time < subray.beginVanishingTime ) {
434
428
 
435
429
  // Ray is steady (nor propagating nor vanishing)
430
+
436
431
  scope.createPrism( segment );
437
432
  scope.onDecideSubrayCreation( segment, scope );
438
433
 
@@ -441,6 +436,7 @@
441
436
  if ( scope.timeFraction <= subray.vanishingTimeFactor + segment.fraction1 * ( 1 - subray.vanishingTimeFactor ) ) {
442
437
 
443
438
  // Segment has not yet vanished
439
+
444
440
  scope.createPrism( segment );
445
441
 
446
442
  }
@@ -452,13 +448,11 @@
452
448
  } );
453
449
 
454
450
  }
455
-
456
451
  addNewSubray() {
457
452
 
458
453
  return this.subrays[ this.numSubrays ++ ];
459
454
 
460
455
  }
461
-
462
456
  initSubray( subray, rayParameters ) {
463
457
 
464
458
  subray.pos0.copy( rayParameters.sourceOffset );
@@ -479,15 +473,16 @@
479
473
  subray.recursion = 0;
480
474
 
481
475
  }
482
-
483
476
  fractalRay( time, segmentCallback ) {
484
477
 
485
478
  this.time = time;
486
479
  this.currentSegmentCallback = segmentCallback;
487
- this.numSubrays = 0; // Add the top level subray
480
+ this.numSubrays = 0;
488
481
 
489
- this.initSubray( this.addNewSubray(), this.rayParameters ); // Process all subrays that are being generated until consuming all of them
482
+ // Add the top level subray
483
+ this.initSubray( this.addNewSubray(), this.rayParameters );
490
484
 
485
+ // Process all subrays that are being generated until consuming all of them
491
486
  for ( let subrayIndex = 0; subrayIndex < this.numSubrays; subrayIndex ++ ) {
492
487
 
493
488
  const subray = this.subrays[ subrayIndex ];
@@ -523,7 +518,6 @@
523
518
  this.currentSubray = null;
524
519
 
525
520
  }
526
-
527
521
  fractalRayRecursive( segment ) {
528
522
 
529
523
  // Leave recursion condition
@@ -532,12 +526,11 @@
532
526
  this.currentSegmentCallback( segment );
533
527
  return;
534
528
 
535
- } // Interpolation
536
-
529
+ }
537
530
 
531
+ // Interpolation
538
532
  this.forwards.subVectors( segment.pos1, segment.pos0 );
539
533
  let lForwards = this.forwards.length();
540
-
541
534
  if ( lForwards < 0.000001 ) {
542
535
 
543
536
  this.forwards.set( 0, 0, 0.01 );
@@ -550,11 +543,14 @@
550
543
  const timeDimension = this.time * this.currentSubray.timeScale * Math.pow( 2, segment.iteration );
551
544
  this.middlePos.lerpVectors( segment.pos0, segment.pos1, 0.5 );
552
545
  this.middleLinPos.lerpVectors( segment.linPos0, segment.linPos1, 0.5 );
553
- const p = this.middleLinPos; // Noise
546
+ const p = this.middleLinPos;
554
547
 
548
+ // Noise
555
549
  this.newPos.set( this.simplexX.noise4d( p.x, p.y, p.z, timeDimension ), this.simplexY.noise4d( p.x, p.y, p.z, timeDimension ), this.simplexZ.noise4d( p.x, p.y, p.z, timeDimension ) );
556
550
  this.newPos.multiplyScalar( segment.positionVariationFactor * lForwards );
557
- this.newPos.add( this.middlePos ); // Recursion
551
+ this.newPos.add( this.middlePos );
552
+
553
+ // Recursion
558
554
 
559
555
  const newSegment1 = this.getNewSegment();
560
556
  newSegment1.pos0.copy( segment.pos0 );
@@ -587,12 +583,11 @@
587
583
  this.fractalRayRecursive( newSegment2 );
588
584
 
589
585
  }
590
-
591
586
  createPrism( segment ) {
592
587
 
593
588
  // Creates one triangular prism and its vertices at the segment
594
- this.forwardsFill.subVectors( segment.pos1, segment.pos0 ).normalize();
595
589
 
590
+ this.forwardsFill.subVectors( segment.pos1, segment.pos0 ).normalize();
596
591
  if ( this.isInitialSegment ) {
597
592
 
598
593
  this.currentCreateTriangleVertices( segment.pos0, segment.up0, this.forwardsFill, segment.radius0, 0 );
@@ -604,10 +599,10 @@
604
599
  this.createPrismFaces();
605
600
 
606
601
  }
607
-
608
602
  createTriangleVerticesWithoutUVs( pos, up, forwards, radius ) {
609
603
 
610
604
  // Create an equilateral triangle (only vertices)
605
+
611
606
  this.side.crossVectors( up, forwards ).multiplyScalar( radius * LightningStrike.COS30DEG );
612
607
  this.down.copy( up ).multiplyScalar( - radius * LightningStrike.SIN30DEG );
613
608
  const p = this.vPos;
@@ -627,10 +622,10 @@
627
622
  this.currentVertex += 3;
628
623
 
629
624
  }
630
-
631
625
  createTriangleVerticesWithUVs( pos, up, forwards, radius, u ) {
632
626
 
633
627
  // Create an equilateral triangle (only vertices)
628
+
634
629
  this.side.crossVectors( up, forwards ).multiplyScalar( radius * LightningStrike.COS30DEG );
635
630
  this.down.copy( up ).multiplyScalar( - radius * LightningStrike.SIN30DEG );
636
631
  const p = this.vPos;
@@ -657,10 +652,7 @@
657
652
  this.currentVertex += 3;
658
653
 
659
654
  }
660
-
661
- createPrismFaces( vertex
662
- /*, index*/
663
- ) {
655
+ createPrismFaces( vertex /*, index*/ ) {
664
656
 
665
657
  const indices = this.indices;
666
658
  vertex = this.currentVertex - 6;
@@ -684,14 +676,13 @@
684
676
  indices[ this.currentIndex ++ ] = vertex + 5;
685
677
 
686
678
  }
687
-
688
679
  createDefaultSubrayCreationCallbacks() {
689
680
 
690
681
  const random1 = this.randomGenerator.random;
691
-
692
682
  this.onDecideSubrayCreation = function ( segment, lightningStrike ) {
693
683
 
694
684
  // Decide subrays creation at parent (sub)ray segment
685
+
695
686
  const subray = lightningStrike.currentSubray;
696
687
  const period = lightningStrike.rayParameters.subrayPeriod;
697
688
  const dutyCycle = lightningStrike.rayParameters.subrayDutyCycle;
@@ -701,10 +692,10 @@
701
692
  const childSubraySeed = random1() * ( currentCycle + 1 );
702
693
  const isActive = phase % period <= dutyCycle * period;
703
694
  let probability = 0;
704
-
705
695
  if ( isActive ) {
706
696
 
707
- probability = lightningStrike.subrayProbability; // Distribution test: probability *= segment.fraction0 > 0.5 && segment.fraction0 < 0.9 ? 1 / 0.4 : 0;
697
+ probability = lightningStrike.subrayProbability;
698
+ // Distribution test: probability *= segment.fraction0 > 0.5 && segment.fraction0 < 0.9 ? 1 / 0.4 : 0;
708
699
 
709
700
  }
710
701
 
@@ -724,7 +715,6 @@
724
715
  childSubray.radius1 = Math.min( lightningStrike.rayParameters.minRadius, segment.radius1 * lightningStrike.rayParameters.radius1Factor );
725
716
  childSubray.birthTime = phase0 + currentCycle * period;
726
717
  childSubray.deathTime = childSubray.birthTime + period * dutyCycle;
727
-
728
718
  if ( ! lightningStrike.rayParameters.isEternal && subray.recursion == 0 ) {
729
719
 
730
720
  childSubray.birthTime = Math.max( childSubray.birthTime, subray.birthTime );
@@ -748,10 +738,10 @@
748
738
  const vec2Forward = new THREE.Vector3();
749
739
  const vec3Side = new THREE.Vector3();
750
740
  const vec4Up = new THREE.Vector3();
751
-
752
741
  this.onSubrayCreation = function ( segment, parentSubray, childSubray, lightningStrike ) {
753
742
 
754
743
  // Decide childSubray origin and destination positions (pos0 and pos1) and possibly other properties of childSubray
744
+
755
745
  // Just use the default cone position generator
756
746
  lightningStrike.subrayCylinderPosition( segment, parentSubray, childSubray, 0.5, 0.6, 0.2 );
757
747
 
@@ -760,6 +750,7 @@
760
750
  this.subrayConePosition = function ( segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor ) {
761
751
 
762
752
  // Sets childSubray pos0 and pos1 in a cone
753
+
763
754
  childSubray.pos0.copy( segment.pos0 );
764
755
  vec1Pos.subVectors( parentSubray.pos1, parentSubray.pos0 );
765
756
  vec2Forward.copy( vec1Pos ).normalize();
@@ -776,6 +767,7 @@
776
767
  this.subrayCylinderPosition = function ( segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor ) {
777
768
 
778
769
  // Sets childSubray pos0 and pos1 in a cylinder
770
+
779
771
  childSubray.pos0.copy( segment.pos0 );
780
772
  vec1Pos.subVectors( parentSubray.pos1, parentSubray.pos0 );
781
773
  vec2Forward.copy( vec1Pos ).normalize();
@@ -790,7 +782,6 @@
790
782
  };
791
783
 
792
784
  }
793
-
794
785
  createSubray() {
795
786
 
796
787
  return {
@@ -817,7 +808,6 @@
817
808
  };
818
809
 
819
810
  }
820
-
821
811
  createSegment() {
822
812
 
823
813
  return {
@@ -836,13 +826,11 @@
836
826
  };
837
827
 
838
828
  }
839
-
840
829
  getNewSegment() {
841
830
 
842
831
  return this.raySegments[ this.currentSegmentIndex ++ ];
843
832
 
844
833
  }
845
-
846
834
  copy( source ) {
847
835
 
848
836
  super.copy( source );
@@ -850,16 +838,15 @@
850
838
  return this;
851
839
 
852
840
  }
853
-
854
841
  clone() {
855
842
 
856
843
  return new this.constructor( LightningStrike.copyParameters( {}, this.rayParameters ) );
857
844
 
858
845
  }
859
846
 
860
- } // Ray states
861
-
847
+ }
862
848
 
849
+ // Ray states
863
850
  LightningStrike.RAY_INITIALIZED = 0;
864
851
  LightningStrike.RAY_UNBORN = 1;
865
852
  LightningStrike.RAY_PROPAGATING = 2;
@@ -11,7 +11,6 @@
11
11
  v *= 2 * Math.PI;
12
12
  u = u * 2;
13
13
  let x, z;
14
-
15
14
  if ( u < Math.PI ) {
16
15
 
17
16
  x = 3 * Math.cos( u ) * ( 1 + Math.sin( u ) ) + 2 * ( 1 - Math.cos( u ) / 2 ) * Math.cos( u ) * Math.cos( v );
@@ -56,6 +55,7 @@
56
55
  mobius3d: function ( u, t, target ) {
57
56
 
58
57
  // volumetric mobius strip
58
+
59
59
  u *= Math.PI;
60
60
  t *= 2 * Math.PI;
61
61
  u = u * 2;
@@ -71,6 +71,7 @@
71
71
 
72
72
  }
73
73
  };
74
+
74
75
  /*********************************************
75
76
  *
76
77
  * Parametric Replacement for TubeGeometry
@@ -87,7 +88,6 @@
87
88
  normals = frames.normals,
88
89
  binormals = frames.binormals;
89
90
  const position = new THREE.Vector3();
90
-
91
91
  function ParametricTube( u, v, target ) {
92
92
 
93
93
  v *= 2 * Math.PI;
@@ -96,7 +96,6 @@
96
96
  const normal = normals[ i ];
97
97
  const binormal = binormals[ i ];
98
98
  const cx = - radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
99
-
100
99
  const cy = radius * Math.sin( v );
101
100
  position.x += cx * normal.x + cy * binormal.x;
102
101
  position.y += cx * normal.y + cy * binormal.y;
@@ -105,7 +104,9 @@
105
104
 
106
105
  }
107
106
 
108
- super( ParametricTube, segments, segmentsRadius ); // proxy internals
107
+ super( ParametricTube, segments, segmentsRadius );
108
+
109
+ // proxy internals
109
110
 
110
111
  this.tangents = tangents;
111
112
  this.normals = normals;
@@ -119,12 +120,12 @@
119
120
  }
120
121
 
121
122
  };
123
+
122
124
  /*********************************************
123
125
  *
124
126
  * Parametric Replacement for TorusKnotGeometry
125
127
  *
126
128
  *********************************************/
127
-
128
129
  ParametricGeometries.TorusKnotGeometry = class TorusKnotGeometry extends ParametricGeometries.TubeGeometry {
129
130
 
130
131
  constructor( radius = 200, tube = 40, segmentsT = 64, segmentsR = 8, p = 2, q = 3 ) {
@@ -144,7 +145,6 @@
144
145
  }
145
146
 
146
147
  }
147
-
148
148
  const segments = segmentsT;
149
149
  const radiusSegments = segmentsR;
150
150
  const extrudePath = new TorusKnotCurve();
@@ -159,12 +159,12 @@
159
159
  }
160
160
 
161
161
  };
162
+
162
163
  /*********************************************
163
164
  *
164
165
  * Parametric Replacement for SphereGeometry
165
166
  *
166
167
  *********************************************/
167
-
168
168
  ParametricGeometries.SphereGeometry = class SphereGeometry extends THREE.ParametricGeometry {
169
169
 
170
170
  constructor( size, u, v ) {
@@ -185,6 +185,7 @@
185
185
  }
186
186
 
187
187
  };
188
+
188
189
  /*********************************************
189
190
  *
190
191
  * Parametric Replacement for PlaneGeometry
@@ -4,7 +4,6 @@
4
4
  * Parametric Surfaces Geometry
5
5
  * based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html
6
6
  */
7
-
8
7
  class ParametricGeometry extends THREE.BufferGeometry {
9
8
 
10
9
  constructor( func = ( u, v, target ) => target.set( u, v, Math.cos( u ) * Math.sin( v ) ), slices = 8, stacks = 8 ) {
@@ -15,7 +14,9 @@
15
14
  func: func,
16
15
  slices: slices,
17
16
  stacks: stacks
18
- }; // buffers
17
+ };
18
+
19
+ // buffers
19
20
 
20
21
  const indices = [];
21
22
  const vertices = [];
@@ -26,20 +27,25 @@
26
27
  const p0 = new THREE.Vector3(),
27
28
  p1 = new THREE.Vector3();
28
29
  const pu = new THREE.Vector3(),
29
- pv = new THREE.Vector3(); // generate vertices, normals and uvs
30
+ pv = new THREE.Vector3();
30
31
 
31
- const sliceCount = slices + 1;
32
+ // generate vertices, normals and uvs
32
33
 
34
+ const sliceCount = slices + 1;
33
35
  for ( let i = 0; i <= stacks; i ++ ) {
34
36
 
35
37
  const v = i / stacks;
36
-
37
38
  for ( let j = 0; j <= slices; j ++ ) {
38
39
 
39
- const u = j / slices; // vertex
40
+ const u = j / slices;
41
+
42
+ // vertex
40
43
 
41
44
  func( u, v, p0 );
42
- vertices.push( p0.x, p0.y, p0.z ); // normal
45
+ vertices.push( p0.x, p0.y, p0.z );
46
+
47
+ // normal
48
+
43
49
  // approximate tangent vectors via finite differences
44
50
 
45
51
  if ( u - EPS >= 0 ) {
@@ -64,18 +70,22 @@
64
70
  func( u, v + EPS, p1 );
65
71
  pv.subVectors( p1, p0 );
66
72
 
67
- } // cross product of tangent vectors returns surface normal
73
+ }
68
74
 
75
+ // cross product of tangent vectors returns surface normal
69
76
 
70
77
  normal.crossVectors( pu, pv ).normalize();
71
- normals.push( normal.x, normal.y, normal.z ); // uv
78
+ normals.push( normal.x, normal.y, normal.z );
79
+
80
+ // uv
72
81
 
73
82
  uvs.push( u, v );
74
83
 
75
84
  }
76
85
 
77
- } // generate indices
86
+ }
78
87
 
88
+ // generate indices
79
89
 
80
90
  for ( let i = 0; i < stacks; i ++ ) {
81
91
 
@@ -84,15 +94,18 @@
84
94
  const a = i * sliceCount + j;
85
95
  const b = i * sliceCount + j + 1;
86
96
  const c = ( i + 1 ) * sliceCount + j + 1;
87
- const d = ( i + 1 ) * sliceCount + j; // faces one and two
97
+ const d = ( i + 1 ) * sliceCount + j;
98
+
99
+ // faces one and two
88
100
 
89
101
  indices.push( a, b, d );
90
102
  indices.push( b, c, d );
91
103
 
92
104
  }
93
105
 
94
- } // build geometry
106
+ }
95
107
 
108
+ // build geometry
96
109
 
97
110
  this.setIndex( indices );
98
111
  this.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );