@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
@@ -30,7 +30,6 @@
30
30
  */
31
31
 
32
32
  const _v1 = new THREE.Vector3();
33
-
34
33
  class ConvexObjectBreaker {
35
34
 
36
35
  constructor( minSizeForBreak = 1.4, smallDelta = 0.0001 ) {
@@ -59,16 +58,15 @@
59
58
  };
60
59
  this.segments = [];
61
60
  const n = 30 * 30;
62
-
63
61
  for ( let i = 0; i < n; i ++ ) this.segments[ i ] = false;
64
62
 
65
63
  }
66
-
67
64
  prepareBreakableObject( object, mass, velocity, angularVelocity, breakable ) {
68
65
 
69
66
  // object is a Object3d (normally a THREE.Mesh), must have a BufferGeometry, and it must be convex.
70
67
  // Its material property is propagated to its children (sub-pieces)
71
68
  // mass must be > 0
69
+
72
70
  if ( ! object.geometry.isBufferGeometry ) {
73
71
 
74
72
  console.error( 'THREE.ConvexObjectBreaker.prepareBreakableObject(): Parameter object must have a BufferGeometry.' );
@@ -82,14 +80,13 @@
82
80
  userData.breakable = breakable;
83
81
 
84
82
  }
83
+
85
84
  /*
86
85
  * @param {int} maxRadialIterations Iterations for radial cuts.
87
86
  * @param {int} maxRandomIterations Max random iterations for not-radial cuts
88
87
  *
89
88
  * Returns the array of pieces
90
89
  */
91
-
92
-
93
90
  subdivideByImpact( object, pointOfImpact, normal, maxRadialIterations, maxRandomIterations ) {
94
91
 
95
92
  const debris = [];
@@ -99,7 +96,6 @@
99
96
  tempPlane1.setFromCoplanarPoints( pointOfImpact, object.position, this.tempVector3 );
100
97
  const maxTotalIterations = maxRandomIterations + maxRadialIterations;
101
98
  const scope = this;
102
-
103
99
  function subdivideRadial( subObject, startAngle, endAngle, numIterations ) {
104
100
 
105
101
  if ( Math.random() < numIterations * 0.05 || numIterations > maxTotalIterations ) {
@@ -110,7 +106,6 @@
110
106
  }
111
107
 
112
108
  let angle = Math.PI;
113
-
114
109
  if ( numIterations === 0 ) {
115
110
 
116
111
  tempPlane2.normal.copy( tempPlane1.normal );
@@ -120,28 +115,29 @@
120
115
 
121
116
  if ( numIterations <= maxRadialIterations ) {
122
117
 
123
- angle = ( endAngle - startAngle ) * ( 0.2 + 0.6 * Math.random() ) + startAngle; // Rotate tempPlane2 at impact point around normal axis and the angle
118
+ angle = ( endAngle - startAngle ) * ( 0.2 + 0.6 * Math.random() ) + startAngle;
124
119
 
120
+ // Rotate tempPlane2 at impact point around normal axis and the angle
125
121
  scope.tempVector3_2.copy( object.position ).sub( pointOfImpact ).applyAxisAngle( normal, angle ).add( pointOfImpact );
126
122
  tempPlane2.setFromCoplanarPoints( pointOfImpact, scope.tempVector3, scope.tempVector3_2 );
127
123
 
128
124
  } else {
129
125
 
130
- angle = ( 0.5 * ( numIterations & 1 ) + 0.2 * ( 2 - Math.random() ) ) * Math.PI; // Rotate tempPlane2 at object position around normal axis and the angle
126
+ angle = ( 0.5 * ( numIterations & 1 ) + 0.2 * ( 2 - Math.random() ) ) * Math.PI;
131
127
 
128
+ // Rotate tempPlane2 at object position around normal axis and the angle
132
129
  scope.tempVector3_2.copy( pointOfImpact ).sub( subObject.position ).applyAxisAngle( normal, angle ).add( subObject.position );
133
130
  scope.tempVector3_3.copy( normal ).add( subObject.position );
134
131
  tempPlane2.setFromCoplanarPoints( subObject.position, scope.tempVector3_3, scope.tempVector3_2 );
135
132
 
136
133
  }
137
134
 
138
- } // Perform the cut
139
-
135
+ }
140
136
 
137
+ // Perform the cut
141
138
  scope.cutByPlane( subObject, tempPlane2, scope.tempResultObjects );
142
139
  const obj1 = scope.tempResultObjects.object1;
143
140
  const obj2 = scope.tempResultObjects.object2;
144
-
145
141
  if ( obj1 ) {
146
142
 
147
143
  subdivideRadial( obj1, startAngle, angle, numIterations + 1 );
@@ -160,20 +156,19 @@
160
156
  return debris;
161
157
 
162
158
  }
163
-
164
159
  cutByPlane( object, plane, output ) {
165
160
 
166
161
  // Returns breakable objects in output.object1 and output.object2 members, the resulting 2 pieces of the cut.
167
162
  // object2 can be null if the plane doesn't cut the object.
168
163
  // object1 can be null only in case of internal error
169
164
  // Returned value is number of pieces, 0 for error.
165
+
170
166
  const geometry = object.geometry;
171
167
  const coords = geometry.attributes.position.array;
172
168
  const normals = geometry.attributes.normal.array;
173
169
  const numPoints = coords.length / 3;
174
170
  let numFaces = numPoints / 3;
175
171
  let indices = geometry.getIndex();
176
-
177
172
  if ( indices ) {
178
173
 
179
174
  indices = indices.array;
@@ -184,6 +179,7 @@
184
179
  function getVertexIndex( faceIdx, vert ) {
185
180
 
186
181
  // vert = 0, 1 or 2.
182
+
187
183
  const idx = faceIdx * 3 + vert;
188
184
  return indices ? indices[ idx ] : idx;
189
185
 
@@ -191,34 +187,34 @@
191
187
 
192
188
  const points1 = [];
193
189
  const points2 = [];
194
- const delta = this.smallDelta; // Reset segments mark
190
+ const delta = this.smallDelta;
195
191
 
192
+ // Reset segments mark
196
193
  const numPointPairs = numPoints * numPoints;
197
-
198
194
  for ( let i = 0; i < numPointPairs; i ++ ) this.segments[ i ] = false;
199
-
200
195
  const p0 = this.tempVector3_P0;
201
196
  const p1 = this.tempVector3_P1;
202
197
  const n0 = this.tempVector3_N0;
203
- const n1 = this.tempVector3_N1; // Iterate through the faces to mark edges shared by coplanar faces
198
+ const n1 = this.tempVector3_N1;
204
199
 
200
+ // Iterate through the faces to mark edges shared by coplanar faces
205
201
  for ( let i = 0; i < numFaces - 1; i ++ ) {
206
202
 
207
203
  const a1 = getVertexIndex( i, 0 );
208
204
  const b1 = getVertexIndex( i, 1 );
209
- const c1 = getVertexIndex( i, 2 ); // Assuming all 3 vertices have the same normal
205
+ const c1 = getVertexIndex( i, 2 );
210
206
 
207
+ // Assuming all 3 vertices have the same normal
211
208
  n0.set( normals[ a1 ], normals[ a1 ] + 1, normals[ a1 ] + 2 );
212
-
213
209
  for ( let j = i + 1; j < numFaces; j ++ ) {
214
210
 
215
211
  const a2 = getVertexIndex( j, 0 );
216
212
  const b2 = getVertexIndex( j, 1 );
217
- const c2 = getVertexIndex( j, 2 ); // Assuming all 3 vertices have the same normal
213
+ const c2 = getVertexIndex( j, 2 );
218
214
 
215
+ // Assuming all 3 vertices have the same normal
219
216
  n1.set( normals[ a2 ], normals[ a2 ] + 1, normals[ a2 ] + 2 );
220
217
  const coplanar = 1 - n0.dot( n1 ) < delta;
221
-
222
218
  if ( coplanar ) {
223
219
 
224
220
  if ( a1 === a2 || a1 === b2 || a1 === c2 ) {
@@ -246,35 +242,35 @@
246
242
 
247
243
  }
248
244
 
249
- } // Transform the plane to object local space
250
-
245
+ }
251
246
 
247
+ // Transform the plane to object local space
252
248
  const localPlane = this.tempPlane_Cut;
253
249
  object.updateMatrix();
254
- ConvexObjectBreaker.transformPlaneToLocalSpace( plane, object.matrix, localPlane ); // Iterate through the faces adding points to both pieces
250
+ ConvexObjectBreaker.transformPlaneToLocalSpace( plane, object.matrix, localPlane );
255
251
 
252
+ // Iterate through the faces adding points to both pieces
256
253
  for ( let i = 0; i < numFaces; i ++ ) {
257
254
 
258
255
  const va = getVertexIndex( i, 0 );
259
256
  const vb = getVertexIndex( i, 1 );
260
257
  const vc = getVertexIndex( i, 2 );
261
-
262
258
  for ( let segment = 0; segment < 3; segment ++ ) {
263
259
 
264
260
  const i0 = segment === 0 ? va : segment === 1 ? vb : vc;
265
261
  const i1 = segment === 0 ? vb : segment === 1 ? vc : va;
266
262
  const segmentState = this.segments[ i0 * numPoints + i1 ];
267
263
  if ( segmentState ) continue; // The segment already has been processed in another face
268
- // Mark segment as processed (also inverted segment)
269
264
 
265
+ // Mark segment as processed (also inverted segment)
270
266
  this.segments[ i0 * numPoints + i1 ] = true;
271
267
  this.segments[ i1 * numPoints + i0 ] = true;
272
268
  p0.set( coords[ 3 * i0 ], coords[ 3 * i0 + 1 ], coords[ 3 * i0 + 2 ] );
273
- p1.set( coords[ 3 * i1 ], coords[ 3 * i1 + 1 ], coords[ 3 * i1 + 2 ] ); // mark: 1 for negative side, 2 for positive side, 3 for coplanar point
269
+ p1.set( coords[ 3 * i1 ], coords[ 3 * i1 + 1 ], coords[ 3 * i1 + 2 ] );
274
270
 
271
+ // mark: 1 for negative side, 2 for positive side, 3 for coplanar point
275
272
  let mark0 = 0;
276
273
  let d = localPlane.distanceToPoint( p0 );
277
-
278
274
  if ( d > delta ) {
279
275
 
280
276
  mark0 = 2;
@@ -291,12 +287,11 @@
291
287
  points1.push( p0.clone() );
292
288
  points2.push( p0.clone() );
293
289
 
294
- } // mark: 1 for negative side, 2 for positive side, 3 for coplanar point
295
-
290
+ }
296
291
 
292
+ // mark: 1 for negative side, 2 for positive side, 3 for coplanar point
297
293
  let mark1 = 0;
298
294
  d = localPlane.distanceToPoint( p1 );
299
-
300
295
  if ( d > delta ) {
301
296
 
302
297
  mark1 = 2;
@@ -318,11 +313,11 @@
318
313
  if ( mark0 === 1 && mark1 === 2 || mark0 === 2 && mark1 === 1 ) {
319
314
 
320
315
  // Intersection of segment with the plane
316
+
321
317
  this.tempLine1.start.copy( p0 );
322
318
  this.tempLine1.end.copy( p1 );
323
319
  let intersection = new THREE.Vector3();
324
320
  intersection = localPlane.intersectLine( this.tempLine1, intersection );
325
-
326
321
  if ( intersection === null ) {
327
322
 
328
323
  // Shouldn't happen
@@ -340,21 +335,19 @@
340
335
 
341
336
  }
342
337
 
343
- } // Calculate debris mass (very fast and imprecise):
344
-
338
+ }
345
339
 
346
- const newMass = object.userData.mass * 0.5; // Calculate debris Center of Mass (again fast and imprecise)
340
+ // Calculate debris mass (very fast and imprecise):
341
+ const newMass = object.userData.mass * 0.5;
347
342
 
343
+ // Calculate debris Center of Mass (again fast and imprecise)
348
344
  this.tempCM1.set( 0, 0, 0 );
349
345
  let radius1 = 0;
350
346
  const numPoints1 = points1.length;
351
-
352
347
  if ( numPoints1 > 0 ) {
353
348
 
354
349
  for ( let i = 0; i < numPoints1; i ++ ) this.tempCM1.add( points1[ i ] );
355
-
356
350
  this.tempCM1.divideScalar( numPoints1 );
357
-
358
351
  for ( let i = 0; i < numPoints1; i ++ ) {
359
352
 
360
353
  const p = points1[ i ];
@@ -370,13 +363,10 @@
370
363
  this.tempCM2.set( 0, 0, 0 );
371
364
  let radius2 = 0;
372
365
  const numPoints2 = points2.length;
373
-
374
366
  if ( numPoints2 > 0 ) {
375
367
 
376
368
  for ( let i = 0; i < numPoints2; i ++ ) this.tempCM2.add( points2[ i ] );
377
-
378
369
  this.tempCM2.divideScalar( numPoints2 );
379
-
380
370
  for ( let i = 0; i < numPoints2; i ++ ) {
381
371
 
382
372
  const p = points2[ i ];
@@ -392,7 +382,6 @@
392
382
  let object1 = null;
393
383
  let object2 = null;
394
384
  let numObjects = 0;
395
-
396
385
  if ( numPoints1 > 4 ) {
397
386
 
398
387
  object1 = new THREE.Mesh( new THREE.ConvexGeometry( points1 ), object.material );
@@ -418,12 +407,12 @@
418
407
  return numObjects;
419
408
 
420
409
  }
421
-
422
410
  static transformFreeVector( v, m ) {
423
411
 
424
412
  // input:
425
413
  // vector interpreted as a free vector
426
414
  // THREE.Matrix4 orthogonal matrix (matrix without scale)
415
+
427
416
  const x = v.x,
428
417
  y = v.y,
429
418
  z = v.z;
@@ -434,12 +423,12 @@
434
423
  return v;
435
424
 
436
425
  }
437
-
438
426
  static transformFreeVectorInverse( v, m ) {
439
427
 
440
428
  // input:
441
429
  // vector interpreted as a free vector
442
430
  // THREE.Matrix4 orthogonal matrix (matrix without scale)
431
+
443
432
  const x = v.x,
444
433
  y = v.y,
445
434
  z = v.z;
@@ -450,12 +439,12 @@
450
439
  return v;
451
440
 
452
441
  }
453
-
454
442
  static transformTiedVectorInverse( v, m ) {
455
443
 
456
444
  // input:
457
445
  // vector interpreted as a tied (ordinary) vector
458
446
  // THREE.Matrix4 orthogonal matrix (matrix without scale)
447
+
459
448
  const x = v.x,
460
449
  y = v.y,
461
450
  z = v.z;
@@ -466,14 +455,14 @@
466
455
  return v;
467
456
 
468
457
  }
469
-
470
458
  static transformPlaneToLocalSpace( plane, m, resultPlane ) {
471
459
 
472
460
  resultPlane.normal.copy( plane.normal );
473
461
  resultPlane.constant = plane.constant;
474
462
  const referencePoint = ConvexObjectBreaker.transformTiedVectorInverse( plane.coplanarPoint( _v1 ), m );
475
- ConvexObjectBreaker.transformFreeVectorInverse( resultPlane.normal, m ); // recalculate constant (like in setFromNormalAndCoplanarPoint)
463
+ ConvexObjectBreaker.transformFreeVectorInverse( resultPlane.normal, m );
476
464
 
465
+ // recalculate constant (like in setFromNormalAndCoplanarPoint)
477
466
  resultPlane.constant = - referencePoint.dot( resultPlane.normal );
478
467
 
479
468
  }
@@ -115,7 +115,6 @@
115
115
  const passThruShader = createShaderMaterial( getPassThroughFragmentShader(), passThruUniforms );
116
116
  const mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), passThruShader );
117
117
  scene.add( mesh );
118
-
119
118
  this.setDataType = function ( type ) {
120
119
 
121
120
  dataType = type;
@@ -164,27 +163,26 @@
164
163
 
165
164
  for ( let i = 0; i < this.variables.length; i ++ ) {
166
165
 
167
- const variable = this.variables[ i ]; // Creates rendertargets and initialize them with input texture
166
+ const variable = this.variables[ i ];
168
167
 
168
+ // Creates rendertargets and initialize them with input texture
169
169
  variable.renderTargets[ 0 ] = this.createRenderTarget( sizeX, sizeY, variable.wrapS, variable.wrapT, variable.minFilter, variable.magFilter );
170
170
  variable.renderTargets[ 1 ] = this.createRenderTarget( sizeX, sizeY, variable.wrapS, variable.wrapT, variable.minFilter, variable.magFilter );
171
171
  this.renderTexture( variable.initialValueTexture, variable.renderTargets[ 0 ] );
172
- this.renderTexture( variable.initialValueTexture, variable.renderTargets[ 1 ] ); // Adds dependencies uniforms to the THREE.ShaderMaterial
172
+ this.renderTexture( variable.initialValueTexture, variable.renderTargets[ 1 ] );
173
173
 
174
+ // Adds dependencies uniforms to the THREE.ShaderMaterial
174
175
  const material = variable.material;
175
176
  const uniforms = material.uniforms;
176
-
177
177
  if ( variable.dependencies !== null ) {
178
178
 
179
179
  for ( let d = 0; d < variable.dependencies.length; d ++ ) {
180
180
 
181
181
  const depVar = variable.dependencies[ d ];
182
-
183
182
  if ( depVar.name !== variable.name ) {
184
183
 
185
184
  // Checks if variable exists
186
185
  let found = false;
187
-
188
186
  for ( let j = 0; j < this.variables.length; j ++ ) {
189
187
 
190
188
  if ( depVar.name === this.variables[ j ].name ) {
@@ -224,15 +222,14 @@
224
222
 
225
223
  const currentTextureIndex = this.currentTextureIndex;
226
224
  const nextTextureIndex = this.currentTextureIndex === 0 ? 1 : 0;
227
-
228
225
  for ( let i = 0, il = this.variables.length; i < il; i ++ ) {
229
226
 
230
- const variable = this.variables[ i ]; // Sets texture dependencies uniforms
227
+ const variable = this.variables[ i ];
231
228
 
229
+ // Sets texture dependencies uniforms
232
230
  if ( variable.dependencies !== null ) {
233
231
 
234
232
  const uniforms = variable.material.uniforms;
235
-
236
233
  for ( let d = 0, dl = variable.dependencies.length; d < dl; d ++ ) {
237
234
 
238
235
  const depVar = variable.dependencies[ d ];
@@ -240,9 +237,9 @@
240
237
 
241
238
  }
242
239
 
243
- } // Performs the computation for this variable
244
-
240
+ }
245
241
 
242
+ // Performs the computation for this variable
246
243
  this.doRenderTarget( variable.material, variable.renderTargets[ nextTextureIndex ] );
247
244
 
248
245
  }
@@ -268,13 +265,11 @@
268
265
  mesh.geometry.dispose();
269
266
  mesh.material.dispose();
270
267
  const variables = this.variables;
271
-
272
268
  for ( let i = 0; i < variables.length; i ++ ) {
273
269
 
274
270
  const variable = variables[ i ];
275
271
  variable.initialValueTexture?.dispose();
276
272
  const renderTargets = variable.renderTargets;
277
-
278
273
  for ( let j = 0; j < renderTargets.length; j ++ ) {
279
274
 
280
275
  const renderTarget = renderTargets[ j ];
@@ -292,7 +287,9 @@
292
287
 
293
288
  }
294
289
 
295
- this.addResolutionDefine = addResolutionDefine; // The following functions can be used to compute things manually
290
+ this.addResolutionDefine = addResolutionDefine;
291
+
292
+ // The following functions can be used to compute things manually
296
293
 
297
294
  function createShaderMaterial( computeFragmentShader, uniforms ) {
298
295
 
@@ -308,7 +305,6 @@
308
305
  }
309
306
 
310
307
  this.createShaderMaterial = createShaderMaterial;
311
-
312
308
  this.createRenderTarget = function ( sizeXTexture, sizeYTexture, wrapS, wrapT, minFilter, magFilter ) {
313
309
 
314
310
  sizeXTexture = sizeXTexture || sizeX;
@@ -344,6 +340,7 @@
344
340
  // Takes a texture, and render out in rendertarget
345
341
  // input = Texture
346
342
  // output = RenderTarget
343
+
347
344
  passThruUniforms.passThruTexture.value = input;
348
345
  this.doRenderTarget( passThruShader, output );
349
346
  passThruUniforms.passThruTexture.value = null;
@@ -358,9 +355,7 @@
358
355
  const currentOutputEncoding = renderer.outputEncoding;
359
356
  const currentToneMapping = renderer.toneMapping;
360
357
  renderer.xr.enabled = false; // Avoid camera modification
361
-
362
358
  renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
363
-
364
359
  renderer.outputEncoding = THREE.LinearEncoding;
365
360
  renderer.toneMapping = THREE.NoToneMapping;
366
361
  mesh.material = material;
@@ -373,8 +368,9 @@
373
368
  renderer.toneMapping = currentToneMapping;
374
369
  renderer.setRenderTarget( currentRenderTarget );
375
370
 
376
- }; // Shaders
371
+ };
377
372
 
373
+ // Shaders
378
374
 
379
375
  function getPassThroughVertexShader() {
380
376
 
@@ -1,17 +1,11 @@
1
1
  ( function () {
2
2
 
3
3
  const _translationObject = new THREE.Vector3();
4
-
5
4
  const _quaternionObject = new THREE.Quaternion();
6
-
7
5
  const _scaleObject = new THREE.Vector3();
8
-
9
6
  const _translationWorld = new THREE.Vector3();
10
-
11
7
  const _quaternionWorld = new THREE.Quaternion();
12
-
13
8
  const _scaleWorld = new THREE.Vector3();
14
-
15
9
  class Gyroscope extends THREE.Object3D {
16
10
 
17
11
  constructor() {
@@ -19,10 +13,11 @@
19
13
  super();
20
14
 
21
15
  }
22
-
23
16
  updateMatrixWorld( force ) {
24
17
 
25
- this.matrixAutoUpdate && this.updateMatrix(); // update matrixWorld
18
+ this.matrixAutoUpdate && this.updateMatrix();
19
+
20
+ // update matrixWorld
26
21
 
27
22
  if ( this.matrixWorldNeedsUpdate || force ) {
28
23
 
@@ -42,8 +37,9 @@
42
37
  this.matrixWorldNeedsUpdate = false;
43
38
  force = true;
44
39
 
45
- } // update children
40
+ }
46
41
 
42
+ // update children
47
43
 
48
44
  for ( let i = 0, l = this.children.length; i < l; i ++ ) {
49
45
 
@@ -14,17 +14,14 @@
14
14
  this.weapons = [];
15
15
  this.activeAnimation = null;
16
16
  this.mixer = null;
17
-
18
17
  this.onLoadComplete = function () {};
19
18
 
20
19
  this.loadCounter = 0;
21
20
 
22
21
  }
23
-
24
22
  loadParts( config ) {
25
23
 
26
24
  const scope = this;
27
-
28
25
  function createPart( geometry, skinMap ) {
29
26
 
30
27
  const materialWireframe = new THREE.MeshLambertMaterial( {
@@ -35,12 +32,16 @@
35
32
  color: 0xffffff,
36
33
  wireframe: false,
37
34
  map: skinMap
38
- } ); //
35
+ } );
36
+
37
+ //
39
38
 
40
39
  const mesh = new THREE.Mesh( geometry, materialTexture );
41
40
  mesh.rotation.y = - Math.PI / 2;
42
41
  mesh.castShadow = true;
43
- mesh.receiveShadow = true; //
42
+ mesh.receiveShadow = true;
43
+
44
+ //
44
45
 
45
46
  mesh.materialTexture = materialTexture;
46
47
  mesh.materialWireframe = materialWireframe;
@@ -52,7 +53,6 @@
52
53
 
53
54
  const textureLoader = new THREE.TextureLoader();
54
55
  const textures = [];
55
-
56
56
  for ( let i = 0; i < textureUrls.length; i ++ ) {
57
57
 
58
58
  textures[ i ] = textureLoader.load( baseUrl + textureUrls[ i ], checkLoadingComplete );
@@ -75,12 +75,13 @@
75
75
 
76
76
  this.loadCounter = config.weapons.length * 2 + config.skins.length + 1;
77
77
  const weaponsTextures = [];
78
-
79
- for ( let i = 0; i < config.weapons.length; i ++ ) weaponsTextures[ i ] = config.weapons[ i ][ 1 ]; // SKINS
80
-
78
+ for ( let i = 0; i < config.weapons.length; i ++ ) weaponsTextures[ i ] = config.weapons[ i ][ 1 ];
79
+ // SKINS
81
80
 
82
81
  this.skinsBody = loadTextures( config.baseUrl + 'skins/', config.skins );
83
- this.skinsWeapon = loadTextures( config.baseUrl + 'skins/', weaponsTextures ); // BODY
82
+ this.skinsWeapon = loadTextures( config.baseUrl + 'skins/', weaponsTextures );
83
+
84
+ // BODY
84
85
 
85
86
  const loader = new THREE.MD2Loader();
86
87
  loader.load( config.baseUrl + config.body, function ( geo ) {
@@ -97,7 +98,9 @@
97
98
  scope.mixer = new THREE.AnimationMixer( mesh );
98
99
  checkLoadingComplete();
99
100
 
100
- } ); // WEAPONS
101
+ } );
102
+
103
+ // WEAPONS
101
104
 
102
105
  const generateCallback = function ( index, name ) {
103
106
 
@@ -123,7 +126,6 @@
123
126
  }
124
127
 
125
128
  }
126
-
127
129
  setPlaybackRate( rate ) {
128
130
 
129
131
  if ( rate !== 0 ) {
@@ -137,7 +139,6 @@
137
139
  }
138
140
 
139
141
  }
140
-
141
142
  setWireframe( wireframeEnabled ) {
142
143
 
143
144
  if ( wireframeEnabled ) {
@@ -153,7 +154,6 @@
153
154
  }
154
155
 
155
156
  }
156
-
157
157
  setSkin( index ) {
158
158
 
159
159
  if ( this.meshBody && this.meshBody.material.wireframe === false ) {
@@ -163,13 +163,10 @@
163
163
  }
164
164
 
165
165
  }
166
-
167
166
  setWeapon( index ) {
168
167
 
169
168
  for ( let i = 0; i < this.weapons.length; i ++ ) this.weapons[ i ].visible = false;
170
-
171
169
  const activeWeapon = this.weapons[ index ];
172
-
173
170
  if ( activeWeapon ) {
174
171
 
175
172
  activeWeapon.visible = true;
@@ -179,7 +176,6 @@
179
176
  }
180
177
 
181
178
  }
182
-
183
179
  setAnimation( clipName ) {
184
180
 
185
181
  if ( this.meshBody ) {
@@ -192,7 +188,6 @@
192
188
  }
193
189
 
194
190
  const action = this.mixer.clipAction( clipName, this.meshBody );
195
-
196
191
  if ( action ) {
197
192
 
198
193
  this.meshBody.activeAction = action.play();
@@ -205,11 +200,9 @@
205
200
  this.syncWeaponAnimation();
206
201
 
207
202
  }
208
-
209
203
  syncWeaponAnimation() {
210
204
 
211
205
  const clipName = this.activeClipName;
212
-
213
206
  if ( this.meshWeapon ) {
214
207
 
215
208
  if ( this.meshWeapon.activeAction ) {
@@ -220,7 +213,6 @@
220
213
  }
221
214
 
222
215
  const action = this.mixer.clipAction( clipName, this.meshWeapon );
223
-
224
216
  if ( action ) {
225
217
 
226
218
  this.meshWeapon.activeAction = action.syncWith( this.meshBody.activeAction ).play();
@@ -230,7 +222,6 @@
230
222
  }
231
223
 
232
224
  }
233
-
234
225
  update( delta ) {
235
226
 
236
227
  if ( this.mixer ) this.mixer.update( delta );