three-stdlib 2.25.0 → 2.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (539) hide show
  1. package/index.cjs +116401 -611
  2. package/index.js +116037 -263
  3. package/package.json +17 -4
  4. package/_polyfill/CapsuleGeometry.cjs +0 -22
  5. package/_polyfill/CapsuleGeometry.js +0 -22
  6. package/_polyfill/CompressedArrayTexture.cjs +0 -12
  7. package/_polyfill/CompressedArrayTexture.js +0 -12
  8. package/_polyfill/Data3DTexture.cjs +0 -17
  9. package/_polyfill/Data3DTexture.js +0 -17
  10. package/animation/AnimationClipCreator.cjs +0 -56
  11. package/animation/AnimationClipCreator.js +0 -56
  12. package/animation/CCDIKSolver.cjs +0 -269
  13. package/animation/CCDIKSolver.js +0 -269
  14. package/animation/MMDAnimationHelper.cjs +0 -688
  15. package/animation/MMDAnimationHelper.js +0 -688
  16. package/animation/MMDPhysics.cjs +0 -830
  17. package/animation/MMDPhysics.js +0 -830
  18. package/cameras/CinematicCamera.cjs +0 -131
  19. package/cameras/CinematicCamera.js +0 -131
  20. package/controls/ArcballControls.cjs +0 -2033
  21. package/controls/ArcballControls.js +0 -2033
  22. package/controls/DeviceOrientationControls.cjs +0 -85
  23. package/controls/DeviceOrientationControls.js +0 -85
  24. package/controls/DragControls.cjs +0 -182
  25. package/controls/DragControls.js +0 -182
  26. package/controls/FirstPersonControls.cjs +0 -229
  27. package/controls/FirstPersonControls.js +0 -229
  28. package/controls/FlyControls.cjs +0 -248
  29. package/controls/FlyControls.js +0 -248
  30. package/controls/OrbitControls.cjs +0 -791
  31. package/controls/OrbitControls.js +0 -791
  32. package/controls/PointerLockControls.cjs +0 -103
  33. package/controls/PointerLockControls.js +0 -103
  34. package/controls/TrackballControls.cjs +0 -502
  35. package/controls/TrackballControls.js +0 -502
  36. package/controls/TransformControls.cjs +0 -1089
  37. package/controls/TransformControls.js +0 -1089
  38. package/controls/experimental/CameraControls.cjs +0 -736
  39. package/controls/experimental/CameraControls.js +0 -736
  40. package/csm/CSM.cjs +0 -244
  41. package/csm/CSM.js +0 -244
  42. package/csm/CSMFrustum.cjs +0 -75
  43. package/csm/CSMFrustum.js +0 -75
  44. package/csm/CSMHelper.cjs +0 -114
  45. package/csm/CSMHelper.js +0 -114
  46. package/csm/CSMShader.cjs +0 -261
  47. package/csm/CSMShader.js +0 -261
  48. package/curves/CurveExtras.cjs +0 -214
  49. package/curves/CurveExtras.js +0 -214
  50. package/curves/NURBSCurve.cjs +0 -35
  51. package/curves/NURBSCurve.js +0 -35
  52. package/curves/NURBSSurface.cjs +0 -28
  53. package/curves/NURBSSurface.js +0 -28
  54. package/curves/NURBSUtils.cjs +0 -226
  55. package/curves/NURBSUtils.js +0 -226
  56. package/deprecated/Geometry.cjs +0 -971
  57. package/deprecated/Geometry.js +0 -971
  58. package/effects/AnaglyphEffect.cjs +0 -102
  59. package/effects/AnaglyphEffect.js +0 -102
  60. package/effects/AsciiEffect.cjs +0 -155
  61. package/effects/AsciiEffect.js +0 -155
  62. package/effects/OutlineEffect.cjs +0 -275
  63. package/effects/OutlineEffect.js +0 -275
  64. package/effects/ParallaxBarrierEffect.cjs +0 -65
  65. package/effects/ParallaxBarrierEffect.js +0 -65
  66. package/effects/PeppersGhostEffect.cjs +0 -88
  67. package/effects/PeppersGhostEffect.js +0 -88
  68. package/effects/StereoEffect.cjs +0 -35
  69. package/effects/StereoEffect.js +0 -35
  70. package/environments/RoomEnvironment.cjs +0 -95
  71. package/environments/RoomEnvironment.js +0 -78
  72. package/exporters/ColladaExporter.cjs +0 -331
  73. package/exporters/ColladaExporter.js +0 -331
  74. package/exporters/DRACOExporter.cjs +0 -141
  75. package/exporters/DRACOExporter.js +0 -141
  76. package/exporters/GLTFExporter.cjs +0 -1909
  77. package/exporters/GLTFExporter.js +0 -1909
  78. package/exporters/MMDExporter.cjs +0 -131
  79. package/exporters/MMDExporter.js +0 -131
  80. package/exporters/OBJExporter.cjs +0 -181
  81. package/exporters/OBJExporter.js +0 -181
  82. package/exporters/PLYExporter.cjs +0 -280
  83. package/exporters/PLYExporter.js +0 -280
  84. package/exporters/STLExporter.cjs +0 -146
  85. package/exporters/STLExporter.js +0 -146
  86. package/exporters/USDZExporter.cjs +0 -340
  87. package/exporters/USDZExporter.js +0 -340
  88. package/geometries/BoxLineGeometry.cjs +0 -45
  89. package/geometries/BoxLineGeometry.js +0 -45
  90. package/geometries/ConvexGeometry.cjs +0 -26
  91. package/geometries/ConvexGeometry.js +0 -26
  92. package/geometries/DecalGeometry.cjs +0 -184
  93. package/geometries/DecalGeometry.js +0 -184
  94. package/geometries/LightningStrike.cjs +0 -553
  95. package/geometries/LightningStrike.js +0 -553
  96. package/geometries/ParametricGeometries.cjs +0 -130
  97. package/geometries/ParametricGeometries.js +0 -130
  98. package/geometries/ParametricGeometry.cjs +0 -63
  99. package/geometries/ParametricGeometry.js +0 -63
  100. package/geometries/RoundedBoxGeometry.cjs +0 -91
  101. package/geometries/RoundedBoxGeometry.js +0 -91
  102. package/geometries/TeapotGeometry.cjs +0 -1563
  103. package/geometries/TeapotGeometry.js +0 -1563
  104. package/geometries/TextGeometry.cjs +0 -27
  105. package/geometries/TextGeometry.js +0 -27
  106. package/helpers/LightProbeHelper.cjs +0 -73
  107. package/helpers/LightProbeHelper.js +0 -73
  108. package/helpers/PositionalAudioHelper.cjs +0 -68
  109. package/helpers/PositionalAudioHelper.js +0 -68
  110. package/helpers/RectAreaLightHelper.cjs +0 -44
  111. package/helpers/RectAreaLightHelper.js +0 -44
  112. package/helpers/VertexNormalsHelper.cjs +0 -47
  113. package/helpers/VertexNormalsHelper.js +0 -47
  114. package/helpers/VertexTangentsHelper.cjs +0 -43
  115. package/helpers/VertexTangentsHelper.js +0 -43
  116. package/interactive/HTMLMesh.cjs +0 -325
  117. package/interactive/HTMLMesh.js +0 -325
  118. package/interactive/InteractiveGroup.cjs +0 -68
  119. package/interactive/InteractiveGroup.js +0 -68
  120. package/interactive/SelectionBox.cjs +0 -134
  121. package/interactive/SelectionBox.js +0 -134
  122. package/interactive/SelectionHelper.cjs +0 -51
  123. package/interactive/SelectionHelper.js +0 -51
  124. package/libs/MeshoptDecoder.cjs +0 -221
  125. package/libs/MeshoptDecoder.js +0 -221
  126. package/libs/MotionControllers.cjs +0 -325
  127. package/libs/MotionControllers.js +0 -325
  128. package/lights/LightProbeGenerator.cjs +0 -145
  129. package/lights/LightProbeGenerator.js +0 -145
  130. package/lights/RectAreaLightUniformsLib.cjs +0 -32846
  131. package/lights/RectAreaLightUniformsLib.js +0 -32846
  132. package/lines/Line2.cjs +0 -13
  133. package/lines/Line2.js +0 -13
  134. package/lines/LineGeometry.cjs +0 -44
  135. package/lines/LineGeometry.js +0 -44
  136. package/lines/LineMaterial.cjs +0 -547
  137. package/lines/LineMaterial.js +0 -547
  138. package/lines/LineSegments2.cjs +0 -203
  139. package/lines/LineSegments2.js +0 -203
  140. package/lines/LineSegmentsGeometry.cjs +0 -124
  141. package/lines/LineSegmentsGeometry.js +0 -124
  142. package/lines/Wireframe.cjs +0 -32
  143. package/lines/Wireframe.js +0 -32
  144. package/lines/WireframeGeometry2.cjs +0 -13
  145. package/lines/WireframeGeometry2.js +0 -13
  146. package/loaders/3DMLoader.cjs +0 -803
  147. package/loaders/3DMLoader.js +0 -803
  148. package/loaders/3MFLoader.cjs +0 -854
  149. package/loaders/3MFLoader.js +0 -854
  150. package/loaders/AMFLoader.cjs +0 -284
  151. package/loaders/AMFLoader.js +0 -284
  152. package/loaders/AssimpLoader.cjs +0 -1434
  153. package/loaders/AssimpLoader.js +0 -1434
  154. package/loaders/BVHLoader.cjs +0 -207
  155. package/loaders/BVHLoader.js +0 -207
  156. package/loaders/BasisTextureLoader.cjs +0 -489
  157. package/loaders/BasisTextureLoader.js +0 -489
  158. package/loaders/ColladaLoader.cjs +0 -2405
  159. package/loaders/ColladaLoader.js +0 -2405
  160. package/loaders/DDSLoader.cjs +0 -148
  161. package/loaders/DDSLoader.js +0 -148
  162. package/loaders/DRACOLoader.cjs +0 -341
  163. package/loaders/DRACOLoader.js +0 -341
  164. package/loaders/EXRLoader.cjs +0 -1356
  165. package/loaders/EXRLoader.js +0 -1356
  166. package/loaders/FBXLoader.cjs +0 -2457
  167. package/loaders/FBXLoader.js +0 -2457
  168. package/loaders/FontLoader.cjs +0 -123
  169. package/loaders/FontLoader.js +0 -123
  170. package/loaders/GCodeLoader.cjs +0 -141
  171. package/loaders/GCodeLoader.js +0 -141
  172. package/loaders/GLTFLoader.cjs +0 -2504
  173. package/loaders/GLTFLoader.js +0 -2504
  174. package/loaders/HDRCubeTextureLoader.cjs +0 -75
  175. package/loaders/HDRCubeTextureLoader.js +0 -75
  176. package/loaders/KMZLoader.cjs +0 -75
  177. package/loaders/KMZLoader.js +0 -75
  178. package/loaders/KTX2Loader.cjs +0 -480
  179. package/loaders/KTX2Loader.js +0 -480
  180. package/loaders/KTXLoader.cjs +0 -93
  181. package/loaders/KTXLoader.js +0 -93
  182. package/loaders/LDrawLoader.cjs +0 -1424
  183. package/loaders/LDrawLoader.js +0 -1424
  184. package/loaders/LUT3dlLoader.cjs +0 -103
  185. package/loaders/LUT3dlLoader.js +0 -103
  186. package/loaders/LUTCubeLoader.cjs +0 -107
  187. package/loaders/LUTCubeLoader.js +0 -107
  188. package/loaders/LWOLoader.cjs +0 -645
  189. package/loaders/LWOLoader.js +0 -645
  190. package/loaders/LottieLoader.cjs +0 -47
  191. package/loaders/LottieLoader.js +0 -47
  192. package/loaders/MD2Loader.cjs +0 -359
  193. package/loaders/MD2Loader.js +0 -359
  194. package/loaders/MDDLoader.cjs +0 -58
  195. package/loaders/MDDLoader.js +0 -58
  196. package/loaders/MMDLoader.cjs +0 -1121
  197. package/loaders/MMDLoader.js +0 -1121
  198. package/loaders/MTLLoader.cjs +0 -304
  199. package/loaders/MTLLoader.js +0 -304
  200. package/loaders/NRRDLoader.cjs +0 -401
  201. package/loaders/NRRDLoader.js +0 -401
  202. package/loaders/OBJLoader.cjs +0 -487
  203. package/loaders/OBJLoader.js +0 -487
  204. package/loaders/PCDLoader.cjs +0 -248
  205. package/loaders/PCDLoader.js +0 -248
  206. package/loaders/PDBLoader.cjs +0 -247
  207. package/loaders/PDBLoader.js +0 -247
  208. package/loaders/PLYLoader.cjs +0 -317
  209. package/loaders/PLYLoader.js +0 -317
  210. package/loaders/PRWMLoader.cjs +0 -160
  211. package/loaders/PRWMLoader.js +0 -160
  212. package/loaders/PVRLoader.cjs +0 -131
  213. package/loaders/PVRLoader.js +0 -131
  214. package/loaders/RGBELoader.cjs +0 -252
  215. package/loaders/RGBELoader.js +0 -252
  216. package/loaders/RGBMLoader.cjs +0 -1004
  217. package/loaders/RGBMLoader.js +0 -1004
  218. package/loaders/STLLoader.cjs +0 -190
  219. package/loaders/STLLoader.js +0 -190
  220. package/loaders/SVGLoader.cjs +0 -1712
  221. package/loaders/SVGLoader.js +0 -1712
  222. package/loaders/TDSLoader.cjs +0 -650
  223. package/loaders/TDSLoader.js +0 -650
  224. package/loaders/TGALoader.cjs +0 -285
  225. package/loaders/TGALoader.js +0 -285
  226. package/loaders/TTFLoader.cjs +0 -131
  227. package/loaders/TTFLoader.js +0 -131
  228. package/loaders/TiltLoader.cjs +0 -375
  229. package/loaders/TiltLoader.js +0 -375
  230. package/loaders/VOXLoader.cjs +0 -432
  231. package/loaders/VOXLoader.js +0 -432
  232. package/loaders/VRMLLoader.cjs +0 -2105
  233. package/loaders/VRMLLoader.js +0 -2105
  234. package/loaders/VRMLoader.cjs +0 -38
  235. package/loaders/VRMLoader.js +0 -38
  236. package/loaders/VTKLoader.cjs +0 -648
  237. package/loaders/VTKLoader.js +0 -648
  238. package/loaders/XLoader.cjs +0 -1258
  239. package/loaders/XLoader.js +0 -1258
  240. package/loaders/XYZLoader.cjs +0 -60
  241. package/loaders/XYZLoader.js +0 -60
  242. package/loaders/lwo/IFFParser.cjs +0 -743
  243. package/loaders/lwo/IFFParser.js +0 -743
  244. package/loaders/lwo/LWO2Parser.cjs +0 -312
  245. package/loaders/lwo/LWO2Parser.js +0 -312
  246. package/loaders/lwo/LWO3Parser.cjs +0 -282
  247. package/loaders/lwo/LWO3Parser.js +0 -282
  248. package/math/Capsule.cjs +0 -98
  249. package/math/Capsule.js +0 -98
  250. package/math/ColorConverter.cjs +0 -42
  251. package/math/ColorConverter.js +0 -42
  252. package/math/ConvexHull.cjs +0 -596
  253. package/math/ConvexHull.js +0 -596
  254. package/math/ImprovedNoise.cjs +0 -304
  255. package/math/ImprovedNoise.js +0 -304
  256. package/math/Lut.cjs +0 -137
  257. package/math/Lut.js +0 -137
  258. package/math/MeshSurfaceSampler.cjs +0 -103
  259. package/math/MeshSurfaceSampler.js +0 -103
  260. package/math/OBB.cjs +0 -242
  261. package/math/OBB.js +0 -242
  262. package/math/Octree.cjs +0 -273
  263. package/math/Octree.js +0 -273
  264. package/math/SimplexNoise.cjs +0 -440
  265. package/math/SimplexNoise.js +0 -440
  266. package/misc/ConvexObjectBreaker.cjs +0 -292
  267. package/misc/ConvexObjectBreaker.js +0 -292
  268. package/misc/GPUComputationRenderer.cjs +0 -205
  269. package/misc/GPUComputationRenderer.js +0 -205
  270. package/misc/Gyroscope.cjs +0 -33
  271. package/misc/Gyroscope.js +0 -33
  272. package/misc/MD2Character.cjs +0 -167
  273. package/misc/MD2Character.js +0 -167
  274. package/misc/MD2CharacterComplex.cjs +0 -332
  275. package/misc/MD2CharacterComplex.js +0 -332
  276. package/misc/MorphAnimMesh.cjs +0 -40
  277. package/misc/MorphAnimMesh.js +0 -40
  278. package/misc/MorphBlendMesh.cjs +0 -179
  279. package/misc/MorphBlendMesh.js +0 -179
  280. package/misc/ProgressiveLightmap.cjs +0 -186
  281. package/misc/ProgressiveLightmap.js +0 -186
  282. package/misc/RollerCoaster.cjs +0 -353
  283. package/misc/RollerCoaster.js +0 -353
  284. package/misc/Timer.cjs +0 -101
  285. package/misc/Timer.js +0 -101
  286. package/misc/TubePainter.cjs +0 -123
  287. package/misc/TubePainter.js +0 -123
  288. package/misc/Volume.cjs +0 -305
  289. package/misc/Volume.js +0 -305
  290. package/misc/VolumeSlice.cjs +0 -114
  291. package/misc/VolumeSlice.js +0 -114
  292. package/misc/WebGL.cjs +0 -74
  293. package/misc/WebGL.js +0 -74
  294. package/modifiers/CurveModifier.cjs +0 -232
  295. package/modifiers/CurveModifier.js +0 -232
  296. package/modifiers/EdgeSplitModifier.cjs +0 -167
  297. package/modifiers/EdgeSplitModifier.js +0 -168
  298. package/modifiers/SimplifyModifier.cjs +0 -301
  299. package/modifiers/SimplifyModifier.js +0 -301
  300. package/modifiers/TessellateModifier.cjs +0 -214
  301. package/modifiers/TessellateModifier.js +0 -214
  302. package/objects/GroundProjectedEnv.cjs +0 -134
  303. package/objects/GroundProjectedEnv.js +0 -134
  304. package/objects/Lensflare.cjs +0 -291
  305. package/objects/Lensflare.js +0 -291
  306. package/objects/LightningStorm.cjs +0 -110
  307. package/objects/LightningStorm.js +0 -110
  308. package/objects/MarchingCubes.cjs +0 -4809
  309. package/objects/MarchingCubes.js +0 -4809
  310. package/objects/Reflector.cjs +0 -202
  311. package/objects/Reflector.js +0 -202
  312. package/objects/ReflectorForSSRPass.cjs +0 -260
  313. package/objects/ReflectorForSSRPass.js +0 -260
  314. package/objects/ReflectorRTT.cjs +0 -10
  315. package/objects/ReflectorRTT.js +0 -10
  316. package/objects/Refractor.cjs +0 -215
  317. package/objects/Refractor.js +0 -215
  318. package/objects/ShadowMesh.cjs +0 -45
  319. package/objects/ShadowMesh.js +0 -45
  320. package/objects/Sky.cjs +0 -200
  321. package/objects/Sky.js +0 -200
  322. package/objects/Water.cjs +0 -242
  323. package/objects/Water.js +0 -242
  324. package/objects/Water2.cjs +0 -256
  325. package/objects/Water2.js +0 -256
  326. package/physics/AmmoPhysics.cjs +0 -166
  327. package/physics/AmmoPhysics.js +0 -166
  328. package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
  329. package/postprocessing/AdaptiveToneMappingPass.js +0 -218
  330. package/postprocessing/AfterimagePass.cjs +0 -68
  331. package/postprocessing/AfterimagePass.js +0 -68
  332. package/postprocessing/BloomPass.cjs +0 -109
  333. package/postprocessing/BloomPass.js +0 -109
  334. package/postprocessing/BokehPass.cjs +0 -90
  335. package/postprocessing/BokehPass.js +0 -90
  336. package/postprocessing/ClearPass.cjs +0 -36
  337. package/postprocessing/ClearPass.js +0 -36
  338. package/postprocessing/CubeTexturePass.cjs +0 -53
  339. package/postprocessing/CubeTexturePass.js +0 -53
  340. package/postprocessing/DotScreenPass.cjs +0 -49
  341. package/postprocessing/DotScreenPass.js +0 -49
  342. package/postprocessing/EffectComposer.cjs +0 -157
  343. package/postprocessing/EffectComposer.js +0 -157
  344. package/postprocessing/FilmPass.cjs +0 -51
  345. package/postprocessing/FilmPass.js +0 -51
  346. package/postprocessing/GlitchPass.cjs +0 -84
  347. package/postprocessing/GlitchPass.js +0 -84
  348. package/postprocessing/HalftonePass.cjs +0 -53
  349. package/postprocessing/HalftonePass.js +0 -53
  350. package/postprocessing/LUTPass.cjs +0 -142
  351. package/postprocessing/LUTPass.js +0 -142
  352. package/postprocessing/MaskPass.cjs +0 -69
  353. package/postprocessing/MaskPass.js +0 -69
  354. package/postprocessing/OutlinePass.cjs +0 -479
  355. package/postprocessing/OutlinePass.js +0 -479
  356. package/postprocessing/Pass.cjs +0 -48
  357. package/postprocessing/Pass.js +0 -48
  358. package/postprocessing/RenderPass.cjs +0 -59
  359. package/postprocessing/RenderPass.js +0 -59
  360. package/postprocessing/RenderPixelatedPass.cjs +0 -199
  361. package/postprocessing/RenderPixelatedPass.js +0 -199
  362. package/postprocessing/SAOPass.cjs +0 -288
  363. package/postprocessing/SAOPass.js +0 -288
  364. package/postprocessing/SMAAPass.cjs +0 -112
  365. package/postprocessing/SMAAPass.js +0 -112
  366. package/postprocessing/SSAARenderPass.cjs +0 -189
  367. package/postprocessing/SSAARenderPass.js +0 -189
  368. package/postprocessing/SSAOPass.cjs +0 -272
  369. package/postprocessing/SSAOPass.js +0 -272
  370. package/postprocessing/SSRPass.cjs +0 -411
  371. package/postprocessing/SSRPass.js +0 -411
  372. package/postprocessing/SavePass.cjs +0 -38
  373. package/postprocessing/SavePass.js +0 -38
  374. package/postprocessing/ShaderPass.cjs +0 -49
  375. package/postprocessing/ShaderPass.js +0 -49
  376. package/postprocessing/TAARenderPass.cjs +0 -174
  377. package/postprocessing/TAARenderPass.js +0 -174
  378. package/postprocessing/TexturePass.cjs +0 -42
  379. package/postprocessing/TexturePass.js +0 -42
  380. package/postprocessing/UnrealBloomPass.cjs +0 -277
  381. package/postprocessing/UnrealBloomPass.js +0 -277
  382. package/postprocessing/WaterPass.cjs +0 -72
  383. package/postprocessing/WaterPass.js +0 -72
  384. package/renderers/CSS2DRenderer.cjs +0 -122
  385. package/renderers/CSS2DRenderer.js +0 -122
  386. package/renderers/CSS3DRenderer.cjs +0 -167
  387. package/renderers/CSS3DRenderer.js +0 -167
  388. package/renderers/Projector.cjs +0 -499
  389. package/renderers/Projector.js +0 -499
  390. package/renderers/SVGRenderer.cjs +0 -311
  391. package/renderers/SVGRenderer.js +0 -311
  392. package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
  393. package/shaders/ACESFilmicToneMappingShader.js +0 -55
  394. package/shaders/AfterimageShader.cjs +0 -32
  395. package/shaders/AfterimageShader.js +0 -32
  396. package/shaders/BasicShader.cjs +0 -12
  397. package/shaders/BasicShader.js +0 -12
  398. package/shaders/BleachBypassShader.cjs +0 -35
  399. package/shaders/BleachBypassShader.js +0 -35
  400. package/shaders/BlendShader.cjs +0 -30
  401. package/shaders/BlendShader.js +0 -30
  402. package/shaders/BokehShader.cjs +0 -109
  403. package/shaders/BokehShader.js +0 -109
  404. package/shaders/BokehShader2.cjs +0 -269
  405. package/shaders/BokehShader2.js +0 -269
  406. package/shaders/BrightnessContrastShader.cjs +0 -32
  407. package/shaders/BrightnessContrastShader.js +0 -32
  408. package/shaders/ColorCorrectionShader.cjs +0 -30
  409. package/shaders/ColorCorrectionShader.js +0 -30
  410. package/shaders/ColorifyShader.cjs +0 -28
  411. package/shaders/ColorifyShader.js +0 -28
  412. package/shaders/ConvolutionShader.cjs +0 -55
  413. package/shaders/ConvolutionShader.js +0 -55
  414. package/shaders/CopyShader.cjs +0 -25
  415. package/shaders/CopyShader.js +0 -25
  416. package/shaders/DOFMipMapShader.cjs +0 -32
  417. package/shaders/DOFMipMapShader.js +0 -32
  418. package/shaders/DepthLimitedBlurShader.cjs +0 -114
  419. package/shaders/DepthLimitedBlurShader.js +0 -114
  420. package/shaders/DigitalGlitch.cjs +0 -85
  421. package/shaders/DigitalGlitch.js +0 -85
  422. package/shaders/DotScreenShader.cjs +0 -39
  423. package/shaders/DotScreenShader.js +0 -39
  424. package/shaders/FXAAShader.cjs +0 -1098
  425. package/shaders/FXAAShader.js +0 -1098
  426. package/shaders/FilmShader.cjs +0 -53
  427. package/shaders/FilmShader.js +0 -53
  428. package/shaders/FocusShader.cjs +0 -55
  429. package/shaders/FocusShader.js +0 -55
  430. package/shaders/FreiChenShader.cjs +0 -64
  431. package/shaders/FreiChenShader.js +0 -64
  432. package/shaders/FresnelShader.cjs +0 -47
  433. package/shaders/FresnelShader.js +0 -47
  434. package/shaders/GammaCorrectionShader.cjs +0 -23
  435. package/shaders/GammaCorrectionShader.js +0 -23
  436. package/shaders/GodRaysShader.cjs +0 -183
  437. package/shaders/GodRaysShader.js +0 -183
  438. package/shaders/HalftoneShader.cjs +0 -228
  439. package/shaders/HalftoneShader.js +0 -228
  440. package/shaders/HorizontalBlurShader.cjs +0 -49
  441. package/shaders/HorizontalBlurShader.js +0 -49
  442. package/shaders/HorizontalTiltShiftShader.cjs +0 -37
  443. package/shaders/HorizontalTiltShiftShader.js +0 -37
  444. package/shaders/HueSaturationShader.cjs +0 -43
  445. package/shaders/HueSaturationShader.js +0 -43
  446. package/shaders/KaleidoShader.cjs +0 -34
  447. package/shaders/KaleidoShader.js +0 -34
  448. package/shaders/LuminosityHighPassShader.cjs +0 -37
  449. package/shaders/LuminosityHighPassShader.js +0 -37
  450. package/shaders/LuminosityShader.cjs +0 -25
  451. package/shaders/LuminosityShader.js +0 -25
  452. package/shaders/MirrorShader.cjs +0 -35
  453. package/shaders/MirrorShader.js +0 -35
  454. package/shaders/NormalMapShader.cjs +0 -31
  455. package/shaders/NormalMapShader.js +0 -31
  456. package/shaders/ParallaxShader.cjs +0 -133
  457. package/shaders/ParallaxShader.js +0 -133
  458. package/shaders/PixelShader.cjs +0 -28
  459. package/shaders/PixelShader.js +0 -28
  460. package/shaders/RGBShiftShader.cjs +0 -30
  461. package/shaders/RGBShiftShader.js +0 -30
  462. package/shaders/SAOShader.cjs +0 -144
  463. package/shaders/SAOShader.js +0 -144
  464. package/shaders/SMAAShader.cjs +0 -358
  465. package/shaders/SMAAShader.js +0 -358
  466. package/shaders/SSAOShader.cjs +0 -182
  467. package/shaders/SSAOShader.js +0 -182
  468. package/shaders/SSRShader.cjs +0 -342
  469. package/shaders/SSRShader.js +0 -342
  470. package/shaders/SepiaShader.cjs +0 -29
  471. package/shaders/SepiaShader.js +0 -29
  472. package/shaders/SobelOperatorShader.cjs +0 -54
  473. package/shaders/SobelOperatorShader.js +0 -54
  474. package/shaders/SubsurfaceScatteringShader.cjs +0 -98
  475. package/shaders/SubsurfaceScatteringShader.js +0 -98
  476. package/shaders/TechnicolorShader.cjs +0 -24
  477. package/shaders/TechnicolorShader.js +0 -24
  478. package/shaders/ToneMapShader.cjs +0 -51
  479. package/shaders/ToneMapShader.js +0 -51
  480. package/shaders/ToonShader.cjs +0 -188
  481. package/shaders/ToonShader.js +0 -188
  482. package/shaders/TriangleBlurShader.cjs +0 -37
  483. package/shaders/TriangleBlurShader.js +0 -37
  484. package/shaders/UnpackDepthRGBAShader.cjs +0 -26
  485. package/shaders/UnpackDepthRGBAShader.js +0 -26
  486. package/shaders/VerticalBlurShader.cjs +0 -50
  487. package/shaders/VerticalBlurShader.js +0 -50
  488. package/shaders/VerticalTiltShiftShader.cjs +0 -37
  489. package/shaders/VerticalTiltShiftShader.js +0 -37
  490. package/shaders/VignetteShader.cjs +0 -38
  491. package/shaders/VignetteShader.js +0 -38
  492. package/shaders/VolumeShader.cjs +0 -225
  493. package/shaders/VolumeShader.js +0 -225
  494. package/shaders/WaterRefractionShader.cjs +0 -59
  495. package/shaders/WaterRefractionShader.js +0 -59
  496. package/shaders/types.cjs +0 -1
  497. package/shaders/types.js +0 -1
  498. package/textures/FlakesTexture.cjs +0 -30
  499. package/textures/FlakesTexture.js +0 -30
  500. package/types/helpers.cjs +0 -4
  501. package/types/helpers.js +0 -4
  502. package/utils/BufferGeometryUtils.cjs +0 -636
  503. package/utils/BufferGeometryUtils.js +0 -636
  504. package/utils/GeometryCompressionUtils.cjs +0 -573
  505. package/utils/GeometryCompressionUtils.js +0 -573
  506. package/utils/GeometryUtils.cjs +0 -109
  507. package/utils/GeometryUtils.js +0 -109
  508. package/utils/RoughnessMipmapper.cjs +0 -223
  509. package/utils/RoughnessMipmapper.js +0 -223
  510. package/utils/SceneUtils.cjs +0 -36
  511. package/utils/SceneUtils.js +0 -36
  512. package/utils/ShadowMapViewer.cjs +0 -111
  513. package/utils/ShadowMapViewer.js +0 -111
  514. package/utils/SkeletonUtils.cjs +0 -211
  515. package/utils/SkeletonUtils.js +0 -211
  516. package/utils/UVsDebug.cjs +0 -80
  517. package/utils/UVsDebug.js +0 -80
  518. package/utils/WorkerPool.cjs +0 -62
  519. package/utils/WorkerPool.js +0 -62
  520. package/webxr/ARButton.cjs +0 -119
  521. package/webxr/ARButton.js +0 -119
  522. package/webxr/OculusHandModel.cjs +0 -82
  523. package/webxr/OculusHandModel.js +0 -82
  524. package/webxr/OculusHandPointerModel.cjs +0 -241
  525. package/webxr/OculusHandPointerModel.js +0 -224
  526. package/webxr/Text2D.cjs +0 -48
  527. package/webxr/Text2D.js +0 -31
  528. package/webxr/VRButton.cjs +0 -111
  529. package/webxr/VRButton.js +0 -111
  530. package/webxr/XRControllerModelFactory.cjs +0 -174
  531. package/webxr/XRControllerModelFactory.js +0 -174
  532. package/webxr/XREstimatedLight.cjs +0 -126
  533. package/webxr/XREstimatedLight.js +0 -126
  534. package/webxr/XRHandMeshModel.cjs +0 -82
  535. package/webxr/XRHandMeshModel.js +0 -82
  536. package/webxr/XRHandModelFactory.cjs +0 -61
  537. package/webxr/XRHandModelFactory.js +0 -61
  538. package/webxr/XRHandPrimitiveModel.cjs +0 -68
  539. package/webxr/XRHandPrimitiveModel.js +0 -68
