@needle-tools/three 0.145.2 → 0.146.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (394) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +3559 -6924
  3. package/build/three.js +3559 -6924
  4. package/build/three.min.js +1 -2
  5. package/build/three.module.js +732 -339
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +49 -66
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +70 -134
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +138 -405
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -54
  14. package/examples/js/controls/FlyControls.js +29 -55
  15. package/examples/js/controls/OrbitControls.js +85 -95
  16. package/examples/js/controls/PointerLockControls.js +5 -14
  17. package/examples/js/controls/TrackballControls.js +33 -86
  18. package/examples/js/controls/TransformControls.js +84 -169
  19. package/examples/js/csm/CSM.js +4 -39
  20. package/examples/js/csm/CSMFrustum.js +3 -9
  21. package/examples/js/csm/CSMHelper.js +24 -4
  22. package/examples/js/csm/CSMShader.js +2 -6
  23. package/examples/js/curves/CurveExtras.js +27 -27
  24. package/examples/js/curves/NURBSCurve.js +4 -16
  25. package/examples/js/curves/NURBSSurface.js +3 -9
  26. package/examples/js/curves/NURBSUtils.js +8 -45
  27. package/examples/js/effects/AnaglyphEffect.js +4 -18
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +26 -30
  30. package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
  31. package/examples/js/effects/PeppersGhostEffect.js +12 -39
  32. package/examples/js/effects/StereoEffect.js +0 -4
  33. package/examples/js/environments/RoomEnvironment.js +12 -10
  34. package/examples/js/exporters/ColladaExporter.js +48 -65
  35. package/examples/js/exporters/DRACOExporter.js +22 -22
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +143 -261
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +42 -33
  40. package/examples/js/exporters/PLYExporter.js +38 -33
  41. package/examples/js/exporters/STLExporter.js +5 -7
  42. package/examples/js/exporters/USDZExporter.js +110 -25
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +11 -6
  45. package/examples/js/geometries/DecalGeometry.js +53 -20
  46. package/examples/js/geometries/LightningStrike.js +54 -67
  47. package/examples/js/geometries/ParametricGeometries.js +8 -7
  48. package/examples/js/geometries/ParametricGeometry.js +25 -12
  49. package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
  50. package/examples/js/geometries/TeapotGeometry.js +54 -50
  51. package/examples/js/geometries/TextGeometry.js +6 -4
  52. package/examples/js/helpers/LightProbeHelper.js +1 -2
  53. package/examples/js/helpers/OctreeHelper.js +22 -20
  54. package/examples/js/helpers/PositionalAudioHelper.js +8 -6
  55. package/examples/js/helpers/RectAreaLightHelper.js +6 -7
  56. package/examples/js/helpers/VertexNormalsHelper.js +15 -13
  57. package/examples/js/helpers/VertexTangentsHelper.js +15 -9
  58. package/examples/js/helpers/ViewHelper.js +31 -16
  59. package/examples/js/interactive/HTMLMesh.js +22 -33
  60. package/examples/js/interactive/InteractiveGroup.js +6 -12
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +0 -8
  63. package/examples/js/lights/LightProbeGenerator.js +32 -39
  64. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  65. package/examples/js/lines/LineGeometry.js +3 -5
  66. package/examples/js/lines/LineMaterial.js +4 -11
  67. package/examples/js/lines/LineSegments2.js +38 -89
  68. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  69. package/examples/js/lines/Wireframe.js +2 -7
  70. package/examples/js/lines/WireframeGeometry2.js +3 -1
  71. package/examples/js/loaders/3DMLoader.js +58 -155
  72. package/examples/js/loaders/3MFLoader.js +72 -106
  73. package/examples/js/loaders/AMFLoader.js +0 -25
  74. package/examples/js/loaders/BVHLoader.js +44 -43
  75. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  76. package/examples/js/loaders/ColladaLoader.js +201 -359
  77. package/examples/js/loaders/DDSLoader.js +24 -25
  78. package/examples/js/loaders/DRACOLoader.js +29 -66
  79. package/examples/js/loaders/EXRLoader.js +67 -164
  80. package/examples/js/loaders/FBXLoader.js +286 -441
  81. package/examples/js/loaders/FontLoader.js +6 -15
  82. package/examples/js/loaders/GCodeLoader.js +15 -16
  83. package/examples/js/loaders/GLTFLoader.js +354 -405
  84. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
  85. package/examples/js/loaders/KMZLoader.js +3 -7
  86. package/examples/js/loaders/KTXLoader.js +12 -30
  87. package/examples/js/loaders/LDrawLoader.js +178 -289
  88. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  89. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  90. package/examples/js/loaders/LWOLoader.js +59 -124
  91. package/examples/js/loaders/LogLuvLoader.js +27 -77
  92. package/examples/js/loaders/LottieLoader.js +4 -4
  93. package/examples/js/loaders/MD2Loader.js +26 -27
  94. package/examples/js/loaders/MDDLoader.js +6 -10
  95. package/examples/js/loaders/MMDLoader.js +180 -189
  96. package/examples/js/loaders/MTLLoader.js +18 -47
  97. package/examples/js/loaders/MaterialXLoader.js +392 -0
  98. package/examples/js/loaders/NRRDLoader.js +44 -84
  99. package/examples/js/loaders/OBJLoader.js +50 -65
  100. package/examples/js/loaders/PCDLoader.js +34 -29
  101. package/examples/js/loaders/PDBLoader.js +17 -13
  102. package/examples/js/loaders/PLYLoader.js +9 -39
  103. package/examples/js/loaders/PRWMLoader.js +11 -22
  104. package/examples/js/loaders/PVRLoader.js +7 -16
  105. package/examples/js/loaders/RGBELoader.js +36 -61
  106. package/examples/js/loaders/RGBMLoader.js +26 -87
  107. package/examples/js/loaders/STLLoader.js +20 -27
  108. package/examples/js/loaders/SVGLoader.js +361 -233
  109. package/examples/js/loaders/TDSLoader.js +81 -118
  110. package/examples/js/loaders/TGALoader.js +39 -41
  111. package/examples/js/loaders/TIFFLoader.js +0 -1
  112. package/examples/js/loaders/TTFLoader.js +0 -8
  113. package/examples/js/loaders/TiltLoader.js +14 -15
  114. package/examples/js/loaders/VOXLoader.js +8 -16
  115. package/examples/js/loaders/VRMLLoader.js +243 -340
  116. package/examples/js/loaders/VTKLoader.js +101 -118
  117. package/examples/js/loaders/XYZLoader.js +2 -4
  118. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  119. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  120. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  121. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  122. package/examples/js/math/Capsule.js +0 -17
  123. package/examples/js/math/ColorConverter.js +3 -3
  124. package/examples/js/math/ConvexHull.js +183 -139
  125. package/examples/js/math/ImprovedNoise.js +1 -1
  126. package/examples/js/math/Lut.js +8 -15
  127. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  128. package/examples/js/math/OBB.js +90 -49
  129. package/examples/js/math/Octree.js +2 -57
  130. package/examples/js/math/SimplexNoise.js +74 -88
  131. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  132. package/examples/js/misc/GPUComputationRenderer.js +14 -18
  133. package/examples/js/misc/Gyroscope.js +5 -9
  134. package/examples/js/misc/MD2Character.js +14 -23
  135. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  136. package/examples/js/misc/MorphAnimMesh.js +0 -6
  137. package/examples/js/misc/MorphBlendMesh.js +3 -30
  138. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  139. package/examples/js/misc/RollerCoaster.js +17 -24
  140. package/examples/js/misc/TubePainter.js +18 -12
  141. package/examples/js/misc/Volume.js +16 -45
  142. package/examples/js/misc/VolumeSlice.js +14 -24
  143. package/examples/js/modifiers/CurveModifier.js +19 -21
  144. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  145. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  146. package/examples/js/modifiers/TessellateModifier.js +2 -9
  147. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  148. package/examples/js/objects/Lensflare.js +47 -38
  149. package/examples/js/objects/LightningStorm.js +10 -13
  150. package/examples/js/objects/MarchingCubes.js +80 -59
  151. package/examples/js/objects/Reflector.js +22 -20
  152. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  153. package/examples/js/objects/Refractor.js +52 -30
  154. package/examples/js/objects/ShadowMesh.js +1 -2
  155. package/examples/js/objects/Sky.js +2 -7
  156. package/examples/js/objects/Water.js +23 -18
  157. package/examples/js/objects/Water2.js +20 -19
  158. package/examples/js/physics/AmmoPhysics.js +23 -20
  159. package/examples/js/physics/OimoPhysics.js +19 -17
  160. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  161. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  162. package/examples/js/postprocessing/BloomPass.js +38 -17
  163. package/examples/js/postprocessing/BokehPass.js +29 -12
  164. package/examples/js/postprocessing/ClearPass.js +1 -6
  165. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  166. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  167. package/examples/js/postprocessing/EffectComposer.js +25 -32
  168. package/examples/js/postprocessing/FilmPass.js +7 -5
  169. package/examples/js/postprocessing/GlitchPass.js +10 -11
  170. package/examples/js/postprocessing/HalftonePass.js +9 -9
  171. package/examples/js/postprocessing/LUTPass.js +2 -15
  172. package/examples/js/postprocessing/MaskPass.js +20 -17
  173. package/examples/js/postprocessing/OutlinePass.js +45 -36
  174. package/examples/js/postprocessing/Pass.js +11 -14
  175. package/examples/js/postprocessing/RenderPass.js +3 -7
  176. package/examples/js/postprocessing/SAOPass.js +40 -32
  177. package/examples/js/postprocessing/SMAAPass.js +34 -17
  178. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  179. package/examples/js/postprocessing/SSAOPass.js +56 -42
  180. package/examples/js/postprocessing/SSRPass.js +78 -61
  181. package/examples/js/postprocessing/SavePass.js +14 -6
  182. package/examples/js/postprocessing/ShaderPass.js +9 -8
  183. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  184. package/examples/js/postprocessing/TexturePass.js +7 -4
  185. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  186. package/examples/js/renderers/CSS2DRenderer.js +2 -21
  187. package/examples/js/renderers/CSS3DRenderer.js +3 -24
  188. package/examples/js/renderers/Projector.js +29 -85
  189. package/examples/js/renderers/SVGRenderer.js +4 -50
  190. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  191. package/examples/js/shaders/AfterimageShader.js +3 -6
  192. package/examples/js/shaders/BasicShader.js +3 -6
  193. package/examples/js/shaders/BleachBypassShader.js +3 -6
  194. package/examples/js/shaders/BlendShader.js +3 -6
  195. package/examples/js/shaders/BokehShader.js +3 -6
  196. package/examples/js/shaders/BokehShader2.js +4 -13
  197. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  198. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  199. package/examples/js/shaders/ColorifyShader.js +2 -6
  200. package/examples/js/shaders/ConvolutionShader.js +5 -10
  201. package/examples/js/shaders/CopyShader.js +3 -6
  202. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  203. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  204. package/examples/js/shaders/DigitalGlitch.js +3 -6
  205. package/examples/js/shaders/DotScreenShader.js +2 -6
  206. package/examples/js/shaders/FXAAShader.js +1 -3
  207. package/examples/js/shaders/FilmShader.js +3 -6
  208. package/examples/js/shaders/FocusShader.js +3 -6
  209. package/examples/js/shaders/FreiChenShader.js +2 -6
  210. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  211. package/examples/js/shaders/GodRaysShader.js +11 -24
  212. package/examples/js/shaders/HalftoneShader.js +3 -6
  213. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  214. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  215. package/examples/js/shaders/HueSaturationShader.js +3 -6
  216. package/examples/js/shaders/KaleidoShader.js +3 -6
  217. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  218. package/examples/js/shaders/LuminosityShader.js +3 -6
  219. package/examples/js/shaders/MMDToonShader.js +2 -6
  220. package/examples/js/shaders/MirrorShader.js +3 -6
  221. package/examples/js/shaders/NormalMapShader.js +2 -6
  222. package/examples/js/shaders/RGBShiftShader.js +3 -6
  223. package/examples/js/shaders/SAOShader.js +2 -6
  224. package/examples/js/shaders/SMAAShader.js +6 -18
  225. package/examples/js/shaders/SSAOShader.js +2 -6
  226. package/examples/js/shaders/SSRShader.js +6 -18
  227. package/examples/js/shaders/SepiaShader.js +3 -6
  228. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  229. package/examples/js/shaders/TechnicolorShader.js +3 -6
  230. package/examples/js/shaders/ToneMapShader.js +3 -6
  231. package/examples/js/shaders/ToonShader.js +8 -24
  232. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  233. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  234. package/examples/js/shaders/VelocityShader.js +126 -0
  235. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  236. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  237. package/examples/js/shaders/VignetteShader.js +3 -6
  238. package/examples/js/shaders/VolumeShader.js +2 -6
  239. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  240. package/examples/js/textures/FlakesTexture.js +0 -1
  241. package/examples/js/utils/BufferGeometryUtils.js +234 -168
  242. package/examples/js/utils/CameraUtils.js +5 -20
  243. package/examples/js/utils/GPUStatsPanel.js +3 -12
  244. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  245. package/examples/js/utils/GeometryUtils.js +13 -18
  246. package/examples/js/utils/LDrawUtils.js +8 -11
  247. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  248. package/examples/js/utils/SceneUtils.js +117 -6
  249. package/examples/js/utils/ShadowMapViewer.js +17 -14
  250. package/examples/js/utils/SkeletonUtils.js +13 -27
  251. package/examples/js/utils/UVsDebug.js +20 -12
  252. package/examples/js/utils/WorkerPool.js +1 -11
  253. package/examples/jsm/animation/CCDIKSolver.js +1 -1
  254. package/examples/jsm/capabilities/WebGPU.js +3 -1
  255. package/examples/jsm/controls/OrbitControls.js +44 -4
  256. package/examples/jsm/exporters/GLTFExporter.js +17 -131
  257. package/examples/jsm/exporters/USDZExporter.js +94 -28
  258. package/examples/jsm/interactive/HTMLMesh.js +2 -0
  259. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  260. package/examples/jsm/loaders/3DMLoader.js +1 -2
  261. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  262. package/examples/jsm/loaders/FBXLoader.js +16 -2
  263. package/examples/jsm/loaders/GLTFLoader.js +204 -377
  264. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  265. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  266. package/examples/jsm/loaders/LottieLoader.js +4 -2
  267. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  268. package/examples/jsm/loaders/PCDLoader.js +1 -1
  269. package/examples/jsm/loaders/PLYLoader.js +68 -16
  270. package/examples/jsm/loaders/SVGLoader.js +227 -14
  271. package/examples/jsm/loaders/USDZLoader.js +31 -16
  272. package/examples/jsm/nodes/Nodes.js +14 -2
  273. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  274. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  275. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  276. package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
  277. package/examples/jsm/nodes/core/Node.js +1 -1
  278. package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
  279. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  280. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  281. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  282. package/examples/jsm/nodes/core/constants.js +13 -13
  283. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  284. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  285. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  286. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  287. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  288. package/examples/jsm/nodes/materials/Materials.js +9 -7
  289. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  290. package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
  291. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  292. package/examples/jsm/nodes/math/MathNode.js +5 -0
  293. package/examples/jsm/nodes/math/OperatorNode.js +6 -1
  294. package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
  295. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
  296. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
  297. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  298. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  299. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  300. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  301. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  302. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  303. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  304. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  305. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  306. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  307. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  308. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  309. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  310. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  311. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  312. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  313. package/examples/jsm/postprocessing/OutlinePass.js +10 -0
  314. package/examples/jsm/postprocessing/Pass.js +2 -0
  315. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  316. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  317. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  318. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  319. package/examples/jsm/postprocessing/SavePass.js +17 -1
  320. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  321. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  322. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  323. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  324. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
  325. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  326. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  327. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  328. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  329. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
  330. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  331. package/examples/jsm/shaders/VelocityShader.js +128 -0
  332. package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
  333. package/examples/jsm/utils/SceneUtils.js +129 -4
  334. package/examples/jsm/utils/TextureUtils.js +85 -0
  335. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  336. package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
  337. package/package.json +11 -12
  338. package/src/Three.js +1 -0
  339. package/src/audio/AudioContext.js +5 -5
  340. package/src/cameras/CubeCamera.js +14 -14
  341. package/src/constants.js +1 -1
  342. package/src/core/InstancedBufferGeometry.js +1 -7
  343. package/src/extras/Earcut.js +67 -67
  344. package/src/helpers/DirectionalLightHelper.js +5 -1
  345. package/src/helpers/HemisphereLightHelper.js +4 -1
  346. package/src/helpers/PointLightHelper.js +2 -1
  347. package/src/helpers/SpotLightHelper.js +4 -2
  348. package/src/lights/PointLight.js +2 -2
  349. package/src/lights/SpotLight.js +2 -2
  350. package/src/loaders/FileLoader.js +4 -1
  351. package/src/loaders/ObjectLoader.js +5 -1
  352. package/src/materials/Material.js +1 -1
  353. package/src/math/Color.js +5 -5
  354. package/src/math/Matrix3.js +53 -18
  355. package/src/math/Ray.js +2 -5
  356. package/src/math/Sphere.js +19 -26
  357. package/src/objects/InstancedMesh.js +7 -0
  358. package/src/objects/LOD.js +25 -6
  359. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  360. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  361. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  362. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  363. package/src/renderers/WebGLRenderTarget.js +1 -1
  364. package/src/renderers/WebGLRenderer.js +36 -62
  365. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  367. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  369. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  370. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  371. package/src/renderers/shaders/ShaderChunk.js +3 -0
  372. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  373. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  374. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  375. package/src/renderers/shaders/ShaderLib.js +20 -6
  376. package/src/renderers/shaders/UniformsLib.js +1 -1
  377. package/src/renderers/shaders/UniformsUtils.js +15 -0
  378. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  379. package/src/renderers/webgl/WebGLBackground.js +15 -7
  380. package/src/renderers/webgl/WebGLCubeUVMaps.js +1 -1
  381. package/src/renderers/webgl/WebGLLights.js +0 -4
  382. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  383. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  384. package/src/renderers/webgl/WebGLState.js +31 -1
  385. package/src/renderers/webgl/WebGLTextures.js +71 -18
  386. package/src/renderers/webgl/WebGLUniforms.js +116 -20
  387. package/src/renderers/webgl/WebGLUtils.js +1 -1
  388. package/src/renderers/webxr/WebXRController.js +46 -13
  389. package/src/renderers/webxr/WebXRManager.js +85 -3
  390. package/src/scenes/Scene.js +8 -0
  391. package/src/textures/CompressedArrayTexture.js +18 -0
  392. package/examples/js/libs/lottie_canvas.js +0 -12751
  393. package/examples/js/shaders/PixelShader.js +0 -51
  394. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -1,13 +1,9 @@
