@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,25 +1,24 @@
1
1
  ( function () {
2
2
 
3
3
  const _tempNormal = new THREE.Vector3();
4
-
5
4
  function getUv( faceDirVector, normal, uvAxis, projectionAxis, radius, sideLength ) {
6
5
 
7
- const totArcLength = 2 * Math.PI * radius / 4; // length of the planes between the arcs on each axis
6
+ const totArcLength = 2 * Math.PI * radius / 4;
8
7
 
8
+ // length of the planes between the arcs on each axis
9
9
  const centerLength = Math.max( sideLength - 2 * radius, 0 );
10
- const halfArc = Math.PI / 4; // Get the vector projected onto the Y plane
10
+ const halfArc = Math.PI / 4;
11
11
 
12
+ // Get the vector projected onto the Y plane
12
13
  _tempNormal.copy( normal );
13
-
14
14
  _tempNormal[ projectionAxis ] = 0;
15
+ _tempNormal.normalize();
15
16
 
16
- _tempNormal.normalize(); // total amount of UV space alloted to a single arc
17
-
18
-
19
- const arcUvRatio = 0.5 * totArcLength / ( totArcLength + centerLength ); // the distance along one arc the point is at
17
+ // total amount of UV space alloted to a single arc
18
+ const arcUvRatio = 0.5 * totArcLength / ( totArcLength + centerLength );
20
19
 
20
+ // the distance along one arc the point is at
21
21
  const arcAngleRatio = 1.0 - _tempNormal.angleTo( faceDirVector ) / halfArc;
22
-
23
22
  if ( Math.sign( _tempNormal[ uvAxis ] ) === 1 ) {
24
23
 
25
24
  return arcAngleRatio * arcUvRatio;
@@ -39,17 +38,21 @@
39
38
  constructor( width = 1, height = 1, depth = 1, segments = 2, radius = 0.1 ) {
40
39
 
41
40
  // ensure segments is odd so we have a plane connecting the rounded corners
42
- segments = segments * 2 + 1; // ensure radius isn't bigger than shortest side
41
+ segments = segments * 2 + 1;
43
42
 
43
+ // ensure radius isn't bigger than shortest side
44
44
  radius = Math.min( width / 2, height / 2, depth / 2, radius );
45
- super( 1, 1, 1, segments, segments, segments ); // if we just have one segment we're the same as a regular box
45
+ super( 1, 1, 1, segments, segments, segments );
46
46
 
47
+ // if we just have one segment we're the same as a regular box
47
48
  if ( segments === 1 ) return;
48
49
  const geometry2 = this.toNonIndexed();
49
50
  this.index = null;
50
51
  this.attributes.position = geometry2.attributes.position;
51
52
  this.attributes.normal = geometry2.attributes.normal;
52
- this.attributes.uv = geometry2.attributes.uv; //
53
+ this.attributes.uv = geometry2.attributes.uv;
54
+
55
+ //
53
56
 
54
57
  const position = new THREE.Vector3();
55
58
  const normal = new THREE.Vector3();
@@ -60,7 +63,6 @@
60
63
  const faceTris = positions.length / 6;
61
64
  const faceDirVector = new THREE.Vector3();
62
65
  const halfSegmentSize = 0.5 / segments;
63
-
64
66
  for ( let i = 0, j = 0; i < positions.length; i += 3, j += 2 ) {
65
67
 
66
68
  position.fromArray( positions, i );
@@ -76,51 +78,51 @@
76
78
  normals[ i + 1 ] = normal.y;
77
79
  normals[ i + 2 ] = normal.z;
78
80
  const side = Math.floor( i / faceTris );
79
-
80
81
  switch ( side ) {
81
82
 
82
83
  case 0:
83
84
  // right
85
+
84
86
  // generate UVs along Z then Y
85
87
  faceDirVector.set( 1, 0, 0 );
86
88
  uvs[ j + 0 ] = getUv( faceDirVector, normal, 'z', 'y', radius, depth );
87
89
  uvs[ j + 1 ] = 1.0 - getUv( faceDirVector, normal, 'y', 'z', radius, height );
88
90
  break;
89
-
90
91
  case 1:
91
92
  // left
93
+
92
94
  // generate UVs along Z then Y
93
95
  faceDirVector.set( - 1, 0, 0 );
94
96
  uvs[ j + 0 ] = 1.0 - getUv( faceDirVector, normal, 'z', 'y', radius, depth );
95
97
  uvs[ j + 1 ] = 1.0 - getUv( faceDirVector, normal, 'y', 'z', radius, height );
96
98
  break;
97
-
98
99
  case 2:
99
100
  // top
101
+
100
102
  // generate UVs along X then Z
101
103
  faceDirVector.set( 0, 1, 0 );
102
104
  uvs[ j + 0 ] = 1.0 - getUv( faceDirVector, normal, 'x', 'z', radius, width );
103
105
  uvs[ j + 1 ] = getUv( faceDirVector, normal, 'z', 'x', radius, depth );
104
106
  break;
105
-
106
107
  case 3:
107
108
  // bottom
109
+
108
110
  // generate UVs along X then Z
109
111
  faceDirVector.set( 0, - 1, 0 );
110
112
  uvs[ j + 0 ] = 1.0 - getUv( faceDirVector, normal, 'x', 'z', radius, width );
111
113
  uvs[ j + 1 ] = 1.0 - getUv( faceDirVector, normal, 'z', 'x', radius, depth );
112
114
  break;
113
-
114
115
  case 4:
115
116
  // front
117
+
116
118
  // generate UVs along X then Y
117
119
  faceDirVector.set( 0, 0, 1 );
118
120
  uvs[ j + 0 ] = 1.0 - getUv( faceDirVector, normal, 'x', 'y', radius, width );
119
121
  uvs[ j + 1 ] = 1.0 - getUv( faceDirVector, normal, 'y', 'x', radius, height );
120
122
  break;
121
-
122
123
  case 5:
123
124
  // back
125
+
124
126
  // generate UVs along X then Y
125
127
  faceDirVector.set( 0, 0, - 1 );
126
128
  uvs[ j + 0 ] = getUv( faceDirVector, normal, 'x', 'y', radius, width );
@@ -53,37 +53,35 @@
53
53
  constructor( size = 50, segments = 10, bottom = true, lid = true, body = true, fitLid = true, blinn = true ) {
54
54
 
55
55
  // 32 * 4 * 4 Bezier spline patches
56
- const teapotPatches = [
57
- /*rim*/
58
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27, 18, 28, 29, 30, 21, 31, 32, 33, 24, 34, 35, 36, 27, 37, 38, 39, 30, 40, 41, 0, 33, 42, 43, 4, 36, 44, 45, 8, 39, 46, 47, 12,
59
- /*body*/
60
- 12, 13, 14, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 15, 25, 26, 27, 51, 60, 61, 62, 55, 63, 64, 65, 59, 66, 67, 68, 27, 37, 38, 39, 62, 69, 70, 71, 65, 72, 73, 74, 68, 75, 76, 77, 39, 46, 47, 12, 71, 78, 79, 48, 74, 80, 81, 52, 77, 82, 83, 56, 56, 57, 58, 59, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 59, 66, 67, 68, 87, 96, 97, 98, 91, 99, 100, 101, 95, 102, 103, 104, 68, 75, 76, 77, 98, 105, 106, 107, 101, 108, 109, 110, 104, 111, 112, 113, 77, 82, 83, 56, 107, 114, 115, 84, 110, 116, 117, 88, 113, 118, 119, 92,
61
- /*handle*/
62
- 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 123, 136, 137, 120, 127, 138, 139, 124, 131, 140, 141, 128, 135, 142, 143, 132, 132, 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 151, 68, 152, 153, 154, 135, 142, 143, 132, 147, 155, 156, 144, 151, 157, 158, 148, 154, 159, 160, 68,
63
- /*spout*/
64
- 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 164, 177, 178, 161, 168, 179, 180, 165, 172, 181, 182, 169, 176, 183, 184, 173, 173, 174, 175, 176, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 176, 183, 184, 173, 188, 197, 198, 185, 192, 199, 200, 189, 196, 201, 202, 193,
65
- /*lid*/
66
- 203, 203, 203, 203, 204, 205, 206, 207, 208, 208, 208, 208, 209, 210, 211, 212, 203, 203, 203, 203, 207, 213, 214, 215, 208, 208, 208, 208, 212, 216, 217, 218, 203, 203, 203, 203, 215, 219, 220, 221, 208, 208, 208, 208, 218, 222, 223, 224, 203, 203, 203, 203, 221, 225, 226, 204, 208, 208, 208, 208, 224, 227, 228, 209, 209, 210, 211, 212, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 212, 216, 217, 218, 232, 241, 242, 243, 236, 244, 245, 246, 240, 247, 248, 249, 218, 222, 223, 224, 243, 250, 251, 252, 246, 253, 254, 255, 249, 256, 257, 258, 224, 227, 228, 209, 252, 259, 260, 229, 255, 261, 262, 233, 258, 263, 264, 237,
67
- /*bottom*/
56
+ const teapotPatches = [/*rim*/
57
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27, 18, 28, 29, 30, 21, 31, 32, 33, 24, 34, 35, 36, 27, 37, 38, 39, 30, 40, 41, 0, 33, 42, 43, 4, 36, 44, 45, 8, 39, 46, 47, 12, /*body*/
58
+ 12, 13, 14, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 15, 25, 26, 27, 51, 60, 61, 62, 55, 63, 64, 65, 59, 66, 67, 68, 27, 37, 38, 39, 62, 69, 70, 71, 65, 72, 73, 74, 68, 75, 76, 77, 39, 46, 47, 12, 71, 78, 79, 48, 74, 80, 81, 52, 77, 82, 83, 56, 56, 57, 58, 59, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 59, 66, 67, 68, 87, 96, 97, 98, 91, 99, 100, 101, 95, 102, 103, 104, 68, 75, 76, 77, 98, 105, 106, 107, 101, 108, 109, 110, 104, 111, 112, 113, 77, 82, 83, 56, 107, 114, 115, 84, 110, 116, 117, 88, 113, 118, 119, 92, /*handle*/
59
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 123, 136, 137, 120, 127, 138, 139, 124, 131, 140, 141, 128, 135, 142, 143, 132, 132, 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 151, 68, 152, 153, 154, 135, 142, 143, 132, 147, 155, 156, 144, 151, 157, 158, 148, 154, 159, 160, 68, /*spout*/
60
+ 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 164, 177, 178, 161, 168, 179, 180, 165, 172, 181, 182, 169, 176, 183, 184, 173, 173, 174, 175, 176, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 176, 183, 184, 173, 188, 197, 198, 185, 192, 199, 200, 189, 196, 201, 202, 193, /*lid*/
61
+ 203, 203, 203, 203, 204, 205, 206, 207, 208, 208, 208, 208, 209, 210, 211, 212, 203, 203, 203, 203, 207, 213, 214, 215, 208, 208, 208, 208, 212, 216, 217, 218, 203, 203, 203, 203, 215, 219, 220, 221, 208, 208, 208, 208, 218, 222, 223, 224, 203, 203, 203, 203, 221, 225, 226, 204, 208, 208, 208, 208, 224, 227, 228, 209, 209, 210, 211, 212, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 212, 216, 217, 218, 232, 241, 242, 243, 236, 244, 245, 246, 240, 247, 248, 249, 218, 222, 223, 224, 243, 250, 251, 252, 246, 253, 254, 255, 249, 256, 257, 258, 224, 227, 228, 209, 252, 259, 260, 229, 255, 261, 262, 233, 258, 263, 264, 237, /*bottom*/
68
62
  265, 265, 265, 265, 266, 267, 268, 269, 270, 271, 272, 273, 92, 119, 118, 113, 265, 265, 265, 265, 269, 274, 275, 276, 273, 277, 278, 279, 113, 112, 111, 104, 265, 265, 265, 265, 276, 280, 281, 282, 279, 283, 284, 285, 104, 103, 102, 95, 265, 265, 265, 265, 282, 286, 287, 266, 285, 288, 289, 270, 95, 94, 93, 92 ];
69
63
  const teapotVertices = [ 1.4, 0, 2.4, 1.4, - 0.784, 2.4, 0.784, - 1.4, 2.4, 0, - 1.4, 2.4, 1.3375, 0, 2.53125, 1.3375, - 0.749, 2.53125, 0.749, - 1.3375, 2.53125, 0, - 1.3375, 2.53125, 1.4375, 0, 2.53125, 1.4375, - 0.805, 2.53125, 0.805, - 1.4375, 2.53125, 0, - 1.4375, 2.53125, 1.5, 0, 2.4, 1.5, - 0.84, 2.4, 0.84, - 1.5, 2.4, 0, - 1.5, 2.4, - 0.784, - 1.4, 2.4, - 1.4, - 0.784, 2.4, - 1.4, 0, 2.4, - 0.749, - 1.3375, 2.53125, - 1.3375, - 0.749, 2.53125, - 1.3375, 0, 2.53125, - 0.805, - 1.4375, 2.53125, - 1.4375, - 0.805, 2.53125, - 1.4375, 0, 2.53125, - 0.84, - 1.5, 2.4, - 1.5, - 0.84, 2.4, - 1.5, 0, 2.4, - 1.4, 0.784, 2.4, - 0.784, 1.4, 2.4, 0, 1.4, 2.4, - 1.3375, 0.749, 2.53125, - 0.749, 1.3375, 2.53125, 0, 1.3375, 2.53125, - 1.4375, 0.805, 2.53125, - 0.805, 1.4375, 2.53125, 0, 1.4375, 2.53125, - 1.5, 0.84, 2.4, - 0.84, 1.5, 2.4, 0, 1.5, 2.4, 0.784, 1.4, 2.4, 1.4, 0.784, 2.4, 0.749, 1.3375, 2.53125, 1.3375, 0.749, 2.53125, 0.805, 1.4375, 2.53125, 1.4375, 0.805, 2.53125, 0.84, 1.5, 2.4, 1.5, 0.84, 2.4, 1.75, 0, 1.875, 1.75, - 0.98, 1.875, 0.98, - 1.75, 1.875, 0, - 1.75, 1.875, 2, 0, 1.35, 2, - 1.12, 1.35, 1.12, - 2, 1.35, 0, - 2, 1.35, 2, 0, 0.9, 2, - 1.12, 0.9, 1.12, - 2, 0.9, 0, - 2, 0.9, - 0.98, - 1.75, 1.875, - 1.75, - 0.98, 1.875, - 1.75, 0, 1.875, - 1.12, - 2, 1.35, - 2, - 1.12, 1.35, - 2, 0, 1.35, - 1.12, - 2, 0.9, - 2, - 1.12, 0.9, - 2, 0, 0.9, - 1.75, 0.98, 1.875, - 0.98, 1.75, 1.875, 0, 1.75, 1.875, - 2, 1.12, 1.35, - 1.12, 2, 1.35, 0, 2, 1.35, - 2, 1.12, 0.9, - 1.12, 2, 0.9, 0, 2, 0.9, 0.98, 1.75, 1.875, 1.75, 0.98, 1.875, 1.12, 2, 1.35, 2, 1.12, 1.35, 1.12, 2, 0.9, 2, 1.12, 0.9, 2, 0, 0.45, 2, - 1.12, 0.45, 1.12, - 2, 0.45, 0, - 2, 0.45, 1.5, 0, 0.225, 1.5, - 0.84, 0.225, 0.84, - 1.5, 0.225, 0, - 1.5, 0.225, 1.5, 0, 0.15, 1.5, - 0.84, 0.15, 0.84, - 1.5, 0.15, 0, - 1.5, 0.15, - 1.12, - 2, 0.45, - 2, - 1.12, 0.45, - 2, 0, 0.45, - 0.84, - 1.5, 0.225, - 1.5, - 0.84, 0.225, - 1.5, 0, 0.225, - 0.84, - 1.5, 0.15, - 1.5, - 0.84, 0.15, - 1.5, 0, 0.15, - 2, 1.12, 0.45, - 1.12, 2, 0.45, 0, 2, 0.45, - 1.5, 0.84, 0.225, - 0.84, 1.5, 0.225, 0, 1.5, 0.225, - 1.5, 0.84, 0.15, - 0.84, 1.5, 0.15, 0, 1.5, 0.15, 1.12, 2, 0.45, 2, 1.12, 0.45, 0.84, 1.5, 0.225, 1.5, 0.84, 0.225, 0.84, 1.5, 0.15, 1.5, 0.84, 0.15, - 1.6, 0, 2.025, - 1.6, - 0.3, 2.025, - 1.5, - 0.3, 2.25, - 1.5, 0, 2.25, - 2.3, 0, 2.025, - 2.3, - 0.3, 2.025, - 2.5, - 0.3, 2.25, - 2.5, 0, 2.25, - 2.7, 0, 2.025, - 2.7, - 0.3, 2.025, - 3, - 0.3, 2.25, - 3, 0, 2.25, - 2.7, 0, 1.8, - 2.7, - 0.3, 1.8, - 3, - 0.3, 1.8, - 3, 0, 1.8, - 1.5, 0.3, 2.25, - 1.6, 0.3, 2.025, - 2.5, 0.3, 2.25, - 2.3, 0.3, 2.025, - 3, 0.3, 2.25, - 2.7, 0.3, 2.025, - 3, 0.3, 1.8, - 2.7, 0.3, 1.8, - 2.7, 0, 1.575, - 2.7, - 0.3, 1.575, - 3, - 0.3, 1.35, - 3, 0, 1.35, - 2.5, 0, 1.125, - 2.5, - 0.3, 1.125, - 2.65, - 0.3, 0.9375, - 2.65, 0, 0.9375, - 2, - 0.3, 0.9, - 1.9, - 0.3, 0.6, - 1.9, 0, 0.6, - 3, 0.3, 1.35, - 2.7, 0.3, 1.575, - 2.65, 0.3, 0.9375, - 2.5, 0.3, 1.125, - 1.9, 0.3, 0.6, - 2, 0.3, 0.9, 1.7, 0, 1.425, 1.7, - 0.66, 1.425, 1.7, - 0.66, 0.6, 1.7, 0, 0.6, 2.6, 0, 1.425, 2.6, - 0.66, 1.425, 3.1, - 0.66, 0.825, 3.1, 0, 0.825, 2.3, 0, 2.1, 2.3, - 0.25, 2.1, 2.4, - 0.25, 2.025, 2.4, 0, 2.025, 2.7, 0, 2.4, 2.7, - 0.25, 2.4, 3.3, - 0.25, 2.4, 3.3, 0, 2.4, 1.7, 0.66, 0.6, 1.7, 0.66, 1.425, 3.1, 0.66, 0.825, 2.6, 0.66, 1.425, 2.4, 0.25, 2.025, 2.3, 0.25, 2.1, 3.3, 0.25, 2.4, 2.7, 0.25, 2.4, 2.8, 0, 2.475, 2.8, - 0.25, 2.475, 3.525, - 0.25, 2.49375, 3.525, 0, 2.49375, 2.9, 0, 2.475, 2.9, - 0.15, 2.475, 3.45, - 0.15, 2.5125, 3.45, 0, 2.5125, 2.8, 0, 2.4, 2.8, - 0.15, 2.4, 3.2, - 0.15, 2.4, 3.2, 0, 2.4, 3.525, 0.25, 2.49375, 2.8, 0.25, 2.475, 3.45, 0.15, 2.5125, 2.9, 0.15, 2.475, 3.2, 0.15, 2.4, 2.8, 0.15, 2.4, 0, 0, 3.15, 0.8, 0, 3.15, 0.8, - 0.45, 3.15, 0.45, - 0.8, 3.15, 0, - 0.8, 3.15, 0, 0, 2.85, 0.2, 0, 2.7, 0.2, - 0.112, 2.7, 0.112, - 0.2, 2.7, 0, - 0.2, 2.7, - 0.45, - 0.8, 3.15, - 0.8, - 0.45, 3.15, - 0.8, 0, 3.15, - 0.112, - 0.2, 2.7, - 0.2, - 0.112, 2.7, - 0.2, 0, 2.7, - 0.8, 0.45, 3.15, - 0.45, 0.8, 3.15, 0, 0.8, 3.15, - 0.2, 0.112, 2.7, - 0.112, 0.2, 2.7, 0, 0.2, 2.7, 0.45, 0.8, 3.15, 0.8, 0.45, 3.15, 0.112, 0.2, 2.7, 0.2, 0.112, 2.7, 0.4, 0, 2.55, 0.4, - 0.224, 2.55, 0.224, - 0.4, 2.55, 0, - 0.4, 2.55, 1.3, 0, 2.55, 1.3, - 0.728, 2.55, 0.728, - 1.3, 2.55, 0, - 1.3, 2.55, 1.3, 0, 2.4, 1.3, - 0.728, 2.4, 0.728, - 1.3, 2.4, 0, - 1.3, 2.4, - 0.224, - 0.4, 2.55, - 0.4, - 0.224, 2.55, - 0.4, 0, 2.55, - 0.728, - 1.3, 2.55, - 1.3, - 0.728, 2.55, - 1.3, 0, 2.55, - 0.728, - 1.3, 2.4, - 1.3, - 0.728, 2.4, - 1.3, 0, 2.4, - 0.4, 0.224, 2.55, - 0.224, 0.4, 2.55, 0, 0.4, 2.55, - 1.3, 0.728, 2.55, - 0.728, 1.3, 2.55, 0, 1.3, 2.55, - 1.3, 0.728, 2.4, - 0.728, 1.3, 2.4, 0, 1.3, 2.4, 0.224, 0.4, 2.55, 0.4, 0.224, 2.55, 0.728, 1.3, 2.55, 1.3, 0.728, 2.55, 0.728, 1.3, 2.4, 1.3, 0.728, 2.4, 0, 0, 0, 1.425, 0, 0, 1.425, 0.798, 0, 0.798, 1.425, 0, 0, 1.425, 0, 1.5, 0, 0.075, 1.5, 0.84, 0.075, 0.84, 1.5, 0.075, 0, 1.5, 0.075, - 0.798, 1.425, 0, - 1.425, 0.798, 0, - 1.425, 0, 0, - 0.84, 1.5, 0.075, - 1.5, 0.84, 0.075, - 1.5, 0, 0.075, - 1.425, - 0.798, 0, - 0.798, - 1.425, 0, 0, - 1.425, 0, - 1.5, - 0.84, 0.075, - 0.84, - 1.5, 0.075, 0, - 1.5, 0.075, 0.798, - 1.425, 0, 1.425, - 0.798, 0, 0.84, - 1.5, 0.075, 1.5, - 0.84, 0.075 ];
70
- super(); // number of segments per patch
64
+ super();
71
65
 
72
- segments = Math.max( 2, Math.floor( segments ) ); // Jim Blinn scaled the teapot down in size by about 1.3 for
66
+ // number of segments per patch
67
+ segments = Math.max( 2, Math.floor( segments ) );
68
+
69
+ // Jim Blinn scaled the teapot down in size by about 1.3 for
73
70
  // some rendering tests. He liked the new proportions that he kept
74
71
  // the data in this form. The model was distributed with these new
75
72
  // proportions and became the norm. Trivia: comparing images of the
76
73
  // real teapot and the computer model, the ratio for the bowl of the
77
74
  // real teapot is more like 1.25, but since 1.3 is the traditional
78
75
  // value given, we use it here.
76
+ const blinnScale = 1.3;
79
77
 
80
- const blinnScale = 1.3; // scale the size to be the real scaling factor
81
-
78
+ // scale the size to be the real scaling factor
82
79
  const maxHeight = 3.15 * ( blinn ? 1 : blinnScale );
83
80
  const maxHeight2 = maxHeight / 2;
84
- const trueSize = size / maxHeight2; // Number of elements depends on what is needed. Subtract degenerate
85
- // triangles at tip of bottom and lid out in advance.
81
+ const trueSize = size / maxHeight2;
86
82
 
83
+ // Number of elements depends on what is needed. Subtract degenerate
84
+ // triangles at tip of bottom and lid out in advance.
87
85
  let numTriangles = bottom ? ( 8 * segments - 4 ) * segments : 0;
88
86
  numTriangles += lid ? ( 16 * segments - 4 ) * segments : 0;
89
87
  numTriangles += body ? 40 * segments * segments : 0;
@@ -94,17 +92,19 @@
94
92
  numVertices *= ( segments + 1 ) * ( segments + 1 );
95
93
  const vertices = new Float32Array( numVertices * 3 );
96
94
  const normals = new Float32Array( numVertices * 3 );
97
- const uvs = new Float32Array( numVertices * 2 ); // Bezier form
95
+ const uvs = new Float32Array( numVertices * 2 );
98
96
 
97
+ // Bezier form
99
98
  const ms = new THREE.Matrix4();
100
99
  ms.set( - 1.0, 3.0, - 3.0, 1.0, 3.0, - 6.0, 3.0, 0.0, - 3.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 );
101
100
  const g = [];
102
101
  const sp = [];
103
102
  const tp = [];
104
103
  const dsp = [];
105
- const dtp = []; // M * G * M matrix, sort of see
106
- // http://www.cs.helsinki.fi/group/goa/mallinnus/curves/surfaces.html
104
+ const dtp = [];
107
105
 
106
+ // M * G * M matrix, sort of see
107
+ // http://www.cs.helsinki.fi/group/goa/mallinnus/curves/surfaces.html
108
108
  const mgm = [];
109
109
  const vert = [];
110
110
  const sdir = [];
@@ -126,12 +126,13 @@
126
126
  const vsdir = new THREE.Vector3();
127
127
  const vtdir = new THREE.Vector3();
128
128
  const mst = ms.clone();
129
- mst.transpose(); // internal function: test if triangle has any matching vertices;
130
- // if so, don't save triangle, since it won't display anything.
129
+ mst.transpose();
131
130
 
132
- const notDegenerate = ( vtx1, vtx2, vtx3 ) => // if any vertex matches, return false
131
+ // internal function: test if triangle has any matching vertices;
132
+ // if so, don't save triangle, since it won't display anything.
133
+ const notDegenerate = ( vtx1, vtx2, vtx3 ) =>
134
+ // if any vertex matches, return false
133
135
  ! ( vertices[ vtx1 * 3 ] === vertices[ vtx2 * 3 ] && vertices[ vtx1 * 3 + 1 ] === vertices[ vtx2 * 3 + 1 ] && vertices[ vtx1 * 3 + 2 ] === vertices[ vtx2 * 3 + 2 ] || vertices[ vtx1 * 3 ] === vertices[ vtx3 * 3 ] && vertices[ vtx1 * 3 + 1 ] === vertices[ vtx3 * 3 + 1 ] && vertices[ vtx1 * 3 + 2 ] === vertices[ vtx3 * 3 + 2 ] || vertices[ vtx2 * 3 ] === vertices[ vtx3 * 3 ] && vertices[ vtx2 * 3 + 1 ] === vertices[ vtx3 * 3 + 1 ] && vertices[ vtx2 * 3 + 2 ] === vertices[ vtx3 * 3 + 2 ] );
134
-
135
136
  for ( let i = 0; i < 3; i ++ ) {
136
137
 
137
138
  mgm[ i ] = new THREE.Matrix4();
@@ -146,7 +147,6 @@
146
147
  let normCount = 0;
147
148
  let uvCount = 0;
148
149
  let indexCount = 0;
149
-
150
150
  for ( let surf = minPatches; surf < maxPatches; surf ++ ) {
151
151
 
152
152
  // lid is in the middle of the data, patches 20-27,
@@ -162,9 +162,10 @@
162
162
  for ( let c = 0; c < 4; c ++ ) {
163
163
 
164
164
  // transposed
165
- g[ c * 4 + r ] = teapotVertices[ teapotPatches[ surf * 16 + r * 4 + c ] * 3 + i ]; // is the lid to be made larger, and is this a point on the lid
166
- // that is X or Y?
165
+ g[ c * 4 + r ] = teapotVertices[ teapotPatches[ surf * 16 + r * 4 + c ] * 3 + i ];
167
166
 
167
+ // is the lid to be made larger, and is this a point on the lid
168
+ // that is X or Y?
168
169
  if ( fitLid && surf >= 20 && surf < 28 && i !== 2 ) {
169
170
 
170
171
  // increase XY size by 7.7%, found empirically. I don't
@@ -172,10 +173,10 @@
172
173
  // space -1 to 1 for Y (Y is up for the final model).
173
174
  g[ c * 4 + r ] *= 1.077;
174
175
 
175
- } // Blinn "fixed" the teapot by dividing Z by blinnScale, and that's the
176
- // data we now use. The original teapot is taller. Fix it:
177
-
176
+ }
178
177
 
178
+ // Blinn "fixed" the teapot by dividing Z by blinnScale, and that's the
179
+ // data we now use. The original teapot is taller. Fix it:
179
180
  if ( ! blinn && i === 2 ) {
180
181
 
181
182
  g[ c * 4 + r ] *= blinnScale;
@@ -190,25 +191,24 @@
190
191
  tmtx.multiplyMatrices( gmx, ms );
191
192
  mgm[ i ].multiplyMatrices( mst, tmtx );
192
193
 
193
- } // step along, get points, and output
194
-
194
+ }
195
195
 
196
+ // step along, get points, and output
196
197
  for ( let sstep = 0; sstep <= segments; sstep ++ ) {
197
198
 
198
199
  const s = sstep / segments;
199
-
200
200
  for ( let tstep = 0; tstep <= segments; tstep ++ ) {
201
201
 
202
- const t = tstep / segments; // point from basis
203
- // get power vectors and their derivatives
202
+ const t = tstep / segments;
204
203
 
204
+ // point from basis
205
+ // get power vectors and their derivatives
205
206
  for ( p = 4, sval = tval = 1.0; p --; ) {
206
207
 
207
208
  sp[ p ] = sval;
208
209
  tp[ p ] = tval;
209
210
  sval *= s;
210
211
  tval *= t;
211
-
212
212
  if ( p === 3 ) {
213
213
 
214
214
  dsp[ p ] = dtp[ p ] = 0.0;
@@ -228,15 +228,17 @@
228
228
  vsp.fromArray( sp );
229
229
  vtp.fromArray( tp );
230
230
  vdsp.fromArray( dsp );
231
- vdtp.fromArray( dtp ); // do for x,y,z
231
+ vdtp.fromArray( dtp );
232
232
 
233
+ // do for x,y,z
233
234
  for ( let i = 0; i < 3; i ++ ) {
234
235
 
235
236
  // multiply power vectors times matrix to get value
236
237
  tcoord = vsp.clone();
237
238
  tcoord.applyMatrix4( mgm[ i ] );
238
- vert[ i ] = tcoord.dot( vtp ); // get s and t tangent vectors
239
+ vert[ i ] = tcoord.dot( vtp );
239
240
 
241
+ // get s and t tangent vectors
240
242
  tcoord = vdsp.clone();
241
243
  tcoord.applyMatrix4( mgm[ i ] );
242
244
  sdir[ i ] = tcoord.dot( vtp );
@@ -244,14 +246,15 @@
244
246
  tcoord.applyMatrix4( mgm[ i ] );
245
247
  tdir[ i ] = tcoord.dot( vdtp );
246
248
 
247
- } // find normal
248
-
249
+ }
249
250
 
251
+ // find normal
250
252
  vsdir.fromArray( sdir );
251
253
  vtdir.fromArray( tdir );
252
254
  norm.crossVectors( vtdir, vsdir );
253
- norm.normalize(); // if X and Z length is 0, at the cusp, so point the normal up or down, depending on patch number
255
+ norm.normalize();
254
256
 
257
+ // if X and Z length is 0, at the cusp, so point the normal up or down, depending on patch number
255
258
  if ( vert[ 0 ] === 0 && vert[ 1 ] === 0 ) {
256
259
 
257
260
  // if above the middle of the teapot, normal points up, else down
@@ -262,9 +265,9 @@
262
265
  // standard output: rotate on X axis
263
266
  normOut.set( norm.x, norm.z, - norm.y );
264
267
 
265
- } // store it all
266
-
268
+ }
267
269
 
270
+ // store it all
268
271
  vertices[ vertCount ++ ] = trueSize * vert[ 0 ];
269
272
  vertices[ vertCount ++ ] = trueSize * ( vert[ 2 ] - maxHeight2 );
270
273
  vertices[ vertCount ++ ] = - trueSize * vert[ 1 ];
@@ -276,9 +279,9 @@
276
279
 
277
280
  }
278
281
 
279
- } // save the faces
280
-
282
+ }
281
283
 
284
+ // save the faces
282
285
  for ( let sstep = 0; sstep < segments; sstep ++ ) {
283
286
 
284
287
  for ( let tstep = 0; tstep < segments; tstep ++ ) {
@@ -286,9 +289,10 @@
286
289
  const v1 = surfCount * vertPerRow * vertPerRow + sstep * vertPerRow + tstep;
287
290
  const v2 = v1 + 1;
288
291
  const v3 = v2 + vertPerRow;
289
- const v4 = v1 + vertPerRow; // Normals and UVs cannot be shared. Without clone(), you can see the consequences
290
- // of sharing if you call geometry.applyMatrix4( matrix ).
292
+ const v4 = v1 + vertPerRow;
291
293
 
294
+ // Normals and UVs cannot be shared. Without clone(), you can see the consequences
295
+ // of sharing if you call geometry.applyMatrix4( matrix ).
292
296
  if ( notDegenerate( v1, v2, v3 ) ) {
293
297
 
294
298
  indices[ indexCount ++ ] = v1;
@@ -307,9 +311,9 @@
307
311
 
308
312
  }
309
313
 
310
- } // increment only if a surface was used
311
-
314
+ }
312
315
 
316
+ // increment only if a surface was used
313
317
  surfCount ++;
314
318
 
315
319
  }
@@ -16,22 +16,24 @@
16
16
  * bevelOffset: <float> // how far from text outline does bevel start
17
17
  * }
18
18
  */
19
-
20
19
  class TextGeometry extends THREE.ExtrudeGeometry {
21
20
 
22
21
  constructor( text, parameters = {} ) {
23
22
 
24
23
  const font = parameters.font;
25
-
26
24
  if ( font === undefined ) {
27
25
 
28
26
  super(); // generate default extrude geometry
29
27
 
30
28
  } else {
31
29
 
32
- const shapes = font.generateShapes( text, parameters.size ); // translate parameters to THREE.ExtrudeGeometry API
30
+ const shapes = font.generateShapes( text, parameters.size );
31
+
32
+ // translate parameters to THREE.ExtrudeGeometry API
33
+
34
+ parameters.depth = parameters.height !== undefined ? parameters.height : 50;
33
35
 
34
- parameters.depth = parameters.height !== undefined ? parameters.height : 50; // defaults
36
+ // defaults
35
37
 
36
38
  if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
37
39
  if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
@@ -11,6 +11,7 @@
11
11
  value: lightProbe.sh.coefficients
12
12
  },
13
13
  // by reference
14
+
14
15
  intensity: {
15
16
  value: lightProbe.intensity
16
17
  }
@@ -26,14 +27,12 @@
26
27
  this.onBeforeRender();
27
28
 
28
29
  }
29
-
30
30
  dispose() {
31
31
 
32
32
  this.geometry.dispose();
33
33
  this.material.dispose();
34
34
 
35
35
  }
36
-
37
36
  onBeforeRender() {
38
37
 
39
38
  this.position.copy( this.lightProbe.position );
@@ -4,8 +4,19 @@
4
4
 
5
5
  constructor( octree, color = 0xffff00 ) {
6
6
 
7
- const vertices = [];
7
+ super( new THREE.BufferGeometry(), new THREE.LineBasicMaterial( {
8
+ color: color,
9
+ toneMapped: false
10
+ } ) );
11
+ this.octree = octree;
12
+ this.color = color;
13
+ this.type = 'OctreeHelper';
14
+ this.update();
8
15
 
16
+ }
17
+ update() {
18
+
19
+ const vertices = [];
9
20
  function traverse( tree ) {
10
21
 
11
22
  for ( let i = 0; i < tree.length; i ++ ) {
@@ -14,37 +25,28 @@
14
25
  const max = tree[ i ].box.max;
15
26
  vertices.push( max.x, max.y, max.z );
16
27
  vertices.push( min.x, max.y, max.z ); // 0, 1
17
-
18
28
  vertices.push( min.x, max.y, max.z );
19
29
  vertices.push( min.x, min.y, max.z ); // 1, 2
20
-
21
30
  vertices.push( min.x, min.y, max.z );
22
31
  vertices.push( max.x, min.y, max.z ); // 2, 3
23
-
24
32
  vertices.push( max.x, min.y, max.z );
25
33
  vertices.push( max.x, max.y, max.z ); // 3, 0
26
34
 
27
35
  vertices.push( max.x, max.y, min.z );
28
36
  vertices.push( min.x, max.y, min.z ); // 4, 5
29
-
30
37
  vertices.push( min.x, max.y, min.z );
31
38
  vertices.push( min.x, min.y, min.z ); // 5, 6
32
-
33
39
  vertices.push( min.x, min.y, min.z );
34
40
  vertices.push( max.x, min.y, min.z ); // 6, 7
35
-
36
41
  vertices.push( max.x, min.y, min.z );
37
42
  vertices.push( max.x, max.y, min.z ); // 7, 4
38
43
 
39
44
  vertices.push( max.x, max.y, max.z );
40
45
  vertices.push( max.x, max.y, min.z ); // 0, 4
41
-
42
46
  vertices.push( min.x, max.y, max.z );
43
47
  vertices.push( min.x, max.y, min.z ); // 1, 5
44
-
45
48
  vertices.push( min.x, min.y, max.z );
46
49
  vertices.push( min.x, min.y, min.z ); // 2, 6
47
-
48
50
  vertices.push( max.x, min.y, max.z );
49
51
  vertices.push( max.x, min.y, min.z ); // 3, 7
50
52
 
@@ -54,16 +56,16 @@
54
56
 
55
57
  }
56
58
 
57
- traverse( octree.subTrees );
58
- const geometry = new THREE.BufferGeometry();
59
- geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
60
- super( geometry, new THREE.LineBasicMaterial( {
61
- color: color,
62
- toneMapped: false
63
- } ) );
64
- this.octree = octree;
65
- this.color = color;
66
- this.type = 'OctreeHelper';
59
+ traverse( this.octree.subTrees );
60
+ this.geometry.dispose();
61
+ this.geometry = new THREE.BufferGeometry();
62
+ this.geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
63
+
64
+ }
65
+ dispose() {
66
+
67
+ this.geometry.dispose();
68
+ this.material.dispose();
67
69
 
68
70
  }
69
71
 
@@ -23,7 +23,6 @@
23
23
  this.update();
24
24
 
25
25
  }
26
-
27
26
  update() {
28
27
 
29
28
  const audio = this.audio;
@@ -40,14 +39,15 @@
40
39
  let stride;
41
40
  const geometry = this.geometry;
42
41
  const positionAttribute = geometry.attributes.position;
43
- geometry.clearGroups(); //
42
+ geometry.clearGroups();
43
+
44
+ //
44
45
 
45
46
  function generateSegment( from, to, divisions, materialIndex ) {
46
47
 
47
48
  const step = ( to - from ) / divisions;
48
49
  positionAttribute.setXYZ( start, 0, 0, 0 );
49
50
  count ++;
50
-
51
51
  for ( i = from; i < to; i += step ) {
52
52
 
53
53
  stride = start + count;
@@ -62,18 +62,20 @@
62
62
  start += count;
63
63
  count = 0;
64
64
 
65
- } //
65
+ }
66
66
 
67
+ //
67
68
 
68
69
  generateSegment( - halfConeOuterAngle, - halfConeInnerAngle, divisionsOuterAngle, 0 );
69
70
  generateSegment( - halfConeInnerAngle, halfConeInnerAngle, divisionsInnerAngle, 1 );
70
- generateSegment( halfConeInnerAngle, halfConeOuterAngle, divisionsOuterAngle, 0 ); //
71
+ generateSegment( halfConeInnerAngle, halfConeOuterAngle, divisionsOuterAngle, 0 );
72
+
73
+ //
71
74
 
72
75
  positionAttribute.needsUpdate = true;
73
76
  if ( coneInnerAngle === coneOuterAngle ) this.material[ 0 ].visible = false;
74
77
 
75
78
  }
76
-
77
79
  dispose() {
78
80
 
79
81
  this.geometry.dispose();
@@ -18,8 +18,9 @@
18
18
  super( geometry, material );
19
19
  this.light = light;
20
20
  this.color = color; // optional hardwired color for the helper
21
+ this.type = 'RectAreaLightHelper';
21
22
 
22
- this.type = 'RectAreaLightHelper'; //
23
+ //
23
24
 
24
25
  const positions2 = [ 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, 1, 0, - 1, - 1, 0, 1, - 1, 0 ];
25
26
  const geometry2 = new THREE.BufferGeometry();
@@ -31,11 +32,9 @@
31
32
  } ) ) );
32
33
 
33
34
  }
34
-
35
35
  updateMatrixWorld() {
36
36
 
37
37
  this.scale.set( 0.5 * this.light.width, 0.5 * this.light.height, 1 );
38
-
39
38
  if ( this.color !== undefined ) {
40
39
 
41
40
  this.material.color.set( this.color );
@@ -43,21 +42,21 @@
43
42
 
44
43
  } else {
45
44
 
46
- this.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); // prevent hue shift
45
+ this.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
47
46
 
47
+ // prevent hue shift
48
48
  const c = this.material.color;
49
49
  const max = Math.max( c.r, c.g, c.b );
50
50
  if ( max > 1 ) c.multiplyScalar( 1 / max );
51
51
  this.children[ 0 ].material.color.copy( this.material.color );
52
52
 
53
- } // ignore world scale on light
54
-
53
+ }
55
54
 
55
+ // ignore world scale on light
56
56
  this.matrixWorld.extractRotation( this.light.matrixWorld ).scale( this.scale ).copyPosition( this.light.matrixWorld );
57
57
  this.children[ 0 ].matrixWorld.copy( this.matrixWorld );
58
58
 
59
59
  }
60
-
61
60
  dispose() {
62
61
 
63
62
  this.geometry.dispose();