three-stdlib 2.25.0 → 2.25.1

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