super-three 0.141.0 → 0.147.0

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 (646) hide show
  1. package/README.md +9 -9
  2. package/build/three.cjs +2441 -1569
  3. package/build/three.js +2441 -1569
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +2847 -1576
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +50 -67
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +71 -150
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +149 -403
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -61
  14. package/examples/js/controls/FlyControls.js +29 -63
  15. package/examples/js/controls/OrbitControls.js +125 -103
  16. package/examples/js/controls/PointerLockControls.js +5 -22
  17. package/examples/js/controls/TrackballControls.js +33 -88
  18. package/examples/js/controls/TransformControls.js +101 -182
  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 +6 -20
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +30 -54
  30. package/examples/js/effects/ParallaxBarrierEffect.js +2 -15
  31. package/examples/js/effects/PeppersGhostEffect.js +14 -41
  32. package/examples/js/effects/StereoEffect.js +2 -6
  33. package/examples/js/environments/RoomEnvironment.js +32 -8
  34. package/examples/js/exporters/ColladaExporter.js +52 -78
  35. package/examples/js/exporters/DRACOExporter.js +22 -34
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +168 -345
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +40 -52
  40. package/examples/js/exporters/PLYExporter.js +50 -57
  41. package/examples/js/exporters/STLExporter.js +5 -14
  42. package/examples/js/exporters/USDZExporter.js +119 -27
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +12 -7
  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 +23 -17
  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 +25 -39
  60. package/examples/js/interactive/InteractiveGroup.js +9 -14
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +2 -8
  63. package/examples/js/libs/ktx-parse.umd.js +1 -0
  64. package/examples/js/libs/meshopt_decoder.js +98 -32
  65. package/examples/js/lights/LightProbeGenerator.js +32 -39
  66. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  67. package/examples/js/lines/LineGeometry.js +3 -5
  68. package/examples/js/lines/LineMaterial.js +4 -11
  69. package/examples/js/lines/LineSegments2.js +40 -89
  70. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  71. package/examples/js/lines/Wireframe.js +2 -7
  72. package/examples/js/lines/WireframeGeometry2.js +3 -1
  73. package/examples/js/loaders/3DMLoader.js +58 -155
  74. package/examples/js/loaders/3MFLoader.js +72 -106
  75. package/examples/js/loaders/AMFLoader.js +0 -25
  76. package/examples/js/loaders/BVHLoader.js +44 -43
  77. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  78. package/examples/js/loaders/ColladaLoader.js +229 -359
  79. package/examples/js/loaders/DDSLoader.js +24 -25
  80. package/examples/js/loaders/DRACOLoader.js +30 -90
  81. package/examples/js/loaders/EXRLoader.js +69 -177
  82. package/examples/js/loaders/FBXLoader.js +294 -441
  83. package/examples/js/loaders/FontLoader.js +9 -31
  84. package/examples/js/loaders/GCodeLoader.js +15 -16
  85. package/examples/js/loaders/GLTFLoader.js +458 -739
  86. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -17
  87. package/examples/js/loaders/KMZLoader.js +3 -7
  88. package/examples/js/loaders/KTXLoader.js +12 -30
  89. package/examples/js/loaders/LDrawLoader.js +309 -355
  90. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  91. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  92. package/examples/js/loaders/LWOLoader.js +59 -124
  93. package/examples/js/loaders/LogLuvLoader.js +27 -77
  94. package/examples/js/loaders/LottieLoader.js +4 -4
  95. package/examples/js/loaders/MD2Loader.js +26 -27
  96. package/examples/js/loaders/MDDLoader.js +6 -10
  97. package/examples/js/loaders/MMDLoader.js +180 -189
  98. package/examples/js/loaders/MTLLoader.js +18 -47
  99. package/examples/js/loaders/NRRDLoader.js +44 -84
  100. package/examples/js/loaders/OBJLoader.js +56 -77
  101. package/examples/js/loaders/PCDLoader.js +92 -42
  102. package/examples/js/loaders/PDBLoader.js +17 -13
  103. package/examples/js/loaders/PLYLoader.js +65 -51
  104. package/examples/js/loaders/PRWMLoader.js +11 -22
  105. package/examples/js/loaders/PVRLoader.js +7 -16
  106. package/examples/js/loaders/RGBELoader.js +36 -61
  107. package/examples/js/loaders/RGBMLoader.js +26 -87
  108. package/examples/js/loaders/STLLoader.js +20 -27
  109. package/examples/js/loaders/SVGLoader.js +365 -236
  110. package/examples/js/loaders/TDSLoader.js +81 -118
  111. package/examples/js/loaders/TGALoader.js +39 -41
  112. package/examples/js/loaders/TIFFLoader.js +30 -0
  113. package/examples/js/loaders/TTFLoader.js +0 -8
  114. package/examples/js/loaders/TiltLoader.js +14 -15
  115. package/examples/js/loaders/VOXLoader.js +8 -16
  116. package/examples/js/loaders/VRMLLoader.js +266 -354
  117. package/examples/js/loaders/VTKLoader.js +102 -119
  118. package/examples/js/loaders/XYZLoader.js +2 -4
  119. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  120. package/examples/js/loaders/lwo/LWO2Parser.js +39 -89
  121. package/examples/js/loaders/lwo/LWO3Parser.js +38 -79
  122. package/examples/js/materials/MeshGouraudMaterial.js +387 -0
  123. package/examples/js/math/Capsule.js +0 -17
  124. package/examples/js/math/ColorConverter.js +3 -53
  125. package/examples/js/math/ConvexHull.js +185 -141
  126. package/examples/js/math/ImprovedNoise.js +1 -1
  127. package/examples/js/math/Lut.js +8 -15
  128. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  129. package/examples/js/math/OBB.js +90 -49
  130. package/examples/js/math/Octree.js +2 -57
  131. package/examples/js/math/SimplexNoise.js +74 -88
  132. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  133. package/examples/js/misc/GPUComputationRenderer.js +47 -14
  134. package/examples/js/misc/Gyroscope.js +5 -9
  135. package/examples/js/misc/MD2Character.js +14 -23
  136. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  137. package/examples/js/misc/MorphAnimMesh.js +0 -6
  138. package/examples/js/misc/MorphBlendMesh.js +3 -30
  139. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  140. package/examples/js/misc/RollerCoaster.js +17 -24
  141. package/examples/js/misc/TubePainter.js +18 -12
  142. package/examples/js/misc/Volume.js +173 -194
  143. package/examples/js/misc/VolumeSlice.js +91 -99
  144. package/examples/js/modifiers/CurveModifier.js +19 -21
  145. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  146. package/examples/js/modifiers/SimplifyModifier.js +57 -60
  147. package/examples/js/modifiers/TessellateModifier.js +2 -9
  148. package/examples/js/objects/GroundProjectedEnv.js +181 -0
  149. package/examples/js/objects/Lensflare.js +47 -38
  150. package/examples/js/objects/LightningStorm.js +10 -13
  151. package/examples/js/objects/MarchingCubes.js +80 -59
  152. package/examples/js/objects/Reflector.js +31 -22
  153. package/examples/js/objects/ReflectorForSSRPass.js +20 -25
  154. package/examples/js/objects/Refractor.js +61 -33
  155. package/examples/js/objects/ShadowMesh.js +6 -3
  156. package/examples/js/objects/Sky.js +2 -7
  157. package/examples/js/objects/Water.js +23 -18
  158. package/examples/js/objects/Water2.js +20 -19
  159. package/examples/js/physics/AmmoPhysics.js +23 -20
  160. package/examples/js/physics/OimoPhysics.js +19 -17
  161. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  162. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  163. package/examples/js/postprocessing/BloomPass.js +38 -17
  164. package/examples/js/postprocessing/BokehPass.js +29 -12
  165. package/examples/js/postprocessing/ClearPass.js +1 -6
  166. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  167. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  168. package/examples/js/postprocessing/EffectComposer.js +25 -32
  169. package/examples/js/postprocessing/FilmPass.js +7 -5
  170. package/examples/js/postprocessing/GlitchPass.js +10 -11
  171. package/examples/js/postprocessing/HalftonePass.js +9 -9
  172. package/examples/js/postprocessing/LUTPass.js +2 -15
  173. package/examples/js/postprocessing/MaskPass.js +20 -17
  174. package/examples/js/postprocessing/OutlinePass.js +49 -38
  175. package/examples/js/postprocessing/Pass.js +11 -14
  176. package/examples/js/postprocessing/RenderPass.js +3 -7
  177. package/examples/js/postprocessing/RenderPixelatedPass.js +215 -0
  178. package/examples/js/postprocessing/SAOPass.js +40 -32
  179. package/examples/js/postprocessing/SMAAPass.js +34 -17
  180. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  181. package/examples/js/postprocessing/SSAOPass.js +56 -42
  182. package/examples/js/postprocessing/SSRPass.js +78 -61
  183. package/examples/js/postprocessing/SavePass.js +14 -6
  184. package/examples/js/postprocessing/ShaderPass.js +9 -8
  185. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  186. package/examples/js/postprocessing/TexturePass.js +7 -4
  187. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  188. package/examples/js/renderers/CSS2DRenderer.js +4 -23
  189. package/examples/js/renderers/CSS3DRenderer.js +5 -26
  190. package/examples/js/renderers/Projector.js +31 -108
  191. package/examples/js/renderers/SVGRenderer.js +4 -50
  192. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  193. package/examples/js/shaders/AfterimageShader.js +3 -6
  194. package/examples/js/shaders/BasicShader.js +3 -6
  195. package/examples/js/shaders/BleachBypassShader.js +3 -6
  196. package/examples/js/shaders/BlendShader.js +3 -6
  197. package/examples/js/shaders/BokehShader.js +3 -6
  198. package/examples/js/shaders/BokehShader2.js +4 -13
  199. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  200. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  201. package/examples/js/shaders/ColorifyShader.js +2 -6
  202. package/examples/js/shaders/ConvolutionShader.js +5 -10
  203. package/examples/js/shaders/CopyShader.js +3 -6
  204. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  205. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  206. package/examples/js/shaders/DigitalGlitch.js +3 -6
  207. package/examples/js/shaders/DotScreenShader.js +2 -6
  208. package/examples/js/shaders/FXAAShader.js +1 -3
  209. package/examples/js/shaders/FilmShader.js +3 -6
  210. package/examples/js/shaders/FocusShader.js +3 -6
  211. package/examples/js/shaders/FreiChenShader.js +2 -6
  212. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  213. package/examples/js/shaders/GodRaysShader.js +11 -24
  214. package/examples/js/shaders/HalftoneShader.js +3 -6
  215. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  216. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  217. package/examples/js/shaders/HueSaturationShader.js +3 -6
  218. package/examples/js/shaders/KaleidoShader.js +3 -6
  219. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  220. package/examples/js/shaders/LuminosityShader.js +4 -7
  221. package/examples/js/shaders/MMDToonShader.js +2 -4
  222. package/examples/js/shaders/MirrorShader.js +3 -6
  223. package/examples/js/shaders/NormalMapShader.js +2 -6
  224. package/examples/js/shaders/RGBShiftShader.js +3 -6
  225. package/examples/js/shaders/SAOShader.js +2 -6
  226. package/examples/js/shaders/SMAAShader.js +6 -18
  227. package/examples/js/shaders/SSAOShader.js +2 -6
  228. package/examples/js/shaders/SSRShader.js +6 -18
  229. package/examples/js/shaders/SepiaShader.js +3 -6
  230. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  231. package/examples/js/shaders/TechnicolorShader.js +3 -6
  232. package/examples/js/shaders/ToneMapShader.js +4 -7
  233. package/examples/js/shaders/ToonShader.js +8 -24
  234. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  235. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  236. package/examples/js/shaders/VelocityShader.js +126 -0
  237. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  238. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  239. package/examples/js/shaders/VignetteShader.js +3 -6
  240. package/examples/js/shaders/VolumeShader.js +2 -6
  241. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  242. package/examples/js/textures/FlakesTexture.js +0 -1
  243. package/examples/js/utils/BufferGeometryUtils.js +237 -171
  244. package/examples/js/utils/CameraUtils.js +5 -20
  245. package/examples/js/utils/GPUStatsPanel.js +3 -12
  246. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  247. package/examples/js/utils/GeometryUtils.js +15 -36
  248. package/examples/js/utils/LDrawUtils.js +8 -11
  249. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  250. package/examples/js/utils/SceneUtils.js +109 -14
  251. package/examples/js/utils/ShadowMapViewer.js +17 -14
  252. package/examples/js/utils/SkeletonUtils.js +13 -27
  253. package/examples/js/utils/UVsDebug.js +20 -12
  254. package/examples/js/utils/WorkerPool.js +1 -11
  255. package/examples/jsm/animation/CCDIKSolver.js +27 -3
  256. package/examples/jsm/animation/MMDPhysics.js +28 -22
  257. package/examples/jsm/capabilities/WebGPU.js +3 -1
  258. package/examples/jsm/controls/ArcballControls.js +17 -2
  259. package/examples/jsm/controls/FirstPersonControls.js +20 -27
  260. package/examples/jsm/controls/FlyControls.js +16 -24
  261. package/examples/jsm/controls/OrbitControls.js +44 -9
  262. package/examples/jsm/controls/PointerLockControls.js +0 -7
  263. package/examples/jsm/controls/TrackballControls.js +14 -5
  264. package/examples/jsm/controls/TransformControls.js +18 -16
  265. package/examples/jsm/csm/CSM.js +1 -0
  266. package/examples/jsm/csm/CSMHelper.js +30 -0
  267. package/examples/jsm/effects/AnaglyphEffect.js +2 -2
  268. package/examples/jsm/effects/OutlineEffect.js +4 -25
  269. package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
  270. package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
  271. package/examples/jsm/effects/StereoEffect.js +2 -2
  272. package/examples/jsm/environments/RoomEnvironment.js +23 -0
  273. package/examples/jsm/exporters/ColladaExporter.js +4 -13
  274. package/examples/jsm/exporters/DRACOExporter.js +0 -13
  275. package/examples/jsm/exporters/GLTFExporter.js +29 -110
  276. package/examples/jsm/exporters/KTX2Exporter.js +29 -29
  277. package/examples/jsm/exporters/OBJExporter.js +0 -18
  278. package/examples/jsm/exporters/PLYExporter.js +14 -22
  279. package/examples/jsm/exporters/STLExporter.js +1 -9
  280. package/examples/jsm/exporters/USDZExporter.js +107 -4
  281. package/examples/jsm/geometries/ConvexGeometry.js +1 -1
  282. package/examples/jsm/geometries/ParametricGeometry.js +0 -6
  283. package/examples/jsm/helpers/OctreeHelper.js +22 -8
  284. package/examples/jsm/helpers/VertexNormalsHelper.js +7 -1
  285. package/examples/jsm/helpers/VertexTangentsHelper.js +7 -0
  286. package/examples/jsm/helpers/ViewHelper.js +24 -0
  287. package/examples/jsm/interactive/HTMLMesh.js +14 -15
  288. package/examples/jsm/interactive/InteractiveGroup.js +4 -2
  289. package/examples/jsm/interactive/SelectionHelper.js +5 -3
  290. package/examples/jsm/libs/flow.module.js +610 -160
  291. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  292. package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
  293. package/examples/jsm/libs/utif.module.js +1579 -0
  294. package/examples/jsm/libs/zstddec.module.js +1 -0
  295. package/examples/jsm/lines/LineSegments2.js +4 -0
  296. package/examples/jsm/loaders/3DMLoader.js +1 -2
  297. package/examples/jsm/loaders/ColladaLoader.js +29 -0
  298. package/examples/jsm/loaders/DRACOLoader.js +2 -28
  299. package/examples/jsm/loaders/EXRLoader.js +3 -13
  300. package/examples/jsm/loaders/FBXLoader.js +26 -3
  301. package/examples/jsm/loaders/FontLoader.js +3 -16
  302. package/examples/jsm/loaders/GLTFLoader.js +321 -464
  303. package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
  304. package/examples/jsm/loaders/KTX2Loader.js +254 -53
  305. package/examples/jsm/loaders/LDrawLoader.js +149 -87
  306. package/examples/jsm/loaders/LottieLoader.js +4 -2
  307. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  308. package/examples/jsm/loaders/OBJLoader.js +6 -14
  309. package/examples/jsm/loaders/PCDLoader.js +60 -14
  310. package/examples/jsm/loaders/PLYLoader.js +71 -19
  311. package/examples/jsm/loaders/RGBELoader.js +1 -1
  312. package/examples/jsm/loaders/SVGLoader.js +231 -17
  313. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  314. package/examples/jsm/loaders/USDZLoader.js +633 -0
  315. package/examples/jsm/loaders/VRMLLoader.js +36 -26
  316. package/examples/jsm/loaders/VTKLoader.js +1 -1
  317. package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
  318. package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
  319. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  320. package/examples/jsm/math/ColorConverter.js +1 -49
  321. package/examples/jsm/math/ConvexHull.js +4 -4
  322. package/examples/jsm/math/Octree.js +1 -1
  323. package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
  324. package/examples/jsm/misc/Volume.js +169 -171
  325. package/examples/jsm/misc/VolumeSlice.js +78 -80
  326. package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
  327. package/examples/jsm/node-editor/NodeEditor.js +91 -12
  328. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
  329. package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
  330. package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
  331. package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
  332. package/examples/jsm/node-editor/core/BaseNode.js +10 -3
  333. package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
  334. package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
  335. package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
  336. package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
  337. package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
  338. package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
  339. package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
  340. package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
  341. package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
  342. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +7 -10
  343. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
  344. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +7 -10
  345. package/examples/jsm/node-editor/math/AngleEditor.js +4 -4
  346. package/examples/jsm/node-editor/math/DotEditor.js +1 -1
  347. package/examples/jsm/node-editor/math/InvertEditor.js +3 -3
  348. package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
  349. package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
  350. package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
  351. package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
  352. package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
  353. package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
  354. package/examples/jsm/node-editor/scene/MeshEditor.js +11 -8
  355. package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
  356. package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
  357. package/examples/jsm/node-editor/utils/PreviewEditor.js +7 -3
  358. package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
  359. package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
  360. package/examples/jsm/nodes/Nodes.js +70 -13
  361. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  362. package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
  363. package/examples/jsm/nodes/accessors/NormalNode.js +8 -8
  364. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  365. package/examples/jsm/nodes/accessors/PositionNode.js +11 -5
  366. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  367. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  368. package/examples/jsm/nodes/accessors/SkinningNode.js +8 -1
  369. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  370. package/examples/jsm/nodes/core/AttributeNode.js +32 -9
  371. package/examples/jsm/nodes/core/CodeNode.js +3 -3
  372. package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
  373. package/examples/jsm/nodes/core/FunctionNode.js +2 -2
  374. package/examples/jsm/nodes/core/Node.js +15 -13
  375. package/examples/jsm/nodes/core/NodeBuilder.js +67 -18
  376. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  377. package/examples/jsm/nodes/core/NodeUtils.js +23 -1
  378. package/examples/jsm/nodes/core/NodeVarying.js +17 -0
  379. package/examples/jsm/nodes/core/VaryingNode.js +56 -0
  380. package/examples/jsm/nodes/core/constants.js +13 -13
  381. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  382. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
  383. package/examples/jsm/nodes/display/NormalMapNode.js +19 -12
  384. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  385. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  386. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +5 -5
  387. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +3 -3
  388. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +2 -2
  389. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  390. package/examples/jsm/nodes/gpgpu/ComputeNode.js +3 -1
  391. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  392. package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
  393. package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
  394. package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
  395. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +33 -0
  396. package/examples/jsm/nodes/materials/Materials.js +21 -31
  397. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  398. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
  399. package/examples/jsm/nodes/materials/NodeMaterial.js +11 -3
  400. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
  401. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
  402. package/examples/jsm/nodes/materialx/MaterialXNodes.js +59 -0
  403. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
  404. package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
  405. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  406. package/examples/jsm/nodes/math/MathNode.js +7 -17
  407. package/examples/jsm/nodes/math/OperatorNode.js +16 -3
  408. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
  409. package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
  410. package/examples/jsm/nodes/shadernode/ShaderNode.js +40 -25
  411. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +95 -68
  412. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +49 -6
  413. package/examples/jsm/nodes/utils/ConvertNode.js +18 -12
  414. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  415. package/examples/jsm/nodes/utils/JoinNode.js +15 -9
  416. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  417. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +3 -2
  418. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  419. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  420. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  421. package/examples/jsm/nodes/utils/SplitNode.js +21 -5
  422. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  423. package/examples/jsm/nodes/utils/TimerNode.js +23 -3
  424. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  425. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  426. package/examples/jsm/objects/Reflector.js +12 -5
  427. package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
  428. package/examples/jsm/objects/Refractor.js +12 -6
  429. package/examples/jsm/objects/ShadowMesh.js +8 -2
  430. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  431. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  432. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  433. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  434. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  435. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  436. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  437. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  438. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  439. package/examples/jsm/postprocessing/OutlinePass.js +25 -3
  440. package/examples/jsm/postprocessing/Pass.js +2 -0
  441. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  442. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  443. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  444. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  445. package/examples/jsm/postprocessing/SavePass.js +17 -1
  446. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  447. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  448. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  449. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  450. package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
  451. package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
  452. package/examples/jsm/renderers/Projector.js +2 -24
  453. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
  454. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +363 -231
  455. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
  456. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  457. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  458. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +68 -3
  459. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
  460. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
  461. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
  462. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
  463. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
  464. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
  465. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +113 -93
  466. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
  467. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
  468. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  469. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +63 -36
  470. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  471. package/examples/jsm/shaders/LuminosityShader.js +1 -1
  472. package/examples/jsm/shaders/MMDToonShader.js +2 -4
  473. package/examples/jsm/shaders/ToneMapShader.js +1 -1
  474. package/examples/jsm/shaders/VelocityShader.js +128 -0
  475. package/examples/jsm/utils/BufferGeometryUtils.js +176 -43
  476. package/examples/jsm/utils/GeometryUtils.js +17 -25
  477. package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
  478. package/examples/jsm/utils/SceneUtils.js +117 -12
  479. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  480. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
  481. package/examples/jsm/webxr/VRButton.js +1 -7
  482. package/examples/jsm/webxr/XRHandMeshModel.js +8 -3
  483. package/package.json +22 -18
  484. package/src/Three.Legacy.js +262 -36
  485. package/src/Three.js +4 -2
  486. package/src/animation/AnimationAction.js +6 -5
  487. package/src/animation/AnimationClip.js +1 -1
  488. package/src/animation/AnimationMixer.js +1 -1
  489. package/src/animation/AnimationUtils.js +204 -199
  490. package/src/animation/KeyframeTrack.js +1 -1
  491. package/src/animation/PropertyBinding.js +31 -5
  492. package/src/audio/AudioContext.js +5 -5
  493. package/src/cameras/CubeCamera.js +14 -21
  494. package/src/constants.js +2 -4
  495. package/src/core/BufferAttribute.js +81 -111
  496. package/src/core/BufferGeometry.js +3 -41
  497. package/src/core/InstancedBufferAttribute.js +0 -10
  498. package/src/core/InstancedBufferGeometry.js +1 -7
  499. package/src/core/InterleavedBuffer.js +1 -1
  500. package/src/core/InterleavedBufferAttribute.js +57 -8
  501. package/src/core/Object3D.js +22 -5
  502. package/src/core/Uniform.js +0 -7
  503. package/src/core/UniformsGroup.js +92 -0
  504. package/src/extras/DataUtils.js +104 -88
  505. package/src/extras/Earcut.js +67 -67
  506. package/src/extras/core/Path.js +1 -0
  507. package/src/extras/core/ShapePath.js +1 -4
  508. package/src/extras/curves/CatmullRomCurve3.js +4 -2
  509. package/src/geometries/BoxGeometry.js +1 -1
  510. package/src/geometries/CapsuleGeometry.js +1 -1
  511. package/src/geometries/CircleGeometry.js +1 -1
  512. package/src/geometries/ConeGeometry.js +1 -1
  513. package/src/geometries/CylinderGeometry.js +2 -1
  514. package/src/geometries/DodecahedronGeometry.js +1 -1
  515. package/src/geometries/EdgesGeometry.js +5 -4
  516. package/src/geometries/ExtrudeGeometry.js +2 -11
  517. package/src/geometries/IcosahedronGeometry.js +1 -1
  518. package/src/geometries/LatheGeometry.js +2 -2
  519. package/src/geometries/OctahedronGeometry.js +1 -1
  520. package/src/geometries/PlaneGeometry.js +2 -1
  521. package/src/geometries/PolyhedronGeometry.js +2 -2
  522. package/src/geometries/RingGeometry.js +1 -1
  523. package/src/geometries/ShapeGeometry.js +3 -2
  524. package/src/geometries/SphereGeometry.js +2 -1
  525. package/src/geometries/TetrahedronGeometry.js +1 -1
  526. package/src/geometries/TorusGeometry.js +2 -1
  527. package/src/geometries/TorusKnotGeometry.js +2 -1
  528. package/src/geometries/TubeGeometry.js +2 -1
  529. package/src/geometries/WireframeGeometry.js +1 -0
  530. package/src/helpers/ArrowHelper.js +9 -0
  531. package/src/helpers/Box3Helper.js +7 -0
  532. package/src/helpers/BoxHelper.js +7 -1
  533. package/src/helpers/CameraHelper.js +97 -38
  534. package/src/helpers/DirectionalLightHelper.js +6 -1
  535. package/src/helpers/GridHelper.js +7 -0
  536. package/src/helpers/HemisphereLightHelper.js +5 -1
  537. package/src/helpers/PlaneHelper.js +15 -9
  538. package/src/helpers/PointLightHelper.js +2 -1
  539. package/src/helpers/PolarGridHelper.js +25 -14
  540. package/src/helpers/SkeletonHelper.js +7 -0
  541. package/src/helpers/SpotLightHelper.js +5 -2
  542. package/src/lights/LightShadow.js +1 -2
  543. package/src/lights/PointLight.js +2 -2
  544. package/src/lights/SpotLight.js +4 -2
  545. package/src/loaders/FileLoader.js +16 -2
  546. package/src/loaders/LoadingManager.js +1 -1
  547. package/src/loaders/MaterialLoader.js +49 -7
  548. package/src/loaders/ObjectLoader.js +9 -42
  549. package/src/materials/Material.js +2 -34
  550. package/src/materials/Materials.js +0 -27
  551. package/src/materials/MeshLambertMaterial.js +28 -1
  552. package/src/materials/MeshPhysicalMaterial.js +1 -1
  553. package/src/materials/ShaderMaterial.js +3 -7
  554. package/src/math/Color.js +8 -18
  555. package/src/math/MathUtils.js +1 -7
  556. package/src/math/Matrix3.js +54 -25
  557. package/src/math/Matrix4.js +3 -27
  558. package/src/math/Quaternion.js +1 -21
  559. package/src/math/Ray.js +2 -5
  560. package/src/math/Sphere.js +36 -21
  561. package/src/math/Vector2.js +4 -24
  562. package/src/math/Vector3.js +7 -46
  563. package/src/math/Vector4.js +4 -24
  564. package/src/objects/InstancedMesh.js +7 -0
  565. package/src/objects/LOD.js +25 -6
  566. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  567. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  568. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  569. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  570. package/src/renderers/WebGLRenderTarget.js +1 -1
  571. package/src/renderers/WebGLRenderer.js +119 -69
  572. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
  573. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
  574. package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
  575. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
  576. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  577. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
  578. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
  579. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
  580. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
  581. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -13
  582. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  583. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
  584. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  585. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
  586. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
  587. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  588. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -4
  589. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
  590. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
  591. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  592. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
  593. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
  594. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
  595. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
  596. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
  597. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +2 -2
  598. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
  599. package/src/renderers/shaders/ShaderChunk.js +7 -2
  600. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  601. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  602. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  603. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
  604. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
  605. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
  606. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +0 -3
  607. package/src/renderers/shaders/ShaderLib.js +50 -36
  608. package/src/renderers/shaders/UniformsLib.js +13 -12
  609. package/src/renderers/shaders/UniformsUtils.js +29 -0
  610. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  611. package/src/renderers/webgl/WebGLBackground.js +17 -9
  612. package/src/renderers/webgl/WebGLLights.js +37 -17
  613. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  614. package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
  615. package/src/renderers/webgl/WebGLProgram.js +6 -11
  616. package/src/renderers/webgl/WebGLPrograms.js +30 -26
  617. package/src/renderers/webgl/WebGLRenderLists.js +5 -4
  618. package/src/renderers/webgl/WebGLRenderStates.js +5 -4
  619. package/src/renderers/webgl/WebGLShaderCache.js +9 -6
  620. package/src/renderers/webgl/WebGLShadowMap.js +13 -16
  621. package/src/renderers/webgl/WebGLState.js +125 -41
  622. package/src/renderers/webgl/WebGLTextures.js +94 -39
  623. package/src/renderers/webgl/WebGLUniforms.js +156 -28
  624. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  625. package/src/renderers/webgl/WebGLUtils.js +3 -1
  626. package/src/renderers/webvr/WebVRManager.js +42 -9
  627. package/src/renderers/webvr/WebVRUtils.js +1 -1
  628. package/src/renderers/webxr/WebXRController.js +91 -50
  629. package/src/renderers/webxr/WebXRManager.js +127 -34
  630. package/src/scenes/Scene.js +24 -3
  631. package/src/textures/CompressedArrayTexture.js +18 -0
  632. package/src/textures/Source.js +1 -1
  633. package/src/textures/Texture.js +2 -1
  634. package/src/utils.js +1 -1
  635. package/examples/js/controls/experimental/CameraControls.js +0 -1048
  636. package/examples/js/libs/lottie_canvas.js +0 -12751
  637. package/examples/js/loaders/KTX2Loader.js +0 -558
  638. package/examples/js/shaders/PixelShader.js +0 -51
  639. package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
  640. package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
  641. package/examples/jsm/nodes/core/NodeVary.js +0 -14
  642. package/examples/jsm/nodes/core/VaryNode.js +0 -54
  643. package/examples/jsm/package.json +0 -3
  644. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
  645. package/examples/jsm/shaders/PixelShader.js +0 -44
  646. package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
