@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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Port from https://github.com/mapbox/earcut (v2.2.2)
2
+ * Port from https://github.com/mapbox/earcut (v2.2.4)
3
3
  */
4
4
 
5
5
  const Earcut = {
@@ -36,11 +36,11 @@ const Earcut = {
36
36
 
37
37
  // minX, minY and invSize are later used to transform coords into integers for z-order calculation
38
38
  invSize = Math.max( maxX - minX, maxY - minY );
39
- invSize = invSize !== 0 ? 1 / invSize : 0;
39
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
40
40
 
41
41
  }
42
42
 
43
- earcutLinked( outerNode, triangles, dim, minX, minY, invSize );
43
+ earcutLinked( outerNode, triangles, dim, minX, minY, invSize, 0 );
44
44
 
45
45
  return triangles;
46
46
 
@@ -125,9 +125,9 @@ function earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) {
125
125
  if ( invSize ? isEarHashed( ear, minX, minY, invSize ) : isEar( ear ) ) {
126
126
 
127
127
  // cut off the triangle
128
- triangles.push( prev.i / dim );
129
- triangles.push( ear.i / dim );
130
- triangles.push( next.i / dim );
128
+ triangles.push( prev.i / dim | 0 );
129
+ triangles.push( ear.i / dim | 0 );
130
+ triangles.push( next.i / dim | 0 );
131
131
 
132
132
  removeNode( ear );
133
133
 
@@ -182,11 +182,19 @@ function isEar( ear ) {
182
182
  if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
183
183
 
184
184
  // now make sure we don't have other points inside the potential ear
185
- let p = ear.next.next;
185
+ const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
186
186
 
187
- while ( p !== ear.prev ) {
187
+ // triangle bbox; min & max are calculated like this for speed
188
+ const x0 = ax < bx ? ( ax < cx ? ax : cx ) : ( bx < cx ? bx : cx ),
189
+ y0 = ay < by ? ( ay < cy ? ay : cy ) : ( by < cy ? by : cy ),
190
+ x1 = ax > bx ? ( ax > cx ? ax : cx ) : ( bx > cx ? bx : cx ),
191
+ y1 = ay > by ? ( ay > cy ? ay : cy ) : ( by > cy ? by : cy );
192
+
193
+ let p = c.next;
194
+ while ( p !== a ) {
188
195
 
189
- if ( pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) &&
196
+ if ( p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
197
+ pointInTriangle( ax, ay, bx, by, cx, cy, p.x, p.y ) &&
190
198
  area( p.prev, p, p.next ) >= 0 ) return false;
191
199
  p = p.next;
192
200
 
@@ -204,15 +212,17 @@ function isEarHashed( ear, minX, minY, invSize ) {
204
212
 
205
213
  if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
206
214
 
215
+ const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
216
+
207
217
  // triangle bbox; min & max are calculated like this for speed
208
- const minTX = a.x < b.x ? ( a.x < c.x ? a.x : c.x ) : ( b.x < c.x ? b.x : c.x ),
209
- minTY = a.y < b.y ? ( a.y < c.y ? a.y : c.y ) : ( b.y < c.y ? b.y : c.y ),
210
- maxTX = a.x > b.x ? ( a.x > c.x ? a.x : c.x ) : ( b.x > c.x ? b.x : c.x ),
211
- maxTY = a.y > b.y ? ( a.y > c.y ? a.y : c.y ) : ( b.y > c.y ? b.y : c.y );
218
+ const x0 = ax < bx ? ( ax < cx ? ax : cx ) : ( bx < cx ? bx : cx ),
219
+ y0 = ay < by ? ( ay < cy ? ay : cy ) : ( by < cy ? by : cy ),
220
+ x1 = ax > bx ? ( ax > cx ? ax : cx ) : ( bx > cx ? bx : cx ),
221
+ y1 = ay > by ? ( ay > cy ? ay : cy ) : ( by > cy ? by : cy );
212
222
 
213
223
  // z-order range for the current triangle bbox;
214
- const minZ = zOrder( minTX, minTY, minX, minY, invSize ),
215
- maxZ = zOrder( maxTX, maxTY, minX, minY, invSize );
224
+ const minZ = zOrder( x0, y0, minX, minY, invSize ),
225
+ maxZ = zOrder( x1, y1, minX, minY, invSize );
216
226
 
217
227
  let p = ear.prevZ,
218
228
  n = ear.nextZ;
@@ -220,14 +230,12 @@ function isEarHashed( ear, minX, minY, invSize ) {
220
230
  // look for points inside the triangle in both directions
221
231
  while ( p && p.z >= minZ && n && n.z <= maxZ ) {
222
232
 
223
- if ( p !== ear.prev && p !== ear.next &&
224
- pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) &&
225
- area( p.prev, p, p.next ) >= 0 ) return false;
233
+ if ( p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
234
+ pointInTriangle( ax, ay, bx, by, cx, cy, p.x, p.y ) && area( p.prev, p, p.next ) >= 0 ) return false;
226
235
  p = p.prevZ;
227
236
 
228
- if ( n !== ear.prev && n !== ear.next &&
229
- pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y ) &&
230
- area( n.prev, n, n.next ) >= 0 ) return false;
237
+ if ( n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
238
+ pointInTriangle( ax, ay, bx, by, cx, cy, n.x, n.y ) && area( n.prev, n, n.next ) >= 0 ) return false;
231
239
  n = n.nextZ;
232
240
 
233
241
  }
@@ -235,9 +243,8 @@ function isEarHashed( ear, minX, minY, invSize ) {
235
243
  // look for remaining points in decreasing z-order
236
244
  while ( p && p.z >= minZ ) {
237
245
 
238
- if ( p !== ear.prev && p !== ear.next &&
239
- pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) &&
240
- area( p.prev, p, p.next ) >= 0 ) return false;
246
+ if ( p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
247
+ pointInTriangle( ax, ay, bx, by, cx, cy, p.x, p.y ) && area( p.prev, p, p.next ) >= 0 ) return false;
241
248
  p = p.prevZ;
242
249
 
243
250
  }
@@ -245,9 +252,8 @@ function isEarHashed( ear, minX, minY, invSize ) {
245
252
  // look for remaining points in increasing z-order
246
253
  while ( n && n.z <= maxZ ) {
247
254
 
248
- if ( n !== ear.prev && n !== ear.next &&
249
- pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y ) &&
250
- area( n.prev, n, n.next ) >= 0 ) return false;
255
+ if ( n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
256
+ pointInTriangle( ax, ay, bx, by, cx, cy, n.x, n.y ) && area( n.prev, n, n.next ) >= 0 ) return false;
251
257
  n = n.nextZ;
252
258
 
253
259
  }
@@ -267,9 +273,9 @@ function cureLocalIntersections( start, triangles, dim ) {
267
273
 
268
274
  if ( ! equals( a, b ) && intersects( a, p, p.next, b ) && locallyInside( a, b ) && locallyInside( b, a ) ) {
269
275
 
270
- triangles.push( a.i / dim );
271
- triangles.push( p.i / dim );
272
- triangles.push( b.i / dim );
276
+ triangles.push( a.i / dim | 0 );
277
+ triangles.push( p.i / dim | 0 );
278
+ triangles.push( b.i / dim | 0 );
273
279
 
274
280
  // remove two nodes involved
275
281
  removeNode( p );
@@ -307,8 +313,8 @@ function splitEarcut( start, triangles, dim, minX, minY, invSize ) {
307
313
  c = filterPoints( c, c.next );
308
314
 
309
315
  // run earcut on each half
310
- earcutLinked( a, triangles, dim, minX, minY, invSize );
311
- earcutLinked( c, triangles, dim, minX, minY, invSize );
316
+ earcutLinked( a, triangles, dim, minX, minY, invSize, 0 );
317
+ earcutLinked( c, triangles, dim, minX, minY, invSize, 0 );
312
318
  return;
313
319
 
314
320
  }
@@ -344,8 +350,7 @@ function eliminateHoles( data, holeIndices, outerNode, dim ) {
344
350
  // process holes from left to right
345
351
  for ( i = 0; i < queue.length; i ++ ) {
346
352
 
347
- eliminateHole( queue[ i ], outerNode );
348
- outerNode = filterPoints( outerNode, outerNode.next );
353
+ outerNode = eliminateHole( queue[ i ], outerNode );
349
354
 
350
355
  }
351
356
 
@@ -362,26 +367,29 @@ function compareX( a, b ) {
362
367
  // find a bridge between vertices that connects hole with an outer ring and link it
363
368
  function eliminateHole( hole, outerNode ) {
364
369
 
365
- outerNode = findHoleBridge( hole, outerNode );
366
- if ( outerNode ) {
367
-
368
- const b = splitPolygon( outerNode, hole );
370
+ const bridge = findHoleBridge( hole, outerNode );
371
+ if ( ! bridge ) {
369
372
 
370
- // filter collinear points around the cuts
371
- filterPoints( outerNode, outerNode.next );
372
- filterPoints( b, b.next );
373
+ return outerNode;
373
374
 
374
375
  }
375
376
 
377
+ const bridgeReverse = splitPolygon( bridge, hole );
378
+
379
+ // filter collinear points around the cuts
380
+ filterPoints( bridgeReverse, bridgeReverse.next );
381
+ return filterPoints( bridge, bridge.next );
382
+
376
383
  }
377
384
 
378
385
  // David Eberly's algorithm for finding a bridge between hole and outer polygon
379
386
  function findHoleBridge( hole, outerNode ) {
380
387
 
381
- let p = outerNode;
382
- const hx = hole.x;
383
- const hy = hole.y;
384
- let qx = - Infinity, m;
388
+ let p = outerNode,
389
+ qx = - Infinity,
390
+ m;
391
+
392
+ const hx = hole.x, hy = hole.y;
385
393
 
386
394
  // find a segment intersected by a ray from the hole's leftmost point to the left;
387
395
  // segment's endpoint with lesser x will be potential connection point
@@ -393,14 +401,8 @@ function findHoleBridge( hole, outerNode ) {
393
401
  if ( x <= hx && x > qx ) {
394
402
 
395
403
  qx = x;
396
- if ( x === hx ) {
397
-
398
- if ( hy === p.y ) return p;
399
- if ( hy === p.next.y ) return p.next;
400
-
401
- }
402
-
403
404
  m = p.x < p.next.x ? p : p.next;
405
+ if ( x === hx ) return m; // hole touches outer segment; pick leftmost endpoint
404
406
 
405
407
  }
406
408
 
@@ -412,8 +414,6 @@ function findHoleBridge( hole, outerNode ) {
412
414
 
413
415
  if ( ! m ) return null;
414
416
 
415
- if ( hx === qx ) return m; // hole touches outer segment; pick leftmost endpoint
416
-
417
417
  // look for points inside the triangle of hole point, segment intersection and endpoint;
418
418
  // if there are no points found, we have a valid connection;
419
419
  // otherwise choose the point of the minimum angle with the ray as connection point
@@ -462,7 +462,7 @@ function indexCurve( start, minX, minY, invSize ) {
462
462
  let p = start;
463
463
  do {
464
464
 
465
- if ( p.z === null ) p.z = zOrder( p.x, p.y, minX, minY, invSize );
465
+ if ( p.z === 0 ) p.z = zOrder( p.x, p.y, minX, minY, invSize );
466
466
  p.prevZ = p.prev;
467
467
  p.nextZ = p.next;
468
468
  p = p.next;
@@ -546,8 +546,8 @@ function sortLinked( list ) {
546
546
  function zOrder( x, y, minX, minY, invSize ) {
547
547
 
548
548
  // coords are transformed into non-negative 15-bit integer range
549
- x = 32767 * ( x - minX ) * invSize;
550
- y = 32767 * ( y - minY ) * invSize;
549
+ x = ( x - minX ) * invSize | 0;
550
+ y = ( y - minY ) * invSize | 0;
551
551
 
552
552
  x = ( x | ( x << 8 ) ) & 0x00FF00FF;
553
553
  x = ( x | ( x << 4 ) ) & 0x0F0F0F0F;
@@ -582,19 +582,19 @@ function getLeftmost( start ) {
582
582
  // check if a point lies within a convex triangle
583
583
  function pointInTriangle( ax, ay, bx, by, cx, cy, px, py ) {
584
584
 
585
- return ( cx - px ) * ( ay - py ) - ( ax - px ) * ( cy - py ) >= 0 &&
586
- ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 &&
587
- ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0;
585
+ return ( cx - px ) * ( ay - py ) >= ( ax - px ) * ( cy - py ) &&
586
+ ( ax - px ) * ( by - py ) >= ( bx - px ) * ( ay - py ) &&
587
+ ( bx - px ) * ( cy - py ) >= ( cx - px ) * ( by - py );
588
588
 
589
589
  }
590
590
 
591
591
  // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
592
592
  function isValidDiagonal( a, b ) {
593
593
 
594
- return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && // doesn't intersect other edges
595
- ( locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ) && // locally visible
596
- ( area( a.prev, a, b.prev ) || area( a, b.prev, b ) ) || // does not create opposite-facing sectors
597
- equals( a, b ) && area( a.prev, a, a.next ) > 0 && area( b.prev, b, b.next ) > 0 ); // special zero-length case
594
+ return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && // dones't intersect other edges
595
+ ( locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ) && // locally visible
596
+ ( area( a.prev, a, b.prev ) || area( a, b.prev, b ) ) || // does not create opposite-facing sectors
597
+ equals( a, b ) && area( a.prev, a, a.next ) > 0 && area( b.prev, b, b.next ) > 0 ); // special zero-length case
598
598
 
599
599
  }
600
600
 
@@ -651,7 +651,7 @@ function intersectsPolygon( a, b ) {
651
651
  do {
652
652
 
653
653
  if ( p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
654
- intersects( p, p.next, a, b ) ) return true;
654
+ intersects( p, p.next, a, b ) ) return true;
655
655
  p = p.next;
656
656
 
657
657
  } while ( p !== a );
@@ -679,7 +679,7 @@ function middleInside( a, b ) {
679
679
  do {
680
680
 
681
681
  if ( ( ( p.y > py ) !== ( p.next.y > py ) ) && p.next.y !== p.y &&
682
- ( px < ( p.next.x - p.x ) * ( py - p.y ) / ( p.next.y - p.y ) + p.x ) )
682
+ ( px < ( p.next.x - p.x ) * ( py - p.y ) / ( p.next.y - p.y ) + p.x ) )
683
683
  inside = ! inside;
684
684
  p = p.next;
685
685
 
@@ -761,7 +761,7 @@ function Node( i, x, y ) {
761
761
  this.next = null;
762
762
 
763
763
  // z-order curve value
764
- this.z = null;
764
+ this.z = 0;
765
765
 
766
766
  // previous and next nodes in z-order
767
767
  this.prevZ = null;
@@ -16,13 +16,14 @@ class DirectionalLightHelper extends Object3D {
16
16
  super();
17
17
 
18
18
  this.light = light;
19
- this.light.updateMatrixWorld();
20
19
 
21
20
  this.matrix = light.matrixWorld;
22
21
  this.matrixAutoUpdate = false;
23
22
 
24
23
  this.color = color;
25
24
 
25
+ this.type = 'DirectionalLightHelper';
26
+
26
27
  if ( size === undefined ) size = 1;
27
28
 
28
29
  let geometry = new BufferGeometry();
@@ -60,6 +61,9 @@ class DirectionalLightHelper extends Object3D {
60
61
 
61
62
  update() {
62
63
 
64
+ this.light.updateWorldMatrix( true, false );
65
+ this.light.target.updateWorldMatrix( true, false );
66
+
63
67
  _v1.setFromMatrixPosition( this.light.matrixWorld );
64
68
  _v2.setFromMatrixPosition( this.light.target.matrixWorld );
65
69
  _v3.subVectors( _v2, _v1 );
@@ -17,13 +17,14 @@ class HemisphereLightHelper extends Object3D {
17
17
  super();
18
18
 
19
19
  this.light = light;
20
- this.light.updateMatrixWorld();
21
20
 
22
21
  this.matrix = light.matrixWorld;
23
22
  this.matrixAutoUpdate = false;
24
23
 
25
24
  this.color = color;
26
25
 
26
+ this.type = 'HemisphereLightHelper';
27
+
27
28
  const geometry = new OctahedronGeometry( size );
28
29
  geometry.rotateY( Math.PI * 0.5 );
29
30
 
@@ -75,6 +76,8 @@ class HemisphereLightHelper extends Object3D {
75
76
 
76
77
  }
77
78
 
79
+ this.light.updateWorldMatrix( true, false );
80
+
78
81
  mesh.lookAt( _vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );
79
82
 
80
83
  }
@@ -12,7 +12,6 @@ class PointLightHelper extends Mesh {
12
12
  super( geometry, material );
13
13
 
14
14
  this.light = light;
15
- this.light.updateMatrixWorld();
16
15
 
17
16
  this.color = color;
18
17
 
@@ -58,6 +57,8 @@ class PointLightHelper extends Mesh {
58
57
 
59
58
  update() {
60
59
 
60
+ this.light.updateWorldMatrix( true, false );
61
+
61
62
  if ( this.color !== undefined ) {
62
63
 
63
64
  this.material.color.set( this.color );
@@ -14,13 +14,14 @@ class SpotLightHelper extends Object3D {
14
14
  super();
15
15
 
16
16
  this.light = light;
17
- this.light.updateMatrixWorld();
18
17
 
19
18
  this.matrix = light.matrixWorld;
20
19
  this.matrixAutoUpdate = false;
21
20
 
22
21
  this.color = color;
23
22
 
23
+ this.type = 'SpotLightHelper';
24
+
24
25
  const geometry = new BufferGeometry();
25
26
 
26
27
  const positions = [
@@ -63,7 +64,8 @@ class SpotLightHelper extends Object3D {
63
64
 
64
65
  update() {
65
66
 
66
- this.light.updateMatrixWorld();
67
+ this.light.updateWorldMatrix( true, false );
68
+ this.light.target.updateWorldMatrix( true, false );
67
69
 
68
70
  const coneLength = this.light.distance ? this.light.distance : 1000;
69
71
  const coneWidth = coneLength * Math.tan( this.light.angle );
@@ -3,7 +3,7 @@ import { PointLightShadow } from './PointLightShadow.js';
3
3
 
4
4
  class PointLight extends Light {
5
5
 
6
- constructor( color, intensity, distance = 0, decay = 1 ) {
6
+ constructor( color, intensity, distance = 0, decay = 2 ) {
7
7
 
8
8
  super( color, intensity );
9
9
 
@@ -12,7 +12,7 @@ class PointLight extends Light {
12
12
  this.type = 'PointLight';
13
13
 
14
14
  this.distance = distance;
15
- this.decay = decay; // for physically correct lights, should be 2.
15
+ this.decay = decay;
16
16
 
17
17
  this.shadow = new PointLightShadow();
18
18
 
@@ -4,7 +4,7 @@ import { Object3D } from '../core/Object3D.js';
4
4
 
5
5
  class SpotLight extends Light {
6
6
 
7
- constructor( color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1 ) {
7
+ constructor( color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 2 ) {
8
8
 
9
9
  super( color, intensity );
10
10
 
@@ -20,7 +20,7 @@ class SpotLight extends Light {
20
20
  this.distance = distance;
21
21
  this.angle = angle;
22
22
  this.penumbra = penumbra;
23
- this.decay = decay; // for physically correct lights, should be 2.
23
+ this.decay = decay;
24
24
 
25
25
  this.map = null;
26
26
 
@@ -109,7 +109,10 @@ class FileLoader extends Loader {
109
109
 
110
110
  const callbacks = loading[ url ];
111
111
  const reader = response.body.getReader();
112
- const contentLength = response.headers.get( 'Content-Length' );
112
+
113
+ // Nginx needs X-File-Size check
114
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
115
+ const contentLength = response.headers.get( 'Content-Length' ) || response.headers.get( 'X-File-Size' );
113
116
  const total = contentLength ? parseInt( contentLength ) : 0;
114
117
  const lengthComputable = total !== 0;
115
118
  let loaded = 0;
@@ -101,6 +101,8 @@ class ObjectLoader extends Loader {
101
101
 
102
102
  if ( metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry' ) {
103
103
 
104
+ if ( onError !== undefined ) onError( new Error( 'THREE.ObjectLoader: Can\'t load ' + url ) );
105
+
104
106
  console.error( 'THREE.ObjectLoader: Can\'t load ' + url );
105
107
  return;
106
108
 
@@ -780,6 +782,8 @@ class ObjectLoader extends Loader {
780
782
 
781
783
  }
782
784
 
785
+ if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
786
+
783
787
  break;
784
788
 
785
789
  case 'PerspectiveCamera':
@@ -1014,7 +1018,7 @@ class ObjectLoader extends Loader {
1014
1018
 
1015
1019
  if ( child !== undefined ) {
1016
1020
 
1017
- object.addLevel( child, level.distance );
1021
+ object.addLevel( child, level.distance, level.hysteresis );
1018
1022
 
1019
1023
  }
1020
1024
 
@@ -300,7 +300,7 @@ class Material extends EventDispatcher {
300
300
  if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;
301
301
  if ( this.thickness !== undefined ) data.thickness = this.thickness;
302
302
  if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
303
- if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance;
303
+ if ( this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity ) data.attenuationDistance = this.attenuationDistance;
304
304
  if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
305
305
 
306
306
  if ( this.size !== undefined ) data.size = this.size;
package/src/math/Color.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clamp, euclideanModulo, lerp } from './MathUtils.js';
2
2
  import { ColorManagement, SRGBToLinear, LinearToSRGB } from './ColorManagement.js';
3
- import { SRGBColorSpace, LinearSRGBColorSpace } from '../constants.js';
3
+ import { SRGBColorSpace } from '../constants.js';
4
4
 
5
5
  const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
6
6
  'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
@@ -117,7 +117,7 @@ class Color {
117
117
 
118
118
  }
119
119
 
120
- setRGB( r, g, b, colorSpace = LinearSRGBColorSpace ) {
120
+ setRGB( r, g, b, colorSpace = ColorManagement.workingColorSpace ) {
121
121
 
122
122
  this.r = r;
123
123
  this.g = g;
@@ -129,7 +129,7 @@ class Color {
129
129
 
130
130
  }
131
131
 
132
- setHSL( h, s, l, colorSpace = LinearSRGBColorSpace ) {
132
+ setHSL( h, s, l, colorSpace = ColorManagement.workingColorSpace ) {
133
133
 
134
134
  // h,s,l ranges are in 0.0 - 1.0
135
135
  h = euclideanModulo( h, 1 );
@@ -369,7 +369,7 @@ class Color {
369
369
 
370
370
  }
371
371
 
372
- getHSL( target, colorSpace = LinearSRGBColorSpace ) {
372
+ getHSL( target, colorSpace = ColorManagement.workingColorSpace ) {
373
373
 
374
374
  // h,s,l ranges are in 0.0 - 1.0
375
375
 
@@ -414,7 +414,7 @@ class Color {
414
414
 
415
415
  }
416
416
 
417
- getRGB( target, colorSpace = LinearSRGBColorSpace ) {
417
+ getRGB( target, colorSpace = ColorManagement.workingColorSpace ) {
418
418
 
419
419
  ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
420
420
 
@@ -231,12 +231,11 @@ class Matrix3 {
231
231
 
232
232
  }
233
233
 
234
- scale( sx, sy ) {
234
+ //
235
235
 
236
- const te = this.elements;
236
+ scale( sx, sy ) {
237
237
 
238
- te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;
239
- te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;
238
+ this.premultiply( _m3.makeScale( sx, sy ) );
240
239
 
241
240
  return this;
242
241
 
@@ -244,37 +243,71 @@ class Matrix3 {
244
243
 
245
244
  rotate( theta ) {
246
245
 
246
+ this.premultiply( _m3.makeRotation( - theta ) );
247
+
248
+ return this;
249
+
250
+ }
251
+
252
+ translate( tx, ty ) {
253
+
254
+ this.premultiply( _m3.makeTranslation( tx, ty ) );
255
+
256
+ return this;
257
+
258
+ }
259
+
260
+ // for 2D Transforms
261
+
262
+ makeTranslation( x, y ) {
263
+
264
+ this.set(
265
+
266
+ 1, 0, x,
267
+ 0, 1, y,
268
+ 0, 0, 1
269
+
270
+ );
271
+
272
+ return this;
273
+
274
+ }
275
+
276
+ makeRotation( theta ) {
277
+
278
+ // counterclockwise
279
+
247
280
  const c = Math.cos( theta );
248
281
  const s = Math.sin( theta );
249
282
 
250
- const te = this.elements;
251
-
252
- const a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];
253
- const a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];
283
+ this.set(
254
284
 
255
- te[ 0 ] = c * a11 + s * a21;
256
- te[ 3 ] = c * a12 + s * a22;
257
- te[ 6 ] = c * a13 + s * a23;
285
+ c, - s, 0,
286
+ s, c, 0,
287
+ 0, 0, 1
258
288
 
259
- te[ 1 ] = - s * a11 + c * a21;
260
- te[ 4 ] = - s * a12 + c * a22;
261
- te[ 7 ] = - s * a13 + c * a23;
289
+ );
262
290
 
263
291
  return this;
264
292
 
265
293
  }
266
294
 
267
- translate( tx, ty ) {
295
+ makeScale( x, y ) {
268
296
 
269
- const te = this.elements;
297
+ this.set(
270
298
 
271
- te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];
272
- te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];
299
+ x, 0, 0,
300
+ 0, y, 0,
301
+ 0, 0, 1
302
+
303
+ );
273
304
 
274
305
  return this;
275
306
 
276
307
  }
277
308
 
309
+ //
310
+
278
311
  equals( matrix ) {
279
312
 
280
313
  const te = this.elements;
@@ -330,4 +363,6 @@ class Matrix3 {
330
363
 
331
364
  }
332
365
 
366
+ const _m3 = /*@__PURE__*/ new Matrix3();
367
+
333
368
  export { Matrix3 };
package/src/math/Ray.js CHANGED
@@ -356,12 +356,9 @@ class Ray {
356
356
 
357
357
  if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;
358
358
 
359
- // These lines also handle the case where tmin or tmax is NaN
360
- // (result of 0 * Infinity). x !== x returns true if x is NaN
359
+ if ( tymin > tmin || isNaN( tmin ) ) tmin = tymin;
361
360
 
362
- if ( tymin > tmin || tmin !== tmin ) tmin = tymin;
363
-
364
- if ( tymax < tmax || tmax !== tmax ) tmax = tymax;
361
+ if ( tymax < tmax || isNaN( tmax ) ) tmax = tymax;
365
362
 
366
363
  if ( invdirz >= 0 ) {
367
364