@@ -1,2033 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { Matrix4, EventDispatcher, Vector2, Vector3, Quaternion, Group, EllipseCurve, BufferGeometry, PerspectiveCamera, MathUtils, OrthographicCamera, Box3, Sphere, GridHelper, LineBasicMaterial, Line, Raycaster } from "three";
8
- const STATE = {
9
- IDLE: Symbol(),
10
- ROTATE: Symbol(),
11
- PAN: Symbol(),
12
- SCALE: Symbol(),
13
- FOV: Symbol(),
14
- FOCUS: Symbol(),
15
- ZROTATE: Symbol(),
16
- TOUCH_MULTI: Symbol(),
17
- ANIMATION_FOCUS: Symbol(),
18
- ANIMATION_ROTATE: Symbol()
19
- };
20
- const INPUT = {
21
- NONE: Symbol(),
22
- ONE_FINGER: Symbol(),
23
- ONE_FINGER_SWITCHED: Symbol(),
24
- TWO_FINGER: Symbol(),
25
- MULT_FINGER: Symbol(),
26
- CURSOR: Symbol()
27
- };
28
- const _center = {
29
- x: 0,
30
- y: 0
31
- };
32
- const _transformation = {
33
- camera: /* @__PURE__ */ new Matrix4(),
34
- gizmos: /* @__PURE__ */ new Matrix4()
35
- };
36
- const _changeEvent = { type: "change" };
37
- const _startEvent = { type: "start" };
38
- const _endEvent = { type: "end" };
39
- class ArcballControls extends EventDispatcher {
40
- constructor(camera, domElement = null, scene = null) {
41
- super();
42
- __publicField(this, "camera");
43
- __publicField(this, "domElement");
44
- __publicField(this, "scene");
45
- __publicField(this, "mouseActions");
46
- __publicField(this, "_mouseOp");
47
- __publicField(this, "_v2_1");
48
- __publicField(this, "_v3_1");
49
- __publicField(this, "_v3_2");
50
- __publicField(this, "_m4_1");
51
- __publicField(this, "_m4_2");
52
- __publicField(this, "_quat");
53
- __publicField(this, "_translationMatrix");
54
- __publicField(this, "_rotationMatrix");
55
- __publicField(this, "_scaleMatrix");
56
- __publicField(this, "_rotationAxis");
57
- __publicField(this, "_cameraMatrixState");
58
- __publicField(this, "_cameraProjectionState");
59
- __publicField(this, "_fovState");
60
- __publicField(this, "_upState");
61
- __publicField(this, "_zoomState");
62
- __publicField(this, "_nearPos");
63
- __publicField(this, "_farPos");
64
- __publicField(this, "_gizmoMatrixState");
65
- __publicField(this, "_up0");
66
- __publicField(this, "_zoom0");
67
- __publicField(this, "_fov0");
68
- __publicField(this, "_initialNear");
69
- __publicField(this, "_nearPos0");
70
- __publicField(this, "_initialFar");
71
- __publicField(this, "_farPos0");
72
- __publicField(this, "_cameraMatrixState0");
73
- __publicField(this, "_gizmoMatrixState0");
74
- __publicField(this, "_button");
75
- __publicField(this, "_touchStart");
76
- __publicField(this, "_touchCurrent");
77
- __publicField(this, "_input");
78
- __publicField(this, "_switchSensibility");
79
- __publicField(this, "_startFingerDistance");
80
- __publicField(this, "_currentFingerDistance");
81
- __publicField(this, "_startFingerRotation");
82
- __publicField(this, "_currentFingerRotation");
83
- __publicField(this, "_devPxRatio");
84
- __publicField(this, "_downValid");
85
- __publicField(this, "_nclicks");
86
- __publicField(this, "_downEvents");
87
- __publicField(this, "_clickStart");
88
- __publicField(this, "_maxDownTime");
89
- __publicField(this, "_maxInterval");
90
- __publicField(this, "_posThreshold");
91
- __publicField(this, "_movementThreshold");
92
- __publicField(this, "_currentCursorPosition");
93
- __publicField(this, "_startCursorPosition");
94
- __publicField(this, "_grid");
95
- __publicField(this, "_gridPosition");
96
- __publicField(this, "_gizmos");
97
- __publicField(this, "_curvePts");
98
- __publicField(this, "_timeStart");
99
- __publicField(this, "_animationId");
100
- __publicField(this, "focusAnimationTime");
101
- __publicField(this, "_timePrev");
102
- __publicField(this, "_timeCurrent");
103
- __publicField(this, "_anglePrev");
104
- __publicField(this, "_angleCurrent");
105
- __publicField(this, "_cursorPosPrev");
106
- __publicField(this, "_cursorPosCurr");
107
- __publicField(this, "_wPrev");
108
- __publicField(this, "_wCurr");
109
- __publicField(this, "adjustNearFar");
110
- __publicField(this, "scaleFactor");
111
- __publicField(this, "dampingFactor");
112
- __publicField(this, "wMax");
113
- __publicField(this, "enableAnimations");
114
- __publicField(this, "enableGrid");
115
- __publicField(this, "cursorZoom");
116
- __publicField(this, "minFov");
117
- __publicField(this, "maxFov");
118
- __publicField(this, "enabled");
119
- __publicField(this, "enablePan");
120
- __publicField(this, "enableRotate");
121
- __publicField(this, "enableZoom");
122
- __publicField(this, "minDistance");
123
- __publicField(this, "maxDistance");
124
- __publicField(this, "minZoom");
125
- __publicField(this, "maxZoom");
126
- __publicField(this, "target");
127
- __publicField(this, "_currentTarget");
128
- __publicField(this, "_tbRadius");
129
- __publicField(this, "_state");
130
- //listeners
131
- __publicField(this, "onWindowResize", () => {
132
- const scale = (this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z) / 3;
133
- if (this.camera) {
134
- const tbRadius = this.calculateTbRadius(this.camera);
135
- if (tbRadius !== void 0) {
136
- this._tbRadius = tbRadius;
137
- }
138
- }
139
- const newRadius = this._tbRadius / scale;
140
- const curve = new EllipseCurve(0, 0, newRadius, newRadius);
141
- const points = curve.getPoints(this._curvePts);
142
- const curveGeometry = new BufferGeometry().setFromPoints(points);
143
- for (const gizmo in this._gizmos.children) {
144
- const child = this._gizmos.children[gizmo];
145
- child.geometry = curveGeometry;
146
- }
147
- this.dispatchEvent(_changeEvent);
148
- });
149
- __publicField(this, "onContextMenu", (event) => {
150
- if (!this.enabled) {
151
- return;
152
- }
153
- for (let i = 0; i < this.mouseActions.length; i++) {
154
- if (this.mouseActions[i].mouse == 2) {
155
- event.preventDefault();
156
- break;
157
- }
158
- }
159
- });
160
- __publicField(this, "onPointerCancel", () => {
161
- this._touchStart.splice(0, this._touchStart.length);
162
- this._touchCurrent.splice(0, this._touchCurrent.length);
163
- this._input = INPUT.NONE;
164
- });
165
- __publicField(this, "onPointerDown", (event) => {
166
- if (event.button == 0 && event.isPrimary) {
167
- this._downValid = true;
168
- this._downEvents.push(event);
169
- } else {
170
- this._downValid = false;
171
- }
172
- if (event.pointerType == "touch" && this._input != INPUT.CURSOR) {
173
- this._touchStart.push(event);
174
- this._touchCurrent.push(event);
175
- switch (this._input) {
176
- case INPUT.NONE:
177
- this._input = INPUT.ONE_FINGER;
178
- this.onSinglePanStart(event, "ROTATE");
179
- window.addEventListener("pointermove", this.onPointerMove);
180
- window.addEventListener("pointerup", this.onPointerUp);
181
- break;
182
- case INPUT.ONE_FINGER:
183
- case INPUT.ONE_FINGER_SWITCHED:
184
- this._input = INPUT.TWO_FINGER;
185
- this.onRotateStart();
186
- this.onPinchStart();
187
- this.onDoublePanStart();
188
- break;
189
- case INPUT.TWO_FINGER:
190
- this._input = INPUT.MULT_FINGER;
191
- this.onTriplePanStart();
192
- break;
193
- }
194
- } else if (event.pointerType != "touch" && this._input == INPUT.NONE) {
195
- let modifier = null;
196
- if (event.ctrlKey || event.metaKey) {
197
- modifier = "CTRL";
198
- } else if (event.shiftKey) {
199
- modifier = "SHIFT";
200
- }
201
- this._mouseOp = this.getOpFromAction(event.button, modifier);
202
- if (this._mouseOp) {
203
- window.addEventListener("pointermove", this.onPointerMove);
204
- window.addEventListener("pointerup", this.onPointerUp);
205
- this._input = INPUT.CURSOR;
206
- this._button = event.button;
207
- this.onSinglePanStart(event, this._mouseOp);
208
- }
209
- }
210
- });
211
- __publicField(this, "onPointerMove", (event) => {
212
- if (event.pointerType == "touch" && this._input != INPUT.CURSOR) {
213
- switch (this._input) {
214
- case INPUT.ONE_FINGER:
215
- this.updateTouchEvent(event);
216
- this.onSinglePanMove(event, STATE.ROTATE);
217
- break;
218
- case INPUT.ONE_FINGER_SWITCHED:
219
- const movement = this.calculatePointersDistance(this._touchCurrent[0], event) * this._devPxRatio;
220
- if (movement >= this._switchSensibility) {
221
- this._input = INPUT.ONE_FINGER;
222
- this.updateTouchEvent(event);
223
- this.onSinglePanStart(event, "ROTATE");
224
- break;
225
- }
226
- break;
227
- case INPUT.TWO_FINGER:
228
- this.updateTouchEvent(event);
229
- this.onRotateMove();
230
- this.onPinchMove();
231
- this.onDoublePanMove();
232
- break;
233
- case INPUT.MULT_FINGER:
234
- this.updateTouchEvent(event);
235
- this.onTriplePanMove();
236
- break;
237
- }
238
- } else if (event.pointerType != "touch" && this._input == INPUT.CURSOR) {
239
- let modifier = null;
240
- if (event.ctrlKey || event.metaKey) {
241
- modifier = "CTRL";
242
- } else if (event.shiftKey) {
243
- modifier = "SHIFT";
244
- }
245
- const mouseOpState = this.getOpStateFromAction(this._button, modifier);
246
- if (mouseOpState) {
247
- this.onSinglePanMove(event, mouseOpState);
248
- }
249
- }
250
- if (this._downValid) {
251
- const movement = this.calculatePointersDistance(this._downEvents[this._downEvents.length - 1], event) * this._devPxRatio;
252
- if (movement > this._movementThreshold) {
253
- this._downValid = false;
254
- }
255
- }
256
- });
257
- __publicField(this, "onPointerUp", (event) => {
258
- if (event.pointerType == "touch" && this._input != INPUT.CURSOR) {
259
- const nTouch = this._touchCurrent.length;
260
- for (let i = 0; i < nTouch; i++) {
261
- if (this._touchCurrent[i].pointerId == event.pointerId) {
262
- this._touchCurrent.splice(i, 1);
263
- this._touchStart.splice(i, 1);
264
- break;
265
- }
266
- }
267
- switch (this._input) {
268
- case INPUT.ONE_FINGER:
269
- case INPUT.ONE_FINGER_SWITCHED:
270
- window.removeEventListener("pointermove", this.onPointerMove);
271
- window.removeEventListener("pointerup", this.onPointerUp);
272
- this._input = INPUT.NONE;
273
- this.onSinglePanEnd();
274
- break;
275
- case INPUT.TWO_FINGER:
276
- this.onDoublePanEnd();
277
- this.onPinchEnd();
278
- this.onRotateEnd();
279
- this._input = INPUT.ONE_FINGER_SWITCHED;
280
- break;
281
- case INPUT.MULT_FINGER:
282
- if (this._touchCurrent.length == 0) {
283
- window.removeEventListener("pointermove", this.onPointerMove);
284
- window.removeEventListener("pointerup", this.onPointerUp);
285
- this._input = INPUT.NONE;
286
- this.onTriplePanEnd();
287
- }
288
- break;
289
- }
290
- } else if (event.pointerType != "touch" && this._input == INPUT.CURSOR) {
291
- window.removeEventListener("pointermove", this.onPointerMove);
292
- window.removeEventListener("pointerup", this.onPointerUp);
293
- this._input = INPUT.NONE;
294
- this.onSinglePanEnd();
295
- this._button = -1;
296
- }
297
- if (event.isPrimary) {
298
- if (this._downValid) {
299
- const downTime = event.timeStamp - this._downEvents[this._downEvents.length - 1].timeStamp;
300
- if (downTime <= this._maxDownTime) {
301
- if (this._nclicks == 0) {
302
- this._nclicks = 1;
303
- this._clickStart = performance.now();
304
- } else {
305
- const clickInterval = event.timeStamp - this._clickStart;
306
- const movement = this.calculatePointersDistance(this._downEvents[1], this._downEvents[0]) * this._devPxRatio;
307
- if (clickInterval <= this._maxInterval && movement <= this._posThreshold) {
308
- this._nclicks = 0;
309
- this._downEvents.splice(0, this._downEvents.length);
310
- this.onDoubleTap(event);
311
- } else {
312
- this._nclicks = 1;
313
- this._downEvents.shift();
314
- this._clickStart = performance.now();
315
- }
316
- }
317
- } else {
318
- this._downValid = false;
319
- this._nclicks = 0;
320
- this._downEvents.splice(0, this._downEvents.length);
321
- }
322
- } else {
323
- this._nclicks = 0;
324
- this._downEvents.splice(0, this._downEvents.length);
325
- }
326
- }
327
- });
328
- __publicField(this, "onWheel", (event) => {
329
- var _a, _b;
330
- if (this.enabled && this.enableZoom && this.domElement) {
331
- let modifier = null;
332
- if (event.ctrlKey || event.metaKey) {
333
- modifier = "CTRL";
334
- } else if (event.shiftKey) {
335
- modifier = "SHIFT";
336
- }
337
- const mouseOp = this.getOpFromAction("WHEEL", modifier);
338
- if (mouseOp) {
339
- event.preventDefault();
340
- this.dispatchEvent(_startEvent);
341
- const notchDeltaY = 125;
342
- let sgn = event.deltaY / notchDeltaY;
343
- let size = 1;
344
- if (sgn > 0) {
345
- size = 1 / this.scaleFactor;
346
- } else if (sgn < 0) {
347
- size = this.scaleFactor;
348
- }
349
- switch (mouseOp) {
350
- case "ZOOM":
351
- this.updateTbState(STATE.SCALE, true);
352
- if (sgn > 0) {
353
- size = 1 / Math.pow(this.scaleFactor, sgn);
354
- } else if (sgn < 0) {
355
- size = Math.pow(this.scaleFactor, -sgn);
356
- }
357
- if (this.cursorZoom && this.enablePan) {
358
- let scalePoint;
359
- if (this.camera instanceof OrthographicCamera) {
360
- scalePoint = (_a = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement)) == null ? void 0 : _a.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._gizmos.position);
361
- }
362
- if (this.camera instanceof PerspectiveCamera) {
363
- scalePoint = (_b = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement)) == null ? void 0 : _b.applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
364
- }
365
- if (scalePoint !== void 0)
366
- this.applyTransformMatrix(this.applyScale(size, scalePoint));
367
- } else {
368
- this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
369
- }
370
- if (this._grid) {
371
- this.disposeGrid();
372
- this.drawGrid();
373
- }
374
- this.updateTbState(STATE.IDLE, false);
375
- this.dispatchEvent(_changeEvent);
376
- this.dispatchEvent(_endEvent);
377
- break;
378
- case "FOV":
379
- if (this.camera instanceof PerspectiveCamera) {
380
- this.updateTbState(STATE.FOV, true);
381
- if (event.deltaX != 0) {
382
- sgn = event.deltaX / notchDeltaY;
383
- size = 1;
384
- if (sgn > 0) {
385
- size = 1 / Math.pow(this.scaleFactor, sgn);
386
- } else if (sgn < 0) {
387
- size = Math.pow(this.scaleFactor, -sgn);
388
- }
389
- }
390
- this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
391
- const x = this._v3_1.distanceTo(this._gizmos.position);
392
- let xNew = x / size;
393
- xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);
394
- const y = x * Math.tan(MathUtils.DEG2RAD * this.camera.fov * 0.5);
395
- let newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2);
396
- if (newFov > this.maxFov) {
397
- newFov = this.maxFov;
398
- } else if (newFov < this.minFov) {
399
- newFov = this.minFov;
400
- }
401
- const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
402
- size = x / newDistance;
403
- this.setFov(newFov);
404
- this.applyTransformMatrix(this.applyScale(size, this._gizmos.position, false));
405
- }
406
- if (this._grid) {
407
- this.disposeGrid();
408
- this.drawGrid();
409
- }
410
- this.updateTbState(STATE.IDLE, false);
411
- this.dispatchEvent(_changeEvent);
412
- this.dispatchEvent(_endEvent);
413
- break;
414
- }
415
- }
416
- }
417
- });
418
- __publicField(this, "onSinglePanStart", (event, operation) => {
419
- if (this.enabled && this.domElement) {
420
- this.dispatchEvent(_startEvent);
421
- this.setCenter(event.clientX, event.clientY);
422
- switch (operation) {
423
- case "PAN":
424
- if (!this.enablePan)
425
- return;
426
- if (this._animationId != -1) {
427
- cancelAnimationFrame(this._animationId);
428
- this._animationId = -1;
429
- this._timeStart = -1;
430
- this.activateGizmos(false);
431
- this.dispatchEvent(_changeEvent);
432
- }
433
- if (this.camera) {
434
- this.updateTbState(STATE.PAN, true);
435
- const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
436
- if (rayDir !== void 0) {
437
- this._startCursorPosition.copy(rayDir);
438
- }
439
- if (this.enableGrid) {
440
- this.drawGrid();
441
- this.dispatchEvent(_changeEvent);
442
- }
443
- }
444
- break;
445
- case "ROTATE":
446
- if (!this.enableRotate)
447
- return;
448
- if (this._animationId != -1) {
449
- cancelAnimationFrame(this._animationId);
450
- this._animationId = -1;
451
- this._timeStart = -1;
452
- }
453
- if (this.camera) {
454
- this.updateTbState(STATE.ROTATE, true);
455
- const rayDir = this.unprojectOnTbSurface(this.camera, _center.x, _center.y, this.domElement, this._tbRadius);
456
- if (rayDir !== void 0) {
457
- this._startCursorPosition.copy(rayDir);
458
- }
459
- this.activateGizmos(true);
460
- if (this.enableAnimations) {
461
- this._timePrev = this._timeCurrent = performance.now();
462
- this._angleCurrent = this._anglePrev = 0;
463
- this._cursorPosPrev.copy(this._startCursorPosition);
464
- this._cursorPosCurr.copy(this._cursorPosPrev);
465
- this._wCurr = 0;
466
- this._wPrev = this._wCurr;
467
- }
468
- }
469
- this.dispatchEvent(_changeEvent);
470
- break;
471
- case "FOV":
472
- if (!this.enableZoom)
473
- return;
474
- if (this.camera instanceof PerspectiveCamera) {
475
- if (this._animationId != -1) {
476
- cancelAnimationFrame(this._animationId);
477
- this._animationId = -1;
478
- this._timeStart = -1;
479
- this.activateGizmos(false);
480
- this.dispatchEvent(_changeEvent);
481
- }
482
- this.updateTbState(STATE.FOV, true);
483
- this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
484
- this._currentCursorPosition.copy(this._startCursorPosition);
485
- }
486
- break;
487
- case "ZOOM":
488
- if (!this.enableZoom)
489
- return;
490
- if (this._animationId != -1) {
491
- cancelAnimationFrame(this._animationId);
492
- this._animationId = -1;
493
- this._timeStart = -1;
494
- this.activateGizmos(false);
495
- this.dispatchEvent(_changeEvent);
496
- }
497
- this.updateTbState(STATE.SCALE, true);
498
- this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
499
- this._currentCursorPosition.copy(this._startCursorPosition);
500
- break;
501
- }
502
- }
503
- });
504
- __publicField(this, "onSinglePanMove", (event, opState) => {
505
- if (this.enabled && this.domElement) {
506
- const restart = opState != this._state;
507
- this.setCenter(event.clientX, event.clientY);
508
- switch (opState) {
509
- case STATE.PAN:
510
- if (this.enablePan && this.camera) {
511
- if (restart) {
512
- this.dispatchEvent(_endEvent);
513
- this.dispatchEvent(_startEvent);
514
- this.updateTbState(opState, true);
515
- const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
516
- if (rayDir !== void 0) {
517
- this._startCursorPosition.copy(rayDir);
518
- }
519
- if (this.enableGrid) {
520
- this.drawGrid();
521
- }
522
- this.activateGizmos(false);
523
- } else {
524
- const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
525
- if (rayDir !== void 0) {
526
- this._currentCursorPosition.copy(rayDir);
527
- }
528
- this.applyTransformMatrix(this.pan(this._startCursorPosition, this._currentCursorPosition));
529
- }
530
- }
531
- break;
532
- case STATE.ROTATE:
533
- if (this.enableRotate && this.camera) {
534
- if (restart) {
535
- this.dispatchEvent(_endEvent);
536
- this.dispatchEvent(_startEvent);
537
- this.updateTbState(opState, true);
538
- const rayDir = this.unprojectOnTbSurface(
539
- this.camera,
540
- _center.x,
541
- _center.y,
542
- this.domElement,
543
- this._tbRadius
544
- );
545
- if (rayDir !== void 0) {
546
- this._startCursorPosition.copy(rayDir);
547
- }
548
- if (this.enableGrid) {
549
- this.disposeGrid();
550
- }
551
- this.activateGizmos(true);
552
- } else {
553
- const rayDir = this.unprojectOnTbSurface(
554
- this.camera,
555
- _center.x,
556
- _center.y,
557
- this.domElement,
558
- this._tbRadius
559
- );
560
- if (rayDir !== void 0) {
561
- this._currentCursorPosition.copy(rayDir);
562
- }
563
- const distance = this._startCursorPosition.distanceTo(this._currentCursorPosition);
564
- const angle = this._startCursorPosition.angleTo(this._currentCursorPosition);
565
- const amount = Math.max(distance / this._tbRadius, angle);
566
- this.applyTransformMatrix(
567
- this.rotate(this.calculateRotationAxis(this._startCursorPosition, this._currentCursorPosition), amount)
568
- );
569
- if (this.enableAnimations) {
570
- this._timePrev = this._timeCurrent;
571
- this._timeCurrent = performance.now();
572
- this._anglePrev = this._angleCurrent;
573
- this._angleCurrent = amount;
574
- this._cursorPosPrev.copy(this._cursorPosCurr);
575
- this._cursorPosCurr.copy(this._currentCursorPosition);
576
- this._wPrev = this._wCurr;
577
- this._wCurr = this.calculateAngularSpeed(
578
- this._anglePrev,
579
- this._angleCurrent,
580
- this._timePrev,
581
- this._timeCurrent
582
- );
583
- }
584
- }
585
- }
586
- break;
587
- case STATE.SCALE:
588
- if (this.enableZoom) {
589
- if (restart) {
590
- this.dispatchEvent(_endEvent);
591
- this.dispatchEvent(_startEvent);
592
- this.updateTbState(opState, true);
593
- this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
594
- this._currentCursorPosition.copy(this._startCursorPosition);
595
- if (this.enableGrid) {
596
- this.disposeGrid();
597
- }
598
- this.activateGizmos(false);
599
- } else {
600
- const screenNotches = 8;
601
- this._currentCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
602
- const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
603
- let size = 1;
604
- if (movement < 0) {
605
- size = 1 / Math.pow(this.scaleFactor, -movement * screenNotches);
606
- } else if (movement > 0) {
607
- size = Math.pow(this.scaleFactor, movement * screenNotches);
608
- }
609
- this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
610
- }
611
- }
612
- break;
613
- case STATE.FOV:
614
- if (this.enableZoom && this.camera instanceof PerspectiveCamera) {
615
- if (restart) {
616
- this.dispatchEvent(_endEvent);
617
- this.dispatchEvent(_startEvent);
618
- this.updateTbState(opState, true);
619
- this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
620
- this._currentCursorPosition.copy(this._startCursorPosition);
621
- if (this.enableGrid) {
622
- this.disposeGrid();
623
- }
624
- this.activateGizmos(false);
625
- } else {
626
- const screenNotches = 8;
627
- this._currentCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
628
- const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
629
- let size = 1;
630
- if (movement < 0) {
631
- size = 1 / Math.pow(this.scaleFactor, -movement * screenNotches);
632
- } else if (movement > 0) {
633
- size = Math.pow(this.scaleFactor, movement * screenNotches);
634
- }
635
- this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
636
- const x = this._v3_1.distanceTo(this._gizmos.position);
637
- let xNew = x / size;
638
- xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);
639
- const y = x * Math.tan(MathUtils.DEG2RAD * this._fovState * 0.5);
640
- let newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2);
641
- newFov = MathUtils.clamp(newFov, this.minFov, this.maxFov);
642
- const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
643
- size = x / newDistance;
644
- this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
645
- this.setFov(newFov);
646
- this.applyTransformMatrix(this.applyScale(size, this._v3_2, false));
647
- const direction = this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(newDistance / x);
648
- this._m4_1.makeTranslation(direction.x, direction.y, direction.z);
649
- }
650
- }
651
- break;
652
- }
653
- this.dispatchEvent(_changeEvent);
654
- }
655
- });
656
- __publicField(this, "onSinglePanEnd", () => {
657
- if (this._state == STATE.ROTATE) {
658
- if (!this.enableRotate) {
659
- return;
660
- }
661
- if (this.enableAnimations) {
662
- const deltaTime = performance.now() - this._timeCurrent;
663
- if (deltaTime < 120) {
664
- const w = Math.abs((this._wPrev + this._wCurr) / 2);
665
- const self = this;
666
- this._animationId = window.requestAnimationFrame(function(t) {
667
- self.updateTbState(STATE.ANIMATION_ROTATE, true);
668
- const rotationAxis = self.calculateRotationAxis(self._cursorPosPrev, self._cursorPosCurr);
669
- self.onRotationAnim(t, rotationAxis, Math.min(w, self.wMax));
670
- });
671
- } else {
672
- this.updateTbState(STATE.IDLE, false);
673
- this.activateGizmos(false);
674
- this.dispatchEvent(_changeEvent);
675
- }
676
- } else {
677
- this.updateTbState(STATE.IDLE, false);
678
- this.activateGizmos(false);
679
- this.dispatchEvent(_changeEvent);
680
- }
681
- } else if (this._state == STATE.PAN || this._state == STATE.IDLE) {
682
- this.updateTbState(STATE.IDLE, false);
683
- if (this.enableGrid) {
684
- this.disposeGrid();
685
- }
686
- this.activateGizmos(false);
687
- this.dispatchEvent(_changeEvent);
688
- }
689
- this.dispatchEvent(_endEvent);
690
- });
691
- __publicField(this, "onDoubleTap", (event) => {
692
- if (this.enabled && this.enablePan && this.scene && this.camera && this.domElement) {
693
- this.dispatchEvent(_startEvent);
694
- this.setCenter(event.clientX, event.clientY);
695
- const hitP = this.unprojectOnObj(this.getCursorNDC(_center.x, _center.y, this.domElement), this.camera);
696
- if (hitP && this.enableAnimations) {
697
- const self = this;
698
- if (this._animationId != -1) {
699
- window.cancelAnimationFrame(this._animationId);
700
- }
701
- this._timeStart = -1;
702
- this._animationId = window.requestAnimationFrame(function(t) {
703
- self.updateTbState(STATE.ANIMATION_FOCUS, true);
704
- self.onFocusAnim(t, hitP, self._cameraMatrixState, self._gizmoMatrixState);
705
- });
706
- } else if (hitP && !this.enableAnimations) {
707
- this.updateTbState(STATE.FOCUS, true);
708
- this.focus(hitP, this.scaleFactor);
709
- this.updateTbState(STATE.IDLE, false);
710
- this.dispatchEvent(_changeEvent);
711
- }
712
- }
713
- this.dispatchEvent(_endEvent);
714
- });
715
- __publicField(this, "onDoublePanStart", () => {
716
- if (this.enabled && this.enablePan && this.camera && this.domElement) {
717
- this.dispatchEvent(_startEvent);
718
- this.updateTbState(STATE.PAN, true);
719
- this.setCenter(
720
- (this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2,
721
- (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
722
- );
723
- const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement, true);
724
- if (rayDir !== void 0) {
725
- this._startCursorPosition.copy(rayDir);
726
- }
727
- this._currentCursorPosition.copy(this._startCursorPosition);
728
- this.activateGizmos(false);
729
- }
730
- });
731
- __publicField(this, "onDoublePanMove", () => {
732
- if (this.enabled && this.enablePan && this.camera && this.domElement) {
733
- this.setCenter(
734
- (this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2,
735
- (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
736
- );
737
- if (this._state != STATE.PAN) {
738
- this.updateTbState(STATE.PAN, true);
739
- this._startCursorPosition.copy(this._currentCursorPosition);
740
- }
741
- const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement, true);
742
- if (rayDir !== void 0)
743
- this._currentCursorPosition.copy(rayDir);
744
- this.applyTransformMatrix(this.pan(this._startCursorPosition, this._currentCursorPosition, true));
745
- this.dispatchEvent(_changeEvent);
746
- }
747
- });
748
- __publicField(this, "onDoublePanEnd", () => {
749
- this.updateTbState(STATE.IDLE, false);
750
- this.dispatchEvent(_endEvent);
751
- });
752
- __publicField(this, "onRotateStart", () => {
753
- var _a;
754
- if (this.enabled && this.enableRotate) {
755
- this.dispatchEvent(_startEvent);
756
- this.updateTbState(STATE.ZROTATE, true);
757
- this._startFingerRotation = this.getAngle(this._touchCurrent[1], this._touchCurrent[0]) + this.getAngle(this._touchStart[1], this._touchStart[0]);
758
- this._currentFingerRotation = this._startFingerRotation;
759
- (_a = this.camera) == null ? void 0 : _a.getWorldDirection(this._rotationAxis);
760
- if (!this.enablePan && !this.enableZoom) {
761
- this.activateGizmos(true);
762
- }
763
- }
764
- });
765
- __publicField(this, "onRotateMove", () => {
766
- var _a;
767
- if (this.enabled && this.enableRotate && this.camera && this.domElement) {
768
- this.setCenter(
769
- (this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2,
770
- (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
771
- );
772
- let rotationPoint;
773
- if (this._state != STATE.ZROTATE) {
774
- this.updateTbState(STATE.ZROTATE, true);
775
- this._startFingerRotation = this._currentFingerRotation;
776
- }
777
- this._currentFingerRotation = this.getAngle(this._touchCurrent[1], this._touchCurrent[0]) + this.getAngle(this._touchStart[1], this._touchStart[0]);
778
- if (!this.enablePan) {
779
- rotationPoint = new Vector3().setFromMatrixPosition(this._gizmoMatrixState);
780
- } else if (this.camera) {
781
- this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
782
- rotationPoint = (_a = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) == null ? void 0 : _a.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._v3_2);
783
- }
784
- const amount = MathUtils.DEG2RAD * (this._startFingerRotation - this._currentFingerRotation);
785
- if (rotationPoint !== void 0) {
786
- this.applyTransformMatrix(this.zRotate(rotationPoint, amount));
787
- }
788
- this.dispatchEvent(_changeEvent);
789
- }
790
- });
791
- __publicField(this, "onRotateEnd", () => {
792
- this.updateTbState(STATE.IDLE, false);
793
- this.activateGizmos(false);
794
- this.dispatchEvent(_endEvent);
795
- });
796
- __publicField(this, "onPinchStart", () => {
797
- if (this.enabled && this.enableZoom) {
798
- this.dispatchEvent(_startEvent);
799
- this.updateTbState(STATE.SCALE, true);
800
- this._startFingerDistance = this.calculatePointersDistance(this._touchCurrent[0], this._touchCurrent[1]);
801
- this._currentFingerDistance = this._startFingerDistance;
802
- this.activateGizmos(false);
803
- }
804
- });
805
- __publicField(this, "onPinchMove", () => {
806
- var _a, _b;
807
- if (this.enabled && this.enableZoom && this.domElement) {
808
- this.setCenter(
809
- (this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2,
810
- (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
811
- );
812
- const minDistance = 12;
813
- if (this._state != STATE.SCALE) {
814
- this._startFingerDistance = this._currentFingerDistance;
815
- this.updateTbState(STATE.SCALE, true);
816
- }
817
- this._currentFingerDistance = Math.max(
818
- this.calculatePointersDistance(this._touchCurrent[0], this._touchCurrent[1]),
819
- minDistance * this._devPxRatio
820
- );
821
- const amount = this._currentFingerDistance / this._startFingerDistance;
822
- let scalePoint;
823
- if (!this.enablePan) {
824
- scalePoint = this._gizmos.position;
825
- } else {
826
- if (this.camera instanceof OrthographicCamera) {
827
- scalePoint = (_a = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) == null ? void 0 : _a.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._gizmos.position);
828
- } else if (this.camera instanceof PerspectiveCamera) {
829
- scalePoint = (_b = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) == null ? void 0 : _b.applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
830
- }
831
- }
832
- if (scalePoint !== void 0) {
833
- this.applyTransformMatrix(this.applyScale(amount, scalePoint));
834
- }
835
- this.dispatchEvent(_changeEvent);
836
- }
837
- });
838
- __publicField(this, "onPinchEnd", () => {
839
- this.updateTbState(STATE.IDLE, false);
840
- this.dispatchEvent(_endEvent);
841
- });
842
- __publicField(this, "onTriplePanStart", () => {
843
- if (this.enabled && this.enableZoom && this.domElement) {
844
- this.dispatchEvent(_startEvent);
845
- this.updateTbState(STATE.SCALE, true);
846
- let clientX = 0;
847
- let clientY = 0;
848
- const nFingers = this._touchCurrent.length;
849
- for (let i = 0; i < nFingers; i++) {
850
- clientX += this._touchCurrent[i].clientX;
851
- clientY += this._touchCurrent[i].clientY;
852
- }
853
- this.setCenter(clientX / nFingers, clientY / nFingers);
854
- this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
855
- this._currentCursorPosition.copy(this._startCursorPosition);
856
- }
857
- });
858
- __publicField(this, "onTriplePanMove", () => {
859
- if (this.enabled && this.enableZoom && this.camera && this.domElement) {
860
- let clientX = 0;
861
- let clientY = 0;
862
- const nFingers = this._touchCurrent.length;
863
- for (let i = 0; i < nFingers; i++) {
864
- clientX += this._touchCurrent[i].clientX;
865
- clientY += this._touchCurrent[i].clientY;
866
- }
867
- this.setCenter(clientX / nFingers, clientY / nFingers);
868
- const screenNotches = 8;
869
- this._currentCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
870
- const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
871
- let size = 1;
872
- if (movement < 0) {
873
- size = 1 / Math.pow(this.scaleFactor, -movement * screenNotches);
874
- } else if (movement > 0) {
875
- size = Math.pow(this.scaleFactor, movement * screenNotches);
876
- }
877
- this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
878
- const x = this._v3_1.distanceTo(this._gizmos.position);
879
- let xNew = x / size;
880
- xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);
881
- const y = x * Math.tan(MathUtils.DEG2RAD * this._fovState * 0.5);
882
- let newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2);
883
- newFov = MathUtils.clamp(newFov, this.minFov, this.maxFov);
884
- const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
885
- size = x / newDistance;
886
- this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
887
- this.setFov(newFov);
888
- this.applyTransformMatrix(this.applyScale(size, this._v3_2, false));
889
- const direction = this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(newDistance / x);
890
- this._m4_1.makeTranslation(direction.x, direction.y, direction.z);
891
- this.dispatchEvent(_changeEvent);
892
- }
893
- });
894
- __publicField(this, "onTriplePanEnd", () => {
895
- this.updateTbState(STATE.IDLE, false);
896
- this.dispatchEvent(_endEvent);
897
- });
898
- /**
899
- * Set _center's x/y coordinates
900
- * @param {Number} clientX
901
- * @param {Number} clientY
902
- */
903
- __publicField(this, "setCenter", (clientX, clientY) => {
904
- _center.x = clientX;
905
- _center.y = clientY;
906
- });
907
- /**
908
- * Set default mouse actions
909
- */
910
- __publicField(this, "initializeMouseActions", () => {
911
- this.setMouseAction("PAN", 0, "CTRL");
912
- this.setMouseAction("PAN", 2);
913
- this.setMouseAction("ROTATE", 0);
914
- this.setMouseAction("ZOOM", "WHEEL");
915
- this.setMouseAction("ZOOM", 1);
916
- this.setMouseAction("FOV", "WHEEL", "SHIFT");
917
- this.setMouseAction("FOV", 1, "SHIFT");
918
- });
919
- /**
920
- * Set a new mouse action by specifying the operation to be performed and a mouse/key combination. In case of conflict, replaces the existing one
921
- * @param {String} operation The operation to be performed ('PAN', 'ROTATE', 'ZOOM', 'FOV)
922
- * @param {*} mouse A mouse button (0, 1, 2) or 'WHEEL' for wheel notches
923
- * @param {*} key The keyboard modifier ('CTRL', 'SHIFT') or null if key is not needed
924
- * @returns {Boolean} True if the mouse action has been successfully added, false otherwise
925
- */
926
- __publicField(this, "setMouseAction", (operation, mouse, key = null) => {
927
- const operationInput = ["PAN", "ROTATE", "ZOOM", "FOV"];
928
- const mouseInput = [0, 1, 2, "WHEEL"];
929
- const keyInput = ["CTRL", "SHIFT", null];
930
- let state;
931
- if (!operationInput.includes(operation) || !mouseInput.includes(mouse) || !keyInput.includes(key)) {
932
- return false;
933
- }
934
- if (mouse == "WHEEL") {
935
- if (operation != "ZOOM" && operation != "FOV") {
936
- return false;
937
- }
938
- }
939
- switch (operation) {
940
- case "PAN":
941
- state = STATE.PAN;
942
- break;
943
- case "ROTATE":
944
- state = STATE.ROTATE;
945
- break;
946
- case "ZOOM":
947
- state = STATE.SCALE;
948
- break;
949
- case "FOV":
950
- state = STATE.FOV;
951
- break;
952
- }
953
- const action = {
954
- operation,
955
- mouse,
956
- key,
957
- state
958
- };
959
- for (let i = 0; i < this.mouseActions.length; i++) {
960
- if (this.mouseActions[i].mouse == action.mouse && this.mouseActions[i].key == action.key) {
961
- this.mouseActions.splice(i, 1, action);
962
- return true;
963
- }
964
- }
965
- this.mouseActions.push(action);
966
- return true;
967
- });
968
- /**
969
- * Return the operation associated to a mouse/keyboard combination
970
- * @param {*} mouse A mouse button (0, 1, 2) or 'WHEEL' for wheel notches
971
- * @param {*} key The keyboard modifier ('CTRL', 'SHIFT') or null if key is not needed
972
- * @returns The operation if it has been found, null otherwise
973
- */
974
- __publicField(this, "getOpFromAction", (mouse, key) => {
975
- let action;
976
- for (let i = 0; i < this.mouseActions.length; i++) {
977
- action = this.mouseActions[i];
978
- if (action.mouse == mouse && action.key == key) {
979
- return action.operation;
980
- }
981
- }
982
- if (key) {
983
- for (let i = 0; i < this.mouseActions.length; i++) {
984
- action = this.mouseActions[i];
985
- if (action.mouse == mouse && action.key == null) {
986
- return action.operation;
987
- }
988
- }
989
- }
990
- return null;
991
- });
992
- /**
993
- * Get the operation associated to mouse and key combination and returns the corresponding FSA state
994
- * @param {Number} mouse Mouse button
995
- * @param {String} key Keyboard modifier
996
- * @returns The FSA state obtained from the operation associated to mouse/keyboard combination
997
- */
998
- __publicField(this, "getOpStateFromAction", (mouse, key) => {
999
- let action;
1000
- for (let i = 0; i < this.mouseActions.length; i++) {
1001
- action = this.mouseActions[i];
1002
- if (action.mouse == mouse && action.key == key) {
1003
- return action.state;
1004
- }
1005
- }
1006
- if (key) {
1007
- for (let i = 0; i < this.mouseActions.length; i++) {
1008
- action = this.mouseActions[i];
1009
- if (action.mouse == mouse && action.key == null) {
1010
- return action.state;
1011
- }
1012
- }
1013
- }
1014
- return null;
1015
- });
1016
- /**
1017
- * Calculate the angle between two pointers
1018
- * @param {PointerEvent} p1
1019
- * @param {PointerEvent} p2
1020
- * @returns {Number} The angle between two pointers in degrees
1021
- */
1022
- __publicField(this, "getAngle", (p1, p2) => {
1023
- return Math.atan2(p2.clientY - p1.clientY, p2.clientX - p1.clientX) * 180 / Math.PI;
1024
- });
1025
- /**
1026
- * Update a PointerEvent inside current pointerevents array
1027
- * @param {PointerEvent} event
1028
- */
1029
- __publicField(this, "updateTouchEvent", (event) => {
1030
- for (let i = 0; i < this._touchCurrent.length; i++) {
1031
- if (this._touchCurrent[i].pointerId == event.pointerId) {
1032
- this._touchCurrent.splice(i, 1, event);
1033
- break;
1034
- }
1035
- }
1036
- });
1037
- /**
1038
- * Calculate the angular speed
1039
- * @param {Number} p0 Position at t0
1040
- * @param {Number} p1 Position at t1
1041
- * @param {Number} t0 Initial time in milliseconds
1042
- * @param {Number} t1 Ending time in milliseconds
1043
- */
1044
- __publicField(this, "calculateAngularSpeed", (p0, p1, t0, t1) => {
1045
- const s = p1 - p0;
1046
- const t = (t1 - t0) / 1e3;
1047
- if (t == 0) {
1048
- return 0;
1049
- }
1050
- return s / t;
1051
- });
1052
- /**
1053
- * Calculate the distance between two pointers
1054
- * @param {PointerEvent} p0 The first pointer
1055
- * @param {PointerEvent} p1 The second pointer
1056
- * @returns {number} The distance between the two pointers
1057
- */
1058
- __publicField(this, "calculatePointersDistance", (p0, p1) => {
1059
- return Math.sqrt(Math.pow(p1.clientX - p0.clientX, 2) + Math.pow(p1.clientY - p0.clientY, 2));
1060
- });
1061
- /**
1062
- * Calculate the rotation axis as the vector perpendicular between two vectors
1063
- * @param {Vector3} vec1 The first vector
1064
- * @param {Vector3} vec2 The second vector
1065
- * @returns {Vector3} The normalized rotation axis
1066
- */
1067
- __publicField(this, "calculateRotationAxis", (vec1, vec2) => {
1068
- this._rotationMatrix.extractRotation(this._cameraMatrixState);
1069
- this._quat.setFromRotationMatrix(this._rotationMatrix);
1070
- this._rotationAxis.crossVectors(vec1, vec2).applyQuaternion(this._quat);
1071
- return this._rotationAxis.normalize().clone();
1072
- });
1073
- /**
1074
- * Calculate the trackball radius so that gizmo's diamater will be 2/3 of the minimum side of the camera frustum
1075
- * @param {Camera} camera
1076
- * @returns {Number} The trackball radius
1077
- */
1078
- __publicField(this, "calculateTbRadius", (camera) => {
1079
- const factor = 0.67;
1080
- const distance = camera.position.distanceTo(this._gizmos.position);
1081
- if (camera instanceof PerspectiveCamera) {
1082
- const halfFovV = MathUtils.DEG2RAD * camera.fov * 0.5;
1083
- const halfFovH = Math.atan(camera.aspect * Math.tan(halfFovV));
1084
- return Math.tan(Math.min(halfFovV, halfFovH)) * distance * factor;
1085
- } else if (camera instanceof OrthographicCamera) {
1086
- return Math.min(camera.top, camera.right) * factor;
1087
- }
1088
- });
1089
- /**
1090
- * Focus operation consist of positioning the point of interest in front of the camera and a slightly zoom in
1091
- * @param {Vector3} point The point of interest
1092
- * @param {Number} size Scale factor
1093
- * @param {Number} amount Amount of operation to be completed (used for focus animations, default is complete full operation)
1094
- */
1095
- __publicField(this, "focus", (point, size, amount = 1) => {
1096
- if (this.camera) {
1097
- const focusPoint = point.clone();
1098
- focusPoint.sub(this._gizmos.position).multiplyScalar(amount);
1099
- this._translationMatrix.makeTranslation(focusPoint.x, focusPoint.y, focusPoint.z);
1100
- const gizmoStateTemp = this._gizmoMatrixState.clone();
1101
- this._gizmoMatrixState.premultiply(this._translationMatrix);
1102
- this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1103
- const cameraStateTemp = this._cameraMatrixState.clone();
1104
- this._cameraMatrixState.premultiply(this._translationMatrix);
1105
- this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
1106
- if (this.enableZoom) {
1107
- this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
1108
- }
1109
- this._gizmoMatrixState.copy(gizmoStateTemp);
1110
- this._cameraMatrixState.copy(cameraStateTemp);
1111
- }
1112
- });
1113
- /**
1114
- * Draw a grid and add it to the scene
1115
- */
1116
- __publicField(this, "drawGrid", () => {
1117
- if (this.scene) {
1118
- const color = 8947848;
1119
- const multiplier = 3;
1120
- let size, divisions, maxLength, tick;
1121
- if (this.camera instanceof OrthographicCamera) {
1122
- const width = this.camera.right - this.camera.left;
1123
- const height = this.camera.bottom - this.camera.top;
1124
- maxLength = Math.max(width, height);
1125
- tick = maxLength / 20;
1126
- size = maxLength / this.camera.zoom * multiplier;
1127
- divisions = size / tick * this.camera.zoom;
1128
- } else if (this.camera instanceof PerspectiveCamera) {
1129
- const distance = this.camera.position.distanceTo(this._gizmos.position);
1130
- const halfFovV = MathUtils.DEG2RAD * this.camera.fov * 0.5;
1131
- const halfFovH = Math.atan(this.camera.aspect * Math.tan(halfFovV));
1132
- maxLength = Math.tan(Math.max(halfFovV, halfFovH)) * distance * 2;
1133
- tick = maxLength / 20;
1134
- size = maxLength * multiplier;
1135
- divisions = size / tick;
1136
- }
1137
- if (this._grid == null && this.camera) {
1138
- this._grid = new GridHelper(size, divisions, color, color);
1139
- this._grid.position.copy(this._gizmos.position);
1140
- this._gridPosition.copy(this._grid.position);
1141
- this._grid.quaternion.copy(this.camera.quaternion);
1142
- this._grid.rotateX(Math.PI * 0.5);
1143
- this.scene.add(this._grid);
1144
- }
1145
- }
1146
- });
1147
- __publicField(this, "connect", (domElement) => {
1148
- if (domElement === document) {
1149
- console.error(
1150
- 'THREE.ArcballControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'
1151
- );
1152
- }
1153
- this.domElement = domElement;
1154
- this.domElement.style.touchAction = "none";
1155
- this.domElement.addEventListener("contextmenu", this.onContextMenu);
1156
- this.domElement.addEventListener("pointerdown", this.onPointerDown);
1157
- this.domElement.addEventListener("pointercancel", this.onPointerCancel);
1158
- this.domElement.addEventListener("wheel", this.onWheel);
1159
- });
1160
- /**
1161
- * Remove all listeners, stop animations and clean scene
1162
- */
1163
- __publicField(this, "dispose", () => {
1164
- var _a, _b, _c, _d, _e;
1165
- if (this._animationId != -1) {
1166
- window.cancelAnimationFrame(this._animationId);
1167
- }
1168
- (_a = this.domElement) == null ? void 0 : _a.removeEventListener("pointerdown", this.onPointerDown);
1169
- (_b = this.domElement) == null ? void 0 : _b.removeEventListener("pointercancel", this.onPointerCancel);
1170
- (_c = this.domElement) == null ? void 0 : _c.removeEventListener("wheel", this.onWheel);
1171
- (_d = this.domElement) == null ? void 0 : _d.removeEventListener("contextmenu", this.onContextMenu);
1172
- window.removeEventListener("pointermove", this.onPointerMove);
1173
- window.removeEventListener("pointerup", this.onPointerUp);
1174
- window.removeEventListener("resize", this.onWindowResize);
1175
- (_e = this.scene) == null ? void 0 : _e.remove(this._gizmos);
1176
- this.disposeGrid();
1177
- });
1178
- /**
1179
- * remove the grid from the scene
1180
- */
1181
- __publicField(this, "disposeGrid", () => {
1182
- if (this._grid && this.scene) {
1183
- this.scene.remove(this._grid);
1184
- this._grid = null;
1185
- }
1186
- });
1187
- /**
1188
- * Compute the easing out cubic function for ease out effect in animation
1189
- * @param {Number} t The absolute progress of the animation in the bound of 0 (beginning of the) and 1 (ending of animation)
1190
- * @returns {Number} Result of easing out cubic at time t
1191
- */
1192
- __publicField(this, "easeOutCubic", (t) => {
1193
- return 1 - Math.pow(1 - t, 3);
1194
- });
1195
- /**
1196
- * Make rotation gizmos more or less visible
1197
- * @param {Boolean} isActive If true, make gizmos more visible
1198
- */
1199
- __publicField(this, "activateGizmos", (isActive) => {
1200
- for (const gizmo of this._gizmos.children) {
1201
- ;
1202
- gizmo.material.setValues({ opacity: isActive ? 1 : 0.6 });
1203
- }
1204
- });
1205
- /**
1206
- * Calculate the cursor position in NDC
1207
- * @param {number} x Cursor horizontal coordinate within the canvas
1208
- * @param {number} y Cursor vertical coordinate within the canvas
1209
- * @param {HTMLElement} canvas The canvas where the renderer draws its output
1210
- * @returns {Vector2} Cursor normalized position inside the canvas
1211
- */
1212
- __publicField(this, "getCursorNDC", (cursorX, cursorY, canvas) => {
1213
- const canvasRect = canvas.getBoundingClientRect();
1214
- this._v2_1.setX((cursorX - canvasRect.left) / canvasRect.width * 2 - 1);
1215
- this._v2_1.setY((canvasRect.bottom - cursorY) / canvasRect.height * 2 - 1);
1216
- return this._v2_1.clone();
1217
- });
1218
- /**
1219
- * Calculate the cursor position inside the canvas x/y coordinates with the origin being in the center of the canvas
1220
- * @param {Number} x Cursor horizontal coordinate within the canvas
1221
- * @param {Number} y Cursor vertical coordinate within the canvas
1222
- * @param {HTMLElement} canvas The canvas where the renderer draws its output
1223
- * @returns {Vector2} Cursor position inside the canvas
1224
- */
1225
- __publicField(this, "getCursorPosition", (cursorX, cursorY, canvas) => {
1226
- this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
1227
- if (this.camera instanceof OrthographicCamera) {
1228
- this._v2_1.x *= (this.camera.right - this.camera.left) * 0.5;
1229
- this._v2_1.y *= (this.camera.top - this.camera.bottom) * 0.5;
1230
- }
1231
- return this._v2_1.clone();
1232
- });
1233
- /**
1234
- * Set the camera to be controlled
1235
- * @param {Camera} camera The virtual camera to be controlled
1236
- */
1237
- __publicField(this, "setCamera", (camera) => {
1238
- if (camera) {
1239
- camera.lookAt(this.target);
1240
- camera.updateMatrix();
1241
- if (camera instanceof PerspectiveCamera) {
1242
- this._fov0 = camera.fov;
1243
- this._fovState = camera.fov;
1244
- }
1245
- this._cameraMatrixState0.copy(camera.matrix);
1246
- this._cameraMatrixState.copy(this._cameraMatrixState0);
1247
- this._cameraProjectionState.copy(camera.projectionMatrix);
1248
- this._zoom0 = camera.zoom;
1249
- this._zoomState = this._zoom0;
1250
- this._initialNear = camera.near;
1251
- this._nearPos0 = camera.position.distanceTo(this.target) - camera.near;
1252
- this._nearPos = this._initialNear;
1253
- this._initialFar = camera.far;
1254
- this._farPos0 = camera.position.distanceTo(this.target) - camera.far;
1255
- this._farPos = this._initialFar;
1256
- this._up0.copy(camera.up);
1257
- this._upState.copy(camera.up);
1258
- this.camera = camera;
1259
- this.camera.updateProjectionMatrix();
1260
- const tbRadius = this.calculateTbRadius(camera);
1261
- if (tbRadius !== void 0) {
1262
- this._tbRadius = tbRadius;
1263
- }
1264
- this.makeGizmos(this.target, this._tbRadius);
1265
- }
1266
- });
1267
- /**
1268
- * Creates the rotation gizmos matching trackball center and radius
1269
- * @param {Vector3} tbCenter The trackball center
1270
- * @param {number} tbRadius The trackball radius
1271
- */
1272
- __publicField(this, "makeGizmos", (tbCenter, tbRadius) => {
1273
- const curve = new EllipseCurve(0, 0, tbRadius, tbRadius);
1274
- const points = curve.getPoints(this._curvePts);
1275
- const curveGeometry = new BufferGeometry().setFromPoints(points);
1276
- const curveMaterialX = new LineBasicMaterial({ color: 16744576, fog: false, transparent: true, opacity: 0.6 });
1277
- const curveMaterialY = new LineBasicMaterial({ color: 8454016, fog: false, transparent: true, opacity: 0.6 });
1278
- const curveMaterialZ = new LineBasicMaterial({ color: 8421631, fog: false, transparent: true, opacity: 0.6 });
1279
- const gizmoX = new Line(curveGeometry, curveMaterialX);
1280
- const gizmoY = new Line(curveGeometry, curveMaterialY);
1281
- const gizmoZ = new Line(curveGeometry, curveMaterialZ);
1282
- const rotation = Math.PI * 0.5;
1283
- gizmoX.rotation.x = rotation;
1284
- gizmoY.rotation.y = rotation;
1285
- this._gizmoMatrixState0.identity().setPosition(tbCenter);
1286
- this._gizmoMatrixState.copy(this._gizmoMatrixState0);
1287
- if (this.camera && this.camera.zoom != 1) {
1288
- const size = 1 / this.camera.zoom;
1289
- this._scaleMatrix.makeScale(size, size, size);
1290
- this._translationMatrix.makeTranslation(-tbCenter.x, -tbCenter.y, -tbCenter.z);
1291
- this._gizmoMatrixState.premultiply(this._translationMatrix).premultiply(this._scaleMatrix);
1292
- this._translationMatrix.makeTranslation(tbCenter.x, tbCenter.y, tbCenter.z);
1293
- this._gizmoMatrixState.premultiply(this._translationMatrix);
1294
- }
1295
- this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1296
- this._gizmos.clear();
1297
- this._gizmos.add(gizmoX);
1298
- this._gizmos.add(gizmoY);
1299
- this._gizmos.add(gizmoZ);
1300
- });
1301
- /**
1302
- * Perform animation for focus operation
1303
- * @param {Number} time Instant in which this function is called as performance.now()
1304
- * @param {Vector3} point Point of interest for focus operation
1305
- * @param {Matrix4} cameraMatrix Camera matrix
1306
- * @param {Matrix4} gizmoMatrix Gizmos matrix
1307
- */
1308
- __publicField(this, "onFocusAnim", (time, point, cameraMatrix, gizmoMatrix) => {
1309
- if (this._timeStart == -1) {
1310
- this._timeStart = time;
1311
- }
1312
- if (this._state == STATE.ANIMATION_FOCUS) {
1313
- const deltaTime = time - this._timeStart;
1314
- const animTime = deltaTime / this.focusAnimationTime;
1315
- this._gizmoMatrixState.copy(gizmoMatrix);
1316
- if (animTime >= 1) {
1317
- this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1318
- this.focus(point, this.scaleFactor);
1319
- this._timeStart = -1;
1320
- this.updateTbState(STATE.IDLE, false);
1321
- this.activateGizmos(false);
1322
- this.dispatchEvent(_changeEvent);
1323
- } else {
1324
- const amount = this.easeOutCubic(animTime);
1325
- const size = 1 - amount + this.scaleFactor * amount;
1326
- this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1327
- this.focus(point, size, amount);
1328
- this.dispatchEvent(_changeEvent);
1329
- const self = this;
1330
- this._animationId = window.requestAnimationFrame(function(t) {
1331
- self.onFocusAnim(t, point, cameraMatrix, gizmoMatrix.clone());
1332
- });
1333
- }
1334
- } else {
1335
- this._animationId = -1;
1336
- this._timeStart = -1;
1337
- }
1338
- });
1339
- /**
1340
- * Perform animation for rotation operation
1341
- * @param {Number} time Instant in which this function is called as performance.now()
1342
- * @param {Vector3} rotationAxis Rotation axis
1343
- * @param {number} w0 Initial angular velocity
1344
- */
1345
- __publicField(this, "onRotationAnim", (time, rotationAxis, w0) => {
1346
- if (this._timeStart == -1) {
1347
- this._anglePrev = 0;
1348
- this._angleCurrent = 0;
1349
- this._timeStart = time;
1350
- }
1351
- if (this._state == STATE.ANIMATION_ROTATE) {
1352
- const deltaTime = (time - this._timeStart) / 1e3;
1353
- const w = w0 + -this.dampingFactor * deltaTime;
1354
- if (w > 0) {
1355
- this._angleCurrent = 0.5 * -this.dampingFactor * Math.pow(deltaTime, 2) + w0 * deltaTime + 0;
1356
- this.applyTransformMatrix(this.rotate(rotationAxis, this._angleCurrent));
1357
- this.dispatchEvent(_changeEvent);
1358
- const self = this;
1359
- this._animationId = window.requestAnimationFrame(function(t) {
1360
- self.onRotationAnim(t, rotationAxis, w0);
1361
- });
1362
- } else {
1363
- this._animationId = -1;
1364
- this._timeStart = -1;
1365
- this.updateTbState(STATE.IDLE, false);
1366
- this.activateGizmos(false);
1367
- this.dispatchEvent(_changeEvent);
1368
- }
1369
- } else {
1370
- this._animationId = -1;
1371
- this._timeStart = -1;
1372
- if (this._state != STATE.ROTATE) {
1373
- this.activateGizmos(false);
1374
- this.dispatchEvent(_changeEvent);
1375
- }
1376
- }
1377
- });
1378
- /**
1379
- * Perform pan operation moving camera between two points
1380
- * @param {Vector3} p0 Initial point
1381
- * @param {Vector3} p1 Ending point
1382
- * @param {Boolean} adjust If movement should be adjusted considering camera distance (Perspective only)
1383
- */
1384
- __publicField(this, "pan", (p0, p1, adjust = false) => {
1385
- if (this.camera) {
1386
- const movement = p0.clone().sub(p1);
1387
- if (this.camera instanceof OrthographicCamera) {
1388
- movement.multiplyScalar(1 / this.camera.zoom);
1389
- }
1390
- if (this.camera instanceof PerspectiveCamera && adjust) {
1391
- this._v3_1.setFromMatrixPosition(this._cameraMatrixState0);
1392
- this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0);
1393
- const distanceFactor = this._v3_1.distanceTo(this._v3_2) / this.camera.position.distanceTo(this._gizmos.position);
1394
- movement.multiplyScalar(1 / distanceFactor);
1395
- }
1396
- this._v3_1.set(movement.x, movement.y, 0).applyQuaternion(this.camera.quaternion);
1397
- this._m4_1.makeTranslation(this._v3_1.x, this._v3_1.y, this._v3_1.z);
1398
- this.setTransformationMatrices(this._m4_1, this._m4_1);
1399
- }
1400
- return _transformation;
1401
- });
1402
- /**
1403
- * Reset trackball
1404
- */
1405
- __publicField(this, "reset", () => {
1406
- if (this.camera) {
1407
- this.camera.zoom = this._zoom0;
1408
- if (this.camera instanceof PerspectiveCamera) {
1409
- this.camera.fov = this._fov0;
1410
- }
1411
- this.camera.near = this._nearPos;
1412
- this.camera.far = this._farPos;
1413
- this._cameraMatrixState.copy(this._cameraMatrixState0);
1414
- this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
1415
- this.camera.up.copy(this._up0);
1416
- this.camera.updateMatrix();
1417
- this.camera.updateProjectionMatrix();
1418
- this._gizmoMatrixState.copy(this._gizmoMatrixState0);
1419
- this._gizmoMatrixState0.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1420
- this._gizmos.updateMatrix();
1421
- const tbRadius = this.calculateTbRadius(this.camera);
1422
- if (tbRadius !== void 0) {
1423
- this._tbRadius = tbRadius;
1424
- }
1425
- this.makeGizmos(this._gizmos.position, this._tbRadius);
1426
- this.camera.lookAt(this._gizmos.position);
1427
- this.updateTbState(STATE.IDLE, false);
1428
- this.dispatchEvent(_changeEvent);
1429
- }
1430
- });
1431
- /**
1432
- * Rotate the camera around an axis passing by trackball's center
1433
- * @param {Vector3} axis Rotation axis
1434
- * @param {number} angle Angle in radians
1435
- * @returns {Object} Object with 'camera' field containing transformation matrix resulting from the operation to be applied to the camera
1436
- */
1437
- __publicField(this, "rotate", (axis, angle) => {
1438
- const point = this._gizmos.position;
1439
- this._translationMatrix.makeTranslation(-point.x, -point.y, -point.z);
1440
- this._rotationMatrix.makeRotationAxis(axis, -angle);
1441
- this._m4_1.makeTranslation(point.x, point.y, point.z);
1442
- this._m4_1.multiply(this._rotationMatrix);
1443
- this._m4_1.multiply(this._translationMatrix);
1444
- this.setTransformationMatrices(this._m4_1);
1445
- return _transformation;
1446
- });
1447
- __publicField(this, "copyState", () => {
1448
- if (this.camera) {
1449
- const state = JSON.stringify(
1450
- this.camera instanceof OrthographicCamera ? {
1451
- arcballState: {
1452
- cameraFar: this.camera.far,
1453
- cameraMatrix: this.camera.matrix,
1454
- cameraNear: this.camera.near,
1455
- cameraUp: this.camera.up,
1456
- cameraZoom: this.camera.zoom,
1457
- gizmoMatrix: this._gizmos.matrix
1458
- }
1459
- } : {
1460
- arcballState: {
1461
- cameraFar: this.camera.far,
1462
- cameraFov: this.camera.fov,
1463
- cameraMatrix: this.camera.matrix,
1464
- cameraNear: this.camera.near,
1465
- cameraUp: this.camera.up,
1466
- cameraZoom: this.camera.zoom,
1467
- gizmoMatrix: this._gizmos.matrix
1468
- }
1469
- }
1470
- );
1471
- navigator.clipboard.writeText(state);
1472
- }
1473
- });
1474
- __publicField(this, "pasteState", () => {
1475
- const self = this;
1476
- navigator.clipboard.readText().then(function resolved(value) {
1477
- self.setStateFromJSON(value);
1478
- });
1479
- });
1480
- /**
1481
- * Save the current state of the control. This can later be recovered with .reset
1482
- */
1483
- __publicField(this, "saveState", () => {
1484
- if (!this.camera)
1485
- return;
1486
- this._cameraMatrixState0.copy(this.camera.matrix);
1487
- this._gizmoMatrixState0.copy(this._gizmos.matrix);
1488
- this._nearPos = this.camera.near;
1489
- this._farPos = this.camera.far;
1490
- this._zoom0 = this.camera.zoom;
1491
- this._up0.copy(this.camera.up);
1492
- if (this.camera instanceof PerspectiveCamera) {
1493
- this._fov0 = this.camera.fov;
1494
- }
1495
- });
1496
- /**
1497
- * Perform uniform scale operation around a given point
1498
- * @param {Number} size Scale factor
1499
- * @param {Vector3} point Point around which scale
1500
- * @param {Boolean} scaleGizmos If gizmos should be scaled (Perspective only)
1501
- * @returns {Object} Object with 'camera' and 'gizmo' fields containing transformation matrices resulting from the operation to be applied to the camera and gizmos
1502
- */
1503
- __publicField(this, "applyScale", (size, point, scaleGizmos = true) => {
1504
- if (!this.camera)
1505
- return;
1506
- const scalePoint = point.clone();
1507
- let sizeInverse = 1 / size;
1508
- if (this.camera instanceof OrthographicCamera) {
1509
- this.camera.zoom = this._zoomState;
1510
- this.camera.zoom *= size;
1511
- if (this.camera.zoom > this.maxZoom) {
1512
- this.camera.zoom = this.maxZoom;
1513
- sizeInverse = this._zoomState / this.maxZoom;
1514
- } else if (this.camera.zoom < this.minZoom) {
1515
- this.camera.zoom = this.minZoom;
1516
- sizeInverse = this._zoomState / this.minZoom;
1517
- }
1518
- this.camera.updateProjectionMatrix();
1519
- this._v3_1.setFromMatrixPosition(this._gizmoMatrixState);
1520
- this._scaleMatrix.makeScale(sizeInverse, sizeInverse, sizeInverse);
1521
- this._translationMatrix.makeTranslation(-this._v3_1.x, -this._v3_1.y, -this._v3_1.z);
1522
- this._m4_2.makeTranslation(this._v3_1.x, this._v3_1.y, this._v3_1.z).multiply(this._scaleMatrix);
1523
- this._m4_2.multiply(this._translationMatrix);
1524
- scalePoint.sub(this._v3_1);
1525
- const amount = scalePoint.clone().multiplyScalar(sizeInverse);
1526
- scalePoint.sub(amount);
1527
- this._m4_1.makeTranslation(scalePoint.x, scalePoint.y, scalePoint.z);
1528
- this._m4_2.premultiply(this._m4_1);
1529
- this.setTransformationMatrices(this._m4_1, this._m4_2);
1530
- return _transformation;
1531
- }
1532
- if (this.camera instanceof PerspectiveCamera) {
1533
- this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
1534
- this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
1535
- let distance = this._v3_1.distanceTo(scalePoint);
1536
- let amount = distance - distance * sizeInverse;
1537
- const newDistance = distance - amount;
1538
- if (newDistance < this.minDistance) {
1539
- sizeInverse = this.minDistance / distance;
1540
- amount = distance - distance * sizeInverse;
1541
- } else if (newDistance > this.maxDistance) {
1542
- sizeInverse = this.maxDistance / distance;
1543
- amount = distance - distance * sizeInverse;
1544
- }
1545
- let direction = scalePoint.clone().sub(this._v3_1).normalize().multiplyScalar(amount);
1546
- this._m4_1.makeTranslation(direction.x, direction.y, direction.z);
1547
- if (scaleGizmos) {
1548
- const pos = this._v3_2;
1549
- distance = pos.distanceTo(scalePoint);
1550
- amount = distance - distance * sizeInverse;
1551
- direction = scalePoint.clone().sub(this._v3_2).normalize().multiplyScalar(amount);
1552
- this._translationMatrix.makeTranslation(pos.x, pos.y, pos.z);
1553
- this._scaleMatrix.makeScale(sizeInverse, sizeInverse, sizeInverse);
1554
- this._m4_2.makeTranslation(direction.x, direction.y, direction.z).multiply(this._translationMatrix);
1555
- this._m4_2.multiply(this._scaleMatrix);
1556
- this._translationMatrix.makeTranslation(-pos.x, -pos.y, -pos.z);
1557
- this._m4_2.multiply(this._translationMatrix);
1558
- this.setTransformationMatrices(this._m4_1, this._m4_2);
1559
- } else {
1560
- this.setTransformationMatrices(this._m4_1);
1561
- }
1562
- return _transformation;
1563
- }
1564
- });
1565
- /**
1566
- * Set camera fov
1567
- * @param {Number} value fov to be setted
1568
- */
1569
- __publicField(this, "setFov", (value) => {
1570
- if (this.camera instanceof PerspectiveCamera) {
1571
- this.camera.fov = MathUtils.clamp(value, this.minFov, this.maxFov);
1572
- this.camera.updateProjectionMatrix();
1573
- }
1574
- });
1575
- /**
1576
- * Set the trackball's center point
1577
- * @param {Number} x X coordinate
1578
- * @param {Number} y Y coordinate
1579
- * @param {Number} z Z coordinate
1580
- */
1581
- __publicField(this, "setTarget", (x, y, z) => {
1582
- if (this.camera) {
1583
- this.target.set(x, y, z);
1584
- this._gizmos.position.set(x, y, z);
1585
- const tbRadius = this.calculateTbRadius(this.camera);
1586
- if (tbRadius !== void 0) {
1587
- this._tbRadius = tbRadius;
1588
- }
1589
- this.makeGizmos(this.target, this._tbRadius);
1590
- this.camera.lookAt(this.target);
1591
- }
1592
- });
1593
- /**
1594
- * Rotate camera around its direction axis passing by a given point by a given angle
1595
- * @param {Vector3} point The point where the rotation axis is passing trough
1596
- * @param {Number} angle Angle in radians
1597
- * @returns The computed transormation matix
1598
- */
1599
- __publicField(this, "zRotate", (point, angle) => {
1600
- this._rotationMatrix.makeRotationAxis(this._rotationAxis, angle);
1601
- this._translationMatrix.makeTranslation(-point.x, -point.y, -point.z);
1602
- this._m4_1.makeTranslation(point.x, point.y, point.z);
1603
- this._m4_1.multiply(this._rotationMatrix);
1604
- this._m4_1.multiply(this._translationMatrix);
1605
- this._v3_1.setFromMatrixPosition(this._gizmoMatrixState).sub(point);
1606
- this._v3_2.copy(this._v3_1).applyAxisAngle(this._rotationAxis, angle);
1607
- this._v3_2.sub(this._v3_1);
1608
- this._m4_2.makeTranslation(this._v3_2.x, this._v3_2.y, this._v3_2.z);
1609
- this.setTransformationMatrices(this._m4_1, this._m4_2);
1610
- return _transformation;
1611
- });
1612
- /**
1613
- * Unproject the cursor on the 3D object surface
1614
- * @param {Vector2} cursor Cursor coordinates in NDC
1615
- * @param {Camera} camera Virtual camera
1616
- * @returns {Vector3} The point of intersection with the model, if exist, null otherwise
1617
- */
1618
- __publicField(this, "unprojectOnObj", (cursor, camera) => {
1619
- if (!this.scene)
1620
- return null;
1621
- const raycaster = new Raycaster();
1622
- raycaster.near = camera.near;
1623
- raycaster.far = camera.far;
1624
- raycaster.setFromCamera(cursor, camera);
1625
- const intersect = raycaster.intersectObjects(this.scene.children, true);
1626
- for (let i = 0; i < intersect.length; i++) {
1627
- if (intersect[i].object.uuid != this._gizmos.uuid && intersect[i].face) {
1628
- return intersect[i].point.clone();
1629
- }
1630
- }
1631
- return null;
1632
- });
1633
- /**
1634
- * Unproject the cursor on the trackball surface
1635
- * @param {Camera} camera The virtual camera
1636
- * @param {Number} cursorX Cursor horizontal coordinate on screen
1637
- * @param {Number} cursorY Cursor vertical coordinate on screen
1638
- * @param {HTMLElement} canvas The canvas where the renderer draws its output
1639
- * @param {number} tbRadius The trackball radius
1640
- * @returns {Vector3} The unprojected point on the trackball surface
1641
- */
1642
- __publicField(this, "unprojectOnTbSurface", (camera, cursorX, cursorY, canvas, tbRadius) => {
1643
- if (camera instanceof OrthographicCamera) {
1644
- this._v2_1.copy(this.getCursorPosition(cursorX, cursorY, canvas));
1645
- this._v3_1.set(this._v2_1.x, this._v2_1.y, 0);
1646
- const x2 = Math.pow(this._v2_1.x, 2);
1647
- const y2 = Math.pow(this._v2_1.y, 2);
1648
- const r2 = Math.pow(this._tbRadius, 2);
1649
- if (x2 + y2 <= r2 * 0.5) {
1650
- this._v3_1.setZ(Math.sqrt(r2 - (x2 + y2)));
1651
- } else {
1652
- this._v3_1.setZ(r2 * 0.5 / Math.sqrt(x2 + y2));
1653
- }
1654
- return this._v3_1;
1655
- }
1656
- if (camera instanceof PerspectiveCamera) {
1657
- this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
1658
- this._v3_1.set(this._v2_1.x, this._v2_1.y, -1);
1659
- this._v3_1.applyMatrix4(camera.projectionMatrixInverse);
1660
- const rayDir = this._v3_1.clone().normalize();
1661
- const cameraGizmoDistance = camera.position.distanceTo(this._gizmos.position);
1662
- const radius2 = Math.pow(tbRadius, 2);
1663
- const h = this._v3_1.z;
1664
- const l = Math.sqrt(Math.pow(this._v3_1.x, 2) + Math.pow(this._v3_1.y, 2));
1665
- if (l == 0) {
1666
- rayDir.set(this._v3_1.x, this._v3_1.y, tbRadius);
1667
- return rayDir;
1668
- }
1669
- const m = h / l;
1670
- const q = cameraGizmoDistance;
1671
- let a = Math.pow(m, 2) + 1;
1672
- let b = 2 * m * q;
1673
- let c = Math.pow(q, 2) - radius2;
1674
- let delta = Math.pow(b, 2) - 4 * a * c;
1675
- if (delta >= 0) {
1676
- this._v2_1.setX((-b - Math.sqrt(delta)) / (2 * a));
1677
- this._v2_1.setY(m * this._v2_1.x + q);
1678
- const angle = MathUtils.RAD2DEG * this._v2_1.angle();
1679
- if (angle >= 45) {
1680
- const rayLength2 = Math.sqrt(Math.pow(this._v2_1.x, 2) + Math.pow(cameraGizmoDistance - this._v2_1.y, 2));
1681
- rayDir.multiplyScalar(rayLength2);
1682
- rayDir.z += cameraGizmoDistance;
1683
- return rayDir;
1684
- }
1685
- }
1686
- a = m;
1687
- b = q;
1688
- c = -radius2 * 0.5;
1689
- delta = Math.pow(b, 2) - 4 * a * c;
1690
- this._v2_1.setX((-b - Math.sqrt(delta)) / (2 * a));
1691
- this._v2_1.setY(m * this._v2_1.x + q);
1692
- const rayLength = Math.sqrt(Math.pow(this._v2_1.x, 2) + Math.pow(cameraGizmoDistance - this._v2_1.y, 2));
1693
- rayDir.multiplyScalar(rayLength);
1694
- rayDir.z += cameraGizmoDistance;
1695
- return rayDir;
1696
- }
1697
- });
1698
- /**
1699
- * Unproject the cursor on the plane passing through the center of the trackball orthogonal to the camera
1700
- * @param {Camera} camera The virtual camera
1701
- * @param {Number} cursorX Cursor horizontal coordinate on screen
1702
- * @param {Number} cursorY Cursor vertical coordinate on screen
1703
- * @param {HTMLElement} canvas The canvas where the renderer draws its output
1704
- * @param {Boolean} initialDistance If initial distance between camera and gizmos should be used for calculations instead of current (Perspective only)
1705
- * @returns {Vector3} The unprojected point on the trackball plane
1706
- */
1707
- __publicField(this, "unprojectOnTbPlane", (camera, cursorX, cursorY, canvas, initialDistance = false) => {
1708
- if (camera instanceof OrthographicCamera) {
1709
- this._v2_1.copy(this.getCursorPosition(cursorX, cursorY, canvas));
1710
- this._v3_1.set(this._v2_1.x, this._v2_1.y, 0);
1711
- return this._v3_1.clone();
1712
- }
1713
- if (camera instanceof PerspectiveCamera) {
1714
- this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
1715
- this._v3_1.set(this._v2_1.x, this._v2_1.y, -1);
1716
- this._v3_1.applyMatrix4(camera.projectionMatrixInverse);
1717
- const rayDir = this._v3_1.clone().normalize();
1718
- const h = this._v3_1.z;
1719
- const l = Math.sqrt(Math.pow(this._v3_1.x, 2) + Math.pow(this._v3_1.y, 2));
1720
- let cameraGizmoDistance;
1721
- if (initialDistance) {
1722
- cameraGizmoDistance = this._v3_1.setFromMatrixPosition(this._cameraMatrixState0).distanceTo(this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0));
1723
- } else {
1724
- cameraGizmoDistance = camera.position.distanceTo(this._gizmos.position);
1725
- }
1726
- if (l == 0) {
1727
- rayDir.set(0, 0, 0);
1728
- return rayDir;
1729
- }
1730
- const m = h / l;
1731
- const q = cameraGizmoDistance;
1732
- const x = -q / m;
1733
- const rayLength = Math.sqrt(Math.pow(q, 2) + Math.pow(x, 2));
1734
- rayDir.multiplyScalar(rayLength);
1735
- rayDir.z = 0;
1736
- return rayDir;
1737
- }
1738
- });
1739
- /**
1740
- * Update camera and gizmos state
1741
- */
1742
- __publicField(this, "updateMatrixState", () => {
1743
- if (!this.camera)
1744
- return;
1745
- this._cameraMatrixState.copy(this.camera.matrix);
1746
- this._gizmoMatrixState.copy(this._gizmos.matrix);
1747
- if (this.camera instanceof OrthographicCamera) {
1748
- this._cameraProjectionState.copy(this.camera.projectionMatrix);
1749
- this.camera.updateProjectionMatrix();
1750
- this._zoomState = this.camera.zoom;
1751
- }
1752
- if (this.camera instanceof PerspectiveCamera) {
1753
- this._fovState = this.camera.fov;
1754
- }
1755
- });
1756
- /**
1757
- * Update the trackball FSA
1758
- * @param {STATE} newState New state of the FSA
1759
- * @param {Boolean} updateMatrices If matriices state should be updated
1760
- */
1761
- __publicField(this, "updateTbState", (newState, updateMatrices) => {
1762
- this._state = newState;
1763
- if (updateMatrices) {
1764
- this.updateMatrixState();
1765
- }
1766
- });
1767
- __publicField(this, "update", () => {
1768
- const EPS = 1e-6;
1769
- if (!this.target.equals(this._currentTarget) && this.camera) {
1770
- this._gizmos.position.set(this.target.x, this.target.y, this.target.z);
1771
- const tbRadius = this.calculateTbRadius(this.camera);
1772
- if (tbRadius !== void 0) {
1773
- this._tbRadius = tbRadius;
1774
- }
1775
- this.makeGizmos(this.target, this._tbRadius);
1776
- this._currentTarget.copy(this.target);
1777
- }
1778
- if (!this.camera)
1779
- return;
1780
- if (this.camera instanceof OrthographicCamera) {
1781
- if (this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom) {
1782
- const newZoom = MathUtils.clamp(this.camera.zoom, this.minZoom, this.maxZoom);
1783
- this.applyTransformMatrix(this.applyScale(newZoom / this.camera.zoom, this._gizmos.position, true));
1784
- }
1785
- }
1786
- if (this.camera instanceof PerspectiveCamera) {
1787
- const distance = this.camera.position.distanceTo(this._gizmos.position);
1788
- if (distance > this.maxDistance + EPS || distance < this.minDistance - EPS) {
1789
- const newDistance = MathUtils.clamp(distance, this.minDistance, this.maxDistance);
1790
- this.applyTransformMatrix(this.applyScale(newDistance / distance, this._gizmos.position));
1791
- this.updateMatrixState();
1792
- }
1793
- if (this.camera.fov < this.minFov || this.camera.fov > this.maxFov) {
1794
- this.camera.fov = MathUtils.clamp(this.camera.fov, this.minFov, this.maxFov);
1795
- this.camera.updateProjectionMatrix();
1796
- }
1797
- const oldRadius = this._tbRadius;
1798
- const tbRadius = this.calculateTbRadius(this.camera);
1799
- if (tbRadius !== void 0) {
1800
- this._tbRadius = tbRadius;
1801
- }
1802
- if (oldRadius < this._tbRadius - EPS || oldRadius > this._tbRadius + EPS) {
1803
- const scale = (this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z) / 3;
1804
- const newRadius = this._tbRadius / scale;
1805
- const curve = new EllipseCurve(0, 0, newRadius, newRadius);
1806
- const points = curve.getPoints(this._curvePts);
1807
- const curveGeometry = new BufferGeometry().setFromPoints(points);
1808
- for (const gizmo in this._gizmos.children) {
1809
- const child = this._gizmos.children[gizmo];
1810
- child.geometry = curveGeometry;
1811
- }
1812
- }
1813
- }
1814
- this.camera.lookAt(this._gizmos.position);
1815
- });
1816
- __publicField(this, "setStateFromJSON", (json) => {
1817
- const state = JSON.parse(json);
1818
- if (state.arcballState && this.camera) {
1819
- this._cameraMatrixState.fromArray(state.arcballState.cameraMatrix.elements);
1820
- this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
1821
- this.camera.up.copy(state.arcballState.cameraUp);
1822
- this.camera.near = state.arcballState.cameraNear;
1823
- this.camera.far = state.arcballState.cameraFar;
1824
- this.camera.zoom = state.arcballState.cameraZoom;
1825
- if (this.camera instanceof PerspectiveCamera) {
1826
- this.camera.fov = state.arcballState.cameraFov;
1827
- }
1828
- this._gizmoMatrixState.fromArray(state.arcballState.gizmoMatrix.elements);
1829
- this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1830
- this.camera.updateMatrix();
1831
- this.camera.updateProjectionMatrix();
1832
- this._gizmos.updateMatrix();
1833
- const tbRadius = this.calculateTbRadius(this.camera);
1834
- if (tbRadius !== void 0) {
1835
- this._tbRadius = tbRadius;
1836
- }
1837
- const gizmoTmp = new Matrix4().copy(this._gizmoMatrixState0);
1838
- this.makeGizmos(this._gizmos.position, this._tbRadius);
1839
- this._gizmoMatrixState0.copy(gizmoTmp);
1840
- this.camera.lookAt(this._gizmos.position);
1841
- this.updateTbState(STATE.IDLE, false);
1842
- this.dispatchEvent(_changeEvent);
1843
- }
1844
- });
1845
- this.camera = null;
1846
- this.domElement = domElement;
1847
- this.scene = scene;
1848
- this.mouseActions = [];
1849
- this._mouseOp = null;
1850
- this._v2_1 = new Vector2();
1851
- this._v3_1 = new Vector3();
1852
- this._v3_2 = new Vector3();
1853
- this._m4_1 = new Matrix4();
1854
- this._m4_2 = new Matrix4();
1855
- this._quat = new Quaternion();
1856
- this._translationMatrix = new Matrix4();
1857
- this._rotationMatrix = new Matrix4();
1858
- this._scaleMatrix = new Matrix4();
1859
- this._rotationAxis = new Vector3();
1860
- this._cameraMatrixState = new Matrix4();
1861
- this._cameraProjectionState = new Matrix4();
1862
- this._fovState = 1;
1863
- this._upState = new Vector3();
1864
- this._zoomState = 1;
1865
- this._nearPos = 0;
1866
- this._farPos = 0;
1867
- this._gizmoMatrixState = new Matrix4();
1868
- this._up0 = new Vector3();
1869
- this._zoom0 = 1;
1870
- this._fov0 = 0;
1871
- this._initialNear = 0;
1872
- this._nearPos0 = 0;
1873
- this._initialFar = 0;
1874
- this._farPos0 = 0;
1875
- this._cameraMatrixState0 = new Matrix4();
1876
- this._gizmoMatrixState0 = new Matrix4();
1877
- this._button = -1;
1878
- this._touchStart = [];
1879
- this._touchCurrent = [];
1880
- this._input = INPUT.NONE;
1881
- this._switchSensibility = 32;
1882
- this._startFingerDistance = 0;
1883
- this._currentFingerDistance = 0;
1884
- this._startFingerRotation = 0;
1885
- this._currentFingerRotation = 0;
1886
- this._devPxRatio = 0;
1887
- this._downValid = true;
1888
- this._nclicks = 0;
1889
- this._downEvents = [];
1890
- this._clickStart = 0;
1891
- this._maxDownTime = 250;
1892
- this._maxInterval = 300;
1893
- this._posThreshold = 24;
1894
- this._movementThreshold = 24;
1895
- this._currentCursorPosition = new Vector3();
1896
- this._startCursorPosition = new Vector3();
1897
- this._grid = null;
1898
- this._gridPosition = new Vector3();
1899
- this._gizmos = new Group();
1900
- this._curvePts = 128;
1901
- this._timeStart = -1;
1902
- this._animationId = -1;
1903
- this.focusAnimationTime = 500;
1904
- this._timePrev = 0;
1905
- this._timeCurrent = 0;
1906
- this._anglePrev = 0;
1907
- this._angleCurrent = 0;
1908
- this._cursorPosPrev = new Vector3();
1909
- this._cursorPosCurr = new Vector3();
1910
- this._wPrev = 0;
1911
- this._wCurr = 0;
1912
- this.adjustNearFar = false;
1913
- this.scaleFactor = 1.1;
1914
- this.dampingFactor = 25;
1915
- this.wMax = 20;
1916
- this.enableAnimations = true;
1917
- this.enableGrid = false;
1918
- this.cursorZoom = false;
1919
- this.minFov = 5;
1920
- this.maxFov = 90;
1921
- this.enabled = true;
1922
- this.enablePan = true;
1923
- this.enableRotate = true;
1924
- this.enableZoom = true;
1925
- this.minDistance = 0;
1926
- this.maxDistance = Infinity;
1927
- this.minZoom = 0;
1928
- this.maxZoom = Infinity;
1929
- this.target = new Vector3(0, 0, 0);
1930
- this._currentTarget = new Vector3(0, 0, 0);
1931
- this._tbRadius = 1;
1932
- this._state = STATE.IDLE;
1933
- this.setCamera(camera);
1934
- if (this.scene) {
1935
- this.scene.add(this._gizmos);
1936
- }
1937
- this._devPxRatio = window.devicePixelRatio;
1938
- this.initializeMouseActions();
1939
- if (this.domElement)
1940
- this.connect(this.domElement);
1941
- window.addEventListener("resize", this.onWindowResize);
1942
- }
1943
- /**
1944
- * Apply a transformation matrix, to the camera and gizmos
1945
- * @param {Object} transformation Object containing matrices to apply to camera and gizmos
1946
- */
1947
- applyTransformMatrix(transformation) {
1948
- if ((transformation == null ? void 0 : transformation.camera) && this.camera) {
1949
- this._m4_1.copy(this._cameraMatrixState).premultiply(transformation.camera);
1950
- this._m4_1.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
1951
- this.camera.updateMatrix();
1952
- if (this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE) {
1953
- this.camera.up.copy(this._upState).applyQuaternion(this.camera.quaternion);
1954
- }
1955
- }
1956
- if (transformation == null ? void 0 : transformation.gizmos) {
1957
- this._m4_1.copy(this._gizmoMatrixState).premultiply(transformation.gizmos);
1958
- this._m4_1.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
1959
- this._gizmos.updateMatrix();
1960
- }
1961
- if ((this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) && this.camera) {
1962
- const tbRadius = this.calculateTbRadius(this.camera);
1963
- if (tbRadius !== void 0) {
1964
- this._tbRadius = tbRadius;
1965
- }
1966
- if (this.adjustNearFar) {
1967
- const cameraDistance = this.camera.position.distanceTo(this._gizmos.position);
1968
- const bb = new Box3();
1969
- bb.setFromObject(this._gizmos);
1970
- const sphere = new Sphere();
1971
- bb.getBoundingSphere(sphere);
1972
- const adjustedNearPosition = Math.max(this._nearPos0, sphere.radius + sphere.center.length());
1973
- const regularNearPosition = cameraDistance - this._initialNear;
1974
- const minNearPos = Math.min(adjustedNearPosition, regularNearPosition);
1975
- this.camera.near = cameraDistance - minNearPos;
1976
- const adjustedFarPosition = Math.min(this._farPos0, -sphere.radius + sphere.center.length());
1977
- const regularFarPosition = cameraDistance - this._initialFar;
1978
- const minFarPos = Math.min(adjustedFarPosition, regularFarPosition);
1979
- this.camera.far = cameraDistance - minFarPos;
1980
- this.camera.updateProjectionMatrix();
1981
- } else {
1982
- let update = false;
1983
- if (this.camera.near != this._initialNear) {
1984
- this.camera.near = this._initialNear;
1985
- update = true;
1986
- }
1987
- if (this.camera.far != this._initialFar) {
1988
- this.camera.far = this._initialFar;
1989
- update = true;
1990
- }
1991
- if (update) {
1992
- this.camera.updateProjectionMatrix();
1993
- }
1994
- }
1995
- }
1996
- }
1997
- /**
1998
- * Set gizmos visibility
1999
- * @param {Boolean} value Value of gizmos visibility
2000
- */
2001
- setGizmosVisible(value) {
2002
- this._gizmos.visible = value;
2003
- this.dispatchEvent(_changeEvent);
2004
- }
2005
- /**
2006
- * Set values in transformation object
2007
- * @param {Matrix4} camera Transformation to be applied to the camera
2008
- * @param {Matrix4} gizmos Transformation to be applied to gizmos
2009
- */
2010
- setTransformationMatrices(camera = null, gizmos = null) {
2011
- if (camera) {
2012
- if (_transformation.camera) {
2013
- _transformation.camera.copy(camera);
2014
- } else {
2015
- _transformation.camera = camera.clone();
2016
- }
2017
- } else {
2018
- _transformation.camera = null;
2019
- }
2020
- if (gizmos) {
2021
- if (_transformation.gizmos) {
2022
- _transformation.gizmos.copy(gizmos);
2023
- } else {
2024
- _transformation.gizmos = gizmos.clone();
2025
- }
2026
- } else {
2027
- _transformation.gizmos = null;
2028
- }
2029
- }
2030
- }
2031
- export {
2032
- ArcballControls
2033
- };