@@ -1,5 +1,6 @@
1
1
  ( function () {
2
2
 
3
+ //trackball state
3
4
  const STATE = {
4
5
  IDLE: Symbol(),
5
6
  ROTATE: Symbol(),
@@ -19,18 +20,21 @@
19
20
  TWO_FINGER: Symbol(),
20
21
  MULT_FINGER: Symbol(),
21
22
  CURSOR: Symbol()
22
- }; //cursor center coordinates
23
+ };
23
24
 
25
+ //cursor center coordinates
24
26
  const _center = {
25
27
  x: 0,
26
28
  y: 0
27
- }; //transformation matrices for gizmos and camera
29
+ };
28
30
 
31
+ //transformation matrices for gizmos and camera
29
32
  const _transformation = {
30
33
  camera: new THREE.Matrix4(),
31
34
  gizmos: new THREE.Matrix4()
32
- }; //events
35
+ };
33
36
 
37
+ //events
34
38
  const _changeEvent = {
35
39
  type: 'change'
36
40
  };
@@ -40,15 +44,10 @@
40
44
  const _endEvent = {
41
45
  type: 'end'
42
46
  };
43
-
44
47
  const _raycaster = new THREE.Raycaster();
45
-
46
48
  const _offset = new THREE.Vector3();
47
-
48
49
  const _gizmoMatrixStateTemp = new THREE.Matrix4();
