@needle-tools/three 0.145.2 → 0.146.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (394) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +3559 -6924
  3. package/build/three.js +3559 -6924
  4. package/build/three.min.js +1 -2
  5. package/build/three.module.js +732 -339
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +49 -66
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +70 -134
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +138 -405
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -54
  14. package/examples/js/controls/FlyControls.js +29 -55
  15. package/examples/js/controls/OrbitControls.js +85 -95
  16. package/examples/js/controls/PointerLockControls.js +5 -14
  17. package/examples/js/controls/TrackballControls.js +33 -86
  18. package/examples/js/controls/TransformControls.js +84 -169
  19. package/examples/js/csm/CSM.js +4 -39
  20. package/examples/js/csm/CSMFrustum.js +3 -9
  21. package/examples/js/csm/CSMHelper.js +24 -4
  22. package/examples/js/csm/CSMShader.js +2 -6
  23. package/examples/js/curves/CurveExtras.js +27 -27
  24. package/examples/js/curves/NURBSCurve.js +4 -16
  25. package/examples/js/curves/NURBSSurface.js +3 -9
  26. package/examples/js/curves/NURBSUtils.js +8 -45
  27. package/examples/js/effects/AnaglyphEffect.js +4 -18
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +26 -30
  30. package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
  31. package/examples/js/effects/PeppersGhostEffect.js +12 -39
  32. package/examples/js/effects/StereoEffect.js +0 -4
  33. package/examples/js/environments/RoomEnvironment.js +12 -10
  34. package/examples/js/exporters/ColladaExporter.js +48 -65
  35. package/examples/js/exporters/DRACOExporter.js +22 -22
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +143 -261
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +42 -33
  40. package/examples/js/exporters/PLYExporter.js +38 -33
  41. package/examples/js/exporters/STLExporter.js +5 -7
  42. package/examples/js/exporters/USDZExporter.js +110 -25
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +11 -6
  45. package/examples/js/geometries/DecalGeometry.js +53 -20
  46. package/examples/js/geometries/LightningStrike.js +54 -67
  47. package/examples/js/geometries/ParametricGeometries.js +8 -7
  48. package/examples/js/geometries/ParametricGeometry.js +25 -12
  49. package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
  50. package/examples/js/geometries/TeapotGeometry.js +54 -50
  51. package/examples/js/geometries/TextGeometry.js +6 -4
  52. package/examples/js/helpers/LightProbeHelper.js +1 -2
  53. package/examples/js/helpers/OctreeHelper.js +22 -20
  54. package/examples/js/helpers/PositionalAudioHelper.js +8 -6
  55. package/examples/js/helpers/RectAreaLightHelper.js +6 -7
  56. package/examples/js/helpers/VertexNormalsHelper.js +15 -13
  57. package/examples/js/helpers/VertexTangentsHelper.js +15 -9
  58. package/examples/js/helpers/ViewHelper.js +31 -16
  59. package/examples/js/interactive/HTMLMesh.js +22 -33
  60. package/examples/js/interactive/InteractiveGroup.js +6 -12
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +0 -8
  63. package/examples/js/lights/LightProbeGenerator.js +32 -39
  64. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  65. package/examples/js/lines/LineGeometry.js +3 -5
  66. package/examples/js/lines/LineMaterial.js +4 -11
  67. package/examples/js/lines/LineSegments2.js +38 -89
  68. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  69. package/examples/js/lines/Wireframe.js +2 -7
  70. package/examples/js/lines/WireframeGeometry2.js +3 -1
  71. package/examples/js/loaders/3DMLoader.js +58 -155
  72. package/examples/js/loaders/3MFLoader.js +72 -106
  73. package/examples/js/loaders/AMFLoader.js +0 -25
  74. package/examples/js/loaders/BVHLoader.js +44 -43
  75. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  76. package/examples/js/loaders/ColladaLoader.js +201 -359
  77. package/examples/js/loaders/DDSLoader.js +24 -25
  78. package/examples/js/loaders/DRACOLoader.js +29 -66
  79. package/examples/js/loaders/EXRLoader.js +67 -164
  80. package/examples/js/loaders/FBXLoader.js +286 -441
  81. package/examples/js/loaders/FontLoader.js +6 -15
  82. package/examples/js/loaders/GCodeLoader.js +15 -16
  83. package/examples/js/loaders/GLTFLoader.js +354 -405
  84. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
  85. package/examples/js/loaders/KMZLoader.js +3 -7
  86. package/examples/js/loaders/KTXLoader.js +12 -30
  87. package/examples/js/loaders/LDrawLoader.js +178 -289
  88. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  89. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  90. package/examples/js/loaders/LWOLoader.js +59 -124
  91. package/examples/js/loaders/LogLuvLoader.js +27 -77
  92. package/examples/js/loaders/LottieLoader.js +4 -4
  93. package/examples/js/loaders/MD2Loader.js +26 -27
  94. package/examples/js/loaders/MDDLoader.js +6 -10
  95. package/examples/js/loaders/MMDLoader.js +180 -189
  96. package/examples/js/loaders/MTLLoader.js +18 -47
  97. package/examples/js/loaders/MaterialXLoader.js +392 -0
  98. package/examples/js/loaders/NRRDLoader.js +44 -84
  99. package/examples/js/loaders/OBJLoader.js +50 -65
  100. package/examples/js/loaders/PCDLoader.js +34 -29
  101. package/examples/js/loaders/PDBLoader.js +17 -13
  102. package/examples/js/loaders/PLYLoader.js +9 -39
  103. package/examples/js/loaders/PRWMLoader.js +11 -22
  104. package/examples/js/loaders/PVRLoader.js +7 -16
  105. package/examples/js/loaders/RGBELoader.js +36 -61
  106. package/examples/js/loaders/RGBMLoader.js +26 -87
  107. package/examples/js/loaders/STLLoader.js +20 -27
  108. package/examples/js/loaders/SVGLoader.js +361 -233
  109. package/examples/js/loaders/TDSLoader.js +81 -118
  110. package/examples/js/loaders/TGALoader.js +39 -41
  111. package/examples/js/loaders/TIFFLoader.js +0 -1
  112. package/examples/js/loaders/TTFLoader.js +0 -8
  113. package/examples/js/loaders/TiltLoader.js +14 -15
  114. package/examples/js/loaders/VOXLoader.js +8 -16
  115. package/examples/js/loaders/VRMLLoader.js +243 -340
  116. package/examples/js/loaders/VTKLoader.js +101 -118
  117. package/examples/js/loaders/XYZLoader.js +2 -4
  118. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  119. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  120. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  121. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  122. package/examples/js/math/Capsule.js +0 -17
  123. package/examples/js/math/ColorConverter.js +3 -3
  124. package/examples/js/math/ConvexHull.js +183 -139
  125. package/examples/js/math/ImprovedNoise.js +1 -1
  126. package/examples/js/math/Lut.js +8 -15
  127. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  128. package/examples/js/math/OBB.js +90 -49
  129. package/examples/js/math/Octree.js +2 -57
  130. package/examples/js/math/SimplexNoise.js +74 -88
  131. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  132. package/examples/js/misc/GPUComputationRenderer.js +14 -18
  133. package/examples/js/misc/Gyroscope.js +5 -9
  134. package/examples/js/misc/MD2Character.js +14 -23
  135. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  136. package/examples/js/misc/MorphAnimMesh.js +0 -6
  137. package/examples/js/misc/MorphBlendMesh.js +3 -30
  138. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  139. package/examples/js/misc/RollerCoaster.js +17 -24
  140. package/examples/js/misc/TubePainter.js +18 -12
  141. package/examples/js/misc/Volume.js +16 -45
  142. package/examples/js/misc/VolumeSlice.js +14 -24
  143. package/examples/js/modifiers/CurveModifier.js +19 -21
  144. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  145. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  146. package/examples/js/modifiers/TessellateModifier.js +2 -9
  147. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  148. package/examples/js/objects/Lensflare.js +47 -38
  149. package/examples/js/objects/LightningStorm.js +10 -13
  150. package/examples/js/objects/MarchingCubes.js +80 -59
  151. package/examples/js/objects/Reflector.js +22 -20
  152. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  153. package/examples/js/objects/Refractor.js +52 -30
  154. package/examples/js/objects/ShadowMesh.js +1 -2
  155. package/examples/js/objects/Sky.js +2 -7
  156. package/examples/js/objects/Water.js +23 -18
  157. package/examples/js/objects/Water2.js +20 -19
  158. package/examples/js/physics/AmmoPhysics.js +23 -20
  159. package/examples/js/physics/OimoPhysics.js +19 -17
  160. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  161. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  162. package/examples/js/postprocessing/BloomPass.js +38 -17
  163. package/examples/js/postprocessing/BokehPass.js +29 -12
  164. package/examples/js/postprocessing/ClearPass.js +1 -6
  165. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  166. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  167. package/examples/js/postprocessing/EffectComposer.js +25 -32
  168. package/examples/js/postprocessing/FilmPass.js +7 -5
  169. package/examples/js/postprocessing/GlitchPass.js +10 -11
  170. package/examples/js/postprocessing/HalftonePass.js +9 -9
  171. package/examples/js/postprocessing/LUTPass.js +2 -15
  172. package/examples/js/postprocessing/MaskPass.js +20 -17
  173. package/examples/js/postprocessing/OutlinePass.js +45 -36
  174. package/examples/js/postprocessing/Pass.js +11 -14
  175. package/examples/js/postprocessing/RenderPass.js +3 -7
  176. package/examples/js/postprocessing/SAOPass.js +40 -32
  177. package/examples/js/postprocessing/SMAAPass.js +34 -17
  178. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  179. package/examples/js/postprocessing/SSAOPass.js +56 -42
  180. package/examples/js/postprocessing/SSRPass.js +78 -61
  181. package/examples/js/postprocessing/SavePass.js +14 -6
  182. package/examples/js/postprocessing/ShaderPass.js +9 -8
  183. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  184. package/examples/js/postprocessing/TexturePass.js +7 -4
  185. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  186. package/examples/js/renderers/CSS2DRenderer.js +2 -21
  187. package/examples/js/renderers/CSS3DRenderer.js +3 -24
  188. package/examples/js/renderers/Projector.js +29 -85
  189. package/examples/js/renderers/SVGRenderer.js +4 -50
  190. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  191. package/examples/js/shaders/AfterimageShader.js +3 -6
  192. package/examples/js/shaders/BasicShader.js +3 -6
  193. package/examples/js/shaders/BleachBypassShader.js +3 -6
  194. package/examples/js/shaders/BlendShader.js +3 -6
  195. package/examples/js/shaders/BokehShader.js +3 -6
  196. package/examples/js/shaders/BokehShader2.js +4 -13
  197. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  198. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  199. package/examples/js/shaders/ColorifyShader.js +2 -6
  200. package/examples/js/shaders/ConvolutionShader.js +5 -10
  201. package/examples/js/shaders/CopyShader.js +3 -6
  202. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  203. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  204. package/examples/js/shaders/DigitalGlitch.js +3 -6
  205. package/examples/js/shaders/DotScreenShader.js +2 -6
  206. package/examples/js/shaders/FXAAShader.js +1 -3
  207. package/examples/js/shaders/FilmShader.js +3 -6
  208. package/examples/js/shaders/FocusShader.js +3 -6
  209. package/examples/js/shaders/FreiChenShader.js +2 -6
  210. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  211. package/examples/js/shaders/GodRaysShader.js +11 -24
  212. package/examples/js/shaders/HalftoneShader.js +3 -6
  213. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  214. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  215. package/examples/js/shaders/HueSaturationShader.js +3 -6
  216. package/examples/js/shaders/KaleidoShader.js +3 -6
  217. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  218. package/examples/js/shaders/LuminosityShader.js +3 -6
  219. package/examples/js/shaders/MMDToonShader.js +2 -6
  220. package/examples/js/shaders/MirrorShader.js +3 -6
  221. package/examples/js/shaders/NormalMapShader.js +2 -6
  222. package/examples/js/shaders/RGBShiftShader.js +3 -6
  223. package/examples/js/shaders/SAOShader.js +2 -6
  224. package/examples/js/shaders/SMAAShader.js +6 -18
  225. package/examples/js/shaders/SSAOShader.js +2 -6
  226. package/examples/js/shaders/SSRShader.js +6 -18
  227. package/examples/js/shaders/SepiaShader.js +3 -6
  228. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  229. package/examples/js/shaders/TechnicolorShader.js +3 -6
  230. package/examples/js/shaders/ToneMapShader.js +3 -6
  231. package/examples/js/shaders/ToonShader.js +8 -24
  232. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  233. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  234. package/examples/js/shaders/VelocityShader.js +126 -0
  235. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  236. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  237. package/examples/js/shaders/VignetteShader.js +3 -6
  238. package/examples/js/shaders/VolumeShader.js +2 -6
  239. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  240. package/examples/js/textures/FlakesTexture.js +0 -1
  241. package/examples/js/utils/BufferGeometryUtils.js +234 -168
  242. package/examples/js/utils/CameraUtils.js +5 -20
  243. package/examples/js/utils/GPUStatsPanel.js +3 -12
  244. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  245. package/examples/js/utils/GeometryUtils.js +13 -18
  246. package/examples/js/utils/LDrawUtils.js +8 -11
  247. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  248. package/examples/js/utils/SceneUtils.js +117 -6
  249. package/examples/js/utils/ShadowMapViewer.js +17 -14
  250. package/examples/js/utils/SkeletonUtils.js +13 -27
  251. package/examples/js/utils/UVsDebug.js +20 -12
  252. package/examples/js/utils/WorkerPool.js +1 -11
  253. package/examples/jsm/animation/CCDIKSolver.js +1 -1
  254. package/examples/jsm/capabilities/WebGPU.js +3 -1
  255. package/examples/jsm/controls/OrbitControls.js +44 -4
  256. package/examples/jsm/exporters/GLTFExporter.js +17 -131
  257. package/examples/jsm/exporters/USDZExporter.js +94 -28
  258. package/examples/jsm/interactive/HTMLMesh.js +2 -0
  259. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  260. package/examples/jsm/loaders/3DMLoader.js +1 -2
  261. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  262. package/examples/jsm/loaders/FBXLoader.js +16 -2
  263. package/examples/jsm/loaders/GLTFLoader.js +204 -377
  264. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  265. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  266. package/examples/jsm/loaders/LottieLoader.js +4 -2
  267. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  268. package/examples/jsm/loaders/PCDLoader.js +1 -1
  269. package/examples/jsm/loaders/PLYLoader.js +68 -16
  270. package/examples/jsm/loaders/SVGLoader.js +227 -14
  271. package/examples/jsm/loaders/USDZLoader.js +31 -16
  272. package/examples/jsm/nodes/Nodes.js +14 -2
  273. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  274. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  275. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  276. package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
  277. package/examples/jsm/nodes/core/Node.js +1 -1
  278. package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
  279. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  280. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  281. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  282. package/examples/jsm/nodes/core/constants.js +13 -13
  283. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  284. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  285. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  286. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  287. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  288. package/examples/jsm/nodes/materials/Materials.js +9 -7
  289. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  290. package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
  291. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  292. package/examples/jsm/nodes/math/MathNode.js +5 -0
  293. package/examples/jsm/nodes/math/OperatorNode.js +6 -1
  294. package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
  295. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
  296. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
  297. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  298. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  299. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  300. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  301. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  302. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  303. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  304. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  305. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  306. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  307. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  308. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  309. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  310. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  311. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  312. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  313. package/examples/jsm/postprocessing/OutlinePass.js +10 -0
  314. package/examples/jsm/postprocessing/Pass.js +2 -0
  315. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  316. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  317. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  318. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  319. package/examples/jsm/postprocessing/SavePass.js +17 -1
  320. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  321. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  322. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  323. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  324. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
  325. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  326. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  327. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  328. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  329. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
  330. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  331. package/examples/jsm/shaders/VelocityShader.js +128 -0
  332. package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
  333. package/examples/jsm/utils/SceneUtils.js +129 -4
  334. package/examples/jsm/utils/TextureUtils.js +85 -0
  335. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  336. package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
  337. package/package.json +11 -12
  338. package/src/Three.js +1 -0
  339. package/src/audio/AudioContext.js +5 -5
  340. package/src/cameras/CubeCamera.js +14 -14
  341. package/src/constants.js +1 -1
  342. package/src/core/InstancedBufferGeometry.js +1 -7
  343. package/src/extras/Earcut.js +67 -67
  344. package/src/helpers/DirectionalLightHelper.js +5 -1
  345. package/src/helpers/HemisphereLightHelper.js +4 -1
  346. package/src/helpers/PointLightHelper.js +2 -1
  347. package/src/helpers/SpotLightHelper.js +4 -2
  348. package/src/lights/PointLight.js +2 -2
  349. package/src/lights/SpotLight.js +2 -2
  350. package/src/loaders/FileLoader.js +4 -1
  351. package/src/loaders/ObjectLoader.js +5 -1
  352. package/src/materials/Material.js +1 -1
  353. package/src/math/Color.js +5 -5
  354. package/src/math/Matrix3.js +53 -18
  355. package/src/math/Ray.js +2 -5
  356. package/src/math/Sphere.js +19 -26
  357. package/src/objects/InstancedMesh.js +7 -0
  358. package/src/objects/LOD.js +25 -6
  359. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  360. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  361. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  362. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  363. package/src/renderers/WebGLRenderTarget.js +1 -1
  364. package/src/renderers/WebGLRenderer.js +36 -62
  365. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  367. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  369. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  370. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  371. package/src/renderers/shaders/ShaderChunk.js +3 -0
  372. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  373. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  374. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  375. package/src/renderers/shaders/ShaderLib.js +20 -6
  376. package/src/renderers/shaders/UniformsLib.js +1 -1
  377. package/src/renderers/shaders/UniformsUtils.js +15 -0
  378. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  379. package/src/renderers/webgl/WebGLBackground.js +15 -7
  380. package/src/renderers/webgl/WebGLCubeUVMaps.js +1 -1
  381. package/src/renderers/webgl/WebGLLights.js +0 -4
  382. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  383. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  384. package/src/renderers/webgl/WebGLState.js +31 -1
  385. package/src/renderers/webgl/WebGLTextures.js +71 -18
  386. package/src/renderers/webgl/WebGLUniforms.js +116 -20
  387. package/src/renderers/webgl/WebGLUtils.js +1 -1
  388. package/src/renderers/webxr/WebXRController.js +46 -13
  389. package/src/renderers/webxr/WebXRManager.js +85 -3
  390. package/src/scenes/Scene.js +8 -0
  391. package/src/textures/CompressedArrayTexture.js +18 -0
  392. package/examples/js/libs/lottie_canvas.js +0 -12751
  393. package/examples/js/shaders/PixelShader.js +0 -51
  394. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -6,25 +6,19 @@
