@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
@@ -1,13 +1,9 @@
1
1
  ( function () {
2
2
 
3
3
  const _cameraToLightMatrix = new THREE.Matrix4();
4
-
5
4
  const _lightSpaceFrustum = new THREE.CSMFrustum();
6
-
7
5
  const _center = new THREE.Vector3();
8
-
9
6
  const _bbox = new THREE.Box3();
10
-
11
7
  const _uniformArray = [];
12
8
  const _logArray = [];
13
9
  class CSM {
@@ -39,7 +35,6 @@
39
35
  this.injectInclude();
40
36
 
41
37
  }
42
-
43
38
  createLights() {
44
39
 
45
40
  for ( let i = 0; i < this.cascades; i ++ ) {
@@ -58,7 +53,6 @@
58
53
  }
59
54
 
60
55
  }
61
-
62
56
  initCascades() {
63
57
 
64
58
  const camera = this.camera;
@@ -67,24 +61,22 @@
67
61
  this.mainFrustum.split( this.breaks, this.frustums );
68
62
 
69
63
  }
70
-
71
64
  updateShadowBounds() {
72
65
 
73
66
  const frustums = this.frustums;
74
-
75
67
  for ( let i = 0; i < frustums.length; i ++ ) {
76
68
 
77
69
  const light = this.lights[ i ];
78
70
  const shadowCam = light.shadow.camera;
79
- const frustum = this.frustums[ i ]; // Get the two points that represent that furthest points on the frustum assuming
71
+ const frustum = this.frustums[ i ];
72
+
73
+ // Get the two points that represent that furthest points on the frustum assuming
80
74
  // that's either the diagonal across the far plane or the diagonal across the whole
81
75
  // frustum itself.
82
-
83
76
  const nearVerts = frustum.vertices.near;
84
77
  const farVerts = frustum.vertices.far;
85
78
  const point1 = farVerts[ 0 ];
86
79
  let point2;
87
-
88
80
  if ( point1.distanceTo( farVerts[ 2 ] ) > point1.distanceTo( nearVerts[ 2 ] ) ) {
89
81
 
90
82
  point2 = farVerts[ 2 ];
@@ -96,7 +88,6 @@
96
88
  }
97
89
 
98
90
  let squaredBBWidth = point1.distanceTo( point2 );
99
-
100
91
  if ( this.fade ) {
101
92
 
102
93
  // expand the shadow extents by the fade margin if fade is enabled.
@@ -117,27 +108,22 @@
117
108
  }
118
109
 
119
110
  }
120
-
121
111
  getBreaks() {
122
112
 
123
113
  const camera = this.camera;
124
114
  const far = Math.min( camera.far, this.maxFar );
125
115
  this.breaks.length = 0;
126
-
127
116
  switch ( this.mode ) {
128
117
 
129
118
  case 'uniform':
130
119
  uniformSplit( this.cascades, camera.near, far, this.breaks );
131
120
  break;
132
-
133
121
  case 'logarithmic':
134
122
  logarithmicSplit( this.cascades, camera.near, far, this.breaks );
135
123
  break;
136
-
137
124
  case 'practical':
138
125
  practicalSplit( this.cascades, camera.near, far, 0.5, this.breaks );
139
126
  break;
140
-
141
127
  case 'custom':
142
128
  if ( this.customSplitsCallback === undefined ) console.error( 'CSM: Custom split scheme callback not defined.' );
143
129
  this.customSplitsCallback( this.cascades, camera.near, far, this.breaks );
@@ -175,7 +161,6 @@
175
161
  _logArray.length = 0;
176
162
  logarithmicSplit( amount, near, far, _logArray );
177
163
  uniformSplit( amount, near, far, _uniformArray );
178
-
179
164
  for ( let i = 1; i < amount; i ++ ) {
180
165
 
181
166
  target.push( THREE.MathUtils.lerp( _uniformArray[ i - 1 ], _logArray[ i - 1 ], lambda ) );
@@ -187,12 +172,10 @@
187
172
  }
188
173
 
189
174
  }
190
-
191
175
  update() {
192
176
 
193
177
  const camera = this.camera;
194
178
  const frustums = this.frustums;
195
-
196
179
  for ( let i = 0; i < frustums.length; i ++ ) {
197
180
 
198
181
  const light = this.lights[ i ];
@@ -200,31 +183,23 @@
200
183
  const texelWidth = ( shadowCam.right - shadowCam.left ) / this.shadowMapSize;
201
184
  const texelHeight = ( shadowCam.top - shadowCam.bottom ) / this.shadowMapSize;
202
185
  light.shadow.camera.updateMatrixWorld( true );
203
-
204
186
  _cameraToLightMatrix.multiplyMatrices( light.shadow.camera.matrixWorldInverse, camera.matrixWorld );
205
-
206
187
  frustums[ i ].toSpace( _cameraToLightMatrix, _lightSpaceFrustum );
207
188
  const nearVerts = _lightSpaceFrustum.vertices.near;
208
189
  const farVerts = _lightSpaceFrustum.vertices.far;
209
-
210
190
  _bbox.makeEmpty();
211
-
212
191
  for ( let j = 0; j < 4; j ++ ) {
213
192
 
214
193
  _bbox.expandByPoint( nearVerts[ j ] );
215
-
216
194
  _bbox.expandByPoint( farVerts[ j ] );
217
195
 
218
196
  }
219
197
 
220
198
  _bbox.getCenter( _center );
221
-
222
199
  _center.z = _bbox.max.z + this.lightMargin;
223
200
  _center.x = Math.floor( _center.x / texelWidth ) * texelWidth;
224
201
  _center.y = Math.floor( _center.y / texelHeight ) * texelHeight;
225
-
226
202
  _center.applyMatrix4( light.shadow.camera.matrixWorld );
227
-
228
203
  light.position.copy( _center );
229
204
  light.target.position.copy( _center );
230
205
  light.target.position.x += this.lightDirection.x;
@@ -234,20 +209,17 @@
234
209
  }
235
210
 
236
211
  }
237
-
238
212
  injectInclude() {
239
213
 
240
214
  THREE.ShaderChunk.lights_fragment_begin = THREE.CSMShader.lights_fragment_begin;
241
215
  THREE.ShaderChunk.lights_pars_begin = THREE.CSMShader.lights_pars_begin;
242
216
 
243
217
  }
244
-
245
218
  setupMaterial( material ) {
246
219
 
247
220
  material.defines = material.defines || {};
248
221
  material.defines.USE_CSM = 1;
249
222
  material.defines.CSM_CASCADES = this.cascades;
250
-
251
223
  if ( this.fade ) {
252
224
 
253
225
  material.defines.CSM_FADE = '';
@@ -257,7 +229,6 @@
257
229
  const breaksVec2 = [];
258
230
  const scope = this;
259
231
  const shaders = this.shaders;
260
-
261
232
  material.onBeforeCompile = function ( shader ) {
262
233
 
263
234
  const far = Math.min( scope.camera.far, scope.maxFar );
@@ -278,7 +249,6 @@
278
249
  shaders.set( material, null );
279
250
 
280
251
  }
281
-
282
252
  updateUniforms() {
283
253
 
284
254
  const far = Math.min( this.camera.far, this.maxFar );
@@ -309,7 +279,6 @@
309
279
  }, this );
310
280
 
311
281
  }
312
-
313
282
  getExtendedBreaks( target ) {
314
283
 
315
284
  while ( target.length < this.breaks.length ) {
@@ -319,7 +288,6 @@
319
288
  }
320
289
 
321
290
  target.length = this.breaks.length;
322
-
323
291
  for ( let i = 0; i < this.cascades; i ++ ) {
324
292
 
325
293
  const amount = this.breaks[ i ];
@@ -330,7 +298,6 @@
330
298
  }
331
299
 
332
300
  }
333
-
334
301
  updateFrustums() {
335
302
 
336
303
  this.getBreaks();
@@ -339,17 +306,16 @@
339
306
  this.updateUniforms();
340
307
 
341
308
  }
342
-
343
309
  remove() {
344
310
 
345
311
  for ( let i = 0; i < this.lights.length; i ++ ) {
346
312
 
313
+ this.parent.remove( this.lights[ i ].target );
347
314
  this.parent.remove( this.lights[ i ] );
348
315
 
349
316
  }
350
317
 
351
318
  }
352
-
353
319
  dispose() {
354
320
 
355
321
  const shaders = this.shaders;
@@ -359,7 +325,6 @@
359
325
  delete material.defines.USE_CSM;
360
326
  delete material.defines.CSM_CASCADES;
361
327
  delete material.defines.CSM_FADE;
362
-
363
328
  if ( shader !== null ) {
364
329
 
365
330
  delete shader.uniforms.CSM_cascades;
@@ -1,7 +1,6 @@
1
1
  ( function () {
2
2
 
3
3
  const inverseProjectionMatrix = new THREE.Matrix4();
4
-
5
4
  class CSMFrustum {
6
5
 
7
6
  constructor( data ) {
@@ -11,7 +10,6 @@
11
10
  near: [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ],
12
11
  far: [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ]
13
12
  };
14
-
15
13
  if ( data.projectionMatrix !== undefined ) {
16
14
 
17
15
  this.setFromProjectionMatrix( data.projectionMatrix, data.maxFar || 10000 );
@@ -19,11 +17,12 @@
19
17
  }
20
18
 
21
19
  }
22
-
23
20
  setFromProjectionMatrix( projectionMatrix, maxFar ) {
24
21
 
25
22
  const isOrthographic = projectionMatrix.elements[ 2 * 4 + 3 ] === 0;
26
- inverseProjectionMatrix.copy( projectionMatrix ).invert(); // 3 --- 0 vertices.near/far order
23
+ inverseProjectionMatrix.copy( projectionMatrix ).invert();
24
+
25
+ // 3 --- 0 vertices.near/far order
27
26
  // | |
28
27
  // 2 --- 1
29
28
  // clip space spans from [-1, 1]
@@ -45,7 +44,6 @@
45
44
 
46
45
  v.applyMatrix4( inverseProjectionMatrix );
47
46
  const absZ = Math.abs( v.z );
48
-
49
47
  if ( isOrthographic ) {
50
48
 
51
49
  v.z *= Math.min( maxFar / absZ, 1.0 );
@@ -60,7 +58,6 @@
60
58
  return this.vertices;
61
59
 
62
60
  }
63
-
64
61
  split( breaks, target ) {
65
62
 
66
63
  while ( breaks.length > target.length ) {
@@ -70,11 +67,9 @@
70
67
  }
71
68
 
72
69
  target.length = breaks.length;
73
-
74
70
  for ( let i = 0; i < breaks.length; i ++ ) {
75
71
 
76
72
  const cascade = target[ i ];
77
-
78
73
  if ( i === 0 ) {
79
74
 
80
75
  for ( let j = 0; j < 4; j ++ ) {
@@ -114,7 +109,6 @@
114
109
  }
115
110
 
116
111
  }
117
-
118
112
  toSpace( cameraMatrix, target ) {
119
113
 
120
114
  for ( let i = 0; i < 4; i ++ ) {
@@ -22,7 +22,6 @@
22
22
  this.shadowLines = [];
23
23
 
24
24
  }
25
-
26
25
  updateVisibility() {
27
26
 
28
27
  const displayFrustum = this.displayFrustum;
@@ -32,7 +31,6 @@
32
31
  const cascadeLines = this.cascadeLines;
33
32
  const cascadePlanes = this.cascadePlanes;
34
33
  const shadowLines = this.shadowLines;
35
-
36
34
  for ( let i = 0, l = cascadeLines.length; i < l; i ++ ) {
37
35
 
38
36
  const cascadeLine = cascadeLines[ i ];
@@ -47,7 +45,6 @@
47
45
  frustumLines.visible = displayFrustum;
48
46
 
49
47
  }
50
-
51
48
  update() {
52
49
 
53
50
  const csm = this.csm;
@@ -65,7 +62,6 @@
65
62
  this.quaternion.copy( camera.quaternion );
66
63
  this.scale.copy( camera.scale );
67
64
  this.updateMatrixWorld( true );
68
-
69
65
  while ( cascadeLines.length > cascades ) {
70
66
 
71
67
  this.remove( cascadeLines.pop() );
@@ -137,6 +133,30 @@
137
133
  frustumLinePositions.needsUpdate = true;
138
134
 
139
135
  }
136
+ dispose() {
137
+
138
+ const frustumLines = this.frustumLines;
139
+ const cascadeLines = this.cascadeLines;
140
+ const cascadePlanes = this.cascadePlanes;
141
+ const shadowLines = this.shadowLines;
142
+ frustumLines.geometry.dispose();
143
+ frustumLines.material.dispose();
144
+ const cascades = this.csm.cascades;
145
+ for ( let i = 0; i < cascades; i ++ ) {
146
+
147
+ const cascadeLine = cascadeLines[ i ];
148
+ const cascadePlane = cascadePlanes[ i ];
149
+ const shadowLineGroup = shadowLines[ i ];
150
+ const shadowLine = shadowLineGroup.children[ 0 ];
151
+ cascadeLine.dispose(); // THREE.Box3Helper
152
+
153
+ cascadePlane.geometry.dispose();
154
+ cascadePlane.material.dispose();
155
+ shadowLine.dispose(); // THREE.Box3Helper
156
+
157
+ }
158
+
159
+ }
140
160
 
141
161
  }
142
162
 
@@ -1,9 +1,7 @@
1
1
  ( function () {
2
2
 
3
3
  const CSMShader = {
4
- lights_fragment_begin:
5
- /* glsl */
6
- `
4
+ lights_fragment_begin: /* glsl */`
7
5
  GeometricContext geometry;
8
6
 
9
7
  geometry.position = - vViewPosition;
@@ -241,9 +239,7 @@ IncidentLight directLight;
241
239
 
242
240
  #endif
243
241
  `,
244
- lights_pars_begin:
245
- /* glsl */
246
- `
242
+ lights_pars_begin: /* glsl */`
247
243
  #if defined( USE_CSM ) && defined( CSM_CASCADES )
248
244
  uniform vec2 CSM_cascades[CSM_CASCADES];
249
245
  uniform float cameraNear;
@@ -9,6 +9,7 @@
9
9
  * http://www.mi.sanu.ac.rs/vismath/taylorapril2011/Taylor.pdf
10
10
  * https://prideout.net/blog/old/blog/index.html@p=44.html
11
11
  */
12
+
12
13
  // GrannyKnot
13
14
 
14
15
  class GrannyKnot extends THREE.Curve {
@@ -24,8 +25,9 @@
24
25
 
25
26
  }
26
27
 
27
- } // HeartCurve
28
+ }
28
29
 
30
+ // HeartCurve
29
31
 
30
32
  class HeartCurve extends THREE.Curve {
31
33
 
@@ -35,7 +37,6 @@
35
37
  this.scale = scale;
36
38
 
37
39
  }
38
-
39
40
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
40
41
 
41
42
  const point = optionalTarget;
@@ -47,8 +48,9 @@
47
48
 
48
49
  }
49
50
 
50
- } // Viviani's THREE.Curve
51
+ }
51
52
 
53
+ // Viviani's THREE.Curve
52
54
 
53
55
  class VivianiCurve extends THREE.Curve {
54
56
 
@@ -58,12 +60,10 @@
58
60
  this.scale = scale;
59
61
 
60
62
  }
61
-
62
63
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
63
64
 
64
65
  const point = optionalTarget;
65
66
  t = t * 4 * Math.PI; // normalized to 0..1
66
-
67
67
  const a = this.scale / 2;
68
68
  const x = a * ( 1 + Math.cos( t ) );
69
69
  const y = a * Math.sin( t );
@@ -72,8 +72,9 @@
72
72
 
73
73
  }
74
74
 
75
- } // KnotCurve
75
+ }
76
76
 
77
+ // KnotCurve
77
78
 
78
79
  class KnotCurve extends THREE.Curve {
79
80
 
@@ -90,8 +91,9 @@
90
91
 
91
92
  }
92
93
 
93
- } // HelixCurve
94
+ }
94
95
 
96
+ // HelixCurve
95
97
 
96
98
  class HelixCurve extends THREE.Curve {
97
99
 
@@ -99,7 +101,6 @@
99
101
 
100
102
  const point = optionalTarget;
101
103
  const a = 30; // radius
102
-
103
104
  const b = 150; // height
104
105
 
105
106
  const t2 = 2 * Math.PI * t * b / 30;
@@ -110,8 +111,9 @@
110
111
 
111
112
  }
112
113
 
113
- } // TrefoilKnot
114
+ }
114
115
 
116
+ // TrefoilKnot
115
117
 
116
118
  class TrefoilKnot extends THREE.Curve {
117
119
 
@@ -121,7 +123,6 @@
121
123
  this.scale = scale;
122
124
 
123
125
  }
124
-
125
126
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
126
127
 
127
128
  const point = optionalTarget;
@@ -133,8 +134,9 @@
133
134
 
134
135
  }
135
136
 
136
- } // TorusKnot
137
+ }
137
138
 
139
+ // TorusKnot
138
140
 
139
141
  class TorusKnot extends THREE.Curve {
140
142
 
@@ -144,7 +146,6 @@
144
146
  this.scale = scale;
145
147
 
146
148
  }
147
-
148
149
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
149
150
 
150
151
  const point = optionalTarget;
@@ -158,8 +159,9 @@
158
159
 
159
160
  }
160
161
 
161
- } // CinquefoilKnot
162
+ }
162
163
 
164
+ // CinquefoilKnot
163
165
 
164
166
  class CinquefoilKnot extends THREE.Curve {
165
167
 
@@ -169,7 +171,6 @@
169
171
  this.scale = scale;
170
172
 
171
173
  }
172
-
173
174
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
174
175
 
175
176
  const point = optionalTarget;
@@ -183,8 +184,9 @@
183
184
 
184
185
  }
185
186
 
186
- } // TrefoilPolynomialKnot
187
+ }
187
188
 
189
+ // TrefoilPolynomialKnot
188
190
 
189
191
  class TrefoilPolynomialKnot extends THREE.Curve {
190
192
 
@@ -194,7 +196,6 @@
194
196
  this.scale = scale;
195
197
 
196
198
  }
197
-
198
199
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
199
200
 
200
201
  const point = optionalTarget;
@@ -207,14 +208,14 @@
207
208
  }
208
209
 
209
210
  }
210
-
211
211
  function scaleTo( x, y, t ) {
212
212
 
213
213
  const r = y - x;
214
214
  return t * r + x;
215
215
 
216
- } // FigureEightPolynomialKnot
216
+ }
217
217
 
218
+ // FigureEightPolynomialKnot
218
219
 
219
220
  class FigureEightPolynomialKnot extends THREE.Curve {
220
221
 
@@ -224,7 +225,6 @@
224
225
  this.scale = scale;
225
226
 
226
227
  }
227
-
228
228
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
229
229
 
230
230
  const point = optionalTarget;
@@ -236,8 +236,9 @@
236
236
 
237
237
  }
238
238
 
239
- } // DecoratedTorusKnot4a
239
+ }
240
240
 
241
+ // DecoratedTorusKnot4a
241
242
 
242
243
  class DecoratedTorusKnot4a extends THREE.Curve {
243
244
 
@@ -247,7 +248,6 @@
247
248
  this.scale = scale;
248
249
 
249
250
  }
250
-
251
251
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
252
252
 
253
253
  const point = optionalTarget;
@@ -259,8 +259,9 @@
259
259
 
260
260
  }
261
261
 
262
- } // DecoratedTorusKnot4b
262
+ }
263
263
 
264
+ // DecoratedTorusKnot4b
264
265
 
265
266
  class DecoratedTorusKnot4b extends THREE.Curve {
266
267
 
@@ -270,7 +271,6 @@
270
271
  this.scale = scale;
271
272
 
272
273
  }
273
-
274
274
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
275
275
 
276
276
  const point = optionalTarget;
@@ -282,8 +282,9 @@
282
282
 
283
283
  }
284
284
 
285
- } // DecoratedTorusKnot5a
285
+ }
286
286
 
287
+ // DecoratedTorusKnot5a
287
288
 
288
289
  class DecoratedTorusKnot5a extends THREE.Curve {
289
290
 
@@ -293,7 +294,6 @@
293
294
  this.scale = scale;
294
295
 
295
296
  }
296
-
297
297
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
298
298
 
299
299
  const point = optionalTarget;
@@ -305,8 +305,9 @@
305
305
 
306
306
  }
307
307
 
308
- } // DecoratedTorusKnot5c
308
+ }
309
309
 
310
+ // DecoratedTorusKnot5c
310
311
 
311
312
  class DecoratedTorusKnot5c extends THREE.Curve {
312
313
 
@@ -316,7 +317,6 @@
316
317
  this.scale = scale;
317
318
 
318
319
  }
319
-
320
320
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
321
321
 
322
322
  const point = optionalTarget;
@@ -11,24 +11,15 @@
11
11
 
12
12
  class NURBSCurve extends THREE.Curve {
13
13
 
14
- constructor( degree, knots
15
- /* array of reals */
16
- , controlPoints
17
- /* array of Vector(2|3|4) */
18
- , startKnot
19
- /* index in knots */
20
- , endKnot
21
- /* index in knots */
22
- ) {
14
+ constructor( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */, startKnot /* index in knots */, endKnot /* index in knots */ ) {
23
15
 
24
16
  super();
25
17
  this.degree = degree;
26
18
  this.knots = knots;
27
- this.controlPoints = []; // Used by periodic NURBS to remove hidden spans
28
-
19
+ this.controlPoints = [];
20
+ // Used by periodic NURBS to remove hidden spans
29
21
  this.startKnot = startKnot || 0;
30
22
  this.endKnot = endKnot || this.knots.length - 1;
31
-
32
23
  for ( let i = 0; i < controlPoints.length; ++ i ) {
33
24
 
34
25
  // ensure THREE.Vector4 for control points
@@ -38,15 +29,13 @@
38
29
  }
39
30
 
40
31
  }
41
-
42
32
  getPoint( t, optionalTarget = new THREE.Vector3() ) {
43
33
 
44
34
  const point = optionalTarget;
45
35
  const u = this.knots[ this.startKnot ] + t * ( this.knots[ this.endKnot ] - this.knots[ this.startKnot ] ); // linear mapping t->u
46
- // following results in (wx, wy, wz, w) homogeneous point
47
36
 
37
+ // following results in (wx, wy, wz, w) homogeneous point
48
38
  const hpoint = THREE.NURBSUtils.calcBSplinePoint( this.degree, this.knots, this.controlPoints, u );
49
-
50
39
  if ( hpoint.w !== 1.0 ) {
51
40
 
52
41
  // project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
@@ -57,7 +46,6 @@
57
46
  return point.set( hpoint.x, hpoint.y, hpoint.z );
58
47
 
59
48
  }
60
-
61
49
  getTangent( t, optionalTarget = new THREE.Vector3() ) {
62
50
 
63
51
  const tangent = optionalTarget;
@@ -8,11 +8,7 @@
8
8
 
9
9
  class NURBSSurface {
10
10
 
11
- constructor( degree1, degree2, knots1, knots2
12
- /* arrays of reals */
13
- , controlPoints
14
- /* array^2 of Vector(2|3|4) */
15
- ) {
11
+ constructor( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) {
16
12
 
17
13
  this.degree1 = degree1;
18
14
  this.degree2 = degree2;
@@ -20,12 +16,12 @@
20
16
  this.knots2 = knots2;
21
17
  this.controlPoints = [];
22
18
  const len1 = knots1.length - degree1 - 1;
23
- const len2 = knots2.length - degree2 - 1; // ensure THREE.Vector4 for control points
19
+ const len2 = knots2.length - degree2 - 1;
24
20
 
21
+ // ensure THREE.Vector4 for control points
25
22
  for ( let i = 0; i < len1; ++ i ) {
26
23
 
27
24
  this.controlPoints[ i ] = [];
28
-
29
25
  for ( let j = 0; j < len2; ++ j ) {
30
26
 
31
27
  const point = controlPoints[ i ][ j ];
@@ -36,11 +32,9 @@
36
32
  }
37
33
 
38
34
  }
39
-
40
35
  getPoint( t1, t2, target ) {
41
36
 
42
37
  const u = this.knots1[ 0 ] + t1 * ( this.knots1[ this.knots1.length - 1 ] - this.knots1[ 0 ] ); // linear mapping t1->u
43
-
44
38
  const v = this.knots2[ 0 ] + t2 * ( this.knots2[ this.knots2.length - 1 ] - this.knots2[ 0 ] ); // linear mapping t2->u
45
39
 
46
40
  THREE.NURBSUtils.calcSurfacePoint( this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v, target );