@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
@@ -7,7 +7,6 @@
7
7
  super( manager );
8
8
 
9
9
  }
10
-
11
10
  load( url, onLoad, onProgress, onError ) {
12
11
 
13
12
  const scope = this;
@@ -41,40 +40,52 @@
41
40
  }, onProgress, onError );
42
41
 
43
42
  }
44
-
45
43
  parse( data ) {
46
44
 
47
45
  function parseASCII( data ) {
48
46
 
49
47
  // connectivity of the triangles
50
- const indices = []; // triangles vertices
48
+ const indices = [];
51
49
 
52
- const positions = []; // red, green, blue colors in the range 0 to 1
50
+ // triangles vertices
51
+ const positions = [];
53
52
 
54
- const colors = []; // normal vector, one per vertex
53
+ // red, green, blue colors in the range 0 to 1
54
+ const colors = [];
55
55
 
56
+ // normal vector, one per vertex
56
57
  const normals = [];
57
- let result; // pattern for detecting the end of a number sequence
58
+ let result;
58
59
 
59
- const patWord = /^[^\d.\s-]+/; // pattern for reading vertices, 3 floats or integers
60
+ // pattern for detecting the end of a number sequence
61
+ const patWord = /^[^\d.\s-]+/;
60
62
 
61
- const pat3Floats = /(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g; // pattern for connectivity, an integer followed by any number of ints
62
- // the first integer is the number of polygon nodes
63
+ // pattern for reading vertices, 3 floats or integers
64
+ const pat3Floats = /(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g;
63
65
 
64
- const patConnectivity = /^(\d+)\s+([\s\d]*)/; // indicates start of vertex data section
66
+ // pattern for connectivity, an integer followed by any number of ints
67
+ // the first integer is the number of polygon nodes
68
+ const patConnectivity = /^(\d+)\s+([\s\d]*)/;
65
69
 
66
- const patPOINTS = /^POINTS /; // indicates start of polygon connectivity section
70
+ // indicates start of vertex data section
71
+ const patPOINTS = /^POINTS /;
67
72
 
68
- const patPOLYGONS = /^POLYGONS /; // indicates start of triangle strips section
73
+ // indicates start of polygon connectivity section
74
+ const patPOLYGONS = /^POLYGONS /;
69
75
 
70
- const patTRIANGLE_STRIPS = /^TRIANGLE_STRIPS /; // POINT_DATA number_of_values
76
+ // indicates start of triangle strips section
77
+ const patTRIANGLE_STRIPS = /^TRIANGLE_STRIPS /;
71
78
 
72
- const patPOINT_DATA = /^POINT_DATA[ ]+(\d+)/; // CELL_DATA number_of_polys
79
+ // POINT_DATA number_of_values
80
+ const patPOINT_DATA = /^POINT_DATA[ ]+(\d+)/;
73
81
 
74
- const patCELL_DATA = /^CELL_DATA[ ]+(\d+)/; // Start of color section
82
+ // CELL_DATA number_of_polys
83
+ const patCELL_DATA = /^CELL_DATA[ ]+(\d+)/;
75
84
 
76
- const patCOLOR_SCALARS = /^COLOR_SCALARS[ ]+(\w+)[ ]+3/; // NORMALS Normals float
85
+ // Start of color section
86
+ const patCOLOR_SCALARS = /^COLOR_SCALARS[ ]+(\w+)[ ]+3/;
77
87
 
88
+ // NORMALS Normals float
78
89
  const patNORMALS = /^NORMALS[ ]+(\w+)[ ]+(\w+)/;
79
90
  let inPointsSection = false;
80
91
  let inPolygonsSection = false;
@@ -84,11 +95,9 @@
84
95
  let inColorSection = false;
85
96
  let inNormalsSection = false;
86
97
  const lines = data.split( '\n' );
87
-
88
98
  for ( const i in lines ) {
89
99
 
90
100
  const line = lines[ i ].trim();
91
-
92
101
  if ( line.indexOf( 'DATASET' ) === 0 ) {
93
102
 
94
103
  const dataset = line.split( ' ' )[ 1 ];
@@ -114,12 +123,11 @@
114
123
  // numVertices i0 i1 i2 ...
115
124
  const numVertices = parseInt( result[ 1 ] );
116
125
  const inds = result[ 2 ].split( /\s+/ );
117
-
118
126
  if ( numVertices >= 3 ) {
119
127
 
120
128
  const i0 = parseInt( inds[ 0 ] );
121
- let k = 1; // split the polygon in numVertices - 2 triangles
122
-
129
+ let k = 1;
130
+ // split the polygon in numVertices - 2 triangles
123
131
  for ( let j = 0; j < numVertices - 2; ++ j ) {
124
132
 
125
133
  const i1 = parseInt( inds[ k ] );
@@ -140,7 +148,6 @@
140
148
  // numVertices i0 i1 i2 ...
141
149
  const numVertices = parseInt( result[ 1 ] );
142
150
  const inds = result[ 2 ].split( /\s+/ );
143
-
144
151
  if ( numVertices >= 3 ) {
145
152
 
146
153
  // split the polygon in numVertices - 2 triangles
@@ -173,6 +180,7 @@
173
180
  if ( inColorSection ) {
174
181
 
175
182
  // Get the colors
183
+
176
184
  while ( ( result = pat3Floats.exec( line ) ) !== null ) {
177
185
 
178
186
  if ( patWord.exec( line ) !== null ) break;
@@ -186,6 +194,7 @@
186
194
  } else if ( inNormalsSection ) {
187
195
 
188
196
  // Get the normal vectors
197
+
189
198
  while ( ( result = pat3Floats.exec( line ) ) !== null ) {
190
199
 
191
200
  if ( patWord.exec( line ) !== null ) break;
@@ -255,7 +264,6 @@
255
264
  let geometry = new THREE.BufferGeometry();
256
265
  geometry.setIndex( indices );
257
266
  geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
258
-
259
267
  if ( normals.length === positions.length ) {
260
268
 
261
269
  geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
@@ -265,6 +273,7 @@
265
273
  if ( colors.length !== indices.length ) {
266
274
 
267
275
  // stagger
276
+
268
277
  if ( colors.length === positions.length ) {
269
278
 
270
279
  geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
@@ -274,13 +283,12 @@
274
283
  } else {
275
284
 
276
285
  // cell
286
+
277
287
  geometry = geometry.toNonIndexed();
278
288
  const numTriangles = geometry.attributes.position.count / 3;
279
-
280
289
  if ( colors.length === numTriangles * 3 ) {
281
290
 
282
291
  const newColors = [];
283
-
284
292
  for ( let i = 0; i < numTriangles; i ++ ) {
285
293
 
286
294
  const r = colors[ 3 * i + 0 ];
@@ -305,19 +313,18 @@
305
313
  function parseBinary( data ) {
306
314
 
307
315
  const buffer = new Uint8Array( data );
308
- const dataView = new DataView( data ); // Points and normals, by default, are empty
316
+ const dataView = new DataView( data );
309
317
 
318
+ // Points and normals, by default, are empty
310
319
  let points = [];
311
320
  let normals = [];
312
321
  let indices = [];
313
322
  let index = 0;
314
-
315
323
  function findString( buffer, start ) {
316
324
 
317
325
  let index = start;
318
326
  let c = buffer[ index ];
319
327
  const s = [];
320
-
321
328
  while ( c !== 10 ) {
322
329
 
323
330
  s.push( String.fromCharCode( c ) );
@@ -336,13 +343,11 @@
336
343
  }
337
344
 
338
345
  let state, line;
339
-
340
346
  while ( true ) {
341
347
 
342
348
  // Get a string
343
349
  state = findString( buffer, index );
344
350
  line = state.parsedString;
345
-
346
351
  if ( line.indexOf( 'DATASET' ) === 0 ) {
347
352
 
348
353
  const dataset = line.split( ' ' )[ 1 ];
@@ -351,12 +356,12 @@
351
356
  } else if ( line.indexOf( 'POINTS' ) === 0 ) {
352
357
 
353
358
  // Add the points
354
- const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Each point is 3 4-byte floats
359
+ const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 );
355
360
 
361
+ // Each point is 3 4-byte floats
356
362
  const count = numberOfPoints * 4 * 3;
357
363
  points = new Float32Array( numberOfPoints * 3 );
358
364
  let pointIndex = state.next;
359
-
360
365
  for ( let i = 0; i < numberOfPoints; i ++ ) {
361
366
 
362
367
  points[ 3 * i ] = dataView.getFloat32( pointIndex, false );
@@ -364,36 +369,34 @@
364
369
  points[ 3 * i + 2 ] = dataView.getFloat32( pointIndex + 8, false );
365
370
  pointIndex = pointIndex + 12;
366
371
 
367
- } // increment our next pointer
368
-
372
+ }
369
373
 
374
+ // increment our next pointer
370
375
  state.next = state.next + count + 1;
371
376
 
372
377
  } else if ( line.indexOf( 'TRIANGLE_STRIPS' ) === 0 ) {
373
378
 
374
379
  const numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
375
- const size = parseInt( line.split( ' ' )[ 2 ], 10 ); // 4 byte integers
376
-
380
+ const size = parseInt( line.split( ' ' )[ 2 ], 10 );
381
+ // 4 byte integers
377
382
  const count = size * 4;
378
383
  indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
379
384
  let indicesIndex = 0;
380
385
  let pointIndex = state.next;
381
-
382
386
  for ( let i = 0; i < numberOfStrips; i ++ ) {
383
387
 
384
388
  // For each strip, read the first value, then record that many more points
385
389
  const indexCount = dataView.getInt32( pointIndex, false );
386
390
  const strip = [];
387
391
  pointIndex += 4;
388
-
389
392
  for ( let s = 0; s < indexCount; s ++ ) {
390
393
 
391
394
  strip.push( dataView.getInt32( pointIndex, false ) );
392
395
  pointIndex += 4;
393
396
 
394
- } // retrieves the n-2 triangles from the triangle strip
395
-
397
+ }
396
398
 
399
+ // retrieves the n-2 triangles from the triangle strip
397
400
  for ( let j = 0; j < indexCount - 2; j ++ ) {
398
401
 
399
402
  if ( j % 2 ) {
@@ -412,36 +415,34 @@
412
415
 
413
416
  }
414
417
 
415
- } // increment our next pointer
416
-
418
+ }
417
419
 
420
+ // increment our next pointer
418
421
  state.next = state.next + count + 1;
419
422
 
420
423
  } else if ( line.indexOf( 'POLYGONS' ) === 0 ) {
421
424
 
422
425
  const numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 );
423
- const size = parseInt( line.split( ' ' )[ 2 ], 10 ); // 4 byte integers
424
-
426
+ const size = parseInt( line.split( ' ' )[ 2 ], 10 );
427
+ // 4 byte integers
425
428
  const count = size * 4;
426
429
  indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
427
430
  let indicesIndex = 0;
428
431
  let pointIndex = state.next;
429
-
430
432
  for ( let i = 0; i < numberOfStrips; i ++ ) {
431
433
 
432
434
  // For each strip, read the first value, then record that many more points
433
435
  const indexCount = dataView.getInt32( pointIndex, false );
434
436
  const strip = [];
435
437
  pointIndex += 4;
436
-
437
438
  for ( let s = 0; s < indexCount; s ++ ) {
438
439
 
439
440
  strip.push( dataView.getInt32( pointIndex, false ) );
440
441
  pointIndex += 4;
441
442
 
442
- } // divide the polygon in n-2 triangle
443
-
443
+ }
444
444
 
445
+ // divide the polygon in n-2 triangle
445
446
  for ( let j = 1; j < indexCount - 1; j ++ ) {
446
447
 
447
448
  indices[ indicesIndex ++ ] = strip[ 0 ];
@@ -450,21 +451,22 @@
450
451
 
451
452
  }
452
453
 
453
- } // increment our next pointer
454
-
454
+ }
455
455
 
456
+ // increment our next pointer
456
457
  state.next = state.next + count + 1;
457
458
 
458
459
  } else if ( line.indexOf( 'POINT_DATA' ) === 0 ) {
459
460
 
460
- const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); // Grab the next line
461
+ const numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 );
461
462
 
462
- state = findString( buffer, state.next ); // Now grab the binary data
463
+ // Grab the next line
464
+ state = findString( buffer, state.next );
463
465
 
466
+ // Now grab the binary data
464
467
  const count = numberOfPoints * 4 * 3;
465
468
  normals = new Float32Array( numberOfPoints * 3 );
466
469
  let pointIndex = state.next;
467
-
468
470
  for ( let i = 0; i < numberOfPoints; i ++ ) {
469
471
 
470
472
  normals[ 3 * i ] = dataView.getFloat32( pointIndex, false );
@@ -472,16 +474,15 @@
472
474
  normals[ 3 * i + 2 ] = dataView.getFloat32( pointIndex + 8, false );
473
475
  pointIndex += 12;
474
476
 
475
- } // Increment past our data
476
-
477
+ }
477
478
 
479
+ // Increment past our data
478
480
  state.next = state.next + count;
479
481
 
480
- } // Increment index
481
-
482
+ }
482
483
 
484
+ // Increment index
483
485
  index = state.next;
484
-
485
486
  if ( index >= buffer.byteLength ) {
486
487
 
487
488
  break;
@@ -493,7 +494,6 @@
493
494
  const geometry = new THREE.BufferGeometry();
494
495
  geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
495
496
  geometry.setAttribute( 'position', new THREE.BufferAttribute( points, 3 ) );
496
-
497
497
  if ( normals.length === points.length ) {
498
498
 
499
499
  geometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
@@ -527,21 +527,22 @@
527
527
  function parseXML( stringFile ) {
528
528
 
529
529
  // Changes XML to JSON, based on https://davidwalsh.name/convert-xml-json
530
+
530
531
  function xmlToJson( xml ) {
531
532
 
532
533
  // Create the return object
533
534
  let obj = {};
534
-
535
535
  if ( xml.nodeType === 1 ) {
536
536
 
537
537
  // element
538
+
538
539
  // do attributes
540
+
539
541
  if ( xml.attributes ) {
540
542
 
541
543
  if ( xml.attributes.length > 0 ) {
542
544
 
543
545
  obj[ 'attributes' ] = {};
544
-
545
546
  for ( let j = 0; j < xml.attributes.length; j ++ ) {
546
547
 
547
548
  const attribute = xml.attributes.item( j );
@@ -556,18 +557,18 @@
556
557
  } else if ( xml.nodeType === 3 ) {
557
558
 
558
559
  // text
559
- obj = xml.nodeValue.trim();
560
560
 
561
- } // do children
561
+ obj = xml.nodeValue.trim();
562
562
 
563
+ }
563
564
 
565
+ // do children
564
566
  if ( xml.hasChildNodes() ) {
565
567
 
566
568
  for ( let i = 0; i < xml.childNodes.length; i ++ ) {
567
569
 
568
570
  const item = xml.childNodes.item( i );
569
571
  const nodeName = item.nodeName;
570
-
571
572
  if ( typeof obj[ nodeName ] === 'undefined' ) {
572
573
 
573
574
  const tmp = xmlToJson( item );
@@ -593,15 +594,14 @@
593
594
 
594
595
  return obj;
595
596
 
596
- } // Taken from Base64-js
597
-
597
+ }
598
598
 
599
+ // Taken from Base64-js
599
600
  function Base64toByteArray( b64 ) {
600
601
 
601
602
  const Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
602
603
  const revLookup = [];
603
604
  const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
604
-
605
605
  for ( let i = 0, l = code.length; i < l; ++ i ) {
606
606
 
607
607
  revLookup[ code.charCodeAt( i ) ] = i;
@@ -611,7 +611,6 @@
611
611
  revLookup[ '-'.charCodeAt( 0 ) ] = 62;
612
612
  revLookup[ '_'.charCodeAt( 0 ) ] = 63;
613
613
  const len = b64.length;
614
-
615
614
  if ( len % 4 > 0 ) {
616
615
 
617
616
  throw new Error( 'Invalid string. Length must be a multiple of 4' );
@@ -623,7 +622,6 @@
623
622
  const l = placeHolders > 0 ? len - 4 : len;
624
623
  let L = 0;
625
624
  let i, j;
626
-
627
625
  for ( i = 0, j = 0; i < l; i += 4, j += 3 ) {
628
626
 
629
627
  const tmp = revLookup[ b64.charCodeAt( i ) ] << 18 | revLookup[ b64.charCodeAt( i + 1 ) ] << 12 | revLookup[ b64.charCodeAt( i + 2 ) ] << 6 | revLookup[ b64.charCodeAt( i + 3 ) ];
@@ -653,7 +651,6 @@
653
651
  function parseDataArray( ele, compressed ) {
654
652
 
655
653
  let numBytes = 0;
656
-
657
654
  if ( json.attributes.header_type === 'UInt64' ) {
658
655
 
659
656
  numBytes = 8;
@@ -664,8 +661,9 @@
664
661
 
665
662
  }
666
663
 
667
- let txt, content; // Check the format
664
+ let txt, content;
668
665
 
666
+ // Check the format
669
667
  if ( ele.attributes.format === 'binary' && compressed ) {
670
668
 
671
669
  if ( ele.attributes.type === 'Float32' ) {
@@ -676,7 +674,9 @@
676
674
 
677
675
  txt = new Int32Array();
678
676
 
679
- } // VTP data with the header has the following structure:
677
+ }
678
+
679
+ // VTP data with the header has the following structure:
680
680
  // [#blocks][#u-size][#p-size][#c-size-1][#c-size-2]...[#c-size-#blocks][DATA]
681
681
  //
682
682
  // Each token is an integer value whose type is specified by "header_type" at the top of the file (UInt32 if no type specified). The token meanings are:
@@ -688,14 +688,13 @@
688
688
  // The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
689
689
  // computed by summing the compressed block sizes from preceding blocks according to the header.
690
690
 
691
-
692
691
  const textNode = ele[ '#text' ];
693
692
  const rawData = Array.isArray( textNode ) ? textNode[ 0 ] : textNode;
694
- const byteData = Base64toByteArray( rawData ); // Each data point consists of 8 bits regardless of the header type
693
+ const byteData = Base64toByteArray( rawData );
695
694
 
695
+ // Each data point consists of 8 bits regardless of the header type
696
696
  const dataPointSize = 8;
697
697
  let blocks = byteData[ 0 ];
698
-
699
698
  for ( let i = 1; i < numBytes - 1; i ++ ) {
700
699
 
701
700
  blocks = blocks | byteData[ i ] << i * dataPointSize;
@@ -707,15 +706,14 @@
707
706
  headerSize = headerSize + padding;
708
707
  const dataOffsets = [];
709
708
  let currentOffset = headerSize;
710
- dataOffsets.push( currentOffset ); // Get the blocks sizes after the compression.
711
- // There are three blocks before c-size-i, so we skip 3*numBytes
709
+ dataOffsets.push( currentOffset );
712
710
 
711
+ // Get the blocks sizes after the compression.
712
+ // There are three blocks before c-size-i, so we skip 3*numBytes
713
713
  const cSizeStart = 3 * numBytes;
714
-
715
714
  for ( let i = 0; i < blocks; i ++ ) {
716
715
 
717
716
  let currentBlockSize = byteData[ i * numBytes + cSizeStart ];
718
-
719
717
  for ( let j = 1; j < numBytes - 1; j ++ ) {
720
718
 
721
719
  currentBlockSize = currentBlockSize | byteData[ i * numBytes + cSizeStart + j ] << j * dataPointSize;
@@ -730,9 +728,7 @@
730
728
  for ( let i = 0; i < dataOffsets.length - 1; i ++ ) {
731
729
 
732
730
  const data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); // eslint-disable-line no-undef
733
-
734
731
  content = data.buffer;
735
-
736
732
  if ( ele.attributes.type === 'Float32' ) {
737
733
 
738
734
  content = new Float32Array( content );
@@ -748,7 +744,6 @@
748
744
  }
749
745
 
750
746
  delete ele[ '#text' ];
751
-
752
747
  if ( ele.attributes.type === 'Int64' ) {
753
748
 
754
749
  if ( ele.attributes.format === 'binary' ) {
@@ -767,10 +762,11 @@
767
762
 
768
763
  if ( ele.attributes.format === 'binary' && ! compressed ) {
769
764
 
770
- content = Base64toByteArray( ele[ '#text' ] ); // VTP data for the uncompressed case has the following structure:
765
+ content = Base64toByteArray( ele[ '#text' ] );
766
+
767
+ // VTP data for the uncompressed case has the following structure:
771
768
  // [#bytes][DATA]
772
769
  // where "[#bytes]" is an integer value specifying the number of bytes in the block of data following it.
773
-
774
770
  content = content.slice( numBytes ).buffer;
775
771
 
776
772
  } else {
@@ -791,8 +787,9 @@
791
787
 
792
788
  }
793
789
 
794
- delete ele[ '#text' ]; // Get the content and optimize it
790
+ delete ele[ '#text' ];
795
791
 
792
+ // Get the content and optimize it
796
793
  if ( ele.attributes.type === 'Float32' ) {
797
794
 
798
795
  txt = new Float32Array( content );
@@ -804,7 +801,6 @@
804
801
  } else if ( ele.attributes.type === 'Int64' ) {
805
802
 
806
803
  txt = new Int32Array( content );
807
-
808
804
  if ( ele.attributes.format === 'binary' ) {
809
805
 
810
806
  txt = txt.filter( function ( el, idx ) {
@@ -819,42 +815,42 @@
819
815
 
820
816
  } // endif ( ele.attributes.format === 'binary' && compressed )
821
817
 
822
-
823
818
  return txt;
824
819
 
825
- } // Main part
826
- // Get Dom
827
-
828
-
829
- const dom = new DOMParser().parseFromString( stringFile, 'application/xml' ); // Get the doc
820
+ }
830
821
 
831
- const doc = dom.documentElement; // Convert to json
822
+ // Main part
823
+ // Get Dom
824
+ const dom = new DOMParser().parseFromString( stringFile, 'application/xml' );
832
825
 
826
+ // Get the doc
827
+ const doc = dom.documentElement;
828
+ // Convert to json
833
829
  const json = xmlToJson( doc );
834
830
  let points = [];
835
831
  let normals = [];
836
832
  let indices = [];
837
-
838
833
  if ( json.PolyData ) {
839
834
 
840
835
  const piece = json.PolyData.Piece;
841
- const compressed = json.attributes.hasOwnProperty( 'compressor' ); // Can be optimized
842
- // Loop through the sections
836
+ const compressed = json.attributes.hasOwnProperty( 'compressor' );
843
837
 
838
+ // Can be optimized
839
+ // Loop through the sections
844
840
  const sections = [ 'PointData', 'Points', 'Strips', 'Polys' ]; // +['CellData', 'Verts', 'Lines'];
845
-
846
841
  let sectionIndex = 0;
847
842
  const numberOfSections = sections.length;
848
-
849
843
  while ( sectionIndex < numberOfSections ) {
850
844
 
851
- const section = piece[ sections[ sectionIndex ] ]; // If it has a DataArray in it
845
+ const section = piece[ sections[ sectionIndex ] ];
846
+
847
+ // If it has a DataArray in it
852
848
 
853
849
  if ( section && section.DataArray ) {
854
850
 
855
851
  // Depending on the number of DataArrays
856
- let arr;
857
852
 
853
+ let arr;
858
854
  if ( Array.isArray( section.DataArray ) ) {
859
855
 
860
856
  arr = section.DataArray;
@@ -867,7 +863,6 @@
867
863
 
868
864
  let dataArrayIndex = 0;
869
865
  const numberOfDataArrays = arr.length;
870
-
871
866
  while ( dataArrayIndex < numberOfDataArrays ) {
872
867
 
873
868
  // Parse the DataArray
@@ -889,7 +884,6 @@
889
884
 
890
885
  const numberOfPoints = parseInt( piece.attributes.NumberOfPoints );
891
886
  const normalsName = section.attributes.Normals;
892
-
893
887
  if ( numberOfPoints > 0 ) {
894
888
 
895
889
  for ( let i = 0, len = arr.length; i < len; i ++ ) {
@@ -909,13 +903,12 @@
909
903
  }
910
904
 
911
905
  break;
912
- // if it is points
913
906
 
907
+ // if it is points
914
908
  case 'Points':
915
909
  {
916
910
 
917
911
  const numberOfPoints = parseInt( piece.attributes.NumberOfPoints );
918
-
919
912
  if ( numberOfPoints > 0 ) {
920
913
 
921
914
  const components = section.DataArray.attributes.NumberOfComponents;
@@ -927,13 +920,12 @@
927
920
  }
928
921
 
929
922
  break;
930
- // if it is strips
931
923
 
924
+ // if it is strips
932
925
  case 'Strips':
933
926
  {
934
927
 
935
928
  const numberOfStrips = parseInt( piece.attributes.NumberOfStrips );
936
-
937
929
  if ( numberOfStrips > 0 ) {
938
930
 
939
931
  const connectivity = new Int32Array( section.DataArray[ 0 ].text.length );
@@ -943,11 +935,9 @@
943
935
  const size = numberOfStrips + connectivity.length;
944
936
  indices = new Uint32Array( 3 * size - 9 * numberOfStrips );
945
937
  let indicesIndex = 0;
946
-
947
938
  for ( let i = 0, len = numberOfStrips; i < len; i ++ ) {
948
939
 
949
940
  const strip = [];
950
-
951
941
  for ( let s = 0, len1 = offset[ i ], len0 = 0; s < len1 - len0; s ++ ) {
952
942
 
953
943
  strip.push( connectivity[ s ] );
@@ -982,13 +972,12 @@
982
972
  }
983
973
 
984
974
  break;
985
- // if it is polys
986
975
 
976
+ // if it is polys
987
977
  case 'Polys':
988
978
  {
989
979
 
990
980
  const numberOfPolys = parseInt( piece.attributes.NumberOfPolys );
991
-
992
981
  if ( numberOfPolys > 0 ) {
993
982
 
994
983
  const connectivity = new Int32Array( section.DataArray[ 0 ].text.length );
@@ -1002,13 +991,11 @@
1002
991
  let i = 0,
1003
992
  len0 = 0;
1004
993
  const len = numberOfPolys;
1005
-
1006
994
  while ( i < len ) {
1007
995
 
1008
996
  const poly = [];
1009
997
  let s = 0;
1010
998
  const len1 = offset[ i ];
1011
-
1012
999
  while ( s < len1 - len0 ) {
1013
1000
 
1014
1001
  poly.push( connectivity[ connectivityIndex ++ ] );
@@ -1017,7 +1004,6 @@
1017
1004
  }
1018
1005
 
1019
1006
  let j = 1;
1020
-
1021
1007
  while ( j < len1 - len0 - 1 ) {
1022
1008
 
1023
1009
  indices[ indicesIndex ++ ] = poly[ 0 ];
@@ -1037,7 +1023,6 @@
1037
1023
  }
1038
1024
 
1039
1025
  break;
1040
-
1041
1026
  default:
1042
1027
  break;
1043
1028
 
@@ -1052,7 +1037,6 @@
1052
1037
  const geometry = new THREE.BufferGeometry();
1053
1038
  geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
1054
1039
  geometry.setAttribute( 'position', new THREE.BufferAttribute( points, 3 ) );
1055
-
1056
1040
  if ( normals.length === points.length ) {
1057
1041
 
1058
1042
  geometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
@@ -1067,11 +1051,10 @@
1067
1051
 
1068
1052
  }
1069
1053
 
1070
- } // get the 5 first lines of the files to check if there is the key word binary
1071
-
1054
+ }
1072
1055
 
1056
+ // get the 5 first lines of the files to check if there is the key word binary
1073
1057
  const meta = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 250 ) ).split( '\n' );
1074
-
1075
1058
  if ( meta[ 0 ].indexOf( 'xml' ) !== - 1 ) {
1076
1059
 
1077
1060
  return parseXML( THREE.LoaderUtils.decodeText( data ) );