49
-
50
50
  const _cameraMatrixStateTemp = new THREE.Matrix4();
51
-
52
51
  const _scalePointTemp = new THREE.Vector3();
53
52
  /**
54
53
  *
@@ -56,14 +55,11 @@
56
55
  * @param {HTMLElement} domElement Renderer's dom element
57
56
  * @param {Scene} scene The scene to be rendered
58
57
  */
59
-
60
-
61
58
  class ArcballControls extends THREE.EventDispatcher {
62
59
 
63
60
  constructor( _camera, domElement, scene = null ) {
64
61
 
65
62
  super();
66
-
67
63
  this.onWindowResize = () => {
68
64
 
69
65
  const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
@@ -72,7 +68,6 @@
72
68
  const curve = new THREE.EllipseCurve( 0, 0, newRadius, newRadius );
73
69
  const points = curve.getPoints( this._curvePts );
74
70
  const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
75
-
76
71
  for ( const gizmo in this._gizmos.children ) {
77
72
 
78
73
  this._gizmos.children[ gizmo ].geometry = curveGeometry;
@@ -108,9 +103,7 @@
108
103
  this.onPointerCancel = () => {
109
104
 
110
105
  this._touchStart.splice( 0, this._touchStart.length );
111
-
112
106
  this._touchCurrent.splice( 0, this._touchCurrent.length );
113
-
114
107
  this._input = INPUT.NONE;
115
108
 
116
109
  };
@@ -120,9 +113,7 @@
120
113
  if ( event.button == 0 && event.isPrimary ) {
121
114
 
122
115
  this._downValid = true;
123
-
124
116
  this._downEvents.push( event );
125
-
126
117
  this._downStart = performance.now();
127
118
 
128
119
  } else {
@@ -134,9 +125,7 @@
134
125
  if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
135
126
 
136
127
  this._touchStart.push( event );
137
-
138
128
  this._touchCurrent.push( event );
139
-
140
129
  switch ( this._input ) {
141
130
 
142
131
  case INPUT.NONE:
@@ -146,7 +135,6 @@
146
135
  window.addEventListener( 'pointermove', this.onPointerMove );
147
136
  window.addEventListener( 'pointerup', this.onPointerUp );
148
137
  break;
149
-
150
138
  case INPUT.ONE_FINGER:
151
139
  case INPUT.ONE_FINGER_SWITCHED:
152
140
  //doubleStart
@@ -155,7 +143,6 @@
155
143
  this.onPinchStart();
156
144
  this.onDoublePanStart();
157
145
  break;
158
-
159
146
  case INPUT.TWO_FINGER:
160
147
  //multipleStart
161
148
  this._input = INPUT.MULT_FINGER;
@@ -167,7 +154,6 @@
167
154
  } else if ( event.pointerType != 'touch' && this._input == INPUT.NONE ) {
168
155
 
169
156
  let modifier = null;
170
-
171
157
  if ( event.ctrlKey || event.metaKey ) {
172
158
 
173
159
  modifier = 'CTRL';
@@ -179,12 +165,12 @@
179
165
  }
180
166
 
181
167
  this._mouseOp = this.getOpFromAction( event.button, modifier );
182
-
183
168
  if ( this._mouseOp != null ) {
184
169
 
185
170
  window.addEventListener( 'pointermove', this.onPointerMove );
186
- window.addEventListener( 'pointerup', this.onPointerUp ); //singleStart
171
+ window.addEventListener( 'pointerup', this.onPointerUp );
187
172
 
173
+ //singleStart
188
174
  this._input = INPUT.CURSOR;
189
175
  this._button = event.button;
190
176
  this.onSinglePanStart( event, this._mouseOp );
@@ -206,10 +192,8 @@
206
192
  this.updateTouchEvent( event );
207
193
  this.onSinglePanMove( event, STATE.ROTATE );
208
194
  break;
209
-
210
195
  case INPUT.ONE_FINGER_SWITCHED:
211
196
  const movement = this.calculatePointersDistance( this._touchCurrent[ 0 ], event ) * this._devPxRatio;
212
-
213
197
  if ( movement >= this._switchSensibility ) {
214
198
 
215
199
  //singleMove
@@ -221,7 +205,6 @@
221
205
  }
222
206
 
223
207
  break;
224
-
225
208
  case INPUT.TWO_FINGER:
226
209
  //rotate/pan/pinchMove
227
210
  this.updateTouchEvent( event );
@@ -229,7 +212,6 @@
229
212
  this.onPinchMove();
230
213
  this.onDoublePanMove();
231
214
  break;
232
-
233
215
  case INPUT.MULT_FINGER:
234
216
  //multMove
235
217
  this.updateTouchEvent( event );
@@ -241,7 +223,6 @@
241
223
  } else if ( event.pointerType != 'touch' && this._input == INPUT.CURSOR ) {
242
224
 
243
225
  let modifier = null;
244
-
245
226
  if ( event.ctrlKey || event.metaKey ) {
246
227
 
247
228
  modifier = 'CTRL';
@@ -253,20 +234,18 @@
253
234
  }
254
235
 
255
236
  const mouseOpState = this.getOpStateFromAction( this._button, modifier );
256
-
257
237
  if ( mouseOpState != null ) {
258
238
 
259
239
  this.onSinglePanMove( event, mouseOpState );
260
240
 
261
241
  }
262
242
 
263
- } //checkDistance
264
-
243
+ }
265
244
 
245
+ //checkDistance
266
246
  if ( this._downValid ) {
267
247
 
268
248
  const movement = this.calculatePointersDistance( this._downEvents[ this._downEvents.length - 1 ], event ) * this._devPxRatio;
269
-
270
249
  if ( movement > this._movementThreshold ) {
271
250
 
272
251
  this._downValid = false;
@@ -282,15 +261,12 @@
282
261
  if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
283
262
 
284
263
  const nTouch = this._touchCurrent.length;
285
-
286
264
  for ( let i = 0; i < nTouch; i ++ ) {
287
265
 
288
266
  if ( this._touchCurrent[ i ].pointerId == event.pointerId ) {
289
267
 
290
268
  this._touchCurrent.splice( i, 1 );
291
-
292
269
  this._touchStart.splice( i, 1 );
293
-
294
270
  break;
295
271
 
296
272
  }
@@ -307,22 +283,22 @@
307
283
  this._input = INPUT.NONE;
308
284
  this.onSinglePanEnd();
309
285
  break;
310
-
311
286
  case INPUT.TWO_FINGER:
312
287
  //doubleEnd
313
288
  this.onDoublePanEnd( event );
314
289
  this.onPinchEnd( event );
315
- this.onRotateEnd( event ); //switching to singleStart
290
+ this.onRotateEnd( event );
316
291
 
292
+ //switching to singleStart
317
293
  this._input = INPUT.ONE_FINGER_SWITCHED;
318
294
  break;
319
-
320
295
  case INPUT.MULT_FINGER:
321
296
  if ( this._touchCurrent.length == 0 ) {
322
297
 
323
298
  window.removeEventListener( 'pointermove', this.onPointerMove );
324
- window.removeEventListener( 'pointerup', this.onPointerUp ); //multCancel
299
+ window.removeEventListener( 'pointerup', this.onPointerUp );
325
300
 
301
+ //multCancel
326
302
  this._input = INPUT.NONE;
327
303
  this.onTriplePanEnd();
328
304
 
@@ -347,7 +323,6 @@
347
323
  if ( this._downValid ) {
348
324
 
349
325
  const downTime = event.timeStamp - this._downEvents[ this._downEvents.length - 1 ].timeStamp;
350
-
351
326
  if ( downTime <= this._maxDownTime ) {
352
327
 
353
328
  if ( this._nclicks == 0 ) {
@@ -359,26 +334,20 @@
359
334
  } else {
360
335
 
361
336
  const clickInterval = event.timeStamp - this._clickStart;
362
-
363
337
  const movement = this.calculatePointersDistance( this._downEvents[ 1 ], this._downEvents[ 0 ] ) * this._devPxRatio;
364
-
365
338
  if ( clickInterval <= this._maxInterval && movement <= this._posThreshold ) {
366
339
 
367
340
  //second valid click detected
368
341
  //fire double tap and reset values
369
342
  this._nclicks = 0;
370
-
371
343
  this._downEvents.splice( 0, this._downEvents.length );
372
-
373
344
  this.onDoubleTap( event );
374
345
 
375
346
  } else {
376
347
 
377
348
  //new 'first click'
378
349
  this._nclicks = 1;
379
-
380
350
  this._downEvents.shift();
381
-
382
351
  this._clickStart = performance.now();
383
352
 
384
353
  }
@@ -389,7 +358,6 @@
389
358
 
390
359
  this._downValid = false;
391
360
  this._nclicks = 0;
392
-
393
361
  this._downEvents.splice( 0, this._downEvents.length );
394
362
 
395
363
  }
@@ -397,7 +365,6 @@
397
365
  } else {
398
366
 
399
367
  this._nclicks = 0;
400
-
401
368
  this._downEvents.splice( 0, this._downEvents.length );
402
369
 
403
370
  }
@@ -411,7 +378,6 @@
411
378
  if ( this.enabled && this.enableZoom ) {
412
379
 
413
380
  let modifier = null;
414
-
415
381
  if ( event.ctrlKey || event.metaKey ) {
416
382
 
417
383
  modifier = 'CTRL';
@@ -423,16 +389,13 @@
423
389
  }
424
390
 
425
391
  const mouseOp = this.getOpFromAction( 'WHEEL', modifier );
426
-
427
392
  if ( mouseOp != null ) {
428
393
 
429
394
  event.preventDefault();
430
395
  this.dispatchEvent( _startEvent );
431
396
  const notchDeltaY = 125; //distance of one notch of mouse wheel
432
-
433
397
  let sgn = event.deltaY / notchDeltaY;
434
398
  let size = 1;
435
-
436
399
  if ( sgn > 0 ) {
437
400
 
438
401
  size = 1 / this.scaleFactor;
@@ -447,7 +410,6 @@
447
410
 
448
411
  case 'ZOOM':
449
412
  this.updateTbState( STATE.SCALE, true );
450
-
451
413
  if ( sgn > 0 ) {
452
414
 
453
415
  size = 1 / Math.pow( this.scaleFactor, sgn );
@@ -461,7 +423,6 @@
461
423
  if ( this.cursorZoom && this.enablePan ) {
462
424
 
463
425
  let scalePoint;
464
-
465
426
  if ( this.camera.isOrthographicCamera ) {
466
427
 
467
428
  scalePoint = this.unprojectOnTbPlane( this.camera, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._gizmos.position );
@@ -491,11 +452,13 @@
491
452
  this.dispatchEvent( _changeEvent );
492
453
  this.dispatchEvent( _endEvent );
493
454
  break;
494
-
495
455
  case 'FOV':
496
456
  if ( this.camera.isPerspectiveCamera ) {
497
457
 
498
- this.updateTbState( STATE.FOV, true ); //Vertigo effect
458
+ this.updateTbState( STATE.FOV, true );
459
+
460
+ //Vertigo effect
461
+
499
462
  // fov / 2
500
463
  // |\
501
464
  // | \
@@ -505,13 +468,12 @@
505
468
  // | \
506
469
  // | _ _ _\
507
470
  // y
508
- //check for iOs shift shortcut
509
471
 
472
+ //check for iOs shift shortcut
510
473
  if ( event.deltaX != 0 ) {
511
474
 
512
475
  sgn = event.deltaX / notchDeltaY;
513
476
  size = 1;
514
-
515
477
  if ( sgn > 0 ) {
516
478
 
517
479
  size = 1 / Math.pow( this.scaleFactor, sgn );
@@ -525,17 +487,17 @@
525
487
  }
526
488
 
527
489
  this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
528
-
529
490
  const x = this._v3_1.distanceTo( this._gizmos.position );
530
-
531
491
  let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
532
- //check min and max distance
533
492
 
493
+ //check min and max distance
534
494
  xNew = THREE.MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
535
- const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this.camera.fov * 0.5 ); //calculate new fov
495
+ const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this.camera.fov * 0.5 );
536
496
 
537
- let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 ); //check min and max fov
497
+ //calculate new fov
498
+ let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
538
499
 
500
+ //check min and max fov
539
501
  if ( newFov > this.maxFov ) {
540
502
 
541
503
  newFov = this.maxFov;
@@ -579,7 +541,6 @@
579
541
 
580
542
  this.dispatchEvent( _startEvent );
581
543
  this.setCenter( event.clientX, event.clientY );
582
-
583
544
  switch ( operation ) {
584
545
 
585
546
  case 'PAN':
@@ -600,9 +561,7 @@
600
561
  }
601
562
 
602
563
  this.updateTbState( STATE.PAN, true );
603
-
604
564
  this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
605
-
606
565
  if ( this.enableGrid ) {
607
566
 
608
567
  this.drawGrid();
@@ -611,7 +570,6 @@
611
570
  }
612
571
 
613
572
  break;
614
-
615
573
  case 'ROTATE':
616
574
  if ( ! this.enableRotate ) {
617
575
 
@@ -628,20 +586,14 @@
628
586
  }
629
587
 
630
588
  this.updateTbState( STATE.ROTATE, true );
631
-
632
589
  this._startCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
633
-
634
590
  this.activateGizmos( true );
635
-
636
591
  if ( this.enableAnimations ) {
637
592
 
638
593
  this._timePrev = this._timeCurrent = performance.now();
639
594
  this._angleCurrent = this._anglePrev = 0;
640
-
641
595
  this._cursorPosPrev.copy( this._startCursorPosition );
642
-
643
596
  this._cursorPosCurr.copy( this._cursorPosPrev );
644
-
645
597
  this._wCurr = 0;
646
598
  this._wPrev = this._wCurr;
647
599
 
@@ -649,7 +601,6 @@
649
601
 
650
602
  this.dispatchEvent( _changeEvent );
651
603
  break;
652
-
653
604
  case 'FOV':
654
605
  if ( ! this.camera.isPerspectiveCamera || ! this.enableZoom ) {
655
606
 
@@ -668,13 +619,9 @@
668
619
  }
669
620
 
670
621
  this.updateTbState( STATE.FOV, true );
671
-
672
622
  this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
673
-
674
623
  this._currentCursorPosition.copy( this._startCursorPosition );
675
-
676
624
  break;
677
-
678
625
  case 'ZOOM':
679
626
  if ( ! this.enableZoom ) {
680
627
 
@@ -693,11 +640,8 @@
693
640
  }
694
641
 
695
642
  this.updateTbState( STATE.SCALE, true );
696
-
697
643
  this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
698
-
699
644
  this._currentCursorPosition.copy( this._startCursorPosition );
700
-
701
645
  break;
702
646
 
703
647
  }
@@ -712,7 +656,6 @@
712
656
 
713
657
  const restart = opState != this._state;
714
658
  this.setCenter( event.clientX, event.clientY );
715
-
716
659
  switch ( opState ) {
717
660
 
718
661
  case STATE.PAN:
@@ -721,12 +664,11 @@
721
664
  if ( restart ) {
722
665
 
723
666
  //switch to pan operation
667
+
724
668
  this.dispatchEvent( _endEvent );
725
669
  this.dispatchEvent( _startEvent );
726
670
  this.updateTbState( opState, true );
727
-
728
671
  this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
729
-
730
672
  if ( this.enableGrid ) {
731
673
 
732
674
  this.drawGrid();
@@ -739,7 +681,6 @@
739
681
 
740
682
  //continue with pan operation
741
683
  this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
742
-
743
684
  this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition ) );
744
685
 
745
686
  }
@@ -747,19 +688,17 @@
747
688
  }
748
689
 
749
690
  break;
750
-
751
691
  case STATE.ROTATE:
752
692
  if ( this.enableRotate ) {
753
693
 
754
694
  if ( restart ) {
755
695
 
756
696
  //switch to rotate operation
697
+
757
698
  this.dispatchEvent( _endEvent );
758
699
  this.dispatchEvent( _startEvent );
759
700
  this.updateTbState( opState, true );
760
-
761
701
  this._startCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
762
-
763
702
  if ( this.enableGrid ) {
764
703
 
765
704
  this.disposeGrid();
@@ -772,26 +711,19 @@
772
711
 
773
712
  //continue with rotate operation
774
713
  this._currentCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
775
-
776
714
  const distance = this._startCursorPosition.distanceTo( this._currentCursorPosition );
777
-
778
715
  const angle = this._startCursorPosition.angleTo( this._currentCursorPosition );
779
-
780
716
  const amount = Math.max( distance / this._tbRadius, angle ); //effective rotation angle
781
717
 
782
718
  this.applyTransformMatrix( this.rotate( this.calculateRotationAxis( this._startCursorPosition, this._currentCursorPosition ), amount ) );
783
-
784
719
  if ( this.enableAnimations ) {
785
720
 
786
721
  this._timePrev = this._timeCurrent;
787
722
  this._timeCurrent = performance.now();
788
723
  this._anglePrev = this._angleCurrent;
789
724
  this._angleCurrent = amount;
790
-
791
725
  this._cursorPosPrev.copy( this._cursorPosCurr );
792
-
793
726
  this._cursorPosCurr.copy( this._currentCursorPosition );
794
-
795
727
  this._wPrev = this._wCurr;
796
728
  this._wCurr = this.calculateAngularSpeed( this._anglePrev, this._angleCurrent, this._timePrev, this._timeCurrent );
797
729
 
@@ -802,21 +734,18 @@
802
734
  }
803
735
 
804
736
  break;
805
-
806
737
  case STATE.SCALE:
807
738
  if ( this.enableZoom ) {
808
739
 
809
740
  if ( restart ) {
810
741
 
811
742
  //switch to zoom operation
743
+
812
744
  this.dispatchEvent( _endEvent );
813
745
  this.dispatchEvent( _startEvent );
814
746
  this.updateTbState( opState, true );
815
-
816
747
  this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
817
-
818
748
  this._currentCursorPosition.copy( this._startCursorPosition );
819
-
820
749
  if ( this.enableGrid ) {
821
750
 
822
751
  this.disposeGrid();
@@ -829,12 +758,9 @@
829
758
 
830
759
  //continue with zoom operation
831
760
  const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
832
-
833
761
  this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
834
-
835
762
  const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
836
763
  let size = 1;
837
-
838
764
  if ( movement < 0 ) {
839
765
 
840
766
  size = 1 / Math.pow( this.scaleFactor, - movement * screenNotches );
@@ -846,7 +772,6 @@
846
772
  }
847
773
 
848
774
  this._v3_1.setFromMatrixPosition( this._gizmoMatrixState );
849
-
850
775
  this.applyTransformMatrix( this.scale( size, this._v3_1 ) );
851
776
 
852
777
  }
@@ -854,21 +779,18 @@
854
779
  }
855
780
 
856
781
  break;
857
-
858
782
  case STATE.FOV:
859
783
  if ( this.enableZoom && this.camera.isPerspectiveCamera ) {
860
784
 
861
785
  if ( restart ) {
862
786
 
863
787
  //switch to fov operation
788
+
864
789
  this.dispatchEvent( _endEvent );
865
790
  this.dispatchEvent( _startEvent );
866
791
  this.updateTbState( opState, true );
867
-
868
792
  this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
869
-
870
793
  this._currentCursorPosition.copy( this._startCursorPosition );
871
-
872
794
  if ( this.enableGrid ) {
873
795
 
874
796
  this.disposeGrid();
@@ -881,12 +803,9 @@
881
803
 
882
804
  //continue with fov operation
883
805
  const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
884
-
885
806
  this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
886
-
887
807
  const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
888
808
  let size = 1;
889
-
890
809
  if ( movement < 0 ) {
891
810
 
892
811
  size = 1 / Math.pow( this.scaleFactor, - movement * screenNotches );
@@ -898,28 +817,26 @@
898
817
  }
899
818
 
900
819
  this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
901
-
902
820
  const x = this._v3_1.distanceTo( this._gizmos.position );
903
-
904
821
  let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
905
- //check min and max distance
906
822
 
823
+ //check min and max distance
907
824
  xNew = THREE.MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
908
- const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this._fovState * 0.5 ); //calculate new fov
825
+ const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this._fovState * 0.5 );
909
826
 
910
- let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 ); //check min and max fov
827
+ //calculate new fov
828
+ let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
911
829
 
830
+ //check min and max fov
912
831
  newFov = THREE.MathUtils.clamp( newFov, this.minFov, this.maxFov );
913
832
  const newDistance = y / Math.tan( THREE.MathUtils.DEG2RAD * ( newFov / 2 ) );
914
833
  size = x / newDistance;
915
-
916
834
  this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
917
-
918
835
  this.setFov( newFov );
919
- this.applyTransformMatrix( this.scale( size, this._v3_2, false ) ); //adjusting distance
836
+ this.applyTransformMatrix( this.scale( size, this._v3_2, false ) );
920
837
 
838
+ //adjusting distance
921
839
  _offset.copy( this._gizmos.position ).sub( this.camera.position ).normalize().multiplyScalar( newDistance / x );
922
-
923
840
  this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
924
841
 
925
842
  }
@@ -950,7 +867,6 @@
950
867
 
951
868
  //perform rotation animation
952
869
  const deltaTime = performance.now() - this._timeCurrent;
953
-
954
870
  if ( deltaTime < 120 ) {
955
871
 
956
872
  const w = Math.abs( ( this._wPrev + this._wCurr ) / 2 );
@@ -983,7 +899,6 @@
983
899
  } else if ( this._state == STATE.PAN || this._state == STATE.IDLE ) {
984
900
 
985
901
  this.updateTbState( STATE.IDLE, false );
986
-
987
902
  if ( this.enableGrid ) {
988
903
 
989
904
  this.disposeGrid();
@@ -1006,11 +921,9 @@
1006
921
  this.dispatchEvent( _startEvent );
1007
922
  this.setCenter( event.clientX, event.clientY );
1008
923
  const hitP = this.unprojectOnObj( this.getCursorNDC( _center.x, _center.y, this.domElement ), this.camera );
1009
-
1010
924
  if ( hitP != null && this.enableAnimations ) {
1011
925
 
1012
926
  const self = this;
1013
-
1014
927
  if ( this._animationId != - 1 ) {
1015
928
 
1016
929
  window.cancelAnimationFrame( this._animationId );
@@ -1047,11 +960,8 @@
1047
960
  this.dispatchEvent( _startEvent );
1048
961
  this.updateTbState( STATE.PAN, true );
1049
962
  this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1050
-
1051
963
  this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement, true ) );
1052
-
1053
964
  this._currentCursorPosition.copy( this._startCursorPosition );
1054
-
1055
965
  this.activateGizmos( false );
1056
966
 
1057
967
  }
@@ -1063,17 +973,14 @@
1063
973
  if ( this.enabled && this.enablePan ) {
1064
974
 
1065
975
  this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1066
-
1067
976
  if ( this._state != STATE.PAN ) {
1068
977
 
1069
978
  this.updateTbState( STATE.PAN, true );
1070
-
1071
979
  this._startCursorPosition.copy( this._currentCursorPosition );
1072
980
 
1073
981
  }
1074
982
 
1075
983
  this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement, true ) );
1076
-
1077
984
  this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition, true ) );
1078
985
  this.dispatchEvent( _changeEvent );
1079
986
 
@@ -1093,7 +1000,9 @@
1093
1000
  if ( this.enabled && this.enableRotate ) {
1094
1001
 
1095
1002
  this.dispatchEvent( _startEvent );
1096
- this.updateTbState( STATE.ZROTATE, true ); //this._startFingerRotation = event.rotation;
1003
+ this.updateTbState( STATE.ZROTATE, true );
1004
+
1005
+ //this._startFingerRotation = event.rotation;
1097
1006
 
1098
1007
  this._startFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
1099
1008
  this._currentFingerRotation = this._startFingerRotation;
@@ -1115,17 +1024,15 @@
1115
1024
 
1116
1025
  this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1117
1026
  let rotationPoint;
1118
-
1119
1027
  if ( this._state != STATE.ZROTATE ) {
1120
1028
 
1121
1029
  this.updateTbState( STATE.ZROTATE, true );
1122
1030
  this._startFingerRotation = this._currentFingerRotation;
1123
1031
 
1124
- } //this._currentFingerRotation = event.rotation;
1125
-
1032
+ }
1126
1033
 
1034
+ //this._currentFingerRotation = event.rotation;
1127
1035
  this._currentFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
1128
-
1129
1036
  if ( ! this.enablePan ) {
1130
1037
 
1131
1038
  rotationPoint = new THREE.Vector3().setFromMatrixPosition( this._gizmoMatrixState );
@@ -1133,7 +1040,6 @@
1133
1040
  } else {
1134
1041
 
1135
1042
  this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
1136
-
1137
1043
  rotationPoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._v3_2 );
1138
1044
 
1139
1045
  }
@@ -1185,7 +1091,6 @@
1185
1091
  this._currentFingerDistance = Math.max( this.calculatePointersDistance( this._touchCurrent[ 0 ], this._touchCurrent[ 1 ] ), minDistance * this._devPxRatio );
1186
1092
  const amount = this._currentFingerDistance / this._startFingerDistance;
1187
1093
  let scalePoint;
1188
-
1189
1094
  if ( ! this.enablePan ) {
1190
1095
 
1191
1096
  scalePoint = this._gizmos.position;
@@ -1223,12 +1128,12 @@
1223
1128
  if ( this.enabled && this.enableZoom ) {
1224
1129
 
1225
1130
  this.dispatchEvent( _startEvent );
1226
- this.updateTbState( STATE.SCALE, true ); //const center = event.center;
1131
+ this.updateTbState( STATE.SCALE, true );
1227
1132
 
1133
+ //const center = event.center;
1228
1134
  let clientX = 0;
1229
1135
  let clientY = 0;
1230
1136
  const nFingers = this._touchCurrent.length;
1231
-
1232
1137
  for ( let i = 0; i < nFingers; i ++ ) {
1233
1138
 
1234
1139
  clientX += this._touchCurrent[ i ].clientX;
@@ -1237,9 +1142,7 @@
1237
1142
  }
1238
1143
 
1239
1144
  this.setCenter( clientX / nFingers, clientY / nFingers );
1240
-
1241
1145
  this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
1242
-
1243
1146
  this._currentCursorPosition.copy( this._startCursorPosition );
1244
1147
 
1245
1148
  }
@@ -1259,11 +1162,11 @@
1259
1162
  // | \
1260
1163
  // | _ _ _\
1261
1164
  // y
1165
+
1262
1166
  //const center = event.center;
1263
1167
  let clientX = 0;
1264
1168
  let clientY = 0;
1265
1169
  const nFingers = this._touchCurrent.length;
1266
-
1267
1170
  for ( let i = 0; i < nFingers; i ++ ) {
1268
1171
 
1269
1172
  clientX += this._touchCurrent[ i ].clientX;
@@ -1273,12 +1176,9 @@
1273
1176
 
1274
1177
  this.setCenter( clientX / nFingers, clientY / nFingers );
1275
1178
  const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
1276
-
1277
1179
  this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
1278
-
1279
1180
  const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
1280
1181
  let size = 1;
1281
-
1282
1182
  if ( movement < 0 ) {
1283
1183
 
1284
1184
  size = 1 / Math.pow( this.scaleFactor, - movement * screenNotches );
@@ -1290,30 +1190,27 @@
1290
1190
  }
1291
1191
 
1292
1192
  this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
1293
-
1294
1193
  const x = this._v3_1.distanceTo( this._gizmos.position );
1295
-
1296
1194
  let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
1297
- //check min and max distance
1298
1195
 
1196
+ //check min and max distance
1299
1197
  xNew = THREE.MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
1300
- const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this._fovState * 0.5 ); //calculate new fov
1198
+ const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this._fovState * 0.5 );
1301
1199
 
1302
- let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 ); //check min and max fov
1200
+ //calculate new fov
1201
+ let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
1303
1202
 
1203
+ //check min and max fov
1304
1204
  newFov = THREE.MathUtils.clamp( newFov, this.minFov, this.maxFov );
1305
1205
  const newDistance = y / Math.tan( THREE.MathUtils.DEG2RAD * ( newFov / 2 ) );
1306
1206
  size = x / newDistance;
1307
-
1308
1207
  this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
1309
-
1310
1208
  this.setFov( newFov );
1311
- this.applyTransformMatrix( this.scale( size, this._v3_2, false ) ); //adjusting distance
1209
+ this.applyTransformMatrix( this.scale( size, this._v3_2, false ) );
1312
1210
 
1211
+ //adjusting distance
1313
1212
  _offset.copy( this._gizmos.position ).sub( this.camera.position ).normalize().multiplyScalar( newDistance / x );
1314
-
1315
1213
  this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
1316
-
1317
1214
  this.dispatchEvent( _changeEvent );
1318
1215
 
1319
1216
  }
@@ -1323,7 +1220,8 @@
1323
1220
  this.onTriplePanEnd = () => {
1324
1221
 
1325
1222
  this.updateTbState( STATE.IDLE, false );
1326
- this.dispatchEvent( _endEvent ); //this.dispatchEvent( _changeEvent );
1223
+ this.dispatchEvent( _endEvent );
1224
+ //this.dispatchEvent( _changeEvent );
1327
1225
 
1328
1226
  };
1329
1227
 
@@ -1374,7 +1272,6 @@
1374
1272
  const mouseInput = [ 0, 1, 2, 'WHEEL' ];
1375
1273
  const keyInput = [ 'CTRL', 'SHIFT', null ];
1376
1274
  let state;
1377
-
1378
1275
  if ( ! operationInput.includes( operation ) || ! mouseInput.includes( mouse ) || ! keyInput.includes( key ) ) {
1379
1276
 
1380
1277
  //invalid parameters
@@ -1398,15 +1295,12 @@
1398
1295
  case 'PAN':
1399
1296
  state = STATE.PAN;
1400
1297
  break;
1401
-
1402
1298
  case 'ROTATE':
1403
1299
  state = STATE.ROTATE;
1404
1300
  break;
1405
-
1406
1301
  case 'ZOOM':
1407
1302
  state = STATE.SCALE;
1408
1303
  break;
1409
-
1410
1304
  case 'FOV':
1411
1305
  state = STATE.FOV;
1412
1306
  break;
@@ -1419,7 +1313,6 @@
1419
1313
  key: key,
1420
1314
  state: state
1421
1315
  };
1422
-
1423
1316
  for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1424
1317
 
1425
1318
  if ( this.mouseActions[ i ].mouse == action.mouse && this.mouseActions[ i ].key == action.key ) {
@@ -1456,11 +1349,9 @@
1456
1349
  this.getOpFromAction = ( mouse, key ) => {
1457
1350
 
1458
1351
  let action;
1459
-
1460
1352
  for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1461
1353
 
1462
1354
  action = this.mouseActions[ i ];
1463
-
1464
1355
  if ( action.mouse == mouse && action.key == key ) {
1465
1356
 
1466
1357
  return action.operation;
@@ -1474,7 +1365,6 @@
1474
1365
  for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1475
1366
 
1476
1367
  action = this.mouseActions[ i ];
1477
-
1478
1368
  if ( action.mouse == mouse && action.key == null ) {
1479
1369
 
1480
1370
  return action.operation;
@@ -1492,11 +1382,9 @@
1492
1382
  this.getOpStateFromAction = ( mouse, key ) => {
1493
1383
 
1494
1384
  let action;
1495
-
1496
1385
  for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1497
1386
 
1498
1387
  action = this.mouseActions[ i ];
1499
-
1500
1388
  if ( action.mouse == mouse && action.key == key ) {
1501
1389
 
1502
1390
  return action.state;
@@ -1510,7 +1398,6 @@
1510
1398
  for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1511
1399
 
1512
1400
  action = this.mouseActions[ i ];
1513
-
1514
1401
  if ( action.mouse == mouse && action.key == null ) {
1515
1402
 
1516
1403
  return action.state;
@@ -1538,7 +1425,6 @@
1538
1425
  if ( this._touchCurrent[ i ].pointerId == event.pointerId ) {
1539
1426
 
1540
1427
  this._touchCurrent.splice( i, 1, event );
1541
-
1542
1428
  break;
1543
1429
 
1544
1430
  }
@@ -1551,7 +1437,6 @@
1551
1437
 
1552
1438
  const s = p1 - p0;
1553
1439
  const t = ( t1 - t0 ) / 1000;
1554
-
1555
1440
  if ( t == 0 ) {
1556
1441
 
1557
1442
  return 0;
@@ -1571,11 +1456,8 @@
1571
1456
  this.calculateRotationAxis = ( vec1, vec2 ) => {
1572
1457
 
1573
1458
  this._rotationMatrix.extractRotation( this._cameraMatrixState );
1574
-
1575
1459
  this._quat.setFromRotationMatrix( this._rotationMatrix );
1576
-
1577
1460
  this._rotationAxis.crossVectors( vec1, vec2 ).applyQuaternion( this._quat );
1578
-
1579
1461
  return this._rotationAxis.normalize().clone();
1580
1462
 
1581
1463
  };
@@ -1583,13 +1465,10 @@
1583
1465
  this.calculateTbRadius = camera => {
1584
1466
 
1585
1467
  const distance = camera.position.distanceTo( this._gizmos.position );
1586
-
1587
1468
  if ( camera.type == 'PerspectiveCamera' ) {
1588
1469
 
1589
1470
  const halfFovV = THREE.MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
1590
-
1591
1471
  const halfFovH = Math.atan( camera.aspect * Math.tan( halfFovV ) ); //horizontal fov/2 in radians
1592
-
1593
1472
  return Math.tan( Math.min( halfFovV, halfFovH ) ) * distance * this.radiusFactor;
1594
1473
 
1595
1474
  } else if ( camera.type == 'OrthographicCamera' ) {
@@ -1604,22 +1483,15 @@
1604
1483
 
1605
1484
  //move center of camera (along with gizmos) towards point of interest
1606
1485
  _offset.copy( point ).sub( this._gizmos.position ).multiplyScalar( amount );
1607
-
1608
1486
  this._translationMatrix.makeTranslation( _offset.x, _offset.y, _offset.z );
1609
-
1610
1487
  _gizmoMatrixStateTemp.copy( this._gizmoMatrixState );
1611
-
1612
1488
  this._gizmoMatrixState.premultiply( this._translationMatrix );
1613
-
1614
1489
  this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1615
-
1616
1490
  _cameraMatrixStateTemp.copy( this._cameraMatrixState );
1617
-
1618
1491
  this._cameraMatrixState.premultiply( this._translationMatrix );
1492
+ this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
1619
1493
 
1620
- this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale ); //apply zoom
1621
-
1622
-
1494
+ //apply zoom
1623
1495
  if ( this.enableZoom ) {
1624
1496
 
1625
1497
  this.applyTransformMatrix( this.scale( size, this._gizmos.position ) );
@@ -1627,7 +1499,6 @@
1627
1499
  }
1628
1500
 
1629
1501
  this._gizmoMatrixState.copy( _gizmoMatrixStateTemp );
1630
-
1631
1502
  this._cameraMatrixState.copy( _cameraMatrixStateTemp );
1632
1503
 
1633
1504
  };
@@ -1639,7 +1510,6 @@
1639
1510
  const color = 0x888888;
1640
1511
  const multiplier = 3;
1641
1512
  let size, divisions, maxLength, tick;
1642
-
1643
1513
  if ( this.camera.isOrthographicCamera ) {
1644
1514
 
1645
1515
  const width = this.camera.right - this.camera.left;
@@ -1664,15 +1534,10 @@
1664
1534
  if ( this._grid == null ) {
1665
1535
 
1666
1536
  this._grid = new THREE.GridHelper( size, divisions, color, color );
1667
-
1668
1537
  this._grid.position.copy( this._gizmos.position );
1669
-
1670
1538
  this._gridPosition.copy( this._grid.position );
1671
-
1672
1539
  this._grid.quaternion.copy( this.camera.quaternion );
1673
-
1674
1540
  this._grid.rotateX( Math.PI * 0.5 );
1675
-
1676
1541
  this.scene.add( this._grid );
1677
1542
 
1678
1543
  }
@@ -1723,7 +1588,6 @@
1723
1588
  const gizmoX = this._gizmos.children[ 0 ];
1724
1589
  const gizmoY = this._gizmos.children[ 1 ];
1725
1590
  const gizmoZ = this._gizmos.children[ 2 ];
1726
-
1727
1591
  if ( isActive ) {
1728
1592
 
1729
1593
  gizmoX.material.setValues( {
@@ -1755,11 +1619,8 @@
1755
1619
  this.getCursorNDC = ( cursorX, cursorY, canvas ) => {
1756
1620
 
1757
1621
  const canvasRect = canvas.getBoundingClientRect();
1758
-
1759
1622
  this._v2_1.setX( ( cursorX - canvasRect.left ) / canvasRect.width * 2 - 1 );
1760
-
1761
1623
  this._v2_1.setY( ( canvasRect.bottom - cursorY ) / canvasRect.height * 2 - 1 );
1762
-
1763
1624
  return this._v2_1.clone();
1764
1625
 
1765
1626
  };
@@ -1767,7 +1628,6 @@
1767
1628
  this.getCursorPosition = ( cursorX, cursorY, canvas ) => {
1768
1629
 
1769
1630
  this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
1770
-
1771
1631
  this._v2_1.x *= ( this.camera.right - this.camera.left ) * 0.5;
1772
1632
  this._v2_1.y *= ( this.camera.top - this.camera.bottom ) * 0.5;
1773
1633
  return this._v2_1.clone();
@@ -1777,8 +1637,9 @@
1777
1637
  this.setCamera = camera => {
1778
1638
 
1779
1639
  camera.lookAt( this.target );
1780
- camera.updateMatrix(); //setting state
1640
+ camera.updateMatrix();
1781
1641
 
1642
+ //setting state
1782
1643
  if ( camera.type == 'PerspectiveCamera' ) {
1783
1644
 
1784
1645
  this._fov0 = camera.fov;
@@ -1787,11 +1648,8 @@
1787
1648
  }
1788
1649
 
1789
1650
  this._cameraMatrixState0.copy( camera.matrix );
1790
-
1791
1651
  this._cameraMatrixState.copy( this._cameraMatrixState0 );
1792
-
1793
1652
  this._cameraProjectionState.copy( camera.projectionMatrix );
1794
-
1795
1653
  this._zoom0 = camera.zoom;
1796
1654
  this._zoomState = this._zoom0;
1797
1655
  this._initialNear = camera.near;
@@ -1800,14 +1658,12 @@
1800
1658
  this._initialFar = camera.far;
1801
1659
  this._farPos0 = camera.position.distanceTo( this.target ) - camera.far;
1802
1660
  this._farPos = this._initialFar;
1803
-
1804
1661
  this._up0.copy( camera.up );
1805
-
1806
1662
  this._upState.copy( camera.up );
1807
-
1808
1663
  this.camera = camera;
1809
- this.camera.updateProjectionMatrix(); //making gizmos
1664
+ this.camera.updateProjectionMatrix();
1810
1665
 
1666
+ //making gizmos
1811
1667
  this._tbRadius = this.calculateTbRadius( camera );
1812
1668
  this.makeGizmos( this.target, this._tbRadius );
1813
1669
 
@@ -1816,10 +1672,12 @@
1816
1672
  this.makeGizmos = ( tbCenter, tbRadius ) => {
1817
1673
 
1818
1674
  const curve = new THREE.EllipseCurve( 0, 0, tbRadius, tbRadius );
1819
- const points = curve.getPoints( this._curvePts ); //geometry
1675
+ const points = curve.getPoints( this._curvePts );
1820
1676
 
1821
- const curveGeometry = new THREE.BufferGeometry().setFromPoints( points ); //material
1677
+ //geometry
1678
+ const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
1822
1679
 
1680
+ //material
1823
1681
  const curveMaterialX = new THREE.LineBasicMaterial( {
1824
1682
  color: 0xff8080,
1825
1683
  fog: false,
@@ -1837,44 +1695,51 @@
1837
1695
  fog: false,
1838
1696
  transparent: true,
1839
1697
  opacity: 0.6
1840
- } ); //line
1698
+ } );
1841
1699
 
1700
+ //line
1842
1701
  const gizmoX = new THREE.Line( curveGeometry, curveMaterialX );
1843
1702
  const gizmoY = new THREE.Line( curveGeometry, curveMaterialY );
1844
1703
  const gizmoZ = new THREE.Line( curveGeometry, curveMaterialZ );
1845
1704
  const rotation = Math.PI * 0.5;
1846
1705
  gizmoX.rotation.x = rotation;
1847
- gizmoY.rotation.y = rotation; //setting state
1706
+ gizmoY.rotation.y = rotation;
1848
1707
 
1708
+ //setting state
1849
1709
  this._gizmoMatrixState0.identity().setPosition( tbCenter );
1850
-
1851
1710
  this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
1852
-
1853
- if ( this.camera.zoom != 1 ) {
1711
+ if ( this.camera.zoom !== 1 ) {
1854
1712
 
1855
1713
  //adapt gizmos size to camera zoom
1856
1714
  const size = 1 / this.camera.zoom;
1857
-
1858
1715
  this._scaleMatrix.makeScale( size, size, size );
1859
-
1860
1716
  this._translationMatrix.makeTranslation( - tbCenter.x, - tbCenter.y, - tbCenter.z );
1861
-
1862
1717
  this._gizmoMatrixState.premultiply( this._translationMatrix ).premultiply( this._scaleMatrix );
1863
-
1864
1718
  this._translationMatrix.makeTranslation( tbCenter.x, tbCenter.y, tbCenter.z );
1865
-
1866
1719
  this._gizmoMatrixState.premultiply( this._translationMatrix );
1867
1720
 
1868
1721
  }
1869
1722
 
1870
1723
  this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1871
1724
 
1725
+ //
1726
+
1727
+ this._gizmos.traverse( function ( object ) {
1728
+
1729
+ if ( object.isLine ) {
1730
+
1731
+ object.geometry.dispose();
1732
+ object.material.dispose();
1733
+
1734
+ }
1735
+
1736
+ } );
1872
1737
  this._gizmos.clear();
1873
1738
 
1874
- this._gizmos.add( gizmoX );
1739
+ //
1875
1740
 
1741
+ this._gizmos.add( gizmoX );
1876
1742
  this._gizmos.add( gizmoY );
1877
-
1878
1743
  this._gizmos.add( gizmoZ );
1879
1744
 
1880
1745
  };
@@ -1892,14 +1757,12 @@
1892
1757
 
1893
1758
  const deltaTime = time - this._timeStart;
1894
1759
  const animTime = deltaTime / this.focusAnimationTime;
1895
-
1896
1760
  this._gizmoMatrixState.copy( gizmoMatrix );
1897
-
1898
1761
  if ( animTime >= 1 ) {
1899
1762
 
1900
1763
  //animation end
1901
- this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1902
1764
 
1765
+ this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1903
1766
  this.focus( point, this.scaleFactor );
1904
1767
  this._timeStart = - 1;
1905
1768
  this.updateTbState( STATE.IDLE, false );
@@ -1910,9 +1773,7 @@
1910
1773
 
1911
1774
  const amount = this.easeOutCubic( animTime );
1912
1775
  const size = 1 - amount + this.scaleFactor * amount;
1913
-
1914
1776
  this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1915
-
1916
1777
  this.focus( point, size, amount );
1917
1778
  this.dispatchEvent( _changeEvent );
1918
1779
  const self = this;
@@ -1927,6 +1788,7 @@
1927
1788
  } else {
1928
1789
 
1929
1790
  //interrupt animation
1791
+
1930
1792
  this._animationId = - 1;
1931
1793
  this._timeStart = - 1;
1932
1794
 
@@ -1950,7 +1812,6 @@
1950
1812
  //w = w0 + alpha * t
1951
1813
  const deltaTime = ( time - this._timeStart ) / 1000;
1952
1814
  const w = w0 + - this.dampingFactor * deltaTime;
1953
-
1954
1815
  if ( w > 0 ) {
1955
1816
 
1956
1817
  //tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
@@ -1977,9 +1838,9 @@
1977
1838
  } else {
1978
1839
 
1979
1840
  //interrupt animation
1841
+
1980
1842
  this._animationId = - 1;
1981
1843
  this._timeStart = - 1;
1982
-
1983
1844
  if ( this._state != STATE.ROTATE ) {
1984
1845
 
1985
1846
  this.activateGizmos( false );
@@ -1994,7 +1855,6 @@
1994
1855
  this.pan = ( p0, p1, adjust = false ) => {
1995
1856
 
1996
1857
  const movement = p0.clone().sub( p1 );
1997
-
1998
1858
  if ( this.camera.isOrthographicCamera ) {
1999
1859
 
2000
1860
  //adjust movement amount
@@ -2004,20 +1864,14 @@
2004
1864
 
2005
1865
  //adjust movement amount
2006
1866
  this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ); //camera's initial position
2007
-
2008
-
2009
1867
  this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ); //gizmo's initial position
2010
-
2011
-
2012
1868
  const distanceFactor = this._v3_1.distanceTo( this._v3_2 ) / this.camera.position.distanceTo( this._gizmos.position );
2013
1869
  movement.multiplyScalar( 1 / distanceFactor );
2014
1870
 
2015
1871
  }
2016
1872
 
2017
1873
  this._v3_1.set( movement.x, movement.y, 0 ).applyQuaternion( this.camera.quaternion );
2018
-
2019
1874
  this._m4_1.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z );
2020
-
2021
1875
  this.setTransformationMatrices( this._m4_1, this._m4_1 );
2022
1876
  return _transformation;
2023
1877
 
@@ -2026,7 +1880,6 @@
2026
1880
  this.reset = () => {
2027
1881
 
2028
1882
  this.camera.zoom = this._zoom0;
2029
-
2030
1883
  if ( this.camera.isPerspectiveCamera ) {
2031
1884
 
2032
1885
  this.camera.fov = this._fov0;
@@ -2035,21 +1888,14 @@
2035
1888
 
2036
1889
  this.camera.near = this._nearPos;
2037
1890
  this.camera.far = this._farPos;
2038
-
2039
1891
  this._cameraMatrixState.copy( this._cameraMatrixState0 );
2040
-
2041
1892
  this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
2042
-
2043
1893
  this.camera.up.copy( this._up0 );
2044
1894
  this.camera.updateMatrix();
2045
1895
  this.camera.updateProjectionMatrix();
2046
-
2047
1896
  this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
2048
-
2049
1897
  this._gizmoMatrixState0.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
2050
-
2051
1898
  this._gizmos.updateMatrix();
2052
-
2053
1899
  this._tbRadius = this.calculateTbRadius( this.camera );
2054
1900
  this.makeGizmos( this._gizmos.position, this._tbRadius );
2055
1901
  this.camera.lookAt( this._gizmos.position );
@@ -2061,18 +1907,13 @@
2061
1907
  this.rotate = ( axis, angle ) => {
2062
1908
 
2063
1909
  const point = this._gizmos.position; //rotation center
2064
-
2065
1910
  this._translationMatrix.makeTranslation( - point.x, - point.y, - point.z );
1911
+ this._rotationMatrix.makeRotationAxis( axis, - angle );
2066
1912
 
2067
- this._rotationMatrix.makeRotationAxis( axis, - angle ); //rotate camera
2068
-
2069
-
1913
+ //rotate camera
2070
1914
  this._m4_1.makeTranslation( point.x, point.y, point.z );
2071
-
2072
1915
  this._m4_1.multiply( this._rotationMatrix );
2073
-
2074
1916
  this._m4_1.multiply( this._translationMatrix );
2075
-
2076
1917
  this.setTransformationMatrices( this._m4_1 );
2077
1918
  return _transformation;
2078
1919
 
@@ -2081,7 +1922,6 @@
2081
1922
  this.copyState = () => {
2082
1923
 
2083
1924
  let state;
2084
-
2085
1925
  if ( this.camera.isOrthographicCamera ) {
2086
1926
 
2087
1927
  state = JSON.stringify( {
@@ -2129,15 +1969,11 @@
2129
1969
  this.saveState = () => {
2130
1970
 
2131
1971
  this._cameraMatrixState0.copy( this.camera.matrix );
2132
-
2133
1972
  this._gizmoMatrixState0.copy( this._gizmos.matrix );
2134
-
2135
1973
  this._nearPos = this.camera.near;
2136
1974
  this._farPos = this.camera.far;
2137
1975
  this._zoom0 = this.camera.zoom;
2138
-
2139
1976
  this._up0.copy( this.camera.up );
2140
-
2141
1977
  if ( this.camera.isPerspectiveCamera ) {
2142
1978
 
2143
1979
  this._fov0 = this.camera.fov;
@@ -2149,15 +1985,14 @@
2149
1985
  this.scale = ( size, point, scaleGizmos = true ) => {
2150
1986
 
2151
1987
  _scalePointTemp.copy( point );
2152
-
2153
1988
  let sizeInverse = 1 / size;
2154
-
2155
1989
  if ( this.camera.isOrthographicCamera ) {
2156
1990
 
2157
1991
  //camera zoom
2158
1992
  this.camera.zoom = this._zoomState;
2159
- this.camera.zoom *= size; //check min and max zoom
1993
+ this.camera.zoom *= size;
2160
1994
 
1995
+ //check min and max zoom
2161
1996
  if ( this.camera.zoom > this.maxZoom ) {
2162
1997
 
2163
1998
  this.camera.zoom = this.maxZoom;
@@ -2171,46 +2006,34 @@
2171
2006
  }
2172
2007
 
2173
2008
  this.camera.updateProjectionMatrix();
2174
-
2175
2009
  this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ); //gizmos position
2176
- //scale gizmos so they appear in the same spot having the same dimension
2177
-
2178
2010
 
2011
+ //scale gizmos so they appear in the same spot having the same dimension
2179
2012
  this._scaleMatrix.makeScale( sizeInverse, sizeInverse, sizeInverse );
2180
-
2181
2013
  this._translationMatrix.makeTranslation( - this._v3_1.x, - this._v3_1.y, - this._v3_1.z );
2182
-
2183
2014
  this._m4_2.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z ).multiply( this._scaleMatrix );
2015
+ this._m4_2.multiply( this._translationMatrix );
2184
2016
 
2185
- this._m4_2.multiply( this._translationMatrix ); //move camera and gizmos to obtain pinch effect
2186
-
2187
-
2017
+ //move camera and gizmos to obtain pinch effect
2188
2018
  _scalePointTemp.sub( this._v3_1 );
2189
-
2190
2019
  const amount = _scalePointTemp.clone().multiplyScalar( sizeInverse );
2191
-
2192
2020
  _scalePointTemp.sub( amount );
2193
-
2194
2021
  this._m4_1.makeTranslation( _scalePointTemp.x, _scalePointTemp.y, _scalePointTemp.z );
2195
-
2196
2022
  this._m4_2.premultiply( this._m4_1 );
2197
-
2198
2023
  this.setTransformationMatrices( this._m4_1, this._m4_2 );
2199
2024
  return _transformation;
2200
2025
 
2201
2026
  } else if ( this.camera.isPerspectiveCamera ) {
2202
2027
 
2203
2028
  this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
2029
+ this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
2204
2030
 
2205
- this._v3_2.setFromMatrixPosition( this._gizmoMatrixState ); //move camera
2206
-
2207
-
2031
+ //move camera
2208
2032
  let distance = this._v3_1.distanceTo( _scalePointTemp );
2033
+ let amount = distance - distance * sizeInverse;
2209
2034
 
2210
- let amount = distance - distance * sizeInverse; //check min and max distance
2211
-
2035
+ //check min and max distance
2212
2036
  const newDistance = distance - amount;
2213
-
2214
2037
  if ( newDistance < this.minDistance ) {
2215
2038
 
2216
2039
  sizeInverse = this.minDistance / distance;
@@ -2224,30 +2047,20 @@
2224
2047
  }
2225
2048
 
2226
2049
  _offset.copy( _scalePointTemp ).sub( this._v3_1 ).normalize().multiplyScalar( amount );
2227
-
2228
2050
  this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
2229
-
2230
2051
  if ( scaleGizmos ) {
2231
2052
 
2232
2053
  //scale gizmos so they appear in the same spot having the same dimension
2233
2054
  const pos = this._v3_2;
2234
2055
  distance = pos.distanceTo( _scalePointTemp );
2235
2056
  amount = distance - distance * sizeInverse;
2236
-
2237
2057
  _offset.copy( _scalePointTemp ).sub( this._v3_2 ).normalize().multiplyScalar( amount );
2238
-
2239
2058
  this._translationMatrix.makeTranslation( pos.x, pos.y, pos.z );
2240
-
2241
2059
  this._scaleMatrix.makeScale( sizeInverse, sizeInverse, sizeInverse );
2242
-
2243
2060
  this._m4_2.makeTranslation( _offset.x, _offset.y, _offset.z ).multiply( this._translationMatrix );
2244
-
2245
2061
  this._m4_2.multiply( this._scaleMatrix );
2246
-
2247
2062
  this._translationMatrix.makeTranslation( - pos.x, - pos.y, - pos.z );
2248
-
2249
2063
  this._m4_2.multiply( this._translationMatrix );
2250
-
2251
2064
  this.setTransformationMatrices( this._m4_1, this._m4_2 );
2252
2065
 
2253
2066
  } else {
@@ -2276,25 +2089,14 @@
2276
2089
  this.zRotate = ( point, angle ) => {
2277
2090
 
2278
2091
  this._rotationMatrix.makeRotationAxis( this._rotationAxis, angle );
2279
-
2280
2092
  this._translationMatrix.makeTranslation( - point.x, - point.y, - point.z );
2281
-
2282
2093
  this._m4_1.makeTranslation( point.x, point.y, point.z );
2283
-
2284
2094
  this._m4_1.multiply( this._rotationMatrix );
2285
-
2286
2095
  this._m4_1.multiply( this._translationMatrix );
2287
-
2288
2096
  this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ).sub( point ); //vector from rotation center to gizmos position
2289
-
2290
-
2291
2097
  this._v3_2.copy( this._v3_1 ).applyAxisAngle( this._rotationAxis, angle ); //apply rotation
2292
-
2293
-
2294
2098
  this._v3_2.sub( this._v3_1 );
2295
-
2296
2099
  this._m4_2.makeTranslation( this._v3_2.x, this._v3_2.y, this._v3_2.z );
2297
-
2298
2100
  this.setTransformationMatrices( this._m4_1, this._m4_2 );
2299
2101
  return _transformation;
2300
2102
 
@@ -2307,7 +2109,6 @@
2307
2109
  raycaster.far = camera.far;
2308
2110
  raycaster.setFromCamera( cursor, camera );
2309
2111
  const intersect = raycaster.intersectObjects( this.scene.children, true );
2310
-
2311
2112
  for ( let i = 0; i < intersect.length; i ++ ) {
2312
2113
 
2313
2114
  if ( intersect[ i ].object.uuid != this._gizmos.uuid && intersect[ i ].face != null ) {
@@ -2327,13 +2128,10 @@
2327
2128
  if ( camera.type == 'OrthographicCamera' ) {
2328
2129
 
2329
2130
  this._v2_1.copy( this.getCursorPosition( cursorX, cursorY, canvas ) );
2330
-
2331
2131
  this._v3_1.set( this._v2_1.x, this._v2_1.y, 0 );
2332
-
2333
2132
  const x2 = Math.pow( this._v2_1.x, 2 );
2334
2133
  const y2 = Math.pow( this._v2_1.y, 2 );
2335
2134
  const r2 = Math.pow( this._tbRadius, 2 );
2336
-
2337
2135
  if ( x2 + y2 <= r2 * 0.5 ) {
2338
2136
 
2339
2137
  //intersection with sphere
@@ -2352,16 +2150,13 @@
2352
2150
 
2353
2151
  //unproject cursor on the near plane
2354
2152
  this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
2355
-
2356
2153
  this._v3_1.set( this._v2_1.x, this._v2_1.y, - 1 );
2357
-
2358
2154
  this._v3_1.applyMatrix4( camera.projectionMatrixInverse );
2359
-
2360
2155
  const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
2361
-
2362
-
2363
2156
  const cameraGizmoDistance = camera.position.distanceTo( this._gizmos.position );
2364
- const radius2 = Math.pow( tbRadius, 2 ); // camera
2157
+ const radius2 = Math.pow( tbRadius, 2 );
2158
+
2159
+ // camera
2365
2160
  // |\
2366
2161
  // | \
2367
2162
  // | \
@@ -2373,7 +2168,6 @@
2373
2168
 
2374
2169
  const h = this._v3_1.z;
2375
2170
  const l = Math.sqrt( Math.pow( this._v3_1.x, 2 ) + Math.pow( this._v3_1.y, 2 ) );
2376
-
2377
2171
  if ( l == 0 ) {
2378
2172
 
2379
2173
  //ray aligned with camera
@@ -2384,6 +2178,7 @@
2384
2178
 
2385
2179
  const m = h / l;
2386
2180
  const q = cameraGizmoDistance;
2181
+
2387
2182
  /*
2388
2183
  * calculate intersection point between unprojected ray and trackball surface
2389
2184
  *|y = m * x + q
@@ -2391,25 +2186,21 @@
2391
2186
  *
2392
2187
  * (m^2 + 1) * x^2 + (2 * m * q) * x + q^2 - r^2 = 0
2393
2188
  */
2394
-
2395
2189
  let a = Math.pow( m, 2 ) + 1;
2396
2190
  let b = 2 * m * q;
2397
2191
  let c = Math.pow( q, 2 ) - radius2;
2398
2192
  let delta = Math.pow( b, 2 ) - 4 * a * c;
2399
-
2400
2193
  if ( delta >= 0 ) {
2401
2194
 
2402
2195
  //intersection with sphere
2403
2196
  this._v2_1.setX( ( - b - Math.sqrt( delta ) ) / ( 2 * a ) );
2404
-
2405
2197
  this._v2_1.setY( m * this._v2_1.x + q );
2406
-
2407
2198
  const angle = THREE.MathUtils.RAD2DEG * this._v2_1.angle();
2408
-
2409
2199
  if ( angle >= 45 ) {
2410
2200
 
2411
2201
  //if angle between intersection point and X' axis is >= 45°, return that point
2412
2202
  //otherwise, calculate intersection point with hyperboloid
2203
+
2413
2204
  const rayLength = Math.sqrt( Math.pow( this._v2_1.x, 2 ) + Math.pow( cameraGizmoDistance - this._v2_1.y, 2 ) );
2414
2205
  rayDir.multiplyScalar( rayLength );
2415
2206
  rayDir.z += cameraGizmoDistance;
@@ -2417,8 +2208,9 @@
2417
2208
 
2418
2209
  }
2419
2210
 
2420
- } //intersection with hyperboloid
2211
+ }
2421
2212
 
2213
+ //intersection with hyperboloid
2422
2214
  /*
2423
2215
  *|y = m * x + q
2424
2216
  *|y = (1 / x) * (r^2 / 2)
@@ -2426,16 +2218,12 @@
2426
2218
  * m * x^2 + q * x - r^2 / 2 = 0
2427
2219
  */
2428
2220
 
2429
-
2430
2221
  a = m;
2431
2222
  b = q;
2432
2223
  c = - radius2 * 0.5;
2433
2224
  delta = Math.pow( b, 2 ) - 4 * a * c;
2434
-
2435
2225
  this._v2_1.setX( ( - b - Math.sqrt( delta ) ) / ( 2 * a ) );
2436
-
2437
2226
  this._v2_1.setY( m * this._v2_1.x + q );
2438
-
2439
2227
  const rayLength = Math.sqrt( Math.pow( this._v2_1.x, 2 ) + Math.pow( cameraGizmoDistance - this._v2_1.y, 2 ) );
2440
2228
  rayDir.multiplyScalar( rayLength );
2441
2229
  rayDir.z += cameraGizmoDistance;
@@ -2450,21 +2238,18 @@
2450
2238
  if ( camera.type == 'OrthographicCamera' ) {
2451
2239
 
2452
2240
  this._v2_1.copy( this.getCursorPosition( cursorX, cursorY, canvas ) );
2453
-
2454
2241
  this._v3_1.set( this._v2_1.x, this._v2_1.y, 0 );
2455
-
2456
2242
  return this._v3_1.clone();
2457
2243
 
2458
2244
  } else if ( camera.type == 'PerspectiveCamera' ) {
2459
2245
 
2460
- this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) ); //unproject cursor on the near plane
2461
-
2246
+ this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
2462
2247
 
2248
+ //unproject cursor on the near plane
2463
2249
  this._v3_1.set( this._v2_1.x, this._v2_1.y, - 1 );
2464
-
2465
2250
  this._v3_1.applyMatrix4( camera.projectionMatrixInverse );
2466
-
2467
2251
  const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
2252
+
2468
2253
  // camera
2469
2254
  // |\
2470
2255
  // | \
@@ -2475,11 +2260,9 @@
2475
2260
  // _ _ | _ _ _\ _ _ near plane
2476
2261
  // l
2477
2262
 
2478
-
2479
2263
  const h = this._v3_1.z;
2480
2264
  const l = Math.sqrt( Math.pow( this._v3_1.x, 2 ) + Math.pow( this._v3_1.y, 2 ) );
2481
2265
  let cameraGizmoDistance;
2482
-
2483
2266
  if ( initialDistance ) {
2484
2267
 
2485
2268
  cameraGizmoDistance = this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ).distanceTo( this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ) );
@@ -2489,6 +2272,7 @@
2489
2272
  cameraGizmoDistance = camera.position.distanceTo( this._gizmos.position );
2490
2273
 
2491
2274
  }
2275
+
2492
2276
  /*
2493
2277
  * calculate intersection point between unprojected ray and the plane
2494
2278
  *|y = mx + q
@@ -2496,8 +2280,6 @@
2496
2280
  *
2497
2281
  * x = -q/m
2498
2282
  */
2499
-
2500
-
2501
2283
  if ( l == 0 ) {
2502
2284
 
2503
2285
  //ray aligned with camera
@@ -2522,13 +2304,10 @@
2522
2304
 
2523
2305
  //update camera and gizmos state
2524
2306
  this._cameraMatrixState.copy( this.camera.matrix );
2525
-
2526
2307
  this._gizmoMatrixState.copy( this._gizmos.matrix );
2527
-
2528
2308
  if ( this.camera.isOrthographicCamera ) {
2529
2309
 
2530
2310
  this._cameraProjectionState.copy( this.camera.projectionMatrix );
2531
-
2532
2311
  this.camera.updateProjectionMatrix();
2533
2312
  this._zoomState = this.camera.zoom;
2534
2313
 
@@ -2543,7 +2322,6 @@
2543
2322
  this.updateTbState = ( newState, updateMatrices ) => {
2544
2323
 
2545
2324
  this._state = newState;
2546
-
2547
2325
  if ( updateMatrices ) {
2548
2326
 
2549
2327
  this.updateMatrixState();
@@ -2555,20 +2333,16 @@
2555
2333
  this.update = () => {
2556
2334
 
2557
2335
  const EPS = 0.000001;
2558
-
2559
2336
  if ( this.target.equals( this._currentTarget ) === false ) {
2560
2337
 
2561
2338
  this._gizmos.position.copy( this.target ); //for correct radius calculation
2562
-
2563
-
2564
2339
  this._tbRadius = this.calculateTbRadius( this.camera );
2565
2340
  this.makeGizmos( this.target, this._tbRadius );
2566
-
2567
2341
  this._currentTarget.copy( this.target );
2568
2342
 
2569
- } //check min/max parameters
2570
-
2343
+ }
2571
2344
 
2345
+ //check min/max parameters
2572
2346
  if ( this.camera.isOrthographicCamera ) {
2573
2347
 
2574
2348
  //check zoom
@@ -2583,16 +2357,15 @@
2583
2357
 
2584
2358
  //check distance
2585
2359
  const distance = this.camera.position.distanceTo( this._gizmos.position );
2586
-
2587
2360
  if ( distance > this.maxDistance + EPS || distance < this.minDistance - EPS ) {
2588
2361
 
2589
2362
  const newDistance = THREE.MathUtils.clamp( distance, this.minDistance, this.maxDistance );
2590
2363
  this.applyTransformMatrix( this.scale( newDistance / distance, this._gizmos.position ) );
2591
2364
  this.updateMatrixState();
2592
2365
 
2593
- } //check fov
2594
-
2366
+ }
2595
2367
 
2368
+ //check fov
2596
2369
  if ( this.camera.fov < this.minFov || this.camera.fov > this.maxFov ) {
2597
2370
 
2598
2371
  this.camera.fov = THREE.MathUtils.clamp( this.camera.fov, this.minFov, this.maxFov );
@@ -2602,7 +2375,6 @@
2602
2375
 
2603
2376
  const oldRadius = this._tbRadius;
2604
2377
  this._tbRadius = this.calculateTbRadius( this.camera );
2605
-
2606
2378
  if ( oldRadius < this._tbRadius - EPS || oldRadius > this._tbRadius + EPS ) {
2607
2379
 
2608
2380
  const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
@@ -2610,7 +2382,6 @@
2610
2382
  const curve = new THREE.EllipseCurve( 0, 0, newRadius, newRadius );
2611
2383
  const points = curve.getPoints( this._curvePts );
2612
2384
  const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
2613
-
2614
2385
  for ( const gizmo in this._gizmos.children ) {
2615
2386
 
2616
2387
  this._gizmos.children[ gizmo ].geometry = curveGeometry;
@@ -2628,18 +2399,14 @@
2628
2399
  this.setStateFromJSON = json => {
2629
2400
 
2630
2401
  const state = JSON.parse( json );
2631
-
2632
2402
  if ( state.arcballState != undefined ) {
2633
2403
 
2634
2404
  this._cameraMatrixState.fromArray( state.arcballState.cameraMatrix.elements );
2635
-
2636
2405
  this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
2637
-
2638
2406
  this.camera.up.copy( state.arcballState.cameraUp );
2639
2407
  this.camera.near = state.arcballState.cameraNear;
2640
2408
  this.camera.far = state.arcballState.cameraFar;
2641
2409
  this.camera.zoom = state.arcballState.cameraZoom;
2642
-
2643
2410
  if ( this.camera.isPerspectiveCamera ) {
2644
2411
 
2645
2412
  this.camera.fov = state.arcballState.cameraFov;
@@ -2647,20 +2414,14 @@
2647
2414
  }
2648
2415
 
2649
2416
  this._gizmoMatrixState.fromArray( state.arcballState.gizmoMatrix.elements );
2650
-
2651
2417
  this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
2652
-
2653
2418
  this.camera.updateMatrix();
2654
2419
  this.camera.updateProjectionMatrix();
2655
-
2656
2420
  this._gizmos.updateMatrix();
2657
-
2658
2421
  this._tbRadius = this.calculateTbRadius( this.camera );
2659
2422
  const gizmoTmp = new THREE.Matrix4().copy( this._gizmoMatrixState0 );
2660
2423
  this.makeGizmos( this._gizmos.position, this._tbRadius );
2661
-
2662
2424
  this._gizmoMatrixState0.copy( gizmoTmp );
2663
-
2664
2425
  this.camera.lookAt( this._gizmos.position );
2665
2426
  this.updateTbState( STATE.IDLE, false );
2666
2427
  this.dispatchEvent( _changeEvent );
@@ -2676,24 +2437,24 @@
2676
2437
  this._currentTarget = new THREE.Vector3();
2677
2438
  this.radiusFactor = 0.67;
2678
2439
  this.mouseActions = [];
2679
- this._mouseOp = null; //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
2440
+ this._mouseOp = null;
2680
2441
 
2442
+ //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
2681
2443
  this._v2_1 = new THREE.Vector2();
2682
2444
  this._v3_1 = new THREE.Vector3();
2683
2445
  this._v3_2 = new THREE.Vector3();
2684
2446
  this._m4_1 = new THREE.Matrix4();
2685
2447
  this._m4_2 = new THREE.Matrix4();
2686
- this._quat = new THREE.Quaternion(); //transformation matrices
2448
+ this._quat = new THREE.Quaternion();
2687
2449
 
2450
+ //transformation matrices
2688
2451
  this._translationMatrix = new THREE.Matrix4(); //matrix for translation operation
2689
-
2690
2452
  this._rotationMatrix = new THREE.Matrix4(); //matrix for rotation operation
2691
-
2692
2453
  this._scaleMatrix = new THREE.Matrix4(); //matrix for scaling operation
2693
2454
 
2694
2455
  this._rotationAxis = new THREE.Vector3(); //axis for rotate operation
2695
- //camera state
2696
2456
 
2457
+ //camera state
2697
2458
  this._cameraMatrixState = new THREE.Matrix4();
2698
2459
  this._cameraProjectionState = new THREE.Matrix4();
2699
2460
  this._fovState = 1;
@@ -2701,8 +2462,9 @@
2701
2462
  this._zoomState = 1;
2702
2463
  this._nearPos = 0;
2703
2464
  this._farPos = 0;
2704
- this._gizmoMatrixState = new THREE.Matrix4(); //initial values
2465
+ this._gizmoMatrixState = new THREE.Matrix4();
2705
2466
 
2467
+ //initial values
2706
2468
  this._up0 = new THREE.Vector3();
2707
2469
  this._zoom0 = 1;
2708
2470
  this._fov0 = 0;
@@ -2711,81 +2473,70 @@
2711
2473
  this._initialFar = 0;
2712
2474
  this._farPos0 = 0;
2713
2475
  this._cameraMatrixState0 = new THREE.Matrix4();
2714
- this._gizmoMatrixState0 = new THREE.Matrix4(); //pointers array
2476
+ this._gizmoMatrixState0 = new THREE.Matrix4();
2715
2477
 
2478
+ //pointers array
2716
2479
  this._button = - 1;
2717
2480
  this._touchStart = [];
2718
2481
  this._touchCurrent = [];
2719
- this._input = INPUT.NONE; //two fingers touch interaction
2482
+ this._input = INPUT.NONE;
2720
2483
 
2484
+ //two fingers touch interaction
2721
2485
  this._switchSensibility = 32; //minimum movement to be performed to fire single pan start after the second finger has been released
2722
-
2723
2486
  this._startFingerDistance = 0; //distance between two fingers
2724
-
2725
2487
  this._currentFingerDistance = 0;
2726
2488
  this._startFingerRotation = 0; //amount of rotation performed with two fingers
2489
+ this._currentFingerRotation = 0;
2727
2490
 
2728
- this._currentFingerRotation = 0; //double tap
2729
-
2491
+ //double tap
2730
2492
  this._devPxRatio = 0;
2731
2493
  this._downValid = true;
2732
2494
  this._nclicks = 0;
2733
2495
  this._downEvents = [];
2734
2496
  this._downStart = 0; //pointerDown time
2735
-
2736
2497
  this._clickStart = 0; //first click time
2737
-
2738
2498
  this._maxDownTime = 250;
2739
2499
  this._maxInterval = 300;
2740
2500
  this._posThreshold = 24;
2741
- this._movementThreshold = 24; //cursor positions
2501
+ this._movementThreshold = 24;
2742
2502
 
2503
+ //cursor positions
2743
2504
  this._currentCursorPosition = new THREE.Vector3();
2744
- this._startCursorPosition = new THREE.Vector3(); //grid
2505
+ this._startCursorPosition = new THREE.Vector3();
2745
2506
 
2507
+ //grid
2746
2508
  this._grid = null; //grid to be visualized during pan operation
2509
+ this._gridPosition = new THREE.Vector3();
2747
2510
 
2748
- this._gridPosition = new THREE.Vector3(); //gizmos
2749
-
2511
+ //gizmos
2750
2512
  this._gizmos = new THREE.Group();
2751
- this._curvePts = 128; //animations
2513
+ this._curvePts = 128;
2752
2514
 
2515
+ //animations
2753
2516
  this._timeStart = - 1; //initial time
2517
+ this._animationId = - 1;
2754
2518
 
2755
- this._animationId = - 1; //focus animation
2756
-
2519
+ //focus animation
2757
2520
  this.focusAnimationTime = 500; //duration of focus animation in ms
2758
- //rotate animation
2759
2521
 
2522
+ //rotate animation
2760
2523
  this._timePrev = 0; //time at which previous rotate operation has been detected
2761
-
2762
2524
  this._timeCurrent = 0; //time at which current rotate operation has been detected
2763
-
2764
2525
  this._anglePrev = 0; //angle of previous rotation
2765
-
2766
2526
  this._angleCurrent = 0; //angle of current rotation
2767
-
2768
2527
  this._cursorPosPrev = new THREE.Vector3(); //cursor position when previous rotate operation has been detected
2769
-
2770
2528
  this._cursorPosCurr = new THREE.Vector3(); //cursor position when current rotate operation has been detected
2771
-
2772
2529
  this._wPrev = 0; //angular velocity of the previous rotate operation
2773
-
2774
2530
  this._wCurr = 0; //angular velocity of the current rotate operation
2775
- //parameters
2776
2531
 
2532
+ //parameters
2777
2533
  this.adjustNearFar = false;
2778
2534
  this.scaleFactor = 1.1; //zoom/distance multiplier
2779
-
2780
2535
  this.dampingFactor = 25;
2781
2536
  this.wMax = 20; //maximum angular velocity allowed
2782
-
2783
2537
  this.enableAnimations = true; //if animations should be performed
2784
-
2785
2538
  this.enableGrid = false; //if grid should be showed during pan operation
2786
-
2787
2539
  this.cursorZoom = false; //if wheel zoom should be cursor centered
2788
-
2789
2540
  this.minFov = 5;
2790
2541
  this.maxFov = 90;
2791
2542
  this.enabled = true;
@@ -2796,13 +2547,14 @@
2796
2547
  this.minDistance = 0;
2797
2548
  this.maxDistance = Infinity;
2798
2549
  this.minZoom = 0;
2799
- this.maxZoom = Infinity; //trackball parameters
2550
+ this.maxZoom = Infinity;
2800
2551
 
2801
- this._tbRadius = 1; //FSA
2552
+ //trackball parameters
2553
+ this._tbRadius = 1;
2802
2554
 
2555
+ //FSA
2803
2556
  this._state = STATE.IDLE;
2804
2557
  this.setCamera( _camera );
2805
-
2806
2558
  if ( this.scene != null ) {
2807
2559
 
2808
2560
  this.scene.add( this._gizmos );
@@ -2818,8 +2570,9 @@
2818
2570
  this.domElement.addEventListener( 'pointercancel', this.onPointerCancel );
2819
2571
  window.addEventListener( 'resize', this.onWindowResize );
2820
2572
 
2821
- } //listeners
2573
+ }
2822
2574
 
2575
+ //listeners
2823
2576
 
2824
2577
  /**
2825
2578
  * Apply a transformation matrix, to the camera and gizmos
@@ -2830,11 +2583,10 @@
2830
2583
  if ( transformation.camera != null ) {
2831
2584
 
2832
2585
  this._m4_1.copy( this._cameraMatrixState ).premultiply( transformation.camera );
2833
-
2834
2586
  this._m4_1.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
2587
+ this.camera.updateMatrix();
2835
2588
 
2836
- this.camera.updateMatrix(); //update camera up vector
2837
-
2589
+ //update camera up vector
2838
2590
  if ( this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE ) {
2839
2591
 
2840
2592
  this.camera.up.copy( this._upState ).applyQuaternion( this.camera.quaternion );
@@ -2846,9 +2598,7 @@
2846
2598
  if ( transformation.gizmos != null ) {
2847
2599
 
2848
2600
  this._m4_1.copy( this._gizmoMatrixState ).premultiply( transformation.gizmos );
2849
-
2850
2601
  this._m4_1.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
2851
-
2852
2602
  this._gizmos.updateMatrix();
2853
2603
 
2854
2604
  }
@@ -2856,7 +2606,6 @@
2856
2606
  if ( this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS ) {
2857
2607
 
2858
2608
  this._tbRadius = this.calculateTbRadius( this.camera );
2859
-
2860
2609
  if ( this.adjustNearFar ) {
2861
2610
 
2862
2611
  const cameraDistance = this.camera.position.distanceTo( this._gizmos.position );
@@ -2877,7 +2626,6 @@
2877
2626
  } else {
2878
2627
 
2879
2628
  let update = false;
2880
-
2881
2629
  if ( this.camera.near != this._initialNear ) {
2882
2630
 
2883
2631
  this.camera.near = this._initialNear;
@@ -2903,6 +2651,7 @@
2903
2651
  }
2904
2652
 
2905
2653
  }
2654
+
2906
2655
  /**
2907
2656
  * Calculate the angular speed
2908
2657
  * @param {Number} p0 Position at t0
@@ -2911,7 +2660,6 @@
2911
2660
  * @param {Number} t1 Ending time in milliseconds
2912
2661
  */
2913
2662
 
2914
-
2915
2663
  /**
2916
2664
  * Set gizmos visibility
2917
2665
  * @param {Boolean} value Value of gizmos visibility
@@ -2922,12 +2670,11 @@
2922
2670
  this.dispatchEvent( _changeEvent );
2923
2671
 
2924
2672
  }
2673
+
2925
2674
  /**
2926
2675
  * Set gizmos radius factor and redraws gizmos
2927
2676
  * @param {Float} value Value of radius factor
2928
2677
  */
2929
-
2930
-
2931
2678
  setTbRadius( value ) {
2932
2679
 
2933
2680
  this.radiusFactor = value;
@@ -2935,7 +2682,6 @@
2935
2682
  const curve = new THREE.EllipseCurve( 0, 0, this._tbRadius, this._tbRadius );
2936
2683
  const points = curve.getPoints( this._curvePts );
2937
2684
  const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
2938
-
2939
2685
  for ( const gizmo in this._gizmos.children ) {
2940
2686
 
2941
2687
  this._gizmos.children[ gizmo ].geometry = curveGeometry;
@@ -2945,13 +2691,13 @@
2945
2691
  this.dispatchEvent( _changeEvent );
2946
2692
 
2947
2693
  }
2694
+
2948
2695
  /**
2949
2696
  * Creates the rotation gizmos matching trackball center and radius
2950
2697
  * @param {Vector3} tbCenter The trackball center
2951
2698
  * @param {number} tbRadius The trackball radius
2952
2699
  */
2953
2700
 
2954
-
2955
2701
  /**
2956
2702
  * Set values in transformation object
2957
2703
  * @param {Matrix4} camera Transformation to be applied to the camera
@@ -2996,6 +2742,7 @@
2996
2742
  }
2997
2743
 
2998
2744
  }
2745
+
2999
2746
  /**
3000
2747
  * Rotate camera around its direction axis passing by a given point by a given angle
3001
2748
  * @param {Vector3} point The point where the rotation axis is passing trough
@@ -3003,12 +2750,12 @@
3003
2750
  * @returns The computed transormation matix
3004
2751
  */
3005
2752
 
3006
-
3007
2753
  getRaycaster() {
3008
2754
 
3009
2755
  return _raycaster;
3010
2756
 
3011
2757
  }
2758
+
3012
2759
  /**
3013
2760
  * Unproject the cursor on the 3D object surface
3014
2761
  * @param {Vector2} cursor Cursor coordinates in NDC
@@ -3016,7 +2763,6 @@
3016
2763
  * @returns {Vector3} The point of intersection with the model, if exist, null otherwise
3017
2764
  */
3018
2765
 
3019
-
3020
2766
  }
3021
2767
 
3022
2768
  THREE.ArcballControls = ArcballControls;