1
1
  ( function () {
2
2
 
3
3
  const _raycaster = new THREE.Raycaster();
4
-
5
4
  const _tempVector = new THREE.Vector3();
6
-
7
5
  const _tempVector2 = new THREE.Vector3();
8
-
9
6
  const _tempQuaternion = new THREE.Quaternion();
10
-
11
7
  const _unit = {
12
8
  X: new THREE.Vector3( 1, 0, 0 ),
13
9
  Y: new THREE.Vector3( 0, 1, 0 ),
@@ -26,13 +22,11 @@
26
22
  const _objectChangeEvent = {
27
23
  type: 'objectChange'
28
24
  };
29
-
30
25
  class TransformControls extends THREE.Object3D {
31
26
 
32
27
  constructor( camera, domElement ) {
33
28
 
34
29
  super();
35
-
36
30
  if ( domElement === undefined ) {
37
31
 
38
32
  console.warn( 'THREE.TransformControls: The second parameter "domElement" is now mandatory.' );
@@ -46,16 +40,14 @@
46
40
  this.domElement.style.touchAction = 'none'; // disable touch scroll
47
41
 
48
42
  const _gizmo = new TransformControlsGizmo();
49
-
50
43
  this._gizmo = _gizmo;
51
44
  this.add( _gizmo );
52
-
53
45
  const _plane = new TransformControlsPlane();
54
-
55
46
  this._plane = _plane;
56
47
  this.add( _plane );
57
- const scope = this; // Defined getter, setter and store for a property
48
+ const scope = this;
58
49
 
50
+ // Defined getter, setter and store for a property
59
51
  function defineProperty( propName, defaultValue ) {
60
52
 
61
53
  let propValue = defaultValue;
@@ -86,11 +78,12 @@
86
78
  _plane[ propName ] = defaultValue;
87
79
  _gizmo[ propName ] = defaultValue;
88
80
 
89
- } // Define properties with getters/setter
81
+ }
82
+
83
+ // Define properties with getters/setter
90
84
  // Setting the defined property will automatically trigger change event
91
85
  // Defined properties are passed down to gizmo and plane
92
86
 
93
-
94
87
  defineProperty( 'camera', camera );
95
88
  defineProperty( 'object', undefined );
96
89
  defineProperty( 'enabled', true );
@@ -104,7 +97,9 @@
104
97
  defineProperty( 'dragging', false );
105
98
  defineProperty( 'showX', true );
106
99
  defineProperty( 'showY', true );
107
- defineProperty( 'showZ', true ); // Reusable utility variables
100
+ defineProperty( 'showZ', true );
101
+
102
+ // Reusable utility variables
108
103
 
109
104
  const worldPosition = new THREE.Vector3();
110
105
  const worldPositionStart = new THREE.Vector3();
@@ -116,7 +111,9 @@
116
111
  const pointEnd = new THREE.Vector3();
117
112
  const rotationAxis = new THREE.Vector3();
118
113
  const rotationAngle = 0;
119
- const eye = new THREE.Vector3(); // TODO: remove properties unused in plane and gizmo
114
+ const eye = new THREE.Vector3();
115
+
116
+ // TODO: remove properties unused in plane and gizmo
120
117
 
121
118
  defineProperty( 'worldPosition', worldPosition );
122
119
  defineProperty( 'worldPositionStart', worldPositionStart );
@@ -152,15 +149,14 @@
152
149
  this.domElement.addEventListener( 'pointermove', this._onPointerHover );
153
150
  this.domElement.addEventListener( 'pointerup', this._onPointerUp );
154
151
 
155
- } // updateMatrixWorld updates key transformation variables
156
-
152
+ }
157
153
 
154
+ // updateMatrixWorld updates key transformation variables
158
155
  updateMatrixWorld() {
159
156
 
160
157
  if ( this.object !== undefined ) {
161
158
 
162
159
  this.object.updateMatrixWorld();
163
-
164
160
  if ( this.object.parent === null ) {
165
161
 
166
162
  console.error( 'TransformControls: The attached 3D object must be a part of the scene graph.' );
@@ -172,16 +168,13 @@
172
168
  }
173
169
 
174
170
  this.object.matrixWorld.decompose( this.worldPosition, this.worldQuaternion, this._worldScale );
175
-
176
171
  this._parentQuaternionInv.copy( this._parentQuaternion ).invert();
177
-
178
172
  this._worldQuaternionInv.copy( this.worldQuaternion ).invert();
179
173
 
180
174
  }
181
175
 
182
176
  this.camera.updateMatrixWorld();
183
177
  this.camera.matrixWorld.decompose( this.cameraPosition, this.cameraQuaternion, this._cameraScale );
184
-
185
178
  if ( this.camera.isOrthographicCamera ) {
186
179
 
187
180
  this.camera.getWorldDirection( this.eye ).negate();
@@ -195,15 +188,11 @@
195
188
  super.updateMatrixWorld( this );
196
189
 
197
190
  }
198
-
199
191
  pointerHover( pointer ) {
200
192
 
201
193
  if ( this.object === undefined || this.dragging === true ) return;
202
-
203
194
  _raycaster.setFromCamera( pointer, this.camera );
204
-
205
195
  const intersect = intersectObjectWithRay( this._gizmo.picker[ this.mode ], _raycaster );
206
-
207
196
  if ( intersect ) {
208
197
 
209
198
  this.axis = intersect.object.name;
@@ -215,28 +204,20 @@
215
204
  }
216
205
 
217
206
  }
218
-
219
207
  pointerDown( pointer ) {
220
208
 
221
209
  if ( this.object === undefined || this.dragging === true || pointer.button !== 0 ) return;
222
-
223
210
  if ( this.axis !== null ) {
224
211
 
225
212
  _raycaster.setFromCamera( pointer, this.camera );
226
-
227
213
  const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );
228
-
229
214
  if ( planeIntersect ) {
230
215
 
231
216
  this.object.updateMatrixWorld();
232
217
  this.object.parent.updateMatrixWorld();
233
-
234
218
  this._positionStart.copy( this.object.position );
235
-
236
219
  this._quaternionStart.copy( this.object.quaternion );
237
-
238
220
  this._scaleStart.copy( this.object.scale );
239
-
240
221
  this.object.matrixWorld.decompose( this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart );
241
222
  this.pointStart.copy( planeIntersect.point ).sub( this.worldPositionStart );
242
223
 
@@ -249,14 +230,12 @@
249
230
  }
250
231
 
251
232
  }
252
-
253
233
  pointerMove( pointer ) {
254
234
 
255
235
  const axis = this.axis;
256
236
  const mode = this.mode;
257
237
  const object = this.object;
258
238
  let space = this.space;
259
-
260
239
  if ( mode === 'scale' ) {
261
240
 
262
241
  space = 'local';
@@ -268,18 +247,15 @@
268
247
  }
269
248
 
270
249
  if ( object === undefined || axis === null || this.dragging === false || pointer.button !== - 1 ) return;
271
-
272
250
  _raycaster.setFromCamera( pointer, this.camera );
273
-
274
251
  const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );
275
252
  if ( ! planeIntersect ) return;
276
253
  this.pointEnd.copy( planeIntersect.point ).sub( this.worldPositionStart );
277
-
278
254
  if ( mode === 'translate' ) {
279
255
 
280
256
  // Apply translate
281
- this._offset.copy( this.pointEnd ).sub( this.pointStart );
282
257
 
258
+ this._offset.copy( this.pointEnd ).sub( this.pointStart );
283
259
  if ( space === 'local' && axis !== 'XYZ' ) {
284
260
 
285
261
  this._offset.applyQuaternion( this._worldQuaternionInv );
@@ -289,7 +265,6 @@
289
265
  if ( axis.indexOf( 'X' ) === - 1 ) this._offset.x = 0;
290
266
  if ( axis.indexOf( 'Y' ) === - 1 ) this._offset.y = 0;
291
267
  if ( axis.indexOf( 'Z' ) === - 1 ) this._offset.z = 0;
292
-
293
268
  if ( space === 'local' && axis !== 'XYZ' ) {
294
269
 
295
270
  this._offset.applyQuaternion( this._quaternionStart ).divide( this._parentScale );
@@ -300,14 +275,15 @@
300
275
 
301
276
  }
302
277
 
303
- object.position.copy( this._offset ).add( this._positionStart ); // Apply translation snap
278
+ object.position.copy( this._offset ).add( this._positionStart );
279
+
280
+ // Apply translation snap
304
281
 
305
282
  if ( this.translationSnap ) {
306
283
 
307
284
  if ( space === 'local' ) {
308
285
 
309
286
  object.position.applyQuaternion( _tempQuaternion.copy( this._quaternionStart ).invert() );
310
-
311
287
  if ( axis.search( 'X' ) !== - 1 ) {
312
288
 
313
289
  object.position.x = Math.round( object.position.x / this.translationSnap ) * this.translationSnap;
@@ -372,21 +348,15 @@
372
348
 
373
349
  let d = this.pointEnd.length() / this.pointStart.length();
374
350
  if ( this.pointEnd.dot( this.pointStart ) < 0 ) d *= - 1;
375
-
376
351
  _tempVector2.set( d, d, d );
377
352
 
378
353
  } else {
379
354
 
380
355
  _tempVector.copy( this.pointStart );
381
-
382
356
  _tempVector2.copy( this.pointEnd );
383
-
384
357
  _tempVector.applyQuaternion( this._worldQuaternionInv );
385
-
386
358
  _tempVector2.applyQuaternion( this._worldQuaternionInv );
387
-
388
359
  _tempVector2.divide( _tempVector );
389
-
390
360
  if ( axis.search( 'X' ) === - 1 ) {
391
361
 
392
362
  _tempVector2.x = 1;
@@ -405,11 +375,11 @@
405
375
 
406
376
  }
407
377
 
408
- } // Apply scale
378
+ }
409
379
 
380
+ // Apply scale
410
381
 
411
382
  object.scale.copy( this._scaleStart ).multiply( _tempVector2 );
412
-
413
383
  if ( this.scaleSnap ) {
414
384
 
415
385
  if ( axis.search( 'X' ) !== - 1 ) {
@@ -435,18 +405,13 @@
435
405
  } else if ( mode === 'rotate' ) {
436
406
 
437
407
  this._offset.copy( this.pointEnd ).sub( this.pointStart );
438
-
439
408
  const ROTATION_SPEED = 20 / this.worldPosition.distanceTo( _tempVector.setFromMatrixPosition( this.camera.matrixWorld ) );
440
-
441
409
  if ( axis === 'E' ) {
442
410
 
443
411
  this.rotationAxis.copy( this.eye );
444
412
  this.rotationAngle = this.pointEnd.angleTo( this.pointStart );
445
-
446
413
  this._startNorm.copy( this.pointStart ).normalize();
447
-
448
414
  this._endNorm.copy( this.pointEnd ).normalize();
449
-
450
415
  this.rotationAngle *= this._endNorm.cross( this._startNorm ).dot( this.eye ) < 0 ? 1 : - 1;
451
416
 
452
417
  } else if ( axis === 'XYZE' ) {
@@ -457,9 +422,7 @@
457
422
  } else if ( axis === 'X' || axis === 'Y' || axis === 'Z' ) {
458
423
 
459
424
  this.rotationAxis.copy( _unit[ axis ] );
460
-
461
425
  _tempVector.copy( _unit[ axis ] );
462
-
463
426
  if ( space === 'local' ) {
464
427
 
465
428
  _tempVector.applyQuaternion( this.worldQuaternion );
@@ -468,11 +431,13 @@
468
431
 
469
432
  this.rotationAngle = this._offset.dot( _tempVector.cross( this.eye ).normalize() ) * ROTATION_SPEED;
470
433
 
471
- } // Apply rotation snap
434
+ }
472
435
 
436
+ // Apply rotation snap
473
437
 
474
- if ( this.rotationSnap ) this.rotationAngle = Math.round( this.rotationAngle / this.rotationSnap ) * this.rotationSnap; // Apply rotate
438
+ if ( this.rotationSnap ) this.rotationAngle = Math.round( this.rotationAngle / this.rotationSnap ) * this.rotationSnap;
475
439
 
440
+ // Apply rotate
476
441
  if ( space === 'local' && axis !== 'E' && axis !== 'XYZE' ) {
477
442
 
478
443
  object.quaternion.copy( this._quaternionStart );
@@ -492,11 +457,9 @@
492
457
  this.dispatchEvent( _objectChangeEvent );
493
458
 
494
459
  }
495
-
496
460
  pointerUp( pointer ) {
497
461
 
498
462
  if ( pointer.button !== 0 ) return;
499
-
500
463
  if ( this.dragging && this.axis !== null ) {
501
464
 
502
465
  _mouseUpEvent.mode = this.mode;
@@ -508,7 +471,6 @@
508
471
  this.axis = null;
509
472
 
510
473
  }
511
-
512
474
  dispose() {
513
475
 
514
476
  this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
@@ -522,18 +484,18 @@
522
484
 
523
485
  } );
524
486
 
525
- } // Set current object
526
-
487
+ }
527
488
 
489
+ // Set current object
528
490
  attach( object ) {
529
491
 
530
492
  this.object = object;
531
493
  this.visible = true;
532
494
  return this;
533
495
 
534
- } // Detach from object
535
-
496
+ }
536
497
 
498
+ // Detach from object
537
499
  detach() {
538
500
 
539
501
  this.object = undefined;
@@ -542,11 +504,9 @@
542
504
  return this;
543
505
 
544
506
  }
545
-
546
507
  reset() {
547
508
 
548
509
  if ( ! this.enabled ) return;
549
-
550
510
  if ( this.dragging ) {
551
511
 
552
512
  this.object.position.copy( this._positionStart );
@@ -559,58 +519,53 @@
559
519
  }
560
520
 
561
521
  }
562
-
563
522
  getRaycaster() {
564
523
 
565
524
  return _raycaster;
566
525
 
567
- } // TODO: deprecate
526
+ }
568
527
 
528
+ // TODO: deprecate
569
529
 
570
530
  getMode() {
571
531
 
572
532
  return this.mode;
573
533
 
574
534
  }
575
-
576
535
  setMode( mode ) {
577
536
 
578
537
  this.mode = mode;
579
538
 
580
539
  }
581
-
582
540
  setTranslationSnap( translationSnap ) {
583
541
 
584
542
  this.translationSnap = translationSnap;
585
543
 
586
544
  }
587
-
588
545
  setRotationSnap( rotationSnap ) {
589
546
 
590
547
  this.rotationSnap = rotationSnap;
591
548
 
592
549
  }
593
-
594
550
  setScaleSnap( scaleSnap ) {
595
551
 
596
552
  this.scaleSnap = scaleSnap;
597
553
 
598
554
  }
599
-
600
555
  setSize( size ) {
601
556
 
602
557
  this.size = size;
603
558
 
604
559
  }
605
-
606
560
  setSpace( space ) {
607
561
 
608
562
  this.space = space;
609
563
 
610
564
  }
611
565
 
612
- } // mouse / touch event handlers
566
+ }
613
567
 
568
+ // mouse / touch event handlers
614
569
 
615
570
  function getPointer( event ) {
616
571
 
@@ -638,7 +593,6 @@
638
593
  function onPointerHover( event ) {
639
594
 
640
595
  if ( ! this.enabled ) return;
641
-
642
596
  switch ( event.pointerType ) {
643
597
 
644
598
  case 'mouse':
@@ -653,7 +607,6 @@
653
607
  function onPointerDown( event ) {
654
608
 
655
609
  if ( ! this.enabled ) return;
656
-
657
610
  if ( ! document.pointerLockElement ) {
658
611
 
659
612
  this.domElement.setPointerCapture( event.pointerId );
@@ -685,7 +638,6 @@
685
638
  function intersectObjectWithRay( object, raycaster, includeInvisible ) {
686
639
 
687
640
  const allIntersections = raycaster.intersectObject( object, true );
688
-
689
641
  for ( let i = 0; i < allIntersections.length; i ++ ) {
690
642
 
691
643
  if ( allIntersections[ i ].object.visible || includeInvisible ) {
@@ -698,45 +650,35 @@
698
650
 
699
651
  return false;
700
652
 
701
- } //
702
- // Reusable utility variables
653
+ }
703
654
 
655
+ //
704
656
 
705
- const _tempEuler = new THREE.Euler();
657
+ // Reusable utility variables
706
658
 
659
+ const _tempEuler = new THREE.Euler();
707
660
  const _alignVector = new THREE.Vector3( 0, 1, 0 );
708
-
709
661
  const _zeroVector = new THREE.Vector3( 0, 0, 0 );
710
-
711
662
  const _lookAtMatrix = new THREE.Matrix4();
712
-
713
663
  const _tempQuaternion2 = new THREE.Quaternion();
714
-
715
664
  const _identityQuaternion = new THREE.Quaternion();
716
-
717
665
  const _dirVector = new THREE.Vector3();
718
-
719
666
  const _tempMatrix = new THREE.Matrix4();
720
-
721
667
  const _unitX = new THREE.Vector3( 1, 0, 0 );
722
-
723
668
  const _unitY = new THREE.Vector3( 0, 1, 0 );
724
-
725
669
  const _unitZ = new THREE.Vector3( 0, 0, 1 );
726
-
727
670
  const _v1 = new THREE.Vector3();
728
-
729
671
  const _v2 = new THREE.Vector3();
730
-
731
672
  const _v3 = new THREE.Vector3();
732
-
733
673
  class TransformControlsGizmo extends THREE.Object3D {
734
674
 
735
675
  constructor() {
736
676
 
737
677
  super();
738
678
  this.isTransformControlsGizmo = true;
739
- this.type = 'TransformControlsGizmo'; // shared materials
679
+ this.type = 'TransformControlsGizmo';
680
+
681
+ // shared materials
740
682
 
741
683
  const gizmoMaterial = new THREE.MeshBasicMaterial( {
742
684
  depthTest: false,
@@ -751,7 +693,9 @@
751
693
  fog: false,
752
694
  toneMapped: false,
753
695
  transparent: true
754
- } ); // Make unique material for each axis/color
696
+ } );
697
+
698
+ // Make unique material for each axis/color
755
699
 
756
700
  const matInvisible = gizmoMaterial.clone();
757
701
  matInvisible.opacity = 0.15;
@@ -780,7 +724,9 @@
780
724
  const matYellow = gizmoMaterial.clone();
781
725
  matYellow.color.setHex( 0xffff00 );
782
726
  const matGray = gizmoMaterial.clone();
783
- matGray.color.setHex( 0x787878 ); // reusable geometry
727
+ matGray.color.setHex( 0x787878 );
728
+
729
+ // reusable geometry
784
730
 
785
731
  const arrowGeometry = new THREE.CylinderGeometry( 0, 0.04, 0.1, 12 );
786
732
  arrowGeometry.translate( 0, 0.05, 0 );
@@ -790,7 +736,6 @@
790
736
  lineGeometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 1, 0, 0 ], 3 ) );
791
737
  const lineGeometry2 = new THREE.CylinderGeometry( 0.0075, 0.0075, 0.5, 3 );
792
738
  lineGeometry2.translate( 0, 0.25, 0 );
793
-
794
739
  function CircleGeometry( radius, arc ) {
795
740
 
796
741
  const geometry = new THREE.TorusGeometry( radius, 0.0075, 3, 64, arc * Math.PI * 2 );
@@ -798,8 +743,9 @@
798
743
  geometry.rotateX( Math.PI / 2 );
799
744
  return geometry;
800
745
 
801
- } // Special geometry for transform helper. If scaled with position vector it spans from [0,0,0] to position
746
+ }
802
747
 
748
+ // Special geometry for transform helper. If scaled with position vector it spans from [0,0,0] to position
803
749
 
804
750
  function TranslateHelperGeometry() {
805
751
 
@@ -807,8 +753,9 @@
807
753
  geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 1, 1, 1 ], 3 ) );
808
754
  return geometry;
809
755
 
810
- } // Gizmo definitions - custom hierarchy definitions for setupGizmo() function
756
+ }
811
757
 
758
+ // Gizmo definitions - custom hierarchy definitions for setupGizmo() function
812
759
 
813
760
  const gizmoTranslate = {
814
761
  X: [[ new THREE.Mesh( arrowGeometry, matRed ), [ 0.5, 0, 0 ], [ 0, 0, - Math.PI / 2 ]], [ new THREE.Mesh( arrowGeometry, matRed ), [ - 0.5, 0, 0 ], [ 0, 0, Math.PI / 2 ]], [ new THREE.Mesh( lineGeometry2, matRed ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]]],
@@ -875,12 +822,13 @@
875
822
  X: [[ new THREE.Line( lineGeometry, matHelper.clone() ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]],
876
823
  Y: [[ new THREE.Line( lineGeometry, matHelper.clone() ), [ 0, - 1e3, 0 ], [ 0, 0, Math.PI / 2 ], [ 1e6, 1, 1 ], 'helper' ]],
877
824
  Z: [[ new THREE.Line( lineGeometry, matHelper.clone() ), [ 0, 0, - 1e3 ], [ 0, - Math.PI / 2, 0 ], [ 1e6, 1, 1 ], 'helper' ]]
878
- }; // Creates an THREE.Object3D with gizmos described in custom hierarchy definition.
825
+ };
826
+
827
+ // Creates an THREE.Object3D with gizmos described in custom hierarchy definition.
879
828
 
880
829
  function setupGizmo( gizmoMap ) {
881
830
 
882
831
  const gizmo = new THREE.Object3D();
883
-
884
832
  for ( const name in gizmoMap ) {
885
833
 
886
834
  for ( let i = gizmoMap[ name ].length; i --; ) {
@@ -889,11 +837,11 @@
889
837
  const position = gizmoMap[ name ][ i ][ 1 ];
890
838
  const rotation = gizmoMap[ name ][ i ][ 2 ];
891
839
  const scale = gizmoMap[ name ][ i ][ 3 ];
892
- const tag = gizmoMap[ name ][ i ][ 4 ]; // name and tag properties are essential for picking and updating logic.
840
+ const tag = gizmoMap[ name ][ i ][ 4 ];
893
841
 
842
+ // name and tag properties are essential for picking and updating logic.
894
843
  object.name = name;
895
844
  object.tag = tag;
896
-
897
845
  if ( position ) {
898
846
 
899
847
  object.position.set( position[ 0 ], position[ 1 ], position[ 2 ] );
@@ -928,8 +876,9 @@
928
876
 
929
877
  return gizmo;
930
878
 
931
- } // Gizmo creation
879
+ }
932
880
 
881
+ // Gizmo creation
933
882
 
934
883
  this.gizmo = {};
935
884
  this.picker = {};
@@ -942,20 +891,25 @@
942
891
  this.add( this.picker[ 'scale' ] = setupGizmo( pickerScale ) );
943
892
  this.add( this.helper[ 'translate' ] = setupGizmo( helperTranslate ) );
944
893
  this.add( this.helper[ 'rotate' ] = setupGizmo( helperRotate ) );
945
- this.add( this.helper[ 'scale' ] = setupGizmo( helperScale ) ); // Pickers should be hidden always
894
+ this.add( this.helper[ 'scale' ] = setupGizmo( helperScale ) );
895
+
896
+ // Pickers should be hidden always
946
897
 
947
898
  this.picker[ 'translate' ].visible = false;
948
899
  this.picker[ 'rotate' ].visible = false;
949
900
  this.picker[ 'scale' ].visible = false;
950
901
 
951
- } // updateMatrixWorld will update transformations and appearance of individual handles
902
+ }
952
903
 
904
+ // updateMatrixWorld will update transformations and appearance of individual handles
953
905
 
954
906
  updateMatrixWorld( force ) {
955
907
 
956
908
  const space = this.mode === 'scale' ? 'local' : this.space; // scale always oriented to local rotation
957
909
 
958
- const quaternion = space === 'local' ? this.worldQuaternion : _identityQuaternion; // Show only gizmos for current transform mode
910
+ const quaternion = space === 'local' ? this.worldQuaternion : _identityQuaternion;
911
+
912
+ // Show only gizmos for current transform mode
959
913
 
960
914
  this.gizmo[ 'translate' ].visible = this.mode === 'translate';
961
915
  this.gizmo[ 'rotate' ].visible = this.mode === 'rotate';
@@ -967,16 +921,16 @@
967
921
  handles = handles.concat( this.picker[ this.mode ].children );
968
922
  handles = handles.concat( this.gizmo[ this.mode ].children );
969
923
  handles = handles.concat( this.helper[ this.mode ].children );
970
-
971
924
  for ( let i = 0; i < handles.length; i ++ ) {
972
925
 
973
- const handle = handles[ i ]; // hide aligned to camera
926
+ const handle = handles[ i ];
927
+
928
+ // hide aligned to camera
974
929
 
975
930
  handle.visible = true;
976
931
  handle.rotation.set( 0, 0, 0 );
977
932
  handle.position.copy( this.worldPosition );
978
933
  let factor;
979
-
980
934
  if ( this.camera.isOrthographicCamera ) {
981
935
 
982
936
  factor = ( this.camera.top - this.camera.bottom ) / this.camera.zoom;
@@ -987,23 +941,21 @@
987
941
 
988
942
  }
989
943
 
990
- handle.scale.set( 1, 1, 1 ).multiplyScalar( factor * this.size / 4 ); // TODO: simplify helpers and consider decoupling from gizmo
944
+ handle.scale.set( 1, 1, 1 ).multiplyScalar( factor * this.size / 4 );
945
+
946
+ // TODO: simplify helpers and consider decoupling from gizmo
991
947
 
992
948
  if ( handle.tag === 'helper' ) {
993
949
 
994
950
  handle.visible = false;
995
-
996
951
  if ( handle.name === 'AXIS' ) {
997
952
 
998
953
  handle.position.copy( this.worldPositionStart );
999
954
  handle.visible = !! this.axis;
1000
-
1001
955
  if ( this.axis === 'X' ) {
1002
956
 
1003
957
  _tempQuaternion.setFromEuler( _tempEuler.set( 0, 0, 0 ) );
1004
-
1005
958
  handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
1006
-
1007
959
  if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
1008
960
 
1009
961
  handle.visible = false;
@@ -1015,9 +967,7 @@
1015
967
  if ( this.axis === 'Y' ) {
1016
968
 
1017
969
  _tempQuaternion.setFromEuler( _tempEuler.set( 0, 0, Math.PI / 2 ) );
1018
-
1019
970
  handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
1020
-
1021
971
  if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
1022
972
 
1023
973
  handle.visible = false;
@@ -1029,9 +979,7 @@
1029
979
  if ( this.axis === 'Z' ) {
1030
980
 
1031
981
  _tempQuaternion.setFromEuler( _tempEuler.set( 0, Math.PI / 2, 0 ) );
1032
-
1033
982
  handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
1034
-
1035
983
  if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
1036
984
 
1037
985
  handle.visible = false;
@@ -1043,9 +991,7 @@
1043
991
  if ( this.axis === 'XYZE' ) {
1044
992
 
1045
993
  _tempQuaternion.setFromEuler( _tempEuler.set( 0, Math.PI / 2, 0 ) );
1046
-
1047
994
  _alignVector.copy( this.rotationAxis );
1048
-
1049
995
  handle.quaternion.setFromRotationMatrix( _lookAtMatrix.lookAt( _zeroVector, _alignVector, _unitY ) );
1050
996
  handle.quaternion.multiply( _tempQuaternion );
1051
997
  handle.visible = this.dragging;
@@ -1072,18 +1018,14 @@
1072
1018
 
1073
1019
  handle.position.copy( this.worldPositionStart );
1074
1020
  handle.quaternion.copy( this.worldQuaternionStart );
1075
-
1076
1021
  _tempVector.set( 1e-10, 1e-10, 1e-10 ).add( this.worldPositionStart ).sub( this.worldPosition ).multiplyScalar( - 1 );
1077
-
1078
1022
  _tempVector.applyQuaternion( this.worldQuaternionStart.clone().invert() );
1079
-
1080
1023
  handle.scale.copy( _tempVector );
1081
1024
  handle.visible = this.dragging;
1082
1025
 
1083
1026
  } else {
1084
1027
 
1085
1028
  handle.quaternion.copy( quaternion );
1086
-
1087
1029
  if ( this.dragging ) {
1088
1030
 
1089
1031
  handle.position.copy( this.worldPositionStart );
@@ -1100,22 +1042,22 @@
1100
1042
 
1101
1043
  }
1102
1044
 
1103
- } // If updating helper, skip rest of the loop
1104
-
1045
+ }
1105
1046
 
1047
+ // If updating helper, skip rest of the loop
1106
1048
  continue;
1107
1049
 
1108
- } // Align handles to current local or world rotation
1050
+ }
1109
1051
 
1052
+ // Align handles to current local or world rotation
1110
1053
 
1111
1054
  handle.quaternion.copy( quaternion );
1112
-
1113
1055
  if ( this.mode === 'translate' || this.mode === 'scale' ) {
1114
1056
 
1115
1057
  // Hide translate and scale axis facing the camera
1058
+
1116
1059
  const AXIS_HIDE_THRESHOLD = 0.99;
1117
1060
  const PLANE_HIDE_THRESHOLD = 0.2;
1118
-
1119
1061
  if ( handle.name === 'X' ) {
1120
1062
 
1121
1063
  if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) {
@@ -1185,10 +1127,9 @@
1185
1127
  } else if ( this.mode === 'rotate' ) {
1186
1128
 
1187
1129
  // Align handles to current local or world rotation
1188
- _tempQuaternion2.copy( quaternion );
1189
1130
 
1131
+ _tempQuaternion2.copy( quaternion );
1190
1132
  _alignVector.copy( this.eye ).applyQuaternion( _tempQuaternion.copy( quaternion ).invert() );
1191
-
1192
1133
  if ( handle.name.search( 'E' ) !== - 1 ) {
1193
1134
 
1194
1135
  handle.quaternion.setFromRotationMatrix( _lookAtMatrix.lookAt( this.eye, _zeroVector, _unitY ) );
@@ -1198,9 +1139,7 @@
1198
1139
  if ( handle.name === 'X' ) {
1199
1140
 
1200
1141
  _tempQuaternion.setFromAxisAngle( _unitX, Math.atan2( - _alignVector.y, _alignVector.z ) );
1201
-
1202
1142
  _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
1203
-
1204
1143
  handle.quaternion.copy( _tempQuaternion );
1205
1144
 
1206
1145
  }
@@ -1208,9 +1147,7 @@
1208
1147
  if ( handle.name === 'Y' ) {
1209
1148
 
1210
1149
  _tempQuaternion.setFromAxisAngle( _unitY, Math.atan2( _alignVector.x, _alignVector.z ) );
1211
-
1212
1150
  _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
1213
-
1214
1151
  handle.quaternion.copy( _tempQuaternion );
1215
1152
 
1216
1153
  }
@@ -1218,26 +1155,25 @@
1218
1155
  if ( handle.name === 'Z' ) {
1219
1156
 
1220
1157
  _tempQuaternion.setFromAxisAngle( _unitZ, Math.atan2( _alignVector.y, _alignVector.x ) );
1221
-
1222
1158
  _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
1223
-
1224
1159
  handle.quaternion.copy( _tempQuaternion );
1225
1160
 
1226
1161
  }
1227
1162
 
1228
- } // Hide disabled axes
1229
-
1163
+ }
1230
1164
 
1165
+ // Hide disabled axes
1231
1166
  handle.visible = handle.visible && ( handle.name.indexOf( 'X' ) === - 1 || this.showX );
1232
1167
  handle.visible = handle.visible && ( handle.name.indexOf( 'Y' ) === - 1 || this.showY );
1233
1168
  handle.visible = handle.visible && ( handle.name.indexOf( 'Z' ) === - 1 || this.showZ );
1234
- handle.visible = handle.visible && ( handle.name.indexOf( 'E' ) === - 1 || this.showX && this.showY && this.showZ ); // highlight selected axis
1169
+ handle.visible = handle.visible && ( handle.name.indexOf( 'E' ) === - 1 || this.showX && this.showY && this.showZ );
1170
+
1171
+ // highlight selected axis
1235
1172
 
1236
1173
  handle.material._color = handle.material._color || handle.material.color.clone();
1237
1174
  handle.material._opacity = handle.material._opacity || handle.material.opacity;
1238
1175
  handle.material.color.copy( handle.material._color );
1239
1176
  handle.material.opacity = handle.material._opacity;
1240
-
1241
1177
  if ( this.enabled && this.axis ) {
1242
1178
 
1243
1179
  if ( handle.name === this.axis ) {
@@ -1264,8 +1200,9 @@
1264
1200
 
1265
1201
  }
1266
1202
 
1267
- } //
1203
+ }
1268
1204
 
1205
+ //
1269
1206
 
1270
1207
  class TransformControlsPlane extends THREE.Mesh {
1271
1208
 
@@ -1283,7 +1220,6 @@
1283
1220
  this.type = 'TransformControlsPlane';
1284
1221
 
1285
1222
  }
1286
-
1287
1223
  updateMatrixWorld( force ) {
1288
1224
 
1289
1225
  let space = this.space;
@@ -1291,14 +1227,12 @@
1291
1227
  if ( this.mode === 'scale' ) space = 'local'; // scale always oriented to local rotation
1292
1228
 
1293
1229
  _v1.copy( _unitX ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
1294
-
1295
1230
  _v2.copy( _unitY ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
1231
+ _v3.copy( _unitZ ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
1296
1232
 
1297
- _v3.copy( _unitZ ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion ); // Align the plane for current transform mode, axis and space.
1298
-
1233
+ // Align the plane for current transform mode, axis and space.
1299
1234
 
1300
1235
  _alignVector.copy( _v2 );
1301
-
1302
1236
  switch ( this.mode ) {
1303
1237
 
1304
1238
  case 'translate':
@@ -1307,52 +1241,34 @@
1307
1241
 
1308
1242
  case 'X':
1309
1243
  _alignVector.copy( this.eye ).cross( _v1 );
1310
-
1311
1244
  _dirVector.copy( _v1 ).cross( _alignVector );
1312
-
1313
1245
  break;
1314
-
1315
1246
  case 'Y':
1316
1247
  _alignVector.copy( this.eye ).cross( _v2 );
1317
-
1318
1248
  _dirVector.copy( _v2 ).cross( _alignVector );
1319
-
1320
1249
  break;
1321
-
1322
1250
  case 'Z':
1323
1251
  _alignVector.copy( this.eye ).cross( _v3 );
1324
-
1325
1252
  _dirVector.copy( _v3 ).cross( _alignVector );
1326
-
1327
1253
  break;
1328
-
1329
1254
  case 'XY':
1330
1255
  _dirVector.copy( _v3 );
1331
-
1332
1256
  break;
1333
-
1334
1257
  case 'YZ':
1335
1258
  _dirVector.copy( _v1 );
1336
-
1337
1259
  break;
1338
-
1339
1260
  case 'XZ':
1340
1261
  _alignVector.copy( _v3 );
1341
-
1342
1262
  _dirVector.copy( _v2 );
1343
-
1344
1263
  break;
1345
-
1346
1264
  case 'XYZ':
1347
1265
  case 'E':
1348
1266
  _dirVector.set( 0, 0, 0 );
1349
-
1350
1267
  break;
1351
1268
 
1352
1269
  }
1353
1270
 
1354
1271
  break;
1355
-
1356
1272
  case 'rotate':
1357
1273
  default:
1358
1274
  // special case for rotate
@@ -1368,7 +1284,6 @@
1368
1284
  } else {
1369
1285
 
1370
1286
  _tempMatrix.lookAt( _tempVector.set( 0, 0, 0 ), _dirVector, _alignVector );
1371
-
1372
1287
  this.quaternion.setFromRotationMatrix( _tempMatrix );
1373
1288
 
1374
1289
  }