6
6
 
7
7
  const Visible = 0;
8
8
  const Deleted = 1;
9
-
10
9
  const _v1 = new THREE.Vector3();
11
-
12
10
  const _line3 = new THREE.Line3();
13
-
14
11
  const _plane = new THREE.Plane();
15
-
16
12
  const _closestPoint = new THREE.Vector3();
17
-
18
13
  const _triangle = new THREE.Triangle();
19
-
20
14
  class ConvexHull {
21
15
 
22
16
  constructor() {
23
17
 
24
18
  this.tolerance = - 1;
25
19
  this.faces = []; // the generated faces of the convex hull
26
-
27
20
  this.newFaces = []; // this array holds the faces that are generated within a single iteration
21
+
28
22
  // the vertex lists work as follows:
29
23
  //
30
24
  // let 'a' and 'b' be 'Face' instances
@@ -35,7 +29,6 @@
35
29
  // | |
36
30
  // a.outside b.outside
37
31
  //
38
-
39
32
  this.assigned = new VertexList();
40
33
  this.unassigned = new VertexList();
41
34
  this.vertices = []; // vertices of the hull (internal representation of given geometry data)
@@ -45,10 +38,10 @@
45
38
  setFromPoints( points ) {
46
39
 
47
40
  // The algorithm needs at least four points.
41
+
48
42
  if ( points.length >= 4 ) {
49
43
 
50
44
  this.makeEmpty();
51
-
52
45
  for ( let i = 0, l = points.length; i < l; i ++ ) {
53
46
 
54
47
  this.vertices.push( new VertexNode( points[ i ] ) );
@@ -62,7 +55,6 @@
62
55
  return this;
63
56
 
64
57
  }
65
-
66
58
  setFromObject( object ) {
67
59
 
68
60
  const points = [];
@@ -70,11 +62,9 @@
70
62
  object.traverse( function ( node ) {
71
63
 
72
64
  const geometry = node.geometry;
73
-
74
65
  if ( geometry !== undefined ) {
75
66
 
76
67
  const attribute = geometry.attributes.position;
77
-
78
68
  if ( attribute !== undefined ) {
79
69
 
80
70
  for ( let i = 0, l = attribute.count; i < l; i ++ ) {
@@ -93,14 +83,14 @@
93
83
  return this.setFromPoints( points );
94
84
 
95
85
  }
96
-
97
86
  containsPoint( point ) {
98
87
 
99
88
  const faces = this.faces;
100
-
101
89
  for ( let i = 0, l = faces.length; i < l; i ++ ) {
102
90
 
103
- const face = faces[ i ]; // compute signed distance and check on what half space the point lies
91
+ const face = faces[ i ];
92
+
93
+ // compute signed distance and check on what half space the point lies
104
94
 
105
95
  if ( face.distanceToPoint( point ) > this.tolerance ) return false;
106
96
 
@@ -109,37 +99,48 @@
109
99
  return true;
110
100
 
111
101
  }
112
-
113
102
  intersectRay( ray, target ) {
114
103
 
115
104
  // based on "Fast Ray-Convex Polyhedron Intersection" by Eric Haines, GRAPHICS GEMS II
105
+
116
106
  const faces = this.faces;
117
107
  let tNear = - Infinity;
118
108
  let tFar = Infinity;
119
-
120
109
  for ( let i = 0, l = faces.length; i < l; i ++ ) {
121
110
 
122
- const face = faces[ i ]; // interpret faces as planes for the further computation
111
+ const face = faces[ i ];
112
+
113
+ // interpret faces as planes for the further computation
123
114
 
124
115
  const vN = face.distanceToPoint( ray.origin );
125
- const vD = face.normal.dot( ray.direction ); // if the origin is on the positive side of a plane (so the plane can "see" the origin) and
116
+ const vD = face.normal.dot( ray.direction );
117
+
118
+ // if the origin is on the positive side of a plane (so the plane can "see" the origin) and
126
119
  // the ray is turned away or parallel to the plane, there is no intersection
127
120
 
128
- if ( vN > 0 && vD >= 0 ) return null; // compute the distance from the ray’s origin to the intersection with the plane
121
+ if ( vN > 0 && vD >= 0 ) return null;
129
122
 
130
- const t = vD !== 0 ? - vN / vD : 0; // only proceed if the distance is positive. a negative distance means the intersection point
123
+ // compute the distance from the ray’s origin to the intersection with the plane
124
+
125
+ const t = vD !== 0 ? - vN / vD : 0;
126
+
127
+ // only proceed if the distance is positive. a negative distance means the intersection point
131
128
  // lies "behind" the origin
132
129
 
133
- if ( t <= 0 ) continue; // now categorized plane as front-facing or back-facing
130
+ if ( t <= 0 ) continue;
131
+
132
+ // now categorized plane as front-facing or back-facing
134
133
 
135
134
  if ( vD > 0 ) {
136
135
 
137
136
  // plane faces away from the ray, so this plane is a back-face
137
+
138
138
  tFar = Math.min( t, tFar );
139
139
 
140
140
  } else {
141
141
 
142
142
  // front-face
143
+
143
144
  tNear = Math.max( t, tNear );
144
145
 
145
146
  }
@@ -147,13 +148,16 @@
147
148
  if ( tNear > tFar ) {
148
149
 
149
150
  // if tNear ever is greater than tFar, the ray must miss the convex hull
151
+
150
152
  return null;
151
153
 
152
154
  }
153
155
 
154
- } // evaluate intersection point
155
- // always try tNear first since its the closer intersection point
156
+ }
156
157
 
158
+ // evaluate intersection point
159
+
160
+ // always try tNear first since its the closer intersection point
157
161
 
158
162
  if ( tNear !== - Infinity ) {
159
163
 
@@ -168,26 +172,24 @@
168
172
  return target;
169
173
 
170
174
  }
171
-
172
175
  intersectsRay( ray ) {
173
176
 
174
177
  return this.intersectRay( ray, _v1 ) !== null;
175
178
 
176
179
  }
177
-
178
180
  makeEmpty() {
179
181
 
180
182
  this.faces = [];
181
183
  this.vertices = [];
182
184
  return this;
183
185
 
184
- } // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face
186
+ }
185
187
 
188
+ // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face
186
189
 
187
190
  addVertexToFace( vertex, face ) {
188
191
 
189
192
  vertex.face = face;
190
-
191
193
  if ( face.outside === null ) {
192
194
 
193
195
  this.assigned.append( vertex );
@@ -201,22 +203,26 @@
201
203
  face.outside = vertex;
202
204
  return this;
203
205
 
204
- } // Removes a vertex from the 'assigned' list of vertices and from the given face
206
+ }
205
207
 
208
+ // Removes a vertex from the 'assigned' list of vertices and from the given face
206
209
 
207
210
  removeVertexFromFace( vertex, face ) {
208
211
 
209
212
  if ( vertex === face.outside ) {
210
213
 
211
214
  // fix face.outside link
215
+
212
216
  if ( vertex.next !== null && vertex.next.face === face ) {
213
217
 
214
218
  // face has at least 2 outside vertices, move the 'outside' reference
219
+
215
220
  face.outside = vertex.next;
216
221
 
217
222
  } else {
218
223
 
219
224
  // vertex was the only outside vertex that face had
225
+
220
226
  face.outside = null;
221
227
 
222
228
  }
@@ -226,24 +232,27 @@
226
232
  this.assigned.remove( vertex );
227
233
  return this;
228
234
 
229
- } // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list
235
+ }
230
236
 
237
+ // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list
231
238
 
232
239
  removeAllVerticesFromFace( face ) {
233
240
 
234
241
  if ( face.outside !== null ) {
235
242
 
236
243
  // reference to the first and last vertex of this face
244
+
237
245
  const start = face.outside;
238
246
  let end = face.outside;
239
-
240
247
  while ( end.next !== null && end.next.face === face ) {
241
248
 
242
249
  end = end.next;
243
250
 
244
251
  }
245
252
 
246
- this.assigned.removeSubList( start, end ); // fix references
253
+ this.assigned.removeSubList( start, end );
254
+
255
+ // fix references
247
256
 
248
257
  start.prev = end.next = null;
249
258
  face.outside = null;
@@ -251,31 +260,35 @@
251
260
 
252
261
  }
253
262
 
254
- } // Removes all the visible vertices that 'face' is able to see
263
+ }
255
264
 
265
+ // Removes all the visible vertices that 'face' is able to see
256
266
 
257
267
  deleteFaceVertices( face, absorbingFace ) {
258
268
 
259
269
  const faceVertices = this.removeAllVerticesFromFace( face );
260
-
261
270
  if ( faceVertices !== undefined ) {
262
271
 
263
272
  if ( absorbingFace === undefined ) {
264
273
 
265
274
  // mark the vertices to be reassigned to some other face
275
+
266
276
  this.unassigned.appendChain( faceVertices );
267
277
 
268
278
  } else {
269
279
 
270
280
  // if there's an absorbing face try to assign as many vertices as possible to it
271
- let vertex = faceVertices;
272
281
 
282
+ let vertex = faceVertices;
273
283
  do {
274
284
 
275
285
  // we need to buffer the subsequent vertex at this point because the 'vertex.next' reference
276
286
  // will be changed by upcoming method calls
287
+
277
288
  const nextVertex = vertex.next;
278
- const distance = absorbingFace.distanceToPoint( vertex.point ); // check if 'vertex' is able to see 'absorbingFace'
289
+ const distance = absorbingFace.distanceToPoint( vertex.point );
290
+
291
+ // check if 'vertex' is able to see 'absorbingFace'
279
292
 
280
293
  if ( distance > this.tolerance ) {
281
294
 
@@ -285,8 +298,9 @@
285
298
 
286
299
  this.unassigned.append( vertex );
287
300
 
288
- } // now assign next vertex
301
+ }
289
302
 
303
+ // now assign next vertex
290
304
 
291
305
  vertex = nextVertex;
292
306
 
@@ -298,30 +312,28 @@
298
312
 
299
313
  return this;
300
314
 
301
- } // Reassigns as many vertices as possible from the unassigned list to the new faces
315
+ }
302
316
 
317
+ // Reassigns as many vertices as possible from the unassigned list to the new faces
303
318
 
304
319
  resolveUnassignedPoints( newFaces ) {
305
320
 
306
321
  if ( this.unassigned.isEmpty() === false ) {
307
322
 
308
323
  let vertex = this.unassigned.first();
309
-
310
324
  do {
311
325
 
312
326
  // buffer 'next' reference, see .deleteFaceVertices()
327
+
313
328
  const nextVertex = vertex.next;
314
329
  let maxDistance = this.tolerance;
315
330
  let maxFace = null;
316
-
317
331
  for ( let i = 0; i < newFaces.length; i ++ ) {
318
332
 
319
333
  const face = newFaces[ i ];
320
-
321
334
  if ( face.mark === Visible ) {
322
335
 
323
336
  const distance = face.distanceToPoint( vertex.point );
324
-
325
337
  if ( distance > maxDistance ) {
326
338
 
327
339
  maxDistance = distance;
@@ -333,8 +345,9 @@
333
345
 
334
346
  }
335
347
 
336
- } // 'maxFace' can be null e.g. if there are identical vertices
348
+ }
337
349
 
350
+ // 'maxFace' can be null e.g. if there are identical vertices
338
351
 
339
352
  if ( maxFace !== null ) {
340
353
 
@@ -350,15 +363,18 @@
350
363
 
351
364
  return this;
352
365
 
353
- } // Computes the extremes of a simplex which will be the initial hull
366
+ }
354
367
 
368
+ // Computes the extremes of a simplex which will be the initial hull
355
369
 
356
370
  computeExtremes() {
357
371
 
358
372
  const min = new THREE.Vector3();
359
373
  const max = new THREE.Vector3();
360
374
  const minVertices = [];
361
- const maxVertices = []; // initially assume that the first vertex is the min/max
375
+ const maxVertices = [];
376
+
377
+ // initially assume that the first vertex is the min/max
362
378
 
363
379
  for ( let i = 0; i < 3; i ++ ) {
364
380
 
@@ -367,12 +383,16 @@
367
383
  }
368
384
 
369
385
  min.copy( this.vertices[ 0 ].point );
370
- max.copy( this.vertices[ 0 ].point ); // compute the min/max vertex on all six directions
386
+ max.copy( this.vertices[ 0 ].point );
387
+
388
+ // compute the min/max vertex on all six directions
371
389
 
372
390
  for ( let i = 0, l = this.vertices.length; i < l; i ++ ) {
373
391
 
374
392
  const vertex = this.vertices[ i ];
375
- const point = vertex.point; // update the min coordinates
393
+ const point = vertex.point;
394
+
395
+ // update the min coordinates
376
396
 
377
397
  for ( let j = 0; j < 3; j ++ ) {
378
398
 
@@ -383,8 +403,9 @@
383
403
 
384
404
  }
385
405
 
386
- } // update the max coordinates
406
+ }
387
407
 
408
+ // update the max coordinates
388
409
 
389
410
  for ( let j = 0; j < 3; j ++ ) {
390
411
 
@@ -397,8 +418,9 @@
397
418
 
398
419
  }
399
420
 
400
- } // use min/max vectors to compute an optimal epsilon
421
+ }
401
422
 
423
+ // use min/max vectors to compute an optimal epsilon
402
424
 
403
425
  this.tolerance = 3 * Number.EPSILON * ( Math.max( Math.abs( min.x ), Math.abs( max.x ) ) + Math.max( Math.abs( min.y ), Math.abs( max.y ) ) + Math.max( Math.abs( min.z ), Math.abs( max.z ) ) );
404
426
  return {
@@ -406,27 +428,28 @@
406
428
  max: maxVertices
407
429
  };
408
430
 
409
- } // Computes the initial simplex assigning to its faces all the points
410
- // that are candidates to form part of the hull
431
+ }
411
432
 
433
+ // Computes the initial simplex assigning to its faces all the points
434
+ // that are candidates to form part of the hull
412
435
 
413
436
  computeInitialHull() {
414
437
 
415
438
  const vertices = this.vertices;
416
439
  const extremes = this.computeExtremes();
417
440
  const min = extremes.min;
418
- const max = extremes.max; // 1. Find the two vertices 'v0' and 'v1' with the greatest 1d separation
441
+ const max = extremes.max;
442
+
443
+ // 1. Find the two vertices 'v0' and 'v1' with the greatest 1d separation
419
444
  // (max.x - min.x)
420
445
  // (max.y - min.y)
421
446
  // (max.z - min.z)
422
447
 
423
448
  let maxDistance = 0;
424
449
  let index = 0;
425
-
426
450
  for ( let i = 0; i < 3; i ++ ) {
427
451
 
428
452
  const distance = max[ i ].point.getComponent( i ) - min[ i ].point.getComponent( i );
429
-
430
453
  if ( distance > maxDistance ) {
431
454
 
432
455
  maxDistance = distance;
@@ -439,22 +462,19 @@
439
462
  const v0 = min[ index ];
440
463
  const v1 = max[ index ];
441
464
  let v2;
442
- let v3; // 2. The next vertex 'v2' is the one farthest to the line formed by 'v0' and 'v1'
465
+ let v3;
443
466
 
444
- maxDistance = 0;
467
+ // 2. The next vertex 'v2' is the one farthest to the line formed by 'v0' and 'v1'
445
468
 
469
+ maxDistance = 0;
446
470
  _line3.set( v0.point, v1.point );
447
-
448
471
  for ( let i = 0, l = this.vertices.length; i < l; i ++ ) {
449
472
 
450
473
  const vertex = vertices[ i ];
451
-
452
474
  if ( vertex !== v0 && vertex !== v1 ) {
453
475
 
454
476
  _line3.closestPointToPoint( vertex.point, true, _closestPoint );
455
-
456
477
  const distance = _closestPoint.distanceToSquared( vertex.point );
457
-
458
478
  if ( distance > maxDistance ) {
459
479
 
460
480
  maxDistance = distance;
@@ -464,21 +484,18 @@
464
484
 
465
485
  }
466
486
 
467
- } // 3. The next vertex 'v3' is the one farthest to the plane 'v0', 'v1', 'v2'
487
+ }
468
488
 
489
+ // 3. The next vertex 'v3' is the one farthest to the plane 'v0', 'v1', 'v2'
469
490
 
470
491
  maxDistance = - 1;
471
-
472
492
  _plane.setFromCoplanarPoints( v0.point, v1.point, v2.point );
473
-
474
493
  for ( let i = 0, l = this.vertices.length; i < l; i ++ ) {
475
494
 
476
495
  const vertex = vertices[ i ];
477
-
478
496
  if ( vertex !== v0 && vertex !== v1 && vertex !== v2 ) {
479
497
 
480
498
  const distance = Math.abs( _plane.distanceToPoint( vertex.point ) );
481
-
482
499
  if ( distance > maxDistance ) {
483
500
 
484
501
  maxDistance = distance;
@@ -491,17 +508,23 @@
491
508
  }
492
509
 
493
510
  const faces = [];
494
-
495
511
  if ( _plane.distanceToPoint( v3.point ) < 0 ) {
496
512
 
497
513
  // the face is not able to see the point so 'plane.normal' is pointing outside the tetrahedron
498
- faces.push( Face.create( v0, v1, v2 ), Face.create( v3, v1, v0 ), Face.create( v3, v2, v1 ), Face.create( v3, v0, v2 ) ); // set the twin edge
514
+
515
+ faces.push( Face.create( v0, v1, v2 ), Face.create( v3, v1, v0 ), Face.create( v3, v2, v1 ), Face.create( v3, v0, v2 ) );
516
+
517
+ // set the twin edge
499
518
 
500
519
  for ( let i = 0; i < 3; i ++ ) {
501
520
 
502
- const j = ( i + 1 ) % 3; // join face[ i ] i > 0, with the first face
521
+ const j = ( i + 1 ) % 3;
503
522
 
504
- faces[ i + 1 ].getEdge( 2 ).setTwin( faces[ 0 ].getEdge( j ) ); // join face[ i ] with face[ i + 1 ], 1 <= i <= 3
523
+ // join face[ i ] i > 0, with the first face
524
+
525
+ faces[ i + 1 ].getEdge( 2 ).setTwin( faces[ 0 ].getEdge( j ) );
526
+
527
+ // join face[ i ] with face[ i + 1 ], 1 <= i <= 3
505
528
 
506
529
  faces[ i + 1 ].getEdge( 1 ).setTwin( faces[ j + 1 ].getEdge( 0 ) );
507
530
 
@@ -510,41 +533,47 @@
510
533
  } else {
511
534
 
512
535
  // the face is able to see the point so 'plane.normal' is pointing inside the tetrahedron
513
- faces.push( Face.create( v0, v2, v1 ), Face.create( v3, v0, v1 ), Face.create( v3, v1, v2 ), Face.create( v3, v2, v0 ) ); // set the twin edge
536
+
537
+ faces.push( Face.create( v0, v2, v1 ), Face.create( v3, v0, v1 ), Face.create( v3, v1, v2 ), Face.create( v3, v2, v0 ) );
538
+
539
+ // set the twin edge
514
540
 
515
541
  for ( let i = 0; i < 3; i ++ ) {
516
542
 
517
- const j = ( i + 1 ) % 3; // join face[ i ] i > 0, with the first face
543
+ const j = ( i + 1 ) % 3;
544
+
545
+ // join face[ i ] i > 0, with the first face
546
+
547
+ faces[ i + 1 ].getEdge( 2 ).setTwin( faces[ 0 ].getEdge( ( 3 - i ) % 3 ) );
518
548
 
519
- faces[ i + 1 ].getEdge( 2 ).setTwin( faces[ 0 ].getEdge( ( 3 - i ) % 3 ) ); // join face[ i ] with face[ i + 1 ]
549
+ // join face[ i ] with face[ i + 1 ]
520
550
 
521
551
  faces[ i + 1 ].getEdge( 0 ).setTwin( faces[ j + 1 ].getEdge( 1 ) );
522
552
 
523
553
  }
524
554
 
525
- } // the initial hull is the tetrahedron
555
+ }
526
556
 
557
+ // the initial hull is the tetrahedron
527
558
 
528
559
  for ( let i = 0; i < 4; i ++ ) {
529
560
 
530
561
  this.faces.push( faces[ i ] );
531
562
 
532
- } // initial assignment of vertices to the faces of the tetrahedron
563
+ }
533
564
 
565
+ // initial assignment of vertices to the faces of the tetrahedron
534
566
 
535
567
  for ( let i = 0, l = vertices.length; i < l; i ++ ) {
536
568
 
537
569
  const vertex = vertices[ i ];
538
-
539
570
  if ( vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3 ) {
540
571
 
541
572
  maxDistance = this.tolerance;
542
573
  let maxFace = null;
543
-
544
574
  for ( let j = 0; j < 4; j ++ ) {
545
575
 
546
576
  const distance = this.faces[ j ].distanceToPoint( vertex.point );
547
-
548
577
  if ( distance > maxDistance ) {
549
578
 
550
579
  maxDistance = distance;
@@ -566,17 +595,16 @@
566
595
 
567
596
  return this;
568
597
 
569
- } // Removes inactive faces
598
+ }
570
599
 
600
+ // Removes inactive faces
571
601
 
572
602
  reindexFaces() {
573
603
 
574
604
  const activeFaces = [];
575
-
576
605
  for ( let i = 0; i < this.faces.length; i ++ ) {
577
606
 
578
607
  const face = this.faces[ i ];
579
-
580
608
  if ( face.mark === Visible ) {
581
609
 
582
610
  activeFaces.push( face );
@@ -588,24 +616,29 @@
588
616
  this.faces = activeFaces;
589
617
  return this;
590
618
 
591
- } // Finds the next vertex to create faces with the current hull
619
+ }
592
620
 
621
+ // Finds the next vertex to create faces with the current hull
593
622
 
594
623
  nextVertexToAdd() {
595
624
 
596
625
  // if the 'assigned' list of vertices is empty, no vertices are left. return with 'undefined'
626
+
597
627
  if ( this.assigned.isEmpty() === false ) {
598
628
 
599
629
  let eyeVertex,
600
- maxDistance = 0; // grap the first available face and start with the first visible vertex of that face
630
+ maxDistance = 0;
631
+
632
+ // grap the first available face and start with the first visible vertex of that face
601
633
 
602
634
  const eyeFace = this.assigned.first().face;
603
- let vertex = eyeFace.outside; // now calculate the farthest vertex that face can see
635
+ let vertex = eyeFace.outside;
636
+
637
+ // now calculate the farthest vertex that face can see
604
638
 
605
639
  do {
606
640
 
607
641
  const distance = eyeFace.distanceToPoint( vertex.point );
608
-
609
642
  if ( distance > maxDistance ) {
610
643
 
611
644
  maxDistance = distance;
@@ -621,18 +654,19 @@
621
654
 
622
655
  }
623
656
 
624
- } // Computes a chain of half edges in CCW order called the 'horizon'.
657
+ }
658
+
659
+ // Computes a chain of half edges in CCW order called the 'horizon'.
625
660
  // For an edge to be part of the horizon it must join a face that can see
626
661
  // 'eyePoint' and a face that cannot see 'eyePoint'.
627
662
 
628
-
629
663
  computeHorizon( eyePoint, crossEdge, face, horizon ) {
630
664
 
631
665
  // moves face's vertices to the 'unassigned' vertex list
666
+
632
667
  this.deleteFaceVertices( face );
633
668
  face.mark = Deleted;
634
669
  let edge;
635
-
636
670
  if ( crossEdge === null ) {
637
671
 
638
672
  edge = crossEdge = face.getEdge( 0 );
@@ -641,6 +675,7 @@
641
675
 
642
676
  // start from the next edge since 'crossEdge' was already analyzed
643
677
  // (actually 'crossEdge.twin' was the edge who called this method recursively)
678
+
644
679
  edge = crossEdge.next;
645
680
 
646
681
  }
@@ -649,17 +684,18 @@
649
684
 
650
685
  const twinEdge = edge.twin;
651
686
  const oppositeFace = twinEdge.face;
652
-
653
687
  if ( oppositeFace.mark === Visible ) {
654
688
 
655
689
  if ( oppositeFace.distanceToPoint( eyePoint ) > this.tolerance ) {
656
690
 
657
691
  // the opposite face can see the vertex, so proceed with next edge
692
+
658
693
  this.computeHorizon( eyePoint, twinEdge, oppositeFace, horizon );
659
694
 
660
695
  } else {
661
696
 
662
697
  // the opposite face can't see the vertex, so this edge is part of the horizon
698
+
663
699
  horizon.push( edge );
664
700
 
665
701
  }
@@ -672,34 +708,39 @@
672
708
 
673
709
  return this;
674
710
 
675
- } // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order
711
+ }
676
712
 
713
+ // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order
677
714
 
678
715
  addAdjoiningFace( eyeVertex, horizonEdge ) {
679
716
 
680
717
  // all the half edges are created in ccw order thus the face is always pointing outside the hull
718
+
681
719
  const face = Face.create( eyeVertex, horizonEdge.tail(), horizonEdge.head() );
682
- this.faces.push( face ); // join face.getEdge( - 1 ) with the horizon's opposite edge face.getEdge( - 1 ) = face.getEdge( 2 )
720
+ this.faces.push( face );
721
+
722
+ // join face.getEdge( - 1 ) with the horizon's opposite edge face.getEdge( - 1 ) = face.getEdge( 2 )
683
723
 
684
724
  face.getEdge( - 1 ).setTwin( horizonEdge.twin );
685
725
  return face.getEdge( 0 ); // the half edge whose vertex is the eyeVertex
686
726
 
687
- } // Adds 'horizon.length' faces to the hull, each face will be linked with the
688
- // horizon opposite face and the face on the left/right
727
+ }
689
728
 
729
+ // Adds 'horizon.length' faces to the hull, each face will be linked with the
730
+ // horizon opposite face and the face on the left/right
690
731
 
691
732
  addNewFaces( eyeVertex, horizon ) {
692
733
 
693
734
  this.newFaces = [];
694
735
  let firstSideEdge = null;
695
736
  let previousSideEdge = null;
696
-
697
737
  for ( let i = 0; i < horizon.length; i ++ ) {
698
738
 
699
- const horizonEdge = horizon[ i ]; // returns the right side edge
739
+ const horizonEdge = horizon[ i ];
700
740
 
701
- const sideEdge = this.addAdjoiningFace( eyeVertex, horizonEdge );
741
+ // returns the right side edge
702
742
 
743
+ const sideEdge = this.addAdjoiningFace( eyeVertex, horizonEdge );
703
744
  if ( firstSideEdge === null ) {
704
745
 
705
746
  firstSideEdge = sideEdge;
@@ -707,6 +748,7 @@
707
748
  } else {
708
749
 
709
750
  // joins face.getEdge( 1 ) with previousFace.getEdge( 0 )
751
+
710
752
  sideEdge.next.setTwin( previousSideEdge );
711
753
 
712
754
  }
@@ -714,29 +756,34 @@
714
756
  this.newFaces.push( sideEdge.face );
715
757
  previousSideEdge = sideEdge;
716
758
 
717
- } // perform final join of new faces
759
+ }
718
760
 
761
+ // perform final join of new faces
719
762
 
720
763
  firstSideEdge.next.setTwin( previousSideEdge );
721
764
  return this;
722
765
 
723
- } // Adds a vertex to the hull
766
+ }
724
767
 
768
+ // Adds a vertex to the hull
725
769
 
726
770
  addVertexToHull( eyeVertex ) {
727
771
 
728
772
  const horizon = [];
729
- this.unassigned.clear(); // remove 'eyeVertex' from 'eyeVertex.face' so that it can't be added to the 'unassigned' vertex list
773
+ this.unassigned.clear();
774
+
775
+ // remove 'eyeVertex' from 'eyeVertex.face' so that it can't be added to the 'unassigned' vertex list
730
776
 
731
777
  this.removeVertexFromFace( eyeVertex, eyeVertex.face );
732
778
  this.computeHorizon( eyeVertex.point, null, eyeVertex.face, horizon );
733
- this.addNewFaces( eyeVertex, horizon ); // reassign 'unassigned' vertices to the new faces
779
+ this.addNewFaces( eyeVertex, horizon );
780
+
781
+ // reassign 'unassigned' vertices to the new faces
734
782
 
735
783
  this.resolveUnassignedPoints( this.newFaces );
736
784
  return this;
737
785
 
738
786
  }
739
-
740
787
  cleanup() {
741
788
 
742
789
  this.assigned.clear();
@@ -745,11 +792,12 @@
745
792
  return this;
746
793
 
747
794
  }
748
-
749
795
  compute() {
750
796
 
751
797
  let vertex;
752
- this.computeInitialHull(); // add all available vertices gradually to the hull
798
+ this.computeInitialHull();
799
+
800
+ // add all available vertices gradually to the hull
753
801
 
754
802
  while ( ( vertex = this.nextVertexToAdd() ) !== undefined ) {
755
803
 
@@ -763,8 +811,9 @@
763
811
 
764
812
  }
765
813
 
766
- } //
814
+ }
767
815
 
816
+ //
768
817
 
769
818
  class Face {
770
819
 
@@ -774,34 +823,33 @@
774
823
  this.midpoint = new THREE.Vector3();
775
824
  this.area = 0;
776
825
  this.constant = 0; // signed distance from face to the origin
777
-
778
826
  this.outside = null; // reference to a vertex in a vertex list this face can see
779
-
780
827
  this.mark = Visible;
781
828
  this.edge = null;
782
829
 
783
830
  }
784
-
785
831
  static create( a, b, c ) {
786
832
 
787
833
  const face = new Face();
788
834
  const e0 = new HalfEdge( a, face );
789
835
  const e1 = new HalfEdge( b, face );
790
- const e2 = new HalfEdge( c, face ); // join edges
836
+ const e2 = new HalfEdge( c, face );
837
+
838
+ // join edges
791
839
 
792
840
  e0.next = e2.prev = e1;
793
841
  e1.next = e0.prev = e2;
794
- e2.next = e1.prev = e0; // main half edge reference
842
+ e2.next = e1.prev = e0;
843
+
844
+ // main half edge reference
795
845
 
796
846
  face.edge = e0;
797
847
  return face.compute();
798
848
 
799
849
  }
800
-
801
850
  getEdge( i ) {
802
851
 
803
852
  let edge = this.edge;
804
-
805
853
  while ( i > 0 ) {
806
854
 
807
855
  edge = edge.next;
@@ -819,33 +867,28 @@
819
867
  return edge;
820
868
 
821
869
  }
822
-
823
870
  compute() {
824
871
 
825
872
  const a = this.edge.tail();
826
873
  const b = this.edge.head();
827
874
  const c = this.edge.next.head();
828
-
829
875
  _triangle.set( a.point, b.point, c.point );
830
-
831
876
  _triangle.getNormal( this.normal );
832
-
833
877
  _triangle.getMidpoint( this.midpoint );
834
-
835
878
  this.area = _triangle.getArea();
836
879
  this.constant = this.normal.dot( this.midpoint );
837
880
  return this;
838
881
 
839
882
  }
840
-
841
883
  distanceToPoint( point ) {
842
884
 
843
885
  return this.normal.dot( point ) - this.constant;
844
886
 
845
887
  }
846
888
 
847
- } // Entity for a Doubly-Connected Edge List (DCEL).
889
+ }
848
890
 
891
+ // Entity for a Doubly-Connected Edge List (DCEL).
849
892
 
850
893
  class HalfEdge {
851
894
 
@@ -858,24 +901,20 @@
858
901
  this.face = face;
859
902
 
860
903
  }
861
-
862
904
  head() {
863
905
 
864
906
  return this.vertex;
865
907
 
866
908
  }
867
-
868
909
  tail() {
869
910
 
870
911
  return this.prev ? this.prev.vertex : null;
871
912
 
872
913
  }
873
-
874
914
  length() {
875
915
 
876
916
  const head = this.head();
877
917
  const tail = this.tail();
878
-
879
918
  if ( tail !== null ) {
880
919
 
881
920
  return tail.point.distanceTo( head.point );
@@ -885,12 +924,10 @@
885
924
  return - 1;
886
925
 
887
926
  }
888
-
889
927
  lengthSquared() {
890
928
 
891
929
  const head = this.head();
892
930
  const tail = this.tail();
893
-
894
931
  if ( tail !== null ) {
895
932
 
896
933
  return tail.point.distanceToSquared( head.point );
@@ -900,7 +937,6 @@
900
937
  return - 1;
901
938
 
902
939
  }
903
-
904
940
  setTwin( edge ) {
905
941
 
906
942
  this.twin = edge;
@@ -909,8 +945,9 @@
909
945
 
910
946
  }
911
947
 
912
- } // A vertex as a double linked list node.
948
+ }
913
949
 
950
+ // A vertex as a double linked list node.
914
951
 
915
952
  class VertexNode {
916
953
 
@@ -923,8 +960,9 @@
923
960
 
924
961
  }
925
962
 
926
- } // A double linked list that contains vertex nodes.
963
+ }
927
964
 
965
+ // A double linked list that contains vertex nodes.
928
966
 
929
967
  class VertexList {
930
968
 
@@ -934,32 +972,29 @@
934
972
  this.tail = null;
935
973
 
936
974
  }
937
-
938
975
  first() {
939
976
 
940
977
  return this.head;
941
978
 
942
979
  }
943
-
944
980
  last() {
945
981
 
946
982
  return this.tail;
947
983
 
948
984
  }
949
-
950
985
  clear() {
951
986
 
952
987
  this.head = this.tail = null;
953
988
  return this;
954
989
 
955
- } // Inserts a vertex before the target vertex
990
+ }
956
991
 
992
+ // Inserts a vertex before the target vertex
957
993
 
958
994
  insertBefore( target, vertex ) {
959
995
 
960
996
  vertex.prev = target.prev;
961
997
  vertex.next = target;
962
-
963
998
  if ( vertex.prev === null ) {
964
999
 
965
1000
  this.head = vertex;
@@ -973,14 +1008,14 @@
973
1008
  target.prev = vertex;
974
1009
  return this;
975
1010
 
976
- } // Inserts a vertex after the target vertex
1011
+ }
977
1012
 
1013
+ // Inserts a vertex after the target vertex
978
1014
 
979
1015
  insertAfter( target, vertex ) {
980
1016
 
981
1017
  vertex.prev = target;
982
1018
  vertex.next = target.next;
983
-
984
1019
  if ( vertex.next === null ) {
985
1020
 
986
1021
  this.tail = vertex;
@@ -994,8 +1029,9 @@
994
1029
  target.next = vertex;
995
1030
  return this;
996
1031
 
997
- } // Appends a vertex to the end of the linked list
1032
+ }
998
1033
 
1034
+ // Appends a vertex to the end of the linked list
999
1035
 
1000
1036
  append( vertex ) {
1001
1037
 
@@ -1015,8 +1051,9 @@
1015
1051
  this.tail = vertex;
1016
1052
  return this;
1017
1053
 
1018
- } // Appends a chain of vertices where 'vertex' is the head.
1054
+ }
1019
1055
 
1056
+ // Appends a chain of vertices where 'vertex' is the head.
1020
1057
 
1021
1058
  appendChain( vertex ) {
1022
1059
 
@@ -1030,7 +1067,9 @@
1030
1067
 
1031
1068
  }
1032
1069
 
1033
- vertex.prev = this.tail; // ensure that the 'tail' reference points to the last vertex of the chain
1070
+ vertex.prev = this.tail;
1071
+
1072
+ // ensure that the 'tail' reference points to the last vertex of the chain
1034
1073
 
1035
1074
  while ( vertex.next !== null ) {
1036
1075
 
@@ -1041,8 +1080,9 @@
1041
1080
  this.tail = vertex;
1042
1081
  return this;
1043
1082
 
1044
- } // Removes a vertex from the linked list
1083
+ }
1045
1084
 
1085
+ // Removes a vertex from the linked list
1046
1086
 
1047
1087
  remove( vertex ) {
1048
1088
 
@@ -1068,8 +1108,9 @@
1068
1108
 
1069
1109
  return this;
1070
1110
 
1071
- } // Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b
1111
+ }
1072
1112
 
1113
+ // Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b
1073
1114
 
1074
1115
  removeSubList( a, b ) {
1075
1116
 
@@ -1096,7 +1137,6 @@
1096
1137
  return this;
1097
1138
 
1098
1139
  }
1099
-
1100
1140
  isEmpty() {
1101
1141
 
1102
1142
  return this.head === null;
@@ -1106,5 +1146,9 @@
1106
1146
  }
1107
1147
 
1108
1148
  THREE.ConvexHull = ConvexHull;
1149
+ THREE.Face = Face;
1150
+ THREE.HalfEdge = HalfEdge;
1151
+ THREE.VertexList = VertexList;
1152
+ THREE.VertexNode = VertexNode;
1109
1153
 
1110
1154
  } )();