@needle-tools/three 0.145.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/build/three.cjs +36042 -0
  4. package/build/three.js +36048 -0
  5. package/build/three.min.js +6 -0
  6. package/build/three.module.js +49769 -0
  7. package/examples/fonts/LICENSE +13 -0
  8. package/examples/fonts/README.md +11 -0
  9. package/examples/fonts/droid/NOTICE +190 -0
  10. package/examples/fonts/droid/README.txt +18 -0
  11. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  12. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  13. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  14. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  15. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  16. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  17. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  18. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  19. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  20. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  21. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  22. package/examples/fonts/open-sans/open-sans.css +9 -0
  23. package/examples/fonts/optimer_bold.typeface.json +1 -0
  24. package/examples/fonts/optimer_regular.typeface.json +1 -0
  25. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  26. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  27. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  28. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  29. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  30. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/js/animation/AnimationClipCreator.js +97 -0
  34. package/examples/js/animation/CCDIKSolver.js +433 -0
  35. package/examples/js/animation/MMDAnimationHelper.js +1117 -0
  36. package/examples/js/animation/MMDPhysics.js +1238 -0
  37. package/examples/js/cameras/CinematicCamera.js +157 -0
  38. package/examples/js/controls/ArcballControls.js +3037 -0
  39. package/examples/js/controls/DragControls.js +230 -0
  40. package/examples/js/controls/FirstPersonControls.js +334 -0
  41. package/examples/js/controls/FlyControls.js +347 -0
  42. package/examples/js/controls/OrbitControls.js +1075 -0
  43. package/examples/js/controls/PointerLockControls.js +153 -0
  44. package/examples/js/controls/TrackballControls.js +782 -0
  45. package/examples/js/controls/TransformControls.js +1386 -0
  46. package/examples/js/csm/CSM.js +382 -0
  47. package/examples/js/csm/CSMFrustum.js +133 -0
  48. package/examples/js/csm/CSMHelper.js +145 -0
  49. package/examples/js/csm/CSMShader.js +257 -0
  50. package/examples/js/curves/CurveExtras.js +348 -0
  51. package/examples/js/curves/NURBSCurve.js +75 -0
  52. package/examples/js/curves/NURBSSurface.js +54 -0
  53. package/examples/js/curves/NURBSUtils.js +476 -0
  54. package/examples/js/effects/AnaglyphEffect.js +100 -0
  55. package/examples/js/effects/AsciiEffect.js +259 -0
  56. package/examples/js/effects/OutlineEffect.js +454 -0
  57. package/examples/js/effects/ParallaxBarrierEffect.js +75 -0
  58. package/examples/js/effects/PeppersGhostEffect.js +166 -0
  59. package/examples/js/effects/StereoEffect.js +50 -0
  60. package/examples/js/environments/DebugEnvironment.js +53 -0
  61. package/examples/js/environments/RoomEnvironment.js +122 -0
  62. package/examples/js/exporters/ColladaExporter.js +504 -0
  63. package/examples/js/exporters/DRACOExporter.js +212 -0
  64. package/examples/js/exporters/EXRExporter.js +458 -0
  65. package/examples/js/exporters/GLTFExporter.js +2543 -0
  66. package/examples/js/exporters/MMDExporter.js +194 -0
  67. package/examples/js/exporters/OBJExporter.js +251 -0
  68. package/examples/js/exporters/PLYExporter.js +422 -0
  69. package/examples/js/exporters/STLExporter.js +190 -0
  70. package/examples/js/exporters/USDZExporter.js +523 -0
  71. package/examples/js/geometries/BoxLineGeometry.js +60 -0
  72. package/examples/js/geometries/ConvexGeometry.js +48 -0
  73. package/examples/js/geometries/DecalGeometry.js +291 -0
  74. package/examples/js/geometries/LightningStrike.js +874 -0
  75. package/examples/js/geometries/ParametricGeometries.js +215 -0
  76. package/examples/js/geometries/ParametricGeometry.js +108 -0
  77. package/examples/js/geometries/RoundedBoxGeometry.js +140 -0
  78. package/examples/js/geometries/TeapotGeometry.js +331 -0
  79. package/examples/js/geometries/TextGeometry.js +51 -0
  80. package/examples/js/helpers/LightProbeHelper.js +49 -0
  81. package/examples/js/helpers/OctreeHelper.js +74 -0
  82. package/examples/js/helpers/PositionalAudioHelper.js +89 -0
  83. package/examples/js/helpers/RectAreaLightHelper.js +74 -0
  84. package/examples/js/helpers/VertexNormalsHelper.js +72 -0
  85. package/examples/js/helpers/VertexTangentsHelper.js +62 -0
  86. package/examples/js/helpers/ViewHelper.js +266 -0
  87. package/examples/js/interactive/HTMLMesh.js +508 -0
  88. package/examples/js/interactive/InteractiveGroup.js +101 -0
  89. package/examples/js/interactive/SelectionBox.js +262 -0
  90. package/examples/js/interactive/SelectionHelper.js +91 -0
  91. package/examples/js/libs/ammo.wasm.js +822 -0
  92. package/examples/js/libs/ammo.wasm.wasm +0 -0
  93. package/examples/js/libs/basis/README.md +46 -0
  94. package/examples/js/libs/basis/basis_transcoder.js +21 -0
  95. package/examples/js/libs/basis/basis_transcoder.wasm +0 -0
  96. package/examples/js/libs/chevrotain.min.js +3 -0
  97. package/examples/js/libs/draco/README.md +32 -0
  98. package/examples/js/libs/draco/draco_decoder.js +52 -0
  99. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  100. package/examples/js/libs/draco/draco_encoder.js +33 -0
  101. package/examples/js/libs/draco/draco_wasm_wrapper.js +104 -0
  102. package/examples/js/libs/draco/gltf/draco_decoder.js +48 -0
  103. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  104. package/examples/js/libs/draco/gltf/draco_encoder.js +33 -0
  105. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +104 -0
  106. package/examples/js/libs/fflate.min.js +7 -0
  107. package/examples/js/libs/ktx-parse.umd.js +1 -0
  108. package/examples/js/libs/lottie_canvas.js +12751 -0
  109. package/examples/js/libs/meshopt_decoder.js +188 -0
  110. package/examples/js/libs/opentype.min.js +1 -0
  111. package/examples/js/libs/stats.min.js +5 -0
  112. package/examples/js/lights/LightProbeGenerator.js +228 -0
  113. package/examples/js/lights/RectAreaLightUniformsLib.js +56 -0
  114. package/examples/js/lines/Line2.js +19 -0
  115. package/examples/js/lines/LineGeometry.js +71 -0
  116. package/examples/js/lines/LineMaterial.js +642 -0
  117. package/examples/js/lines/LineSegments2.js +362 -0
  118. package/examples/js/lines/LineSegmentsGeometry.js +219 -0
  119. package/examples/js/lines/Wireframe.js +52 -0
  120. package/examples/js/lines/WireframeGeometry2.js +18 -0
  121. package/examples/js/loaders/3DMLoader.js +1370 -0
  122. package/examples/js/loaders/3MFLoader.js +1340 -0
  123. package/examples/js/loaders/AMFLoader.js +529 -0
  124. package/examples/js/loaders/BVHLoader.js +394 -0
  125. package/examples/js/loaders/BasisTextureLoader.js +736 -0
  126. package/examples/js/loaders/ColladaLoader.js +3821 -0
  127. package/examples/js/loaders/DDSLoader.js +245 -0
  128. package/examples/js/loaders/DRACOLoader.js +548 -0
  129. package/examples/js/loaders/EXRLoader.js +2136 -0
  130. package/examples/js/loaders/FBXLoader.js +3835 -0
  131. package/examples/js/loaders/FontLoader.js +169 -0
  132. package/examples/js/loaders/GCodeLoader.js +256 -0
  133. package/examples/js/loaders/GLTFLoader.js +4159 -0
  134. package/examples/js/loaders/HDRCubeTextureLoader.js +93 -0
  135. package/examples/js/loaders/KMZLoader.js +125 -0
  136. package/examples/js/loaders/KTXLoader.js +177 -0
  137. package/examples/js/loaders/LDrawLoader.js +2374 -0
  138. package/examples/js/loaders/LUT3dlLoader.js +139 -0
  139. package/examples/js/loaders/LUTCubeLoader.js +140 -0
  140. package/examples/js/loaders/LWOLoader.js +966 -0
  141. package/examples/js/loaders/LogLuvLoader.js +765 -0
  142. package/examples/js/loaders/LottieLoader.js +62 -0
  143. package/examples/js/loaders/MD2Loader.js +249 -0
  144. package/examples/js/loaders/MDDLoader.js +95 -0
  145. package/examples/js/loaders/MMDLoader.js +1924 -0
  146. package/examples/js/loaders/MTLLoader.js +501 -0
  147. package/examples/js/loaders/NRRDLoader.js +649 -0
  148. package/examples/js/loaders/OBJLoader.js +804 -0
  149. package/examples/js/loaders/PCDLoader.js +408 -0
  150. package/examples/js/loaders/PDBLoader.js +313 -0
  151. package/examples/js/loaders/PLYLoader.js +562 -0
  152. package/examples/js/loaders/PRWMLoader.js +260 -0
  153. package/examples/js/loaders/PVRLoader.js +227 -0
  154. package/examples/js/loaders/RGBELoader.js +467 -0
  155. package/examples/js/loaders/RGBMLoader.js +1415 -0
  156. package/examples/js/loaders/STLLoader.js +371 -0
  157. package/examples/js/loaders/SVGLoader.js +2655 -0
  158. package/examples/js/loaders/TDSLoader.js +1029 -0
  159. package/examples/js/loaders/TGALoader.js +486 -0
  160. package/examples/js/loaders/TIFFLoader.js +31 -0
  161. package/examples/js/loaders/TTFLoader.js +211 -0
  162. package/examples/js/loaders/TiltLoader.js +460 -0
  163. package/examples/js/loaders/VOXLoader.js +248 -0
  164. package/examples/js/loaders/VRMLLoader.js +3237 -0
  165. package/examples/js/loaders/VTKLoader.js +1095 -0
  166. package/examples/js/loaders/XYZLoader.js +91 -0
  167. package/examples/js/loaders/lwo/IFFParser.js +1148 -0
  168. package/examples/js/loaders/lwo/LWO2Parser.js +448 -0
  169. package/examples/js/loaders/lwo/LWO3Parser.js +402 -0
  170. package/examples/js/materials/MeshGouraudMaterial.js +385 -0
  171. package/examples/js/math/Capsule.js +120 -0
  172. package/examples/js/math/ColorConverter.js +33 -0
  173. package/examples/js/math/ConvexHull.js +1110 -0
  174. package/examples/js/math/ImprovedNoise.js +66 -0
  175. package/examples/js/math/Lut.js +171 -0
  176. package/examples/js/math/MeshSurfaceSampler.js +193 -0
  177. package/examples/js/math/OBB.js +341 -0
  178. package/examples/js/math/Octree.js +465 -0
  179. package/examples/js/math/SimplexNoise.js +459 -0
  180. package/examples/js/misc/ConvexObjectBreaker.js +485 -0
  181. package/examples/js/misc/GPUComputationRenderer.js +397 -0
  182. package/examples/js/misc/Gyroscope.js +60 -0
  183. package/examples/js/misc/MD2Character.js +244 -0
  184. package/examples/js/misc/MD2CharacterComplex.js +494 -0
  185. package/examples/js/misc/MorphAnimMesh.js +69 -0
  186. package/examples/js/misc/MorphBlendMesh.js +292 -0
  187. package/examples/js/misc/ProgressiveLightMap.js +331 -0
  188. package/examples/js/misc/RollerCoaster.js +437 -0
  189. package/examples/js/misc/TubePainter.js +161 -0
  190. package/examples/js/misc/Volume.js +466 -0
  191. package/examples/js/misc/VolumeSlice.js +224 -0
  192. package/examples/js/modifiers/CurveModifier.js +311 -0
  193. package/examples/js/modifiers/EdgeSplitModifier.js +258 -0
  194. package/examples/js/modifiers/SimplifyModifier.js +468 -0
  195. package/examples/js/modifiers/TessellateModifier.js +283 -0
  196. package/examples/js/objects/GroundProjectedEnv.js +193 -0
  197. package/examples/js/objects/Lensflare.js +347 -0
  198. package/examples/js/objects/LightningStorm.js +209 -0
  199. package/examples/js/objects/MarchingCubes.js +738 -0
  200. package/examples/js/objects/Reflector.js +214 -0
  201. package/examples/js/objects/ReflectorForSSRPass.js +319 -0
  202. package/examples/js/objects/Refractor.js +261 -0
  203. package/examples/js/objects/ShadowMesh.js +60 -0
  204. package/examples/js/objects/Sky.js +223 -0
  205. package/examples/js/objects/Water.js +287 -0
  206. package/examples/js/objects/Water2.js +306 -0
  207. package/examples/js/physics/AmmoPhysics.js +256 -0
  208. package/examples/js/physics/OimoPhysics.js +215 -0
  209. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +342 -0
  210. package/examples/js/postprocessing/AfterimagePass.js +70 -0
  211. package/examples/js/postprocessing/BloomPass.js +114 -0
  212. package/examples/js/postprocessing/BokehPass.js +103 -0
  213. package/examples/js/postprocessing/ClearPass.js +44 -0
  214. package/examples/js/postprocessing/CubeTexturePass.js +57 -0
  215. package/examples/js/postprocessing/DotScreenPass.js +49 -0
  216. package/examples/js/postprocessing/EffectComposer.js +279 -0
  217. package/examples/js/postprocessing/FilmPass.js +50 -0
  218. package/examples/js/postprocessing/GlitchPass.js +105 -0
  219. package/examples/js/postprocessing/HalftonePass.js +75 -0
  220. package/examples/js/postprocessing/LUTPass.js +184 -0
  221. package/examples/js/postprocessing/MaskPass.js +92 -0
  222. package/examples/js/postprocessing/OutlinePass.js +589 -0
  223. package/examples/js/postprocessing/Pass.js +75 -0
  224. package/examples/js/postprocessing/RenderPass.js +74 -0
  225. package/examples/js/postprocessing/SAOPass.js +366 -0
  226. package/examples/js/postprocessing/SMAAPass.js +153 -0
  227. package/examples/js/postprocessing/SSAARenderPass.js +156 -0
  228. package/examples/js/postprocessing/SSAOPass.js +351 -0
  229. package/examples/js/postprocessing/SSRPass.js +550 -0
  230. package/examples/js/postprocessing/SavePass.js +51 -0
  231. package/examples/js/postprocessing/ShaderPass.js +63 -0
  232. package/examples/js/postprocessing/TAARenderPass.js +128 -0
  233. package/examples/js/postprocessing/TexturePass.js +46 -0
  234. package/examples/js/postprocessing/UnrealBloomPass.js +357 -0
  235. package/examples/js/renderers/CSS2DRenderer.js +197 -0
  236. package/examples/js/renderers/CSS3DRenderer.js +258 -0
  237. package/examples/js/renderers/Projector.js +874 -0
  238. package/examples/js/renderers/SVGRenderer.js +537 -0
  239. package/examples/js/shaders/ACESFilmicToneMappingShader.js +92 -0
  240. package/examples/js/shaders/AfterimageShader.js +63 -0
  241. package/examples/js/shaders/BasicShader.js +30 -0
  242. package/examples/js/shaders/BleachBypassShader.js +65 -0
  243. package/examples/js/shaders/BlendShader.js +57 -0
  244. package/examples/js/shaders/BokehShader.js +159 -0
  245. package/examples/js/shaders/BokehShader2.js +428 -0
  246. package/examples/js/shaders/BrightnessContrastShader.js +61 -0
  247. package/examples/js/shaders/ColorCorrectionShader.js +56 -0
  248. package/examples/js/shaders/ColorifyShader.js +51 -0
  249. package/examples/js/shaders/ConvolutionShader.js +97 -0
  250. package/examples/js/shaders/CopyShader.js +48 -0
  251. package/examples/js/shaders/DOFMipMapShader.js +63 -0
  252. package/examples/js/shaders/DepthLimitedBlurShader.js +180 -0
  253. package/examples/js/shaders/DigitalGlitch.js +130 -0
  254. package/examples/js/shaders/DotScreenShader.js +76 -0
  255. package/examples/js/shaders/FXAAShader.js +286 -0
  256. package/examples/js/shaders/FilmShader.js +113 -0
  257. package/examples/js/shaders/FocusShader.js +98 -0
  258. package/examples/js/shaders/FreiChenShader.js +97 -0
  259. package/examples/js/shaders/GammaCorrectionShader.js +44 -0
  260. package/examples/js/shaders/GodRaysShader.js +297 -0
  261. package/examples/js/shaders/HalftoneShader.js +339 -0
  262. package/examples/js/shaders/HorizontalBlurShader.js +62 -0
  263. package/examples/js/shaders/HorizontalTiltShiftShader.js +68 -0
  264. package/examples/js/shaders/HueSaturationShader.js +72 -0
  265. package/examples/js/shaders/KaleidoShader.js +63 -0
  266. package/examples/js/shaders/LuminosityHighPassShader.js +71 -0
  267. package/examples/js/shaders/LuminosityShader.js +49 -0
  268. package/examples/js/shaders/MMDToonShader.js +100 -0
  269. package/examples/js/shaders/MirrorShader.js +59 -0
  270. package/examples/js/shaders/NormalMapShader.js +59 -0
  271. package/examples/js/shaders/PixelShader.js +51 -0
  272. package/examples/js/shaders/RGBShiftShader.js +59 -0
  273. package/examples/js/shaders/SAOShader.js +213 -0
  274. package/examples/js/shaders/SMAAShader.js +466 -0
  275. package/examples/js/shaders/SSAOShader.js +299 -0
  276. package/examples/js/shaders/SSRShader.js +393 -0
  277. package/examples/js/shaders/SepiaShader.js +55 -0
  278. package/examples/js/shaders/SobelOperatorShader.js +92 -0
  279. package/examples/js/shaders/SubsurfaceScatteringShader.js +49 -0
  280. package/examples/js/shaders/TechnicolorShader.js +46 -0
  281. package/examples/js/shaders/ToneMapShader.js +87 -0
  282. package/examples/js/shaders/ToonShader.js +351 -0
  283. package/examples/js/shaders/TriangleBlurShader.js +74 -0
  284. package/examples/js/shaders/UnpackDepthRGBAShader.js +50 -0
  285. package/examples/js/shaders/VerticalBlurShader.js +62 -0
  286. package/examples/js/shaders/VerticalTiltShiftShader.js +68 -0
  287. package/examples/js/shaders/VignetteShader.js +56 -0
  288. package/examples/js/shaders/VolumeShader.js +300 -0
  289. package/examples/js/shaders/WaterRefractionShader.js +88 -0
  290. package/examples/js/textures/FlakesTexture.js +41 -0
  291. package/examples/js/utils/BufferGeometryUtils.js +1094 -0
  292. package/examples/js/utils/CameraUtils.js +86 -0
  293. package/examples/js/utils/GPUStatsPanel.js +134 -0
  294. package/examples/js/utils/GeometryCompressionUtils.js +574 -0
  295. package/examples/js/utils/GeometryUtils.js +173 -0
  296. package/examples/js/utils/LDrawUtils.js +182 -0
  297. package/examples/js/utils/PackedPhongMaterial.js +107 -0
  298. package/examples/js/utils/SceneUtils.js +103 -0
  299. package/examples/js/utils/ShadowMapViewer.js +180 -0
  300. package/examples/js/utils/SkeletonUtils.js +507 -0
  301. package/examples/js/utils/UVsDebug.js +135 -0
  302. package/examples/js/utils/WorkerPool.js +115 -0
  303. package/examples/jsm/animation/AnimationClipCreator.js +114 -0
  304. package/examples/jsm/animation/CCDIKSolver.js +482 -0
  305. package/examples/jsm/animation/MMDAnimationHelper.js +1207 -0
  306. package/examples/jsm/animation/MMDPhysics.js +1406 -0
  307. package/examples/jsm/cameras/CinematicCamera.js +209 -0
  308. package/examples/jsm/capabilities/WebGL.js +91 -0
  309. package/examples/jsm/capabilities/WebGPU.js +39 -0
  310. package/examples/jsm/controls/ArcballControls.js +3216 -0
  311. package/examples/jsm/controls/DragControls.js +220 -0
  312. package/examples/jsm/controls/FirstPersonControls.js +325 -0
  313. package/examples/jsm/controls/FlyControls.js +284 -0
  314. package/examples/jsm/controls/OrbitControls.js +1249 -0
  315. package/examples/jsm/controls/PointerLockControls.js +157 -0
  316. package/examples/jsm/controls/TrackballControls.js +814 -0
  317. package/examples/jsm/controls/TransformControls.js +1558 -0
  318. package/examples/jsm/csm/CSM.js +378 -0
  319. package/examples/jsm/csm/CSMFrustum.js +152 -0
  320. package/examples/jsm/csm/CSMHelper.js +193 -0
  321. package/examples/jsm/csm/CSMShader.js +251 -0
  322. package/examples/jsm/curves/CurveExtras.js +422 -0
  323. package/examples/jsm/curves/NURBSCurve.js +80 -0
  324. package/examples/jsm/curves/NURBSSurface.js +52 -0
  325. package/examples/jsm/curves/NURBSUtils.js +487 -0
  326. package/examples/jsm/effects/AnaglyphEffect.js +168 -0
  327. package/examples/jsm/effects/AsciiEffect.js +266 -0
  328. package/examples/jsm/effects/OutlineEffect.js +553 -0
  329. package/examples/jsm/effects/ParallaxBarrierEffect.js +116 -0
  330. package/examples/jsm/effects/PeppersGhostEffect.js +153 -0
  331. package/examples/jsm/effects/StereoEffect.js +55 -0
  332. package/examples/jsm/environments/DebugEnvironment.js +52 -0
  333. package/examples/jsm/environments/RoomEnvironment.js +144 -0
  334. package/examples/jsm/exporters/ColladaExporter.js +713 -0
  335. package/examples/jsm/exporters/DRACOExporter.js +225 -0
  336. package/examples/jsm/exporters/EXRExporter.js +507 -0
  337. package/examples/jsm/exporters/GLTFExporter.js +2870 -0
  338. package/examples/jsm/exporters/KTX2Exporter.js +281 -0
  339. package/examples/jsm/exporters/MMDExporter.js +217 -0
  340. package/examples/jsm/exporters/OBJExporter.js +284 -0
  341. package/examples/jsm/exporters/PLYExporter.js +521 -0
  342. package/examples/jsm/exporters/STLExporter.js +195 -0
  343. package/examples/jsm/exporters/USDZExporter.js +1112 -0
  344. package/examples/jsm/geometries/BoxLineGeometry.js +69 -0
  345. package/examples/jsm/geometries/ConvexGeometry.js +59 -0
  346. package/examples/jsm/geometries/DecalGeometry.js +356 -0
  347. package/examples/jsm/geometries/LightningStrike.js +1017 -0
  348. package/examples/jsm/geometries/ParametricGeometries.js +254 -0
  349. package/examples/jsm/geometries/ParametricGeometry.js +129 -0
  350. package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -0
  351. package/examples/jsm/geometries/TeapotGeometry.js +704 -0
  352. package/examples/jsm/geometries/TextGeometry.js +57 -0
  353. package/examples/jsm/helpers/LightProbeHelper.js +130 -0
  354. package/examples/jsm/helpers/OctreeHelper.js +72 -0
  355. package/examples/jsm/helpers/PositionalAudioHelper.js +109 -0
  356. package/examples/jsm/helpers/RectAreaLightHelper.js +85 -0
  357. package/examples/jsm/helpers/VertexNormalsHelper.js +96 -0
  358. package/examples/jsm/helpers/VertexTangentsHelper.js +88 -0
  359. package/examples/jsm/helpers/ViewHelper.js +319 -0
  360. package/examples/jsm/interactive/HTMLMesh.js +550 -0
  361. package/examples/jsm/interactive/InteractiveGroup.js +116 -0
  362. package/examples/jsm/interactive/SelectionBox.js +227 -0
  363. package/examples/jsm/interactive/SelectionHelper.js +97 -0
  364. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +37071 -0
  365. package/examples/jsm/libs/OimoPhysics/index.js +43 -0
  366. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  367. package/examples/jsm/libs/ecsy.module.js +1792 -0
  368. package/examples/jsm/libs/fflate.module.js +2474 -0
  369. package/examples/jsm/libs/flow.module.js +4552 -0
  370. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  371. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  372. package/examples/jsm/libs/meshopt_decoder.module.js +178 -0
  373. package/examples/jsm/libs/mikktspace.module.js +128 -0
  374. package/examples/jsm/libs/mmdparser.module.js +11530 -0
  375. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  376. package/examples/jsm/libs/opentype.module.js +14568 -0
  377. package/examples/jsm/libs/potpack.module.js +125 -0
  378. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  379. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  380. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  381. package/examples/jsm/libs/stats.module.js +167 -0
  382. package/examples/jsm/libs/tween.module.min.js +3 -0
  383. package/examples/jsm/libs/utif.module.js +1579 -0
  384. package/examples/jsm/libs/zstddec.module.js +1 -0
  385. package/examples/jsm/lights/LightProbeGenerator.js +250 -0
  386. package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -0
  387. package/examples/jsm/lines/Line2.js +19 -0
  388. package/examples/jsm/lines/LineGeometry.js +79 -0
  389. package/examples/jsm/lines/LineMaterial.js +702 -0
  390. package/examples/jsm/lines/LineSegments2.js +355 -0
  391. package/examples/jsm/lines/LineSegmentsGeometry.js +241 -0
  392. package/examples/jsm/lines/Wireframe.js +56 -0
  393. package/examples/jsm/lines/WireframeGeometry2.js +24 -0
  394. package/examples/jsm/loaders/3DMLoader.js +1495 -0
  395. package/examples/jsm/loaders/3MFLoader.js +1473 -0
  396. package/examples/jsm/loaders/AMFLoader.js +518 -0
  397. package/examples/jsm/loaders/BVHLoader.js +437 -0
  398. package/examples/jsm/loaders/BasisTextureLoader.js +790 -0
  399. package/examples/jsm/loaders/ColladaLoader.js +4092 -0
  400. package/examples/jsm/loaders/DDSLoader.js +274 -0
  401. package/examples/jsm/loaders/DRACOLoader.js +561 -0
  402. package/examples/jsm/loaders/EXRLoader.js +2310 -0
  403. package/examples/jsm/loaders/FBXLoader.js +4137 -0
  404. package/examples/jsm/loaders/FontLoader.js +183 -0
  405. package/examples/jsm/loaders/GCodeLoader.js +262 -0
  406. package/examples/jsm/loaders/GLTFLoader.js +5221 -0
  407. package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -0
  408. package/examples/jsm/loaders/IFCLoader.js +2431 -0
  409. package/examples/jsm/loaders/KMZLoader.js +130 -0
  410. package/examples/jsm/loaders/KTX2Loader.js +753 -0
  411. package/examples/jsm/loaders/KTXLoader.js +176 -0
  412. package/examples/jsm/loaders/LDrawLoader.js +2464 -0
  413. package/examples/jsm/loaders/LUT3dlLoader.js +151 -0
  414. package/examples/jsm/loaders/LUTCubeLoader.js +153 -0
  415. package/examples/jsm/loaders/LWOLoader.js +1069 -0
  416. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  417. package/examples/jsm/loaders/LottieLoader.js +73 -0
  418. package/examples/jsm/loaders/MD2Loader.js +399 -0
  419. package/examples/jsm/loaders/MDDLoader.js +102 -0
  420. package/examples/jsm/loaders/MMDLoader.js +2242 -0
  421. package/examples/jsm/loaders/MTLLoader.js +567 -0
  422. package/examples/jsm/loaders/NRRDLoader.js +671 -0
  423. package/examples/jsm/loaders/OBJLoader.js +905 -0
  424. package/examples/jsm/loaders/PCDLoader.js +453 -0
  425. package/examples/jsm/loaders/PDBLoader.js +227 -0
  426. package/examples/jsm/loaders/PLYLoader.js +564 -0
  427. package/examples/jsm/loaders/PRWMLoader.js +299 -0
  428. package/examples/jsm/loaders/PVRLoader.js +251 -0
  429. package/examples/jsm/loaders/RGBELoader.js +468 -0
  430. package/examples/jsm/loaders/RGBMLoader.js +1065 -0
  431. package/examples/jsm/loaders/STLLoader.js +399 -0
  432. package/examples/jsm/loaders/SVGLoader.js +2950 -0
  433. package/examples/jsm/loaders/TDSLoader.js +1124 -0
  434. package/examples/jsm/loaders/TGALoader.js +517 -0
  435. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  436. package/examples/jsm/loaders/TTFLoader.js +221 -0
  437. package/examples/jsm/loaders/TiltLoader.js +514 -0
  438. package/examples/jsm/loaders/USDZLoader.js +618 -0
  439. package/examples/jsm/loaders/VOXLoader.js +305 -0
  440. package/examples/jsm/loaders/VRMLLoader.js +3493 -0
  441. package/examples/jsm/loaders/VTKLoader.js +1154 -0
  442. package/examples/jsm/loaders/XYZLoader.js +100 -0
  443. package/examples/jsm/loaders/ifc/web-ifc-api.js +47504 -0
  444. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  445. package/examples/jsm/loaders/lwo/IFFParser.js +1218 -0
  446. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  447. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  448. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  449. package/examples/jsm/math/Capsule.js +137 -0
  450. package/examples/jsm/math/ColorConverter.js +36 -0
  451. package/examples/jsm/math/ConvexHull.js +1271 -0
  452. package/examples/jsm/math/ImprovedNoise.js +71 -0
  453. package/examples/jsm/math/Lut.js +203 -0
  454. package/examples/jsm/math/MeshSurfaceSampler.js +211 -0
  455. package/examples/jsm/math/OBB.js +423 -0
  456. package/examples/jsm/math/Octree.js +462 -0
  457. package/examples/jsm/math/SimplexNoise.js +444 -0
  458. package/examples/jsm/misc/ConvexObjectBreaker.js +525 -0
  459. package/examples/jsm/misc/GPUComputationRenderer.js +454 -0
  460. package/examples/jsm/misc/Gyroscope.js +66 -0
  461. package/examples/jsm/misc/MD2Character.js +276 -0
  462. package/examples/jsm/misc/MD2CharacterComplex.js +576 -0
  463. package/examples/jsm/misc/MorphAnimMesh.js +75 -0
  464. package/examples/jsm/misc/MorphBlendMesh.js +322 -0
  465. package/examples/jsm/misc/ProgressiveLightMap.js +321 -0
  466. package/examples/jsm/misc/RollerCoaster.js +560 -0
  467. package/examples/jsm/misc/TubePainter.js +205 -0
  468. package/examples/jsm/misc/Volume.js +460 -0
  469. package/examples/jsm/misc/VolumeSlice.js +227 -0
  470. package/examples/jsm/modifiers/CurveModifier.js +325 -0
  471. package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -0
  472. package/examples/jsm/modifiers/SimplifyModifier.js +525 -0
  473. package/examples/jsm/modifiers/TessellateModifier.js +307 -0
  474. package/examples/jsm/node-editor/NodeEditor.js +857 -0
  475. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +14 -0
  476. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  477. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  478. package/examples/jsm/node-editor/accessors/UVEditor.js +25 -0
  479. package/examples/jsm/node-editor/core/BaseNode.js +96 -0
  480. package/examples/jsm/node-editor/core/DataFile.js +59 -0
  481. package/examples/jsm/node-editor/core/FileEditor.js +20 -0
  482. package/examples/jsm/node-editor/core/FileURLEditor.js +29 -0
  483. package/examples/jsm/node-editor/display/BlendEditor.js +44 -0
  484. package/examples/jsm/node-editor/display/NormalMapEditor.js +49 -0
  485. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  486. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  487. package/examples/jsm/node-editor/examples/matcap.json +1 -0
  488. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  489. package/examples/jsm/node-editor/examples/rim.json +1 -0
  490. package/examples/jsm/node-editor/inputs/ColorEditor.js +96 -0
  491. package/examples/jsm/node-editor/inputs/FloatEditor.js +23 -0
  492. package/examples/jsm/node-editor/inputs/SliderEditor.js +67 -0
  493. package/examples/jsm/node-editor/inputs/TextureEditor.js +155 -0
  494. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  495. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  496. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  497. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +84 -0
  498. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +102 -0
  499. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +118 -0
  500. package/examples/jsm/node-editor/math/AngleEditor.js +40 -0
  501. package/examples/jsm/node-editor/math/DotEditor.js +35 -0
  502. package/examples/jsm/node-editor/math/InvertEditor.js +39 -0
  503. package/examples/jsm/node-editor/math/LimiterEditor.js +62 -0
  504. package/examples/jsm/node-editor/math/NormalizeEditor.js +28 -0
  505. package/examples/jsm/node-editor/math/OperatorEditor.js +63 -0
  506. package/examples/jsm/node-editor/math/PowerEditor.js +44 -0
  507. package/examples/jsm/node-editor/math/TrigonometryEditor.js +45 -0
  508. package/examples/jsm/node-editor/procedural/CheckerEditor.js +27 -0
  509. package/examples/jsm/node-editor/scene/MeshEditor.js +102 -0
  510. package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
  511. package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
  512. package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
  513. package/examples/jsm/node-editor/utils/OscillatorEditor.js +43 -0
  514. package/examples/jsm/node-editor/utils/PreviewEditor.js +170 -0
  515. package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
  516. package/examples/jsm/node-editor/utils/TimerEditor.js +58 -0
  517. package/examples/jsm/nodes/Nodes.js +346 -0
  518. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  519. package/examples/jsm/nodes/accessors/BufferNode.js +24 -0
  520. package/examples/jsm/nodes/accessors/CameraNode.js +67 -0
  521. package/examples/jsm/nodes/accessors/CubeTextureNode.js +107 -0
  522. package/examples/jsm/nodes/accessors/InstanceNode.js +58 -0
  523. package/examples/jsm/nodes/accessors/MaterialNode.js +152 -0
  524. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +23 -0
  525. package/examples/jsm/nodes/accessors/ModelNode.js +21 -0
  526. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +30 -0
  527. package/examples/jsm/nodes/accessors/NormalNode.js +79 -0
  528. package/examples/jsm/nodes/accessors/Object3DNode.js +122 -0
  529. package/examples/jsm/nodes/accessors/PointUVNode.js +21 -0
  530. package/examples/jsm/nodes/accessors/PositionNode.js +83 -0
  531. package/examples/jsm/nodes/accessors/ReferenceNode.js +65 -0
  532. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  533. package/examples/jsm/nodes/accessors/SkinningNode.js +109 -0
  534. package/examples/jsm/nodes/accessors/StorageBufferNode.js +21 -0
  535. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  536. package/examples/jsm/nodes/accessors/TextureNode.js +100 -0
  537. package/examples/jsm/nodes/accessors/UVNode.js +41 -0
  538. package/examples/jsm/nodes/accessors/UserDataNode.js +23 -0
  539. package/examples/jsm/nodes/core/ArrayUniformNode.js +23 -0
  540. package/examples/jsm/nodes/core/AttributeNode.js +94 -0
  541. package/examples/jsm/nodes/core/BypassNode.js +38 -0
  542. package/examples/jsm/nodes/core/CodeNode.js +50 -0
  543. package/examples/jsm/nodes/core/ConstNode.js +29 -0
  544. package/examples/jsm/nodes/core/ContextNode.js +52 -0
  545. package/examples/jsm/nodes/core/ExpressionNode.js +32 -0
  546. package/examples/jsm/nodes/core/FunctionCallNode.js +82 -0
  547. package/examples/jsm/nodes/core/FunctionNode.js +105 -0
  548. package/examples/jsm/nodes/core/InputNode.js +62 -0
  549. package/examples/jsm/nodes/core/InstanceIndexNode.js +21 -0
  550. package/examples/jsm/nodes/core/Node.js +354 -0
  551. package/examples/jsm/nodes/core/NodeAttribute.js +14 -0
  552. package/examples/jsm/nodes/core/NodeBuilder.js +815 -0
  553. package/examples/jsm/nodes/core/NodeCode.js +15 -0
  554. package/examples/jsm/nodes/core/NodeFrame.js +59 -0
  555. package/examples/jsm/nodes/core/NodeFunction.js +22 -0
  556. package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -0
  557. package/examples/jsm/nodes/core/NodeKeywords.js +80 -0
  558. package/examples/jsm/nodes/core/NodeParser.js +11 -0
  559. package/examples/jsm/nodes/core/NodeUniform.js +28 -0
  560. package/examples/jsm/nodes/core/NodeUtils.js +125 -0
  561. package/examples/jsm/nodes/core/NodeVar.js +14 -0
  562. package/examples/jsm/nodes/core/NodeVarying.js +14 -0
  563. package/examples/jsm/nodes/core/PropertyNode.js +36 -0
  564. package/examples/jsm/nodes/core/TempNode.js +50 -0
  565. package/examples/jsm/nodes/core/UniformNode.js +46 -0
  566. package/examples/jsm/nodes/core/VarNode.js +97 -0
  567. package/examples/jsm/nodes/core/VaryingNode.js +54 -0
  568. package/examples/jsm/nodes/core/constants.js +21 -0
  569. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  570. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
  571. package/examples/jsm/nodes/display/ColorSpaceNode.js +95 -0
  572. package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
  573. package/examples/jsm/nodes/display/NormalMapNode.js +93 -0
  574. package/examples/jsm/nodes/display/ToneMappingNode.js +51 -0
  575. package/examples/jsm/nodes/fog/FogNode.js +31 -0
  576. package/examples/jsm/nodes/fog/FogRangeNode.js +27 -0
  577. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +33 -0
  578. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  579. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +27 -0
  580. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
  581. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +18 -0
  582. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
  583. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +94 -0
  584. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +22 -0
  585. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +12 -0
  586. package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
  587. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  588. package/examples/jsm/nodes/gpgpu/ComputeNode.js +65 -0
  589. package/examples/jsm/nodes/lighting/AONode.js +25 -0
  590. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +37 -0
  591. package/examples/jsm/nodes/lighting/EnvironmentNode.js +66 -0
  592. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +50 -0
  593. package/examples/jsm/nodes/lighting/LightingContextNode.js +75 -0
  594. package/examples/jsm/nodes/lighting/LightingNode.js +19 -0
  595. package/examples/jsm/nodes/lighting/LightsNode.js +120 -0
  596. package/examples/jsm/nodes/lighting/PunctualLightNode.js +68 -0
  597. package/examples/jsm/nodes/loaders/NodeLoader.js +107 -0
  598. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +73 -0
  599. package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
  600. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +46 -0
  601. package/examples/jsm/nodes/materials/Materials.js +53 -0
  602. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +48 -0
  603. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  604. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +168 -0
  605. package/examples/jsm/nodes/materials/NodeMaterial.js +229 -0
  606. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +52 -0
  607. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +106 -0
  608. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
  609. package/examples/jsm/nodes/materialx/MaterialXNodes.js +55 -0
  610. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
  611. package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
  612. package/examples/jsm/nodes/math/CondNode.js +60 -0
  613. package/examples/jsm/nodes/math/MathNode.js +243 -0
  614. package/examples/jsm/nodes/math/OperatorNode.js +214 -0
  615. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -0
  616. package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -0
  617. package/examples/jsm/nodes/parsers/WGSLNodeFunction.js +104 -0
  618. package/examples/jsm/nodes/parsers/WGSLNodeParser.js +14 -0
  619. package/examples/jsm/nodes/procedural/CheckerNode.js +34 -0
  620. package/examples/jsm/nodes/shadernode/ShaderNode.js +264 -0
  621. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +299 -0
  622. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +131 -0
  623. package/examples/jsm/nodes/utils/ArrayElementNode.js +31 -0
  624. package/examples/jsm/nodes/utils/ConvertNode.js +47 -0
  625. package/examples/jsm/nodes/utils/JoinNode.js +42 -0
  626. package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
  627. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +33 -0
  628. package/examples/jsm/nodes/utils/OscNode.js +74 -0
  629. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  630. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  631. package/examples/jsm/nodes/utils/SplitNode.js +102 -0
  632. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +58 -0
  633. package/examples/jsm/nodes/utils/TimerNode.js +84 -0
  634. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  635. package/examples/jsm/objects/Lensflare.js +378 -0
  636. package/examples/jsm/objects/LightningStorm.js +245 -0
  637. package/examples/jsm/objects/MarchingCubes.js +1172 -0
  638. package/examples/jsm/objects/Reflector.js +269 -0
  639. package/examples/jsm/objects/ReflectorForSSRPass.js +349 -0
  640. package/examples/jsm/objects/Refractor.js +332 -0
  641. package/examples/jsm/objects/ShadowMesh.js +80 -0
  642. package/examples/jsm/objects/Sky.js +219 -0
  643. package/examples/jsm/objects/Water.js +329 -0
  644. package/examples/jsm/objects/Water2.js +358 -0
  645. package/examples/jsm/offscreen/jank.js +45 -0
  646. package/examples/jsm/offscreen/offscreen.js +8 -0
  647. package/examples/jsm/offscreen/scene.js +86 -0
  648. package/examples/jsm/physics/AmmoPhysics.js +286 -0
  649. package/examples/jsm/physics/OimoPhysics.js +231 -0
  650. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +369 -0
  651. package/examples/jsm/postprocessing/AfterimagePass.js +90 -0
  652. package/examples/jsm/postprocessing/BloomPass.js +150 -0
  653. package/examples/jsm/postprocessing/BokehPass.js +131 -0
  654. package/examples/jsm/postprocessing/ClearPass.js +46 -0
  655. package/examples/jsm/postprocessing/CubeTexturePass.js +78 -0
  656. package/examples/jsm/postprocessing/DotScreenPass.js +58 -0
  657. package/examples/jsm/postprocessing/EffectComposer.js +310 -0
  658. package/examples/jsm/postprocessing/FilmPass.js +59 -0
  659. package/examples/jsm/postprocessing/GlitchPass.js +118 -0
  660. package/examples/jsm/postprocessing/HalftonePass.js +77 -0
  661. package/examples/jsm/postprocessing/LUTPass.js +173 -0
  662. package/examples/jsm/postprocessing/MaskPass.js +101 -0
  663. package/examples/jsm/postprocessing/OutlinePass.js +646 -0
  664. package/examples/jsm/postprocessing/Pass.js +80 -0
  665. package/examples/jsm/postprocessing/RenderPass.js +81 -0
  666. package/examples/jsm/postprocessing/SAOPass.js +413 -0
  667. package/examples/jsm/postprocessing/SMAAPass.js +188 -0
  668. package/examples/jsm/postprocessing/SSAARenderPass.js +224 -0
  669. package/examples/jsm/postprocessing/SSAOPass.js +450 -0
  670. package/examples/jsm/postprocessing/SSRPass.js +645 -0
  671. package/examples/jsm/postprocessing/SavePass.js +62 -0
  672. package/examples/jsm/postprocessing/ShaderPass.js +68 -0
  673. package/examples/jsm/postprocessing/TAARenderPass.js +167 -0
  674. package/examples/jsm/postprocessing/TexturePass.js +60 -0
  675. package/examples/jsm/postprocessing/UnrealBloomPass.js +403 -0
  676. package/examples/jsm/renderers/CSS2DRenderer.js +210 -0
  677. package/examples/jsm/renderers/CSS3DRenderer.js +313 -0
  678. package/examples/jsm/renderers/Projector.js +918 -0
  679. package/examples/jsm/renderers/SVGRenderer.js +553 -0
  680. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +26 -0
  681. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +733 -0
  682. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +49 -0
  683. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +129 -0
  684. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +144 -0
  685. package/examples/jsm/renderers/webgpu/WebGPUBinding.js +22 -0
  686. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +255 -0
  687. package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +43 -0
  688. package/examples/jsm/renderers/webgpu/WebGPUBufferUtils.js +33 -0
  689. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +78 -0
  690. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +82 -0
  691. package/examples/jsm/renderers/webgpu/WebGPUInfo.js +74 -0
  692. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +36 -0
  693. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +22 -0
  694. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +38 -0
  695. package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +199 -0
  696. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +735 -0
  697. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +296 -0
  698. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
  699. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +969 -0
  700. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +73 -0
  701. package/examples/jsm/renderers/webgpu/WebGPUSampler.js +29 -0
  702. package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +20 -0
  703. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +40 -0
  704. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +183 -0
  705. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +794 -0
  706. package/examples/jsm/renderers/webgpu/WebGPUUniform.js +136 -0
  707. package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +18 -0
  708. package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +299 -0
  709. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  710. package/examples/jsm/renderers/webgpu/constants.js +261 -0
  711. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +801 -0
  712. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +39 -0
  713. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampler.js +21 -0
  714. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniform.js +135 -0
  715. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +83 -0
  716. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +87 -0
  717. package/examples/jsm/shaders/AfterimageShader.js +56 -0
  718. package/examples/jsm/shaders/BasicShader.js +27 -0
  719. package/examples/jsm/shaders/BleachBypassShader.js +60 -0
  720. package/examples/jsm/shaders/BlendShader.js +48 -0
  721. package/examples/jsm/shaders/BokehShader.js +143 -0
  722. package/examples/jsm/shaders/BokehShader2.js +390 -0
  723. package/examples/jsm/shaders/BrightnessContrastShader.js +54 -0
  724. package/examples/jsm/shaders/ColorCorrectionShader.js +50 -0
  725. package/examples/jsm/shaders/ColorifyShader.js +49 -0
  726. package/examples/jsm/shaders/ConvolutionShader.js +101 -0
  727. package/examples/jsm/shaders/CopyShader.js +43 -0
  728. package/examples/jsm/shaders/DOFMipMapShader.js +54 -0
  729. package/examples/jsm/shaders/DepthLimitedBlurShader.js +166 -0
  730. package/examples/jsm/shaders/DigitalGlitch.js +101 -0
  731. package/examples/jsm/shaders/DotScreenShader.js +68 -0
  732. package/examples/jsm/shaders/FXAAShader.js +286 -0
  733. package/examples/jsm/shaders/FilmShader.js +100 -0
  734. package/examples/jsm/shaders/FocusShader.js +87 -0
  735. package/examples/jsm/shaders/FreiChenShader.js +94 -0
  736. package/examples/jsm/shaders/GammaCorrectionShader.js +41 -0
  737. package/examples/jsm/shaders/GodRaysShader.js +313 -0
  738. package/examples/jsm/shaders/HalftoneShader.js +310 -0
  739. package/examples/jsm/shaders/HorizontalBlurShader.js +57 -0
  740. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +61 -0
  741. package/examples/jsm/shaders/HueSaturationShader.js +65 -0
  742. package/examples/jsm/shaders/KaleidoShader.js +56 -0
  743. package/examples/jsm/shaders/LuminosityHighPassShader.js +64 -0
  744. package/examples/jsm/shaders/LuminosityShader.js +46 -0
  745. package/examples/jsm/shaders/MMDToonShader.js +123 -0
  746. package/examples/jsm/shaders/MirrorShader.js +54 -0
  747. package/examples/jsm/shaders/NormalMapShader.js +53 -0
  748. package/examples/jsm/shaders/PixelShader.js +44 -0
  749. package/examples/jsm/shaders/RGBShiftShader.js +52 -0
  750. package/examples/jsm/shaders/SAOShader.js +188 -0
  751. package/examples/jsm/shaders/SMAAShader.js +460 -0
  752. package/examples/jsm/shaders/SSAOShader.js +288 -0
  753. package/examples/jsm/shaders/SSRShader.js +364 -0
  754. package/examples/jsm/shaders/SepiaShader.js +50 -0
  755. package/examples/jsm/shaders/SobelOperatorShader.js +90 -0
  756. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +88 -0
  757. package/examples/jsm/shaders/TechnicolorShader.js +43 -0
  758. package/examples/jsm/shaders/ToneMapShader.js +73 -0
  759. package/examples/jsm/shaders/ToonShader.js +318 -0
  760. package/examples/jsm/shaders/TriangleBlurShader.js +72 -0
  761. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +45 -0
  762. package/examples/jsm/shaders/VerticalBlurShader.js +57 -0
  763. package/examples/jsm/shaders/VerticalTiltShiftShader.js +61 -0
  764. package/examples/jsm/shaders/VignetteShader.js +49 -0
  765. package/examples/jsm/shaders/VolumeShader.js +289 -0
  766. package/examples/jsm/shaders/WaterRefractionShader.js +90 -0
  767. package/examples/jsm/textures/FlakesTexture.js +40 -0
  768. package/examples/jsm/utils/BufferGeometryUtils.js +1222 -0
  769. package/examples/jsm/utils/CameraUtils.js +73 -0
  770. package/examples/jsm/utils/GPUStatsPanel.js +128 -0
  771. package/examples/jsm/utils/GeometryCompressionUtils.js +639 -0
  772. package/examples/jsm/utils/GeometryUtils.js +221 -0
  773. package/examples/jsm/utils/LDrawUtils.js +202 -0
  774. package/examples/jsm/utils/PackedPhongMaterial.js +251 -0
  775. package/examples/jsm/utils/SceneUtils.js +125 -0
  776. package/examples/jsm/utils/ShadowMapViewer.js +210 -0
  777. package/examples/jsm/utils/SkeletonUtils.js +596 -0
  778. package/examples/jsm/utils/UVsDebug.js +165 -0
  779. package/examples/jsm/utils/WorkerPool.js +102 -0
  780. package/examples/jsm/webxr/ARButton.js +208 -0
  781. package/examples/jsm/webxr/OculusHandModel.js +108 -0
  782. package/examples/jsm/webxr/OculusHandPointerModel.js +394 -0
  783. package/examples/jsm/webxr/Text2D.js +38 -0
  784. package/examples/jsm/webxr/VRButton.js +201 -0
  785. package/examples/jsm/webxr/XRControllerModelFactory.js +310 -0
  786. package/examples/jsm/webxr/XREstimatedLight.js +223 -0
  787. package/examples/jsm/webxr/XRHandMeshModel.js +108 -0
  788. package/examples/jsm/webxr/XRHandModelFactory.js +105 -0
  789. package/examples/jsm/webxr/XRHandPrimitiveModel.js +103 -0
  790. package/package.json +179 -0
  791. package/src/Three.Legacy.js +320 -0
  792. package/src/Three.js +180 -0
  793. package/src/animation/AnimationAction.js +700 -0
  794. package/src/animation/AnimationClip.js +473 -0
  795. package/src/animation/AnimationMixer.js +770 -0
  796. package/src/animation/AnimationObjectGroup.js +387 -0
  797. package/src/animation/AnimationUtils.js +361 -0
  798. package/src/animation/KeyframeTrack.js +462 -0
  799. package/src/animation/PropertyBinding.js +719 -0
  800. package/src/animation/PropertyMixer.js +318 -0
  801. package/src/animation/tracks/BooleanKeyframeTrack.js +19 -0
  802. package/src/animation/tracks/ColorKeyframeTrack.js +15 -0
  803. package/src/animation/tracks/NumberKeyframeTrack.js +12 -0
  804. package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -0
  805. package/src/animation/tracks/StringKeyframeTrack.js +15 -0
  806. package/src/animation/tracks/VectorKeyframeTrack.js +12 -0
  807. package/src/audio/Audio.js +391 -0
  808. package/src/audio/AudioAnalyser.js +40 -0
  809. package/src/audio/AudioContext.js +25 -0
  810. package/src/audio/AudioListener.js +137 -0
  811. package/src/audio/PositionalAudio.js +138 -0
  812. package/src/cameras/ArrayCamera.js +17 -0
  813. package/src/cameras/Camera.js +68 -0
  814. package/src/cameras/CubeCamera.js +107 -0
  815. package/src/cameras/OrthographicCamera.js +136 -0
  816. package/src/cameras/PerspectiveCamera.js +233 -0
  817. package/src/cameras/StereoCamera.js +100 -0
  818. package/src/constants.js +181 -0
  819. package/src/core/BufferAttribute.js +493 -0
  820. package/src/core/BufferGeometry.js +1092 -0
  821. package/src/core/Clock.js +74 -0
  822. package/src/core/EventDispatcher.js +87 -0
  823. package/src/core/GLBufferAttribute.js +58 -0
  824. package/src/core/InstancedBufferAttribute.js +39 -0
  825. package/src/core/InstancedBufferGeometry.js +46 -0
  826. package/src/core/InstancedInterleavedBuffer.js +48 -0
  827. package/src/core/InterleavedBuffer.js +145 -0
  828. package/src/core/InterleavedBufferAttribute.js +331 -0
  829. package/src/core/Layers.js +60 -0
  830. package/src/core/Object3D.js +944 -0
  831. package/src/core/Raycaster.js +110 -0
  832. package/src/core/Uniform.js +17 -0
  833. package/src/core/UniformsGroup.js +92 -0
  834. package/src/extras/DataUtils.js +170 -0
  835. package/src/extras/Earcut.js +789 -0
  836. package/src/extras/ImageUtils.js +129 -0
  837. package/src/extras/PMREMGenerator.js +900 -0
  838. package/src/extras/ShapeUtils.js +92 -0
  839. package/src/extras/core/Curve.js +416 -0
  840. package/src/extras/core/CurvePath.js +252 -0
  841. package/src/extras/core/Interpolations.js +79 -0
  842. package/src/extras/core/Path.js +196 -0
  843. package/src/extras/core/Shape.js +102 -0
  844. package/src/extras/core/ShapePath.js +291 -0
  845. package/src/extras/curves/ArcCurve.js +17 -0
  846. package/src/extras/curves/CatmullRomCurve3.js +255 -0
  847. package/src/extras/curves/CubicBezierCurve.js +78 -0
  848. package/src/extras/curves/CubicBezierCurve3.js +79 -0
  849. package/src/extras/curves/Curves.js +10 -0
  850. package/src/extras/curves/EllipseCurve.js +156 -0
  851. package/src/extras/curves/LineCurve.js +90 -0
  852. package/src/extras/curves/LineCurve3.js +75 -0
  853. package/src/extras/curves/QuadraticBezierCurve.js +74 -0
  854. package/src/extras/curves/QuadraticBezierCurve3.js +75 -0
  855. package/src/extras/curves/SplineCurve.js +97 -0
  856. package/src/geometries/BoxGeometry.js +170 -0
  857. package/src/geometries/CapsuleGeometry.js +33 -0
  858. package/src/geometries/CircleGeometry.js +91 -0
  859. package/src/geometries/ConeGeometry.js +31 -0
  860. package/src/geometries/CylinderGeometry.js +276 -0
  861. package/src/geometries/DodecahedronGeometry.js +66 -0
  862. package/src/geometries/EdgesGeometry.js +142 -0
  863. package/src/geometries/ExtrudeGeometry.js +804 -0
  864. package/src/geometries/Geometries.js +21 -0
  865. package/src/geometries/IcosahedronGeometry.js +42 -0
  866. package/src/geometries/LatheGeometry.js +179 -0
  867. package/src/geometries/OctahedronGeometry.js +37 -0
  868. package/src/geometries/PlaneGeometry.js +88 -0
  869. package/src/geometries/PolyhedronGeometry.js +309 -0
  870. package/src/geometries/RingGeometry.js +118 -0
  871. package/src/geometries/ShapeGeometry.js +185 -0
  872. package/src/geometries/SphereGeometry.js +127 -0
  873. package/src/geometries/TetrahedronGeometry.js +34 -0
  874. package/src/geometries/TorusGeometry.js +110 -0
  875. package/src/geometries/TorusKnotGeometry.js +157 -0
  876. package/src/geometries/TubeGeometry.js +193 -0
  877. package/src/geometries/WireframeGeometry.js +137 -0
  878. package/src/helpers/ArrowHelper.js +114 -0
  879. package/src/helpers/AxesHelper.js +68 -0
  880. package/src/helpers/Box3Helper.js +56 -0
  881. package/src/helpers/BoxHelper.js +113 -0
  882. package/src/helpers/CameraHelper.js +269 -0
  883. package/src/helpers/DirectionalLightHelper.js +89 -0
  884. package/src/helpers/GridHelper.js +56 -0
  885. package/src/helpers/HemisphereLightHelper.js +85 -0
  886. package/src/helpers/PlaneHelper.js +63 -0
  887. package/src/helpers/PointLightHelper.js +91 -0
  888. package/src/helpers/PolarGridHelper.js +96 -0
  889. package/src/helpers/SkeletonHelper.js +128 -0
  890. package/src/helpers/SpotLightHelper.js +92 -0
  891. package/src/lights/AmbientLight.js +17 -0
  892. package/src/lights/AmbientLightProbe.js +21 -0
  893. package/src/lights/DirectionalLight.js +43 -0
  894. package/src/lights/DirectionalLightShadow.js +16 -0
  895. package/src/lights/HemisphereLight.js +34 -0
  896. package/src/lights/HemisphereLightProbe.js +30 -0
  897. package/src/lights/Light.js +58 -0
  898. package/src/lights/LightProbe.js +47 -0
  899. package/src/lights/LightShadow.js +147 -0
  900. package/src/lights/PointLight.js +57 -0
  901. package/src/lights/PointLightShadow.js +96 -0
  902. package/src/lights/RectAreaLight.js +56 -0
  903. package/src/lights/SpotLight.js +71 -0
  904. package/src/lights/SpotLightShadow.js +50 -0
  905. package/src/loaders/AnimationLoader.js +66 -0
  906. package/src/loaders/AudioLoader.js +60 -0
  907. package/src/loaders/BufferGeometryLoader.js +224 -0
  908. package/src/loaders/Cache.js +42 -0
  909. package/src/loaders/CompressedTextureLoader.js +134 -0
  910. package/src/loaders/CubeTextureLoader.js +56 -0
  911. package/src/loaders/DataTextureLoader.js +114 -0
  912. package/src/loaders/FileLoader.js +281 -0
  913. package/src/loaders/ImageBitmapLoader.js +99 -0
  914. package/src/loaders/ImageLoader.js +91 -0
  915. package/src/loaders/Loader.js +70 -0
  916. package/src/loaders/LoaderUtils.js +75 -0
  917. package/src/loaders/LoadingManager.js +142 -0
  918. package/src/loaders/MaterialLoader.js +355 -0
  919. package/src/loaders/ObjectLoader.js +1081 -0
  920. package/src/loaders/TextureLoader.js +41 -0
  921. package/src/materials/LineBasicMaterial.js +45 -0
  922. package/src/materials/LineDashedMaterial.js +35 -0
  923. package/src/materials/Material.js +493 -0
  924. package/src/materials/Materials.js +39 -0
  925. package/src/materials/MeshBasicMaterial.js +81 -0
  926. package/src/materials/MeshDepthMaterial.js +54 -0
  927. package/src/materials/MeshDistanceMaterial.js +52 -0
  928. package/src/materials/MeshLambertMaterial.js +116 -0
  929. package/src/materials/MeshMatcapMaterial.js +81 -0
  930. package/src/materials/MeshNormalMaterial.js +61 -0
  931. package/src/materials/MeshPhongMaterial.js +120 -0
  932. package/src/materials/MeshPhysicalMaterial.js +198 -0
  933. package/src/materials/MeshStandardMaterial.js +124 -0
  934. package/src/materials/MeshToonMaterial.js +102 -0
  935. package/src/materials/PointsMaterial.js +50 -0
  936. package/src/materials/RawShaderMaterial.js +17 -0
  937. package/src/materials/ShaderMaterial.js +182 -0
  938. package/src/materials/ShadowMaterial.js +37 -0
  939. package/src/materials/SpriteMaterial.js +54 -0
  940. package/src/math/Box2.js +203 -0
  941. package/src/math/Box3.js +532 -0
  942. package/src/math/Color.js +605 -0
  943. package/src/math/ColorManagement.js +74 -0
  944. package/src/math/Cylindrical.js +61 -0
  945. package/src/math/Euler.js +324 -0
  946. package/src/math/Frustum.js +162 -0
  947. package/src/math/Interpolant.js +241 -0
  948. package/src/math/Line3.js +115 -0
  949. package/src/math/MathUtils.js +321 -0
  950. package/src/math/Matrix3.js +333 -0
  951. package/src/math/Matrix4.js +860 -0
  952. package/src/math/Plane.js +205 -0
  953. package/src/math/Quaternion.js +678 -0
  954. package/src/math/Ray.js +496 -0
  955. package/src/math/Sphere.js +250 -0
  956. package/src/math/Spherical.js +86 -0
  957. package/src/math/SphericalHarmonics3.js +243 -0
  958. package/src/math/Triangle.js +299 -0
  959. package/src/math/Vector2.js +464 -0
  960. package/src/math/Vector3.js +715 -0
  961. package/src/math/Vector4.js +644 -0
  962. package/src/math/interpolants/CubicInterpolant.js +151 -0
  963. package/src/math/interpolants/DiscreteInterpolant.js +26 -0
  964. package/src/math/interpolants/LinearInterpolant.js +38 -0
  965. package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  966. package/src/objects/Bone.js +17 -0
  967. package/src/objects/Group.js +17 -0
  968. package/src/objects/InstancedMesh.js +126 -0
  969. package/src/objects/LOD.js +195 -0
  970. package/src/objects/Line.js +222 -0
  971. package/src/objects/LineLoop.js +17 -0
  972. package/src/objects/LineSegments.js +55 -0
  973. package/src/objects/Mesh.js +397 -0
  974. package/src/objects/Points.js +166 -0
  975. package/src/objects/Skeleton.js +281 -0
  976. package/src/objects/SkinnedMesh.js +151 -0
  977. package/src/objects/Sprite.js +181 -0
  978. package/src/renderers/WebGL1Renderer.js +7 -0
  979. package/src/renderers/WebGL3DRenderTarget.js +22 -0
  980. package/src/renderers/WebGLArrayRenderTarget.js +22 -0
  981. package/src/renderers/WebGLCubeRenderTarget.js +146 -0
  982. package/src/renderers/WebGLMultipleRenderTargets.js +82 -0
  983. package/src/renderers/WebGLRenderTarget.js +110 -0
  984. package/src/renderers/WebGLRenderer.js +2280 -0
  985. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  986. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  987. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +7 -0
  988. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  989. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +18 -0
  990. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  991. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +3 -0
  992. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  993. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +304 -0
  994. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +42 -0
  995. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  996. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +18 -0
  997. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  998. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +33 -0
  999. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  1000. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  1001. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  1002. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -0
  1003. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -0
  1004. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -0
  1005. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -0
  1006. package/src/renderers/shaders/ShaderChunk/common.glsl.js +118 -0
  1007. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +191 -0
  1008. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  1009. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1010. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +36 -0
  1011. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1012. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1013. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1014. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1015. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -0
  1016. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js +3 -0
  1018. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +11 -0
  1019. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +66 -0
  1021. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1022. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1023. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +46 -0
  1024. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1025. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1026. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1027. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1028. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1030. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +121 -0
  1031. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1032. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -0
  1033. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1034. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +199 -0
  1035. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -0
  1036. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +32 -0
  1037. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1038. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
  1039. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +223 -0
  1040. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1041. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +34 -0
  1042. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +120 -0
  1043. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +264 -0
  1044. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1045. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +28 -0
  1046. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1047. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1048. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -0
  1050. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1051. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1052. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +19 -0
  1053. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +19 -0
  1054. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1055. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1056. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1057. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -0
  1058. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -0
  1059. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -0
  1060. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +46 -0
  1061. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +41 -0
  1062. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1063. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1064. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1065. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1066. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +12 -0
  1067. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +54 -0
  1068. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -0
  1069. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +13 -0
  1070. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1071. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +321 -0
  1073. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -0
  1074. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +63 -0
  1075. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1076. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1077. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +33 -0
  1078. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1079. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1080. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1081. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1082. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1083. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +77 -0
  1084. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1085. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +116 -0
  1086. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +7 -0
  1087. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +10 -0
  1088. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +7 -0
  1089. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +7 -0
  1090. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +17 -0
  1091. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +7 -0
  1092. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +15 -0
  1093. package/src/renderers/shaders/ShaderChunk.js +265 -0
  1094. package/src/renderers/shaders/ShaderLib/background.glsl.js +35 -0
  1095. package/src/renderers/shaders/ShaderLib/cube.glsl.js +38 -0
  1096. package/src/renderers/shaders/ShaderLib/depth.glsl.js +92 -0
  1097. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +73 -0
  1098. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1099. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +70 -0
  1100. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +115 -0
  1101. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +123 -0
  1102. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +107 -0
  1103. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +82 -0
  1104. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +125 -0
  1105. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +216 -0
  1106. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +117 -0
  1107. package/src/renderers/shaders/ShaderLib/points.glsl.js +71 -0
  1108. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +49 -0
  1109. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1110. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -0
  1111. package/src/renderers/shaders/ShaderLib.js +331 -0
  1112. package/src/renderers/shaders/UniformsLib.js +218 -0
  1113. package/src/renderers/shaders/UniformsUtils.js +80 -0
  1114. package/src/renderers/webgl/WebGLAnimation.js +53 -0
  1115. package/src/renderers/webgl/WebGLAttributes.js +193 -0
  1116. package/src/renderers/webgl/WebGLBackground.js +228 -0
  1117. package/src/renderers/webgl/WebGLBindingStates.js +623 -0
  1118. package/src/renderers/webgl/WebGLBufferRenderer.js +61 -0
  1119. package/src/renderers/webgl/WebGLCapabilities.js +121 -0
  1120. package/src/renderers/webgl/WebGLClipping.js +167 -0
  1121. package/src/renderers/webgl/WebGLCubeMaps.js +99 -0
  1122. package/src/renderers/webgl/WebGLCubeUVMaps.js +130 -0
  1123. package/src/renderers/webgl/WebGLExtensions.js +96 -0
  1124. package/src/renderers/webgl/WebGLGeometries.js +195 -0
  1125. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +71 -0
  1126. package/src/renderers/webgl/WebGLInfo.js +72 -0
  1127. package/src/renderers/webgl/WebGLLights.js +574 -0
  1128. package/src/renderers/webgl/WebGLMaterials.js +677 -0
  1129. package/src/renderers/webgl/WebGLMorphtargets.js +300 -0
  1130. package/src/renderers/webgl/WebGLObjects.js +72 -0
  1131. package/src/renderers/webgl/WebGLProgram.js +901 -0
  1132. package/src/renderers/webgl/WebGLPrograms.js +542 -0
  1133. package/src/renderers/webgl/WebGLProperties.js +48 -0
  1134. package/src/renderers/webgl/WebGLRenderLists.js +238 -0
  1135. package/src/renderers/webgl/WebGLRenderStates.js +107 -0
  1136. package/src/renderers/webgl/WebGLShader.js +12 -0
  1137. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1138. package/src/renderers/webgl/WebGLShadowMap.js +374 -0
  1139. package/src/renderers/webgl/WebGLState.js +1263 -0
  1140. package/src/renderers/webgl/WebGLTextures.js +1944 -0
  1141. package/src/renderers/webgl/WebGLUniforms.js +1050 -0
  1142. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  1143. package/src/renderers/webgl/WebGLUtils.js +266 -0
  1144. package/src/renderers/webxr/WebXRController.js +307 -0
  1145. package/src/renderers/webxr/WebXRManager.js +731 -0
  1146. package/src/scenes/Fog.js +37 -0
  1147. package/src/scenes/FogExp2.js +34 -0
  1148. package/src/scenes/Scene.js +71 -0
  1149. package/src/textures/CanvasTexture.js +17 -0
  1150. package/src/textures/CompressedTexture.js +28 -0
  1151. package/src/textures/CubeTexture.js +33 -0
  1152. package/src/textures/Data3DTexture.js +35 -0
  1153. package/src/textures/DataArrayTexture.js +27 -0
  1154. package/src/textures/DataTexture.js +22 -0
  1155. package/src/textures/DepthTexture.js +36 -0
  1156. package/src/textures/FramebufferTexture.js +25 -0
  1157. package/src/textures/Source.js +123 -0
  1158. package/src/textures/Texture.js +308 -0
  1159. package/src/textures/VideoTexture.js +55 -0
  1160. package/src/utils.js +71 -0
@@ -0,0 +1,3037 @@
1
+ ( function () {
2
+
3
+ const STATE = {
4
+ IDLE: Symbol(),
5
+ ROTATE: Symbol(),
6
+ PAN: Symbol(),
7
+ SCALE: Symbol(),
8
+ FOV: Symbol(),
9
+ FOCUS: Symbol(),
10
+ ZROTATE: Symbol(),
11
+ TOUCH_MULTI: Symbol(),
12
+ ANIMATION_FOCUS: Symbol(),
13
+ ANIMATION_ROTATE: Symbol()
14
+ };
15
+ const INPUT = {
16
+ NONE: Symbol(),
17
+ ONE_FINGER: Symbol(),
18
+ ONE_FINGER_SWITCHED: Symbol(),
19
+ TWO_FINGER: Symbol(),
20
+ MULT_FINGER: Symbol(),
21
+ CURSOR: Symbol()
22
+ }; //cursor center coordinates
23
+
24
+ const _center = {
25
+ x: 0,
26
+ y: 0
27
+ }; //transformation matrices for gizmos and camera
28
+
29
+ const _transformation = {
30
+ camera: new THREE.Matrix4(),
31
+ gizmos: new THREE.Matrix4()
32
+ }; //events
33
+
34
+ const _changeEvent = {
35
+ type: 'change'
36
+ };
37
+ const _startEvent = {
38
+ type: 'start'
39
+ };
40
+ const _endEvent = {
41
+ type: 'end'
42
+ };
43
+
44
+ const _raycaster = new THREE.Raycaster();
45
+
46
+ const _offset = new THREE.Vector3();
47
+
48
+ const _gizmoMatrixStateTemp = new THREE.Matrix4();
49
+
50
+ const _cameraMatrixStateTemp = new THREE.Matrix4();
51
+
52
+ const _scalePointTemp = new THREE.Vector3();
53
+ /**
54
+ *
55
+ * @param {Camera} camera Virtual camera used in the scene
56
+ * @param {HTMLElement} domElement Renderer's dom element
57
+ * @param {Scene} scene The scene to be rendered
58
+ */
59
+
60
+
61
+ class ArcballControls extends THREE.EventDispatcher {
62
+
63
+ constructor( _camera, domElement, scene = null ) {
64
+
65
+ super();
66
+
67
+ this.onWindowResize = () => {
68
+
69
+ const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
70
+ this._tbRadius = this.calculateTbRadius( this.camera );
71
+ const newRadius = this._tbRadius / scale;
72
+ const curve = new THREE.EllipseCurve( 0, 0, newRadius, newRadius );
73
+ const points = curve.getPoints( this._curvePts );
74
+ const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
75
+
76
+ for ( const gizmo in this._gizmos.children ) {
77
+
78
+ this._gizmos.children[ gizmo ].geometry = curveGeometry;
79
+
80
+ }
81
+
82
+ this.dispatchEvent( _changeEvent );
83
+
84
+ };
85
+
86
+ this.onContextMenu = event => {
87
+
88
+ if ( ! this.enabled ) {
89
+
90
+ return;
91
+
92
+ }
93
+
94
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
95
+
96
+ if ( this.mouseActions[ i ].mouse == 2 ) {
97
+
98
+ //prevent only if button 2 is actually used
99
+ event.preventDefault();
100
+ break;
101
+
102
+ }
103
+
104
+ }
105
+
106
+ };
107
+
108
+ this.onPointerCancel = () => {
109
+
110
+ this._touchStart.splice( 0, this._touchStart.length );
111
+
112
+ this._touchCurrent.splice( 0, this._touchCurrent.length );
113
+
114
+ this._input = INPUT.NONE;
115
+
116
+ };
117
+
118
+ this.onPointerDown = event => {
119
+
120
+ if ( event.button == 0 && event.isPrimary ) {
121
+
122
+ this._downValid = true;
123
+
124
+ this._downEvents.push( event );
125
+
126
+ this._downStart = performance.now();
127
+
128
+ } else {
129
+
130
+ this._downValid = false;
131
+
132
+ }
133
+
134
+ if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
135
+
136
+ this._touchStart.push( event );
137
+
138
+ this._touchCurrent.push( event );
139
+
140
+ switch ( this._input ) {
141
+
142
+ case INPUT.NONE:
143
+ //singleStart
144
+ this._input = INPUT.ONE_FINGER;
145
+ this.onSinglePanStart( event, 'ROTATE' );
146
+ window.addEventListener( 'pointermove', this.onPointerMove );
147
+ window.addEventListener( 'pointerup', this.onPointerUp );
148
+ break;
149
+
150
+ case INPUT.ONE_FINGER:
151
+ case INPUT.ONE_FINGER_SWITCHED:
152
+ //doubleStart
153
+ this._input = INPUT.TWO_FINGER;
154
+ this.onRotateStart();
155
+ this.onPinchStart();
156
+ this.onDoublePanStart();
157
+ break;
158
+
159
+ case INPUT.TWO_FINGER:
160
+ //multipleStart
161
+ this._input = INPUT.MULT_FINGER;
162
+ this.onTriplePanStart( event );
163
+ break;
164
+
165
+ }
166
+
167
+ } else if ( event.pointerType != 'touch' && this._input == INPUT.NONE ) {
168
+
169
+ let modifier = null;
170
+
171
+ if ( event.ctrlKey || event.metaKey ) {
172
+
173
+ modifier = 'CTRL';
174
+
175
+ } else if ( event.shiftKey ) {
176
+
177
+ modifier = 'SHIFT';
178
+
179
+ }
180
+
181
+ this._mouseOp = this.getOpFromAction( event.button, modifier );
182
+
183
+ if ( this._mouseOp != null ) {
184
+
185
+ window.addEventListener( 'pointermove', this.onPointerMove );
186
+ window.addEventListener( 'pointerup', this.onPointerUp ); //singleStart
187
+
188
+ this._input = INPUT.CURSOR;
189
+ this._button = event.button;
190
+ this.onSinglePanStart( event, this._mouseOp );
191
+
192
+ }
193
+
194
+ }
195
+
196
+ };
197
+
198
+ this.onPointerMove = event => {
199
+
200
+ if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
201
+
202
+ switch ( this._input ) {
203
+
204
+ case INPUT.ONE_FINGER:
205
+ //singleMove
206
+ this.updateTouchEvent( event );
207
+ this.onSinglePanMove( event, STATE.ROTATE );
208
+ break;
209
+
210
+ case INPUT.ONE_FINGER_SWITCHED:
211
+ const movement = this.calculatePointersDistance( this._touchCurrent[ 0 ], event ) * this._devPxRatio;
212
+
213
+ if ( movement >= this._switchSensibility ) {
214
+
215
+ //singleMove
216
+ this._input = INPUT.ONE_FINGER;
217
+ this.updateTouchEvent( event );
218
+ this.onSinglePanStart( event, 'ROTATE' );
219
+ break;
220
+
221
+ }
222
+
223
+ break;
224
+
225
+ case INPUT.TWO_FINGER:
226
+ //rotate/pan/pinchMove
227
+ this.updateTouchEvent( event );
228
+ this.onRotateMove();
229
+ this.onPinchMove();
230
+ this.onDoublePanMove();
231
+ break;
232
+
233
+ case INPUT.MULT_FINGER:
234
+ //multMove
235
+ this.updateTouchEvent( event );
236
+ this.onTriplePanMove( event );
237
+ break;
238
+
239
+ }
240
+
241
+ } else if ( event.pointerType != 'touch' && this._input == INPUT.CURSOR ) {
242
+
243
+ let modifier = null;
244
+
245
+ if ( event.ctrlKey || event.metaKey ) {
246
+
247
+ modifier = 'CTRL';
248
+
249
+ } else if ( event.shiftKey ) {
250
+
251
+ modifier = 'SHIFT';
252
+
253
+ }
254
+
255
+ const mouseOpState = this.getOpStateFromAction( this._button, modifier );
256
+
257
+ if ( mouseOpState != null ) {
258
+
259
+ this.onSinglePanMove( event, mouseOpState );
260
+
261
+ }
262
+
263
+ } //checkDistance
264
+
265
+
266
+ if ( this._downValid ) {
267
+
268
+ const movement = this.calculatePointersDistance( this._downEvents[ this._downEvents.length - 1 ], event ) * this._devPxRatio;
269
+
270
+ if ( movement > this._movementThreshold ) {
271
+
272
+ this._downValid = false;
273
+
274
+ }
275
+
276
+ }
277
+
278
+ };
279
+
280
+ this.onPointerUp = event => {
281
+
282
+ if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
283
+
284
+ const nTouch = this._touchCurrent.length;
285
+
286
+ for ( let i = 0; i < nTouch; i ++ ) {
287
+
288
+ if ( this._touchCurrent[ i ].pointerId == event.pointerId ) {
289
+
290
+ this._touchCurrent.splice( i, 1 );
291
+
292
+ this._touchStart.splice( i, 1 );
293
+
294
+ break;
295
+
296
+ }
297
+
298
+ }
299
+
300
+ switch ( this._input ) {
301
+
302
+ case INPUT.ONE_FINGER:
303
+ case INPUT.ONE_FINGER_SWITCHED:
304
+ //singleEnd
305
+ window.removeEventListener( 'pointermove', this.onPointerMove );
306
+ window.removeEventListener( 'pointerup', this.onPointerUp );
307
+ this._input = INPUT.NONE;
308
+ this.onSinglePanEnd();
309
+ break;
310
+
311
+ case INPUT.TWO_FINGER:
312
+ //doubleEnd
313
+ this.onDoublePanEnd( event );
314
+ this.onPinchEnd( event );
315
+ this.onRotateEnd( event ); //switching to singleStart
316
+
317
+ this._input = INPUT.ONE_FINGER_SWITCHED;
318
+ break;
319
+
320
+ case INPUT.MULT_FINGER:
321
+ if ( this._touchCurrent.length == 0 ) {
322
+
323
+ window.removeEventListener( 'pointermove', this.onPointerMove );
324
+ window.removeEventListener( 'pointerup', this.onPointerUp ); //multCancel
325
+
326
+ this._input = INPUT.NONE;
327
+ this.onTriplePanEnd();
328
+
329
+ }
330
+
331
+ break;
332
+
333
+ }
334
+
335
+ } else if ( event.pointerType != 'touch' && this._input == INPUT.CURSOR ) {
336
+
337
+ window.removeEventListener( 'pointermove', this.onPointerMove );
338
+ window.removeEventListener( 'pointerup', this.onPointerUp );
339
+ this._input = INPUT.NONE;
340
+ this.onSinglePanEnd();
341
+ this._button = - 1;
342
+
343
+ }
344
+
345
+ if ( event.isPrimary ) {
346
+
347
+ if ( this._downValid ) {
348
+
349
+ const downTime = event.timeStamp - this._downEvents[ this._downEvents.length - 1 ].timeStamp;
350
+
351
+ if ( downTime <= this._maxDownTime ) {
352
+
353
+ if ( this._nclicks == 0 ) {
354
+
355
+ //first valid click detected
356
+ this._nclicks = 1;
357
+ this._clickStart = performance.now();
358
+
359
+ } else {
360
+
361
+ const clickInterval = event.timeStamp - this._clickStart;
362
+
363
+ const movement = this.calculatePointersDistance( this._downEvents[ 1 ], this._downEvents[ 0 ] ) * this._devPxRatio;
364
+
365
+ if ( clickInterval <= this._maxInterval && movement <= this._posThreshold ) {
366
+
367
+ //second valid click detected
368
+ //fire double tap and reset values
369
+ this._nclicks = 0;
370
+
371
+ this._downEvents.splice( 0, this._downEvents.length );
372
+
373
+ this.onDoubleTap( event );
374
+
375
+ } else {
376
+
377
+ //new 'first click'
378
+ this._nclicks = 1;
379
+
380
+ this._downEvents.shift();
381
+
382
+ this._clickStart = performance.now();
383
+
384
+ }
385
+
386
+ }
387
+
388
+ } else {
389
+
390
+ this._downValid = false;
391
+ this._nclicks = 0;
392
+
393
+ this._downEvents.splice( 0, this._downEvents.length );
394
+
395
+ }
396
+
397
+ } else {
398
+
399
+ this._nclicks = 0;
400
+
401
+ this._downEvents.splice( 0, this._downEvents.length );
402
+
403
+ }
404
+
405
+ }
406
+
407
+ };
408
+
409
+ this.onWheel = event => {
410
+
411
+ if ( this.enabled && this.enableZoom ) {
412
+
413
+ let modifier = null;
414
+
415
+ if ( event.ctrlKey || event.metaKey ) {
416
+
417
+ modifier = 'CTRL';
418
+
419
+ } else if ( event.shiftKey ) {
420
+
421
+ modifier = 'SHIFT';
422
+
423
+ }
424
+
425
+ const mouseOp = this.getOpFromAction( 'WHEEL', modifier );
426
+
427
+ if ( mouseOp != null ) {
428
+
429
+ event.preventDefault();
430
+ this.dispatchEvent( _startEvent );
431
+ const notchDeltaY = 125; //distance of one notch of mouse wheel
432
+
433
+ let sgn = event.deltaY / notchDeltaY;
434
+ let size = 1;
435
+
436
+ if ( sgn > 0 ) {
437
+
438
+ size = 1 / this.scaleFactor;
439
+
440
+ } else if ( sgn < 0 ) {
441
+
442
+ size = this.scaleFactor;
443
+
444
+ }
445
+
446
+ switch ( mouseOp ) {
447
+
448
+ case 'ZOOM':
449
+ this.updateTbState( STATE.SCALE, true );
450
+
451
+ if ( sgn > 0 ) {
452
+
453
+ size = 1 / Math.pow( this.scaleFactor, sgn );
454
+
455
+ } else if ( sgn < 0 ) {
456
+
457
+ size = Math.pow( this.scaleFactor, - sgn );
458
+
459
+ }
460
+
461
+ if ( this.cursorZoom && this.enablePan ) {
462
+
463
+ let scalePoint;
464
+
465
+ if ( this.camera.isOrthographicCamera ) {
466
+
467
+ scalePoint = this.unprojectOnTbPlane( this.camera, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._gizmos.position );
468
+
469
+ } else if ( this.camera.isPerspectiveCamera ) {
470
+
471
+ scalePoint = this.unprojectOnTbPlane( this.camera, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.camera.quaternion ).add( this._gizmos.position );
472
+
473
+ }
474
+
475
+ this.applyTransformMatrix( this.scale( size, scalePoint ) );
476
+
477
+ } else {
478
+
479
+ this.applyTransformMatrix( this.scale( size, this._gizmos.position ) );
480
+
481
+ }
482
+
483
+ if ( this._grid != null ) {
484
+
485
+ this.disposeGrid();
486
+ this.drawGrid();
487
+
488
+ }
489
+
490
+ this.updateTbState( STATE.IDLE, false );
491
+ this.dispatchEvent( _changeEvent );
492
+ this.dispatchEvent( _endEvent );
493
+ break;
494
+
495
+ case 'FOV':
496
+ if ( this.camera.isPerspectiveCamera ) {
497
+
498
+ this.updateTbState( STATE.FOV, true ); //Vertigo effect
499
+ // fov / 2
500
+ // |\
501
+ // | \
502
+ // | \
503
+ // x | \
504
+ // | \
505
+ // | \
506
+ // | _ _ _\
507
+ // y
508
+ //check for iOs shift shortcut
509
+
510
+ if ( event.deltaX != 0 ) {
511
+
512
+ sgn = event.deltaX / notchDeltaY;
513
+ size = 1;
514
+
515
+ if ( sgn > 0 ) {
516
+
517
+ size = 1 / Math.pow( this.scaleFactor, sgn );
518
+
519
+ } else if ( sgn < 0 ) {
520
+
521
+ size = Math.pow( this.scaleFactor, - sgn );
522
+
523
+ }
524
+
525
+ }
526
+
527
+ this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
528
+
529
+ const x = this._v3_1.distanceTo( this._gizmos.position );
530
+
531
+ let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
532
+ //check min and max distance
533
+
534
+ xNew = THREE.MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
535
+ const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this.camera.fov * 0.5 ); //calculate new fov
536
+
537
+ let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 ); //check min and max fov
538
+
539
+ if ( newFov > this.maxFov ) {
540
+
541
+ newFov = this.maxFov;
542
+
543
+ } else if ( newFov < this.minFov ) {
544
+
545
+ newFov = this.minFov;
546
+
547
+ }
548
+
549
+ const newDistance = y / Math.tan( THREE.MathUtils.DEG2RAD * ( newFov / 2 ) );
550
+ size = x / newDistance;
551
+ this.setFov( newFov );
552
+ this.applyTransformMatrix( this.scale( size, this._gizmos.position, false ) );
553
+
554
+ }
555
+
556
+ if ( this._grid != null ) {
557
+
558
+ this.disposeGrid();
559
+ this.drawGrid();
560
+
561
+ }
562
+
563
+ this.updateTbState( STATE.IDLE, false );
564
+ this.dispatchEvent( _changeEvent );
565
+ this.dispatchEvent( _endEvent );
566
+ break;
567
+
568
+ }
569
+
570
+ }
571
+
572
+ }
573
+
574
+ };
575
+
576
+ this.onSinglePanStart = ( event, operation ) => {
577
+
578
+ if ( this.enabled ) {
579
+
580
+ this.dispatchEvent( _startEvent );
581
+ this.setCenter( event.clientX, event.clientY );
582
+
583
+ switch ( operation ) {
584
+
585
+ case 'PAN':
586
+ if ( ! this.enablePan ) {
587
+
588
+ return;
589
+
590
+ }
591
+
592
+ if ( this._animationId != - 1 ) {
593
+
594
+ cancelAnimationFrame( this._animationId );
595
+ this._animationId = - 1;
596
+ this._timeStart = - 1;
597
+ this.activateGizmos( false );
598
+ this.dispatchEvent( _changeEvent );
599
+
600
+ }
601
+
602
+ this.updateTbState( STATE.PAN, true );
603
+
604
+ this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
605
+
606
+ if ( this.enableGrid ) {
607
+
608
+ this.drawGrid();
609
+ this.dispatchEvent( _changeEvent );
610
+
611
+ }
612
+
613
+ break;
614
+
615
+ case 'ROTATE':
616
+ if ( ! this.enableRotate ) {
617
+
618
+ return;
619
+
620
+ }
621
+
622
+ if ( this._animationId != - 1 ) {
623
+
624
+ cancelAnimationFrame( this._animationId );
625
+ this._animationId = - 1;
626
+ this._timeStart = - 1;
627
+
628
+ }
629
+
630
+ this.updateTbState( STATE.ROTATE, true );
631
+
632
+ this._startCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
633
+
634
+ this.activateGizmos( true );
635
+
636
+ if ( this.enableAnimations ) {
637
+
638
+ this._timePrev = this._timeCurrent = performance.now();
639
+ this._angleCurrent = this._anglePrev = 0;
640
+
641
+ this._cursorPosPrev.copy( this._startCursorPosition );
642
+
643
+ this._cursorPosCurr.copy( this._cursorPosPrev );
644
+
645
+ this._wCurr = 0;
646
+ this._wPrev = this._wCurr;
647
+
648
+ }
649
+
650
+ this.dispatchEvent( _changeEvent );
651
+ break;
652
+
653
+ case 'FOV':
654
+ if ( ! this.camera.isPerspectiveCamera || ! this.enableZoom ) {
655
+
656
+ return;
657
+
658
+ }
659
+
660
+ if ( this._animationId != - 1 ) {
661
+
662
+ cancelAnimationFrame( this._animationId );
663
+ this._animationId = - 1;
664
+ this._timeStart = - 1;
665
+ this.activateGizmos( false );
666
+ this.dispatchEvent( _changeEvent );
667
+
668
+ }
669
+
670
+ this.updateTbState( STATE.FOV, true );
671
+
672
+ this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
673
+
674
+ this._currentCursorPosition.copy( this._startCursorPosition );
675
+
676
+ break;
677
+
678
+ case 'ZOOM':
679
+ if ( ! this.enableZoom ) {
680
+
681
+ return;
682
+
683
+ }
684
+
685
+ if ( this._animationId != - 1 ) {
686
+
687
+ cancelAnimationFrame( this._animationId );
688
+ this._animationId = - 1;
689
+ this._timeStart = - 1;
690
+ this.activateGizmos( false );
691
+ this.dispatchEvent( _changeEvent );
692
+
693
+ }
694
+
695
+ this.updateTbState( STATE.SCALE, true );
696
+
697
+ this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
698
+
699
+ this._currentCursorPosition.copy( this._startCursorPosition );
700
+
701
+ break;
702
+
703
+ }
704
+
705
+ }
706
+
707
+ };
708
+
709
+ this.onSinglePanMove = ( event, opState ) => {
710
+
711
+ if ( this.enabled ) {
712
+
713
+ const restart = opState != this._state;
714
+ this.setCenter( event.clientX, event.clientY );
715
+
716
+ switch ( opState ) {
717
+
718
+ case STATE.PAN:
719
+ if ( this.enablePan ) {
720
+
721
+ if ( restart ) {
722
+
723
+ //switch to pan operation
724
+ this.dispatchEvent( _endEvent );
725
+ this.dispatchEvent( _startEvent );
726
+ this.updateTbState( opState, true );
727
+
728
+ this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
729
+
730
+ if ( this.enableGrid ) {
731
+
732
+ this.drawGrid();
733
+
734
+ }
735
+
736
+ this.activateGizmos( false );
737
+
738
+ } else {
739
+
740
+ //continue with pan operation
741
+ this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
742
+
743
+ this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition ) );
744
+
745
+ }
746
+
747
+ }
748
+
749
+ break;
750
+
751
+ case STATE.ROTATE:
752
+ if ( this.enableRotate ) {
753
+
754
+ if ( restart ) {
755
+
756
+ //switch to rotate operation
757
+ this.dispatchEvent( _endEvent );
758
+ this.dispatchEvent( _startEvent );
759
+ this.updateTbState( opState, true );
760
+
761
+ this._startCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
762
+
763
+ if ( this.enableGrid ) {
764
+
765
+ this.disposeGrid();
766
+
767
+ }
768
+
769
+ this.activateGizmos( true );
770
+
771
+ } else {
772
+
773
+ //continue with rotate operation
774
+ this._currentCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
775
+
776
+ const distance = this._startCursorPosition.distanceTo( this._currentCursorPosition );
777
+
778
+ const angle = this._startCursorPosition.angleTo( this._currentCursorPosition );
779
+
780
+ const amount = Math.max( distance / this._tbRadius, angle ); //effective rotation angle
781
+
782
+ this.applyTransformMatrix( this.rotate( this.calculateRotationAxis( this._startCursorPosition, this._currentCursorPosition ), amount ) );
783
+
784
+ if ( this.enableAnimations ) {
785
+
786
+ this._timePrev = this._timeCurrent;
787
+ this._timeCurrent = performance.now();
788
+ this._anglePrev = this._angleCurrent;
789
+ this._angleCurrent = amount;
790
+
791
+ this._cursorPosPrev.copy( this._cursorPosCurr );
792
+
793
+ this._cursorPosCurr.copy( this._currentCursorPosition );
794
+
795
+ this._wPrev = this._wCurr;
796
+ this._wCurr = this.calculateAngularSpeed( this._anglePrev, this._angleCurrent, this._timePrev, this._timeCurrent );
797
+
798
+ }
799
+
800
+ }
801
+
802
+ }
803
+
804
+ break;
805
+
806
+ case STATE.SCALE:
807
+ if ( this.enableZoom ) {
808
+
809
+ if ( restart ) {
810
+
811
+ //switch to zoom operation
812
+ this.dispatchEvent( _endEvent );
813
+ this.dispatchEvent( _startEvent );
814
+ this.updateTbState( opState, true );
815
+
816
+ this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
817
+
818
+ this._currentCursorPosition.copy( this._startCursorPosition );
819
+
820
+ if ( this.enableGrid ) {
821
+
822
+ this.disposeGrid();
823
+
824
+ }
825
+
826
+ this.activateGizmos( false );
827
+
828
+ } else {
829
+
830
+ //continue with zoom operation
831
+ const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
832
+
833
+ this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
834
+
835
+ const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
836
+ let size = 1;
837
+
838
+ if ( movement < 0 ) {
839
+
840
+ size = 1 / Math.pow( this.scaleFactor, - movement * screenNotches );
841
+
842
+ } else if ( movement > 0 ) {
843
+
844
+ size = Math.pow( this.scaleFactor, movement * screenNotches );
845
+
846
+ }
847
+
848
+ this._v3_1.setFromMatrixPosition( this._gizmoMatrixState );
849
+
850
+ this.applyTransformMatrix( this.scale( size, this._v3_1 ) );
851
+
852
+ }
853
+
854
+ }
855
+
856
+ break;
857
+
858
+ case STATE.FOV:
859
+ if ( this.enableZoom && this.camera.isPerspectiveCamera ) {
860
+
861
+ if ( restart ) {
862
+
863
+ //switch to fov operation
864
+ this.dispatchEvent( _endEvent );
865
+ this.dispatchEvent( _startEvent );
866
+ this.updateTbState( opState, true );
867
+
868
+ this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
869
+
870
+ this._currentCursorPosition.copy( this._startCursorPosition );
871
+
872
+ if ( this.enableGrid ) {
873
+
874
+ this.disposeGrid();
875
+
876
+ }
877
+
878
+ this.activateGizmos( false );
879
+
880
+ } else {
881
+
882
+ //continue with fov operation
883
+ const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
884
+
885
+ this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
886
+
887
+ const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
888
+ let size = 1;
889
+
890
+ if ( movement < 0 ) {
891
+
892
+ size = 1 / Math.pow( this.scaleFactor, - movement * screenNotches );
893
+
894
+ } else if ( movement > 0 ) {
895
+
896
+ size = Math.pow( this.scaleFactor, movement * screenNotches );
897
+
898
+ }
899
+
900
+ this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
901
+
902
+ const x = this._v3_1.distanceTo( this._gizmos.position );
903
+
904
+ let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
905
+ //check min and max distance
906
+
907
+ xNew = THREE.MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
908
+ const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this._fovState * 0.5 ); //calculate new fov
909
+
910
+ let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 ); //check min and max fov
911
+
912
+ newFov = THREE.MathUtils.clamp( newFov, this.minFov, this.maxFov );
913
+ const newDistance = y / Math.tan( THREE.MathUtils.DEG2RAD * ( newFov / 2 ) );
914
+ size = x / newDistance;
915
+
916
+ this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
917
+
918
+ this.setFov( newFov );
919
+ this.applyTransformMatrix( this.scale( size, this._v3_2, false ) ); //adjusting distance
920
+
921
+ _offset.copy( this._gizmos.position ).sub( this.camera.position ).normalize().multiplyScalar( newDistance / x );
922
+
923
+ this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
924
+
925
+ }
926
+
927
+ }
928
+
929
+ break;
930
+
931
+ }
932
+
933
+ this.dispatchEvent( _changeEvent );
934
+
935
+ }
936
+
937
+ };
938
+
939
+ this.onSinglePanEnd = () => {
940
+
941
+ if ( this._state == STATE.ROTATE ) {
942
+
943
+ if ( ! this.enableRotate ) {
944
+
945
+ return;
946
+
947
+ }
948
+
949
+ if ( this.enableAnimations ) {
950
+
951
+ //perform rotation animation
952
+ const deltaTime = performance.now() - this._timeCurrent;
953
+
954
+ if ( deltaTime < 120 ) {
955
+
956
+ const w = Math.abs( ( this._wPrev + this._wCurr ) / 2 );
957
+ const self = this;
958
+ this._animationId = window.requestAnimationFrame( function ( t ) {
959
+
960
+ self.updateTbState( STATE.ANIMATION_ROTATE, true );
961
+ const rotationAxis = self.calculateRotationAxis( self._cursorPosPrev, self._cursorPosCurr );
962
+ self.onRotationAnim( t, rotationAxis, Math.min( w, self.wMax ) );
963
+
964
+ } );
965
+
966
+ } else {
967
+
968
+ //cursor has been standing still for over 120 ms since last movement
969
+ this.updateTbState( STATE.IDLE, false );
970
+ this.activateGizmos( false );
971
+ this.dispatchEvent( _changeEvent );
972
+
973
+ }
974
+
975
+ } else {
976
+
977
+ this.updateTbState( STATE.IDLE, false );
978
+ this.activateGizmos( false );
979
+ this.dispatchEvent( _changeEvent );
980
+
981
+ }
982
+
983
+ } else if ( this._state == STATE.PAN || this._state == STATE.IDLE ) {
984
+
985
+ this.updateTbState( STATE.IDLE, false );
986
+
987
+ if ( this.enableGrid ) {
988
+
989
+ this.disposeGrid();
990
+
991
+ }
992
+
993
+ this.activateGizmos( false );
994
+ this.dispatchEvent( _changeEvent );
995
+
996
+ }
997
+
998
+ this.dispatchEvent( _endEvent );
999
+
1000
+ };
1001
+
1002
+ this.onDoubleTap = event => {
1003
+
1004
+ if ( this.enabled && this.enablePan && this.scene != null ) {
1005
+
1006
+ this.dispatchEvent( _startEvent );
1007
+ this.setCenter( event.clientX, event.clientY );
1008
+ const hitP = this.unprojectOnObj( this.getCursorNDC( _center.x, _center.y, this.domElement ), this.camera );
1009
+
1010
+ if ( hitP != null && this.enableAnimations ) {
1011
+
1012
+ const self = this;
1013
+
1014
+ if ( this._animationId != - 1 ) {
1015
+
1016
+ window.cancelAnimationFrame( this._animationId );
1017
+
1018
+ }
1019
+
1020
+ this._timeStart = - 1;
1021
+ this._animationId = window.requestAnimationFrame( function ( t ) {
1022
+
1023
+ self.updateTbState( STATE.ANIMATION_FOCUS, true );
1024
+ self.onFocusAnim( t, hitP, self._cameraMatrixState, self._gizmoMatrixState );
1025
+
1026
+ } );
1027
+
1028
+ } else if ( hitP != null && ! this.enableAnimations ) {
1029
+
1030
+ this.updateTbState( STATE.FOCUS, true );
1031
+ this.focus( hitP, this.scaleFactor );
1032
+ this.updateTbState( STATE.IDLE, false );
1033
+ this.dispatchEvent( _changeEvent );
1034
+
1035
+ }
1036
+
1037
+ }
1038
+
1039
+ this.dispatchEvent( _endEvent );
1040
+
1041
+ };
1042
+
1043
+ this.onDoublePanStart = () => {
1044
+
1045
+ if ( this.enabled && this.enablePan ) {
1046
+
1047
+ this.dispatchEvent( _startEvent );
1048
+ this.updateTbState( STATE.PAN, true );
1049
+ this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1050
+
1051
+ this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement, true ) );
1052
+
1053
+ this._currentCursorPosition.copy( this._startCursorPosition );
1054
+
1055
+ this.activateGizmos( false );
1056
+
1057
+ }
1058
+
1059
+ };
1060
+
1061
+ this.onDoublePanMove = () => {
1062
+
1063
+ if ( this.enabled && this.enablePan ) {
1064
+
1065
+ this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1066
+
1067
+ if ( this._state != STATE.PAN ) {
1068
+
1069
+ this.updateTbState( STATE.PAN, true );
1070
+
1071
+ this._startCursorPosition.copy( this._currentCursorPosition );
1072
+
1073
+ }
1074
+
1075
+ this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement, true ) );
1076
+
1077
+ this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition, true ) );
1078
+ this.dispatchEvent( _changeEvent );
1079
+
1080
+ }
1081
+
1082
+ };
1083
+
1084
+ this.onDoublePanEnd = () => {
1085
+
1086
+ this.updateTbState( STATE.IDLE, false );
1087
+ this.dispatchEvent( _endEvent );
1088
+
1089
+ };
1090
+
1091
+ this.onRotateStart = () => {
1092
+
1093
+ if ( this.enabled && this.enableRotate ) {
1094
+
1095
+ this.dispatchEvent( _startEvent );
1096
+ this.updateTbState( STATE.ZROTATE, true ); //this._startFingerRotation = event.rotation;
1097
+
1098
+ this._startFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
1099
+ this._currentFingerRotation = this._startFingerRotation;
1100
+ this.camera.getWorldDirection( this._rotationAxis ); //rotation axis
1101
+
1102
+ if ( ! this.enablePan && ! this.enableZoom ) {
1103
+
1104
+ this.activateGizmos( true );
1105
+
1106
+ }
1107
+
1108
+ }
1109
+
1110
+ };
1111
+
1112
+ this.onRotateMove = () => {
1113
+
1114
+ if ( this.enabled && this.enableRotate ) {
1115
+
1116
+ this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1117
+ let rotationPoint;
1118
+
1119
+ if ( this._state != STATE.ZROTATE ) {
1120
+
1121
+ this.updateTbState( STATE.ZROTATE, true );
1122
+ this._startFingerRotation = this._currentFingerRotation;
1123
+
1124
+ } //this._currentFingerRotation = event.rotation;
1125
+
1126
+
1127
+ this._currentFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
1128
+
1129
+ if ( ! this.enablePan ) {
1130
+
1131
+ rotationPoint = new THREE.Vector3().setFromMatrixPosition( this._gizmoMatrixState );
1132
+
1133
+ } else {
1134
+
1135
+ this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
1136
+
1137
+ rotationPoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._v3_2 );
1138
+
1139
+ }
1140
+
1141
+ const amount = THREE.MathUtils.DEG2RAD * ( this._startFingerRotation - this._currentFingerRotation );
1142
+ this.applyTransformMatrix( this.zRotate( rotationPoint, amount ) );
1143
+ this.dispatchEvent( _changeEvent );
1144
+
1145
+ }
1146
+
1147
+ };
1148
+
1149
+ this.onRotateEnd = () => {
1150
+
1151
+ this.updateTbState( STATE.IDLE, false );
1152
+ this.activateGizmos( false );
1153
+ this.dispatchEvent( _endEvent );
1154
+
1155
+ };
1156
+
1157
+ this.onPinchStart = () => {
1158
+
1159
+ if ( this.enabled && this.enableZoom ) {
1160
+
1161
+ this.dispatchEvent( _startEvent );
1162
+ this.updateTbState( STATE.SCALE, true );
1163
+ this._startFingerDistance = this.calculatePointersDistance( this._touchCurrent[ 0 ], this._touchCurrent[ 1 ] );
1164
+ this._currentFingerDistance = this._startFingerDistance;
1165
+ this.activateGizmos( false );
1166
+
1167
+ }
1168
+
1169
+ };
1170
+
1171
+ this.onPinchMove = () => {
1172
+
1173
+ if ( this.enabled && this.enableZoom ) {
1174
+
1175
+ this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
1176
+ const minDistance = 12; //minimum distance between fingers (in css pixels)
1177
+
1178
+ if ( this._state != STATE.SCALE ) {
1179
+
1180
+ this._startFingerDistance = this._currentFingerDistance;
1181
+ this.updateTbState( STATE.SCALE, true );
1182
+
1183
+ }
1184
+
1185
+ this._currentFingerDistance = Math.max( this.calculatePointersDistance( this._touchCurrent[ 0 ], this._touchCurrent[ 1 ] ), minDistance * this._devPxRatio );
1186
+ const amount = this._currentFingerDistance / this._startFingerDistance;
1187
+ let scalePoint;
1188
+
1189
+ if ( ! this.enablePan ) {
1190
+
1191
+ scalePoint = this._gizmos.position;
1192
+
1193
+ } else {
1194
+
1195
+ if ( this.camera.isOrthographicCamera ) {
1196
+
1197
+ scalePoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._gizmos.position );
1198
+
1199
+ } else if ( this.camera.isPerspectiveCamera ) {
1200
+
1201
+ scalePoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ).applyQuaternion( this.camera.quaternion ).add( this._gizmos.position );
1202
+
1203
+ }
1204
+
1205
+ }
1206
+
1207
+ this.applyTransformMatrix( this.scale( amount, scalePoint ) );
1208
+ this.dispatchEvent( _changeEvent );
1209
+
1210
+ }
1211
+
1212
+ };
1213
+
1214
+ this.onPinchEnd = () => {
1215
+
1216
+ this.updateTbState( STATE.IDLE, false );
1217
+ this.dispatchEvent( _endEvent );
1218
+
1219
+ };
1220
+
1221
+ this.onTriplePanStart = () => {
1222
+
1223
+ if ( this.enabled && this.enableZoom ) {
1224
+
1225
+ this.dispatchEvent( _startEvent );
1226
+ this.updateTbState( STATE.SCALE, true ); //const center = event.center;
1227
+
1228
+ let clientX = 0;
1229
+ let clientY = 0;
1230
+ const nFingers = this._touchCurrent.length;
1231
+
1232
+ for ( let i = 0; i < nFingers; i ++ ) {
1233
+
1234
+ clientX += this._touchCurrent[ i ].clientX;
1235
+ clientY += this._touchCurrent[ i ].clientY;
1236
+
1237
+ }
1238
+
1239
+ this.setCenter( clientX / nFingers, clientY / nFingers );
1240
+
1241
+ this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
1242
+
1243
+ this._currentCursorPosition.copy( this._startCursorPosition );
1244
+
1245
+ }
1246
+
1247
+ };
1248
+
1249
+ this.onTriplePanMove = () => {
1250
+
1251
+ if ( this.enabled && this.enableZoom ) {
1252
+
1253
+ // fov / 2
1254
+ // |\
1255
+ // | \
1256
+ // | \
1257
+ // x | \
1258
+ // | \
1259
+ // | \
1260
+ // | _ _ _\
1261
+ // y
1262
+ //const center = event.center;
1263
+ let clientX = 0;
1264
+ let clientY = 0;
1265
+ const nFingers = this._touchCurrent.length;
1266
+
1267
+ for ( let i = 0; i < nFingers; i ++ ) {
1268
+
1269
+ clientX += this._touchCurrent[ i ].clientX;
1270
+ clientY += this._touchCurrent[ i ].clientY;
1271
+
1272
+ }
1273
+
1274
+ this.setCenter( clientX / nFingers, clientY / nFingers );
1275
+ const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
1276
+
1277
+ this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
1278
+
1279
+ const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
1280
+ let size = 1;
1281
+
1282
+ if ( movement < 0 ) {
1283
+
1284
+ size = 1 / Math.pow( this.scaleFactor, - movement * screenNotches );
1285
+
1286
+ } else if ( movement > 0 ) {
1287
+
1288
+ size = Math.pow( this.scaleFactor, movement * screenNotches );
1289
+
1290
+ }
1291
+
1292
+ this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
1293
+
1294
+ const x = this._v3_1.distanceTo( this._gizmos.position );
1295
+
1296
+ let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
1297
+ //check min and max distance
1298
+
1299
+ xNew = THREE.MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
1300
+ const y = x * Math.tan( THREE.MathUtils.DEG2RAD * this._fovState * 0.5 ); //calculate new fov
1301
+
1302
+ let newFov = THREE.MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 ); //check min and max fov
1303
+
1304
+ newFov = THREE.MathUtils.clamp( newFov, this.minFov, this.maxFov );
1305
+ const newDistance = y / Math.tan( THREE.MathUtils.DEG2RAD * ( newFov / 2 ) );
1306
+ size = x / newDistance;
1307
+
1308
+ this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
1309
+
1310
+ this.setFov( newFov );
1311
+ this.applyTransformMatrix( this.scale( size, this._v3_2, false ) ); //adjusting distance
1312
+
1313
+ _offset.copy( this._gizmos.position ).sub( this.camera.position ).normalize().multiplyScalar( newDistance / x );
1314
+
1315
+ this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
1316
+
1317
+ this.dispatchEvent( _changeEvent );
1318
+
1319
+ }
1320
+
1321
+ };
1322
+
1323
+ this.onTriplePanEnd = () => {
1324
+
1325
+ this.updateTbState( STATE.IDLE, false );
1326
+ this.dispatchEvent( _endEvent ); //this.dispatchEvent( _changeEvent );
1327
+
1328
+ };
1329
+
1330
+ this.setCenter = ( clientX, clientY ) => {
1331
+
1332
+ _center.x = clientX;
1333
+ _center.y = clientY;
1334
+
1335
+ };
1336
+
1337
+ this.initializeMouseActions = () => {
1338
+
1339
+ this.setMouseAction( 'PAN', 0, 'CTRL' );
1340
+ this.setMouseAction( 'PAN', 2 );
1341
+ this.setMouseAction( 'ROTATE', 0 );
1342
+ this.setMouseAction( 'ZOOM', 'WHEEL' );
1343
+ this.setMouseAction( 'ZOOM', 1 );
1344
+ this.setMouseAction( 'FOV', 'WHEEL', 'SHIFT' );
1345
+ this.setMouseAction( 'FOV', 1, 'SHIFT' );
1346
+
1347
+ };
1348
+
1349
+ this.compareMouseAction = ( action1, action2 ) => {
1350
+
1351
+ if ( action1.operation == action2.operation ) {
1352
+
1353
+ if ( action1.mouse == action2.mouse && action1.key == action2.key ) {
1354
+
1355
+ return true;
1356
+
1357
+ } else {
1358
+
1359
+ return false;
1360
+
1361
+ }
1362
+
1363
+ } else {
1364
+
1365
+ return false;
1366
+
1367
+ }
1368
+
1369
+ };
1370
+
1371
+ this.setMouseAction = ( operation, mouse, key = null ) => {
1372
+
1373
+ const operationInput = [ 'PAN', 'ROTATE', 'ZOOM', 'FOV' ];
1374
+ const mouseInput = [ 0, 1, 2, 'WHEEL' ];
1375
+ const keyInput = [ 'CTRL', 'SHIFT', null ];
1376
+ let state;
1377
+
1378
+ if ( ! operationInput.includes( operation ) || ! mouseInput.includes( mouse ) || ! keyInput.includes( key ) ) {
1379
+
1380
+ //invalid parameters
1381
+ return false;
1382
+
1383
+ }
1384
+
1385
+ if ( mouse == 'WHEEL' ) {
1386
+
1387
+ if ( operation != 'ZOOM' && operation != 'FOV' ) {
1388
+
1389
+ //cannot associate 2D operation to 1D input
1390
+ return false;
1391
+
1392
+ }
1393
+
1394
+ }
1395
+
1396
+ switch ( operation ) {
1397
+
1398
+ case 'PAN':
1399
+ state = STATE.PAN;
1400
+ break;
1401
+
1402
+ case 'ROTATE':
1403
+ state = STATE.ROTATE;
1404
+ break;
1405
+
1406
+ case 'ZOOM':
1407
+ state = STATE.SCALE;
1408
+ break;
1409
+
1410
+ case 'FOV':
1411
+ state = STATE.FOV;
1412
+ break;
1413
+
1414
+ }
1415
+
1416
+ const action = {
1417
+ operation: operation,
1418
+ mouse: mouse,
1419
+ key: key,
1420
+ state: state
1421
+ };
1422
+
1423
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1424
+
1425
+ if ( this.mouseActions[ i ].mouse == action.mouse && this.mouseActions[ i ].key == action.key ) {
1426
+
1427
+ this.mouseActions.splice( i, 1, action );
1428
+ return true;
1429
+
1430
+ }
1431
+
1432
+ }
1433
+
1434
+ this.mouseActions.push( action );
1435
+ return true;
1436
+
1437
+ };
1438
+
1439
+ this.unsetMouseAction = ( mouse, key = null ) => {
1440
+
1441
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1442
+
1443
+ if ( this.mouseActions[ i ].mouse == mouse && this.mouseActions[ i ].key == key ) {
1444
+
1445
+ this.mouseActions.splice( i, 1 );
1446
+ return true;
1447
+
1448
+ }
1449
+
1450
+ }
1451
+
1452
+ return false;
1453
+
1454
+ };
1455
+
1456
+ this.getOpFromAction = ( mouse, key ) => {
1457
+
1458
+ let action;
1459
+
1460
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1461
+
1462
+ action = this.mouseActions[ i ];
1463
+
1464
+ if ( action.mouse == mouse && action.key == key ) {
1465
+
1466
+ return action.operation;
1467
+
1468
+ }
1469
+
1470
+ }
1471
+
1472
+ if ( key != null ) {
1473
+
1474
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1475
+
1476
+ action = this.mouseActions[ i ];
1477
+
1478
+ if ( action.mouse == mouse && action.key == null ) {
1479
+
1480
+ return action.operation;
1481
+
1482
+ }
1483
+
1484
+ }
1485
+
1486
+ }
1487
+
1488
+ return null;
1489
+
1490
+ };
1491
+
1492
+ this.getOpStateFromAction = ( mouse, key ) => {
1493
+
1494
+ let action;
1495
+
1496
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1497
+
1498
+ action = this.mouseActions[ i ];
1499
+
1500
+ if ( action.mouse == mouse && action.key == key ) {
1501
+
1502
+ return action.state;
1503
+
1504
+ }
1505
+
1506
+ }
1507
+
1508
+ if ( key != null ) {
1509
+
1510
+ for ( let i = 0; i < this.mouseActions.length; i ++ ) {
1511
+
1512
+ action = this.mouseActions[ i ];
1513
+
1514
+ if ( action.mouse == mouse && action.key == null ) {
1515
+
1516
+ return action.state;
1517
+
1518
+ }
1519
+
1520
+ }
1521
+
1522
+ }
1523
+
1524
+ return null;
1525
+
1526
+ };
1527
+
1528
+ this.getAngle = ( p1, p2 ) => {
1529
+
1530
+ return Math.atan2( p2.clientY - p1.clientY, p2.clientX - p1.clientX ) * 180 / Math.PI;
1531
+
1532
+ };
1533
+
1534
+ this.updateTouchEvent = event => {
1535
+
1536
+ for ( let i = 0; i < this._touchCurrent.length; i ++ ) {
1537
+
1538
+ if ( this._touchCurrent[ i ].pointerId == event.pointerId ) {
1539
+
1540
+ this._touchCurrent.splice( i, 1, event );
1541
+
1542
+ break;
1543
+
1544
+ }
1545
+
1546
+ }
1547
+
1548
+ };
1549
+
1550
+ this.calculateAngularSpeed = ( p0, p1, t0, t1 ) => {
1551
+
1552
+ const s = p1 - p0;
1553
+ const t = ( t1 - t0 ) / 1000;
1554
+
1555
+ if ( t == 0 ) {
1556
+
1557
+ return 0;
1558
+
1559
+ }
1560
+
1561
+ return s / t;
1562
+
1563
+ };
1564
+
1565
+ this.calculatePointersDistance = ( p0, p1 ) => {
1566
+
1567
+ return Math.sqrt( Math.pow( p1.clientX - p0.clientX, 2 ) + Math.pow( p1.clientY - p0.clientY, 2 ) );
1568
+
1569
+ };
1570
+
1571
+ this.calculateRotationAxis = ( vec1, vec2 ) => {
1572
+
1573
+ this._rotationMatrix.extractRotation( this._cameraMatrixState );
1574
+
1575
+ this._quat.setFromRotationMatrix( this._rotationMatrix );
1576
+
1577
+ this._rotationAxis.crossVectors( vec1, vec2 ).applyQuaternion( this._quat );
1578
+
1579
+ return this._rotationAxis.normalize().clone();
1580
+
1581
+ };
1582
+
1583
+ this.calculateTbRadius = camera => {
1584
+
1585
+ const distance = camera.position.distanceTo( this._gizmos.position );
1586
+
1587
+ if ( camera.type == 'PerspectiveCamera' ) {
1588
+
1589
+ const halfFovV = THREE.MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
1590
+
1591
+ const halfFovH = Math.atan( camera.aspect * Math.tan( halfFovV ) ); //horizontal fov/2 in radians
1592
+
1593
+ return Math.tan( Math.min( halfFovV, halfFovH ) ) * distance * this.radiusFactor;
1594
+
1595
+ } else if ( camera.type == 'OrthographicCamera' ) {
1596
+
1597
+ return Math.min( camera.top, camera.right ) * this.radiusFactor;
1598
+
1599
+ }
1600
+
1601
+ };
1602
+
1603
+ this.focus = ( point, size, amount = 1 ) => {
1604
+
1605
+ //move center of camera (along with gizmos) towards point of interest
1606
+ _offset.copy( point ).sub( this._gizmos.position ).multiplyScalar( amount );
1607
+
1608
+ this._translationMatrix.makeTranslation( _offset.x, _offset.y, _offset.z );
1609
+
1610
+ _gizmoMatrixStateTemp.copy( this._gizmoMatrixState );
1611
+
1612
+ this._gizmoMatrixState.premultiply( this._translationMatrix );
1613
+
1614
+ this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1615
+
1616
+ _cameraMatrixStateTemp.copy( this._cameraMatrixState );
1617
+
1618
+ this._cameraMatrixState.premultiply( this._translationMatrix );
1619
+
1620
+ this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale ); //apply zoom
1621
+
1622
+
1623
+ if ( this.enableZoom ) {
1624
+
1625
+ this.applyTransformMatrix( this.scale( size, this._gizmos.position ) );
1626
+
1627
+ }
1628
+
1629
+ this._gizmoMatrixState.copy( _gizmoMatrixStateTemp );
1630
+
1631
+ this._cameraMatrixState.copy( _cameraMatrixStateTemp );
1632
+
1633
+ };
1634
+
1635
+ this.drawGrid = () => {
1636
+
1637
+ if ( this.scene != null ) {
1638
+
1639
+ const color = 0x888888;
1640
+ const multiplier = 3;
1641
+ let size, divisions, maxLength, tick;
1642
+
1643
+ if ( this.camera.isOrthographicCamera ) {
1644
+
1645
+ const width = this.camera.right - this.camera.left;
1646
+ const height = this.camera.bottom - this.camera.top;
1647
+ maxLength = Math.max( width, height );
1648
+ tick = maxLength / 20;
1649
+ size = maxLength / this.camera.zoom * multiplier;
1650
+ divisions = size / tick * this.camera.zoom;
1651
+
1652
+ } else if ( this.camera.isPerspectiveCamera ) {
1653
+
1654
+ const distance = this.camera.position.distanceTo( this._gizmos.position );
1655
+ const halfFovV = THREE.MathUtils.DEG2RAD * this.camera.fov * 0.5;
1656
+ const halfFovH = Math.atan( this.camera.aspect * Math.tan( halfFovV ) );
1657
+ maxLength = Math.tan( Math.max( halfFovV, halfFovH ) ) * distance * 2;
1658
+ tick = maxLength / 20;
1659
+ size = maxLength * multiplier;
1660
+ divisions = size / tick;
1661
+
1662
+ }
1663
+
1664
+ if ( this._grid == null ) {
1665
+
1666
+ this._grid = new THREE.GridHelper( size, divisions, color, color );
1667
+
1668
+ this._grid.position.copy( this._gizmos.position );
1669
+
1670
+ this._gridPosition.copy( this._grid.position );
1671
+
1672
+ this._grid.quaternion.copy( this.camera.quaternion );
1673
+
1674
+ this._grid.rotateX( Math.PI * 0.5 );
1675
+
1676
+ this.scene.add( this._grid );
1677
+
1678
+ }
1679
+
1680
+ }
1681
+
1682
+ };
1683
+
1684
+ this.dispose = () => {
1685
+
1686
+ if ( this._animationId != - 1 ) {
1687
+
1688
+ window.cancelAnimationFrame( this._animationId );
1689
+
1690
+ }
1691
+
1692
+ this.domElement.removeEventListener( 'pointerdown', this.onPointerDown );
1693
+ this.domElement.removeEventListener( 'pointercancel', this.onPointerCancel );
1694
+ this.domElement.removeEventListener( 'wheel', this.onWheel );
1695
+ this.domElement.removeEventListener( 'contextmenu', this.onContextMenu );
1696
+ window.removeEventListener( 'pointermove', this.onPointerMove );
1697
+ window.removeEventListener( 'pointerup', this.onPointerUp );
1698
+ window.removeEventListener( 'resize', this.onWindowResize );
1699
+ if ( this.scene !== null ) this.scene.remove( this._gizmos );
1700
+ this.disposeGrid();
1701
+
1702
+ };
1703
+
1704
+ this.disposeGrid = () => {
1705
+
1706
+ if ( this._grid != null && this.scene != null ) {
1707
+
1708
+ this.scene.remove( this._grid );
1709
+ this._grid = null;
1710
+
1711
+ }
1712
+
1713
+ };
1714
+
1715
+ this.easeOutCubic = t => {
1716
+
1717
+ return 1 - Math.pow( 1 - t, 3 );
1718
+
1719
+ };
1720
+
1721
+ this.activateGizmos = isActive => {
1722
+
1723
+ const gizmoX = this._gizmos.children[ 0 ];
1724
+ const gizmoY = this._gizmos.children[ 1 ];
1725
+ const gizmoZ = this._gizmos.children[ 2 ];
1726
+
1727
+ if ( isActive ) {
1728
+
1729
+ gizmoX.material.setValues( {
1730
+ opacity: 1
1731
+ } );
1732
+ gizmoY.material.setValues( {
1733
+ opacity: 1
1734
+ } );
1735
+ gizmoZ.material.setValues( {
1736
+ opacity: 1
1737
+ } );
1738
+
1739
+ } else {
1740
+
1741
+ gizmoX.material.setValues( {
1742
+ opacity: 0.6
1743
+ } );
1744
+ gizmoY.material.setValues( {
1745
+ opacity: 0.6
1746
+ } );
1747
+ gizmoZ.material.setValues( {
1748
+ opacity: 0.6
1749
+ } );
1750
+
1751
+ }
1752
+
1753
+ };
1754
+
1755
+ this.getCursorNDC = ( cursorX, cursorY, canvas ) => {
1756
+
1757
+ const canvasRect = canvas.getBoundingClientRect();
1758
+
1759
+ this._v2_1.setX( ( cursorX - canvasRect.left ) / canvasRect.width * 2 - 1 );
1760
+
1761
+ this._v2_1.setY( ( canvasRect.bottom - cursorY ) / canvasRect.height * 2 - 1 );
1762
+
1763
+ return this._v2_1.clone();
1764
+
1765
+ };
1766
+
1767
+ this.getCursorPosition = ( cursorX, cursorY, canvas ) => {
1768
+
1769
+ this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
1770
+
1771
+ this._v2_1.x *= ( this.camera.right - this.camera.left ) * 0.5;
1772
+ this._v2_1.y *= ( this.camera.top - this.camera.bottom ) * 0.5;
1773
+ return this._v2_1.clone();
1774
+
1775
+ };
1776
+
1777
+ this.setCamera = camera => {
1778
+
1779
+ camera.lookAt( this.target );
1780
+ camera.updateMatrix(); //setting state
1781
+
1782
+ if ( camera.type == 'PerspectiveCamera' ) {
1783
+
1784
+ this._fov0 = camera.fov;
1785
+ this._fovState = camera.fov;
1786
+
1787
+ }
1788
+
1789
+ this._cameraMatrixState0.copy( camera.matrix );
1790
+
1791
+ this._cameraMatrixState.copy( this._cameraMatrixState0 );
1792
+
1793
+ this._cameraProjectionState.copy( camera.projectionMatrix );
1794
+
1795
+ this._zoom0 = camera.zoom;
1796
+ this._zoomState = this._zoom0;
1797
+ this._initialNear = camera.near;
1798
+ this._nearPos0 = camera.position.distanceTo( this.target ) - camera.near;
1799
+ this._nearPos = this._initialNear;
1800
+ this._initialFar = camera.far;
1801
+ this._farPos0 = camera.position.distanceTo( this.target ) - camera.far;
1802
+ this._farPos = this._initialFar;
1803
+
1804
+ this._up0.copy( camera.up );
1805
+
1806
+ this._upState.copy( camera.up );
1807
+
1808
+ this.camera = camera;
1809
+ this.camera.updateProjectionMatrix(); //making gizmos
1810
+
1811
+ this._tbRadius = this.calculateTbRadius( camera );
1812
+ this.makeGizmos( this.target, this._tbRadius );
1813
+
1814
+ };
1815
+
1816
+ this.makeGizmos = ( tbCenter, tbRadius ) => {
1817
+
1818
+ const curve = new THREE.EllipseCurve( 0, 0, tbRadius, tbRadius );
1819
+ const points = curve.getPoints( this._curvePts ); //geometry
1820
+
1821
+ const curveGeometry = new THREE.BufferGeometry().setFromPoints( points ); //material
1822
+
1823
+ const curveMaterialX = new THREE.LineBasicMaterial( {
1824
+ color: 0xff8080,
1825
+ fog: false,
1826
+ transparent: true,
1827
+ opacity: 0.6
1828
+ } );
1829
+ const curveMaterialY = new THREE.LineBasicMaterial( {
1830
+ color: 0x80ff80,
1831
+ fog: false,
1832
+ transparent: true,
1833
+ opacity: 0.6
1834
+ } );
1835
+ const curveMaterialZ = new THREE.LineBasicMaterial( {
1836
+ color: 0x8080ff,
1837
+ fog: false,
1838
+ transparent: true,
1839
+ opacity: 0.6
1840
+ } ); //line
1841
+
1842
+ const gizmoX = new THREE.Line( curveGeometry, curveMaterialX );
1843
+ const gizmoY = new THREE.Line( curveGeometry, curveMaterialY );
1844
+ const gizmoZ = new THREE.Line( curveGeometry, curveMaterialZ );
1845
+ const rotation = Math.PI * 0.5;
1846
+ gizmoX.rotation.x = rotation;
1847
+ gizmoY.rotation.y = rotation; //setting state
1848
+
1849
+ this._gizmoMatrixState0.identity().setPosition( tbCenter );
1850
+
1851
+ this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
1852
+
1853
+ if ( this.camera.zoom !== 1 ) {
1854
+
1855
+ //adapt gizmos size to camera zoom
1856
+ const size = 1 / this.camera.zoom;
1857
+
1858
+ this._scaleMatrix.makeScale( size, size, size );
1859
+
1860
+ this._translationMatrix.makeTranslation( - tbCenter.x, - tbCenter.y, - tbCenter.z );
1861
+
1862
+ this._gizmoMatrixState.premultiply( this._translationMatrix ).premultiply( this._scaleMatrix );
1863
+
1864
+ this._translationMatrix.makeTranslation( tbCenter.x, tbCenter.y, tbCenter.z );
1865
+
1866
+ this._gizmoMatrixState.premultiply( this._translationMatrix );
1867
+
1868
+ }
1869
+
1870
+ this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale ); //
1871
+
1872
+
1873
+ this._gizmos.traverse( function ( object ) {
1874
+
1875
+ if ( object.isLine ) {
1876
+
1877
+ object.geometry.dispose();
1878
+ object.material.dispose();
1879
+
1880
+ }
1881
+
1882
+ } );
1883
+
1884
+ this._gizmos.clear(); //
1885
+
1886
+
1887
+ this._gizmos.add( gizmoX );
1888
+
1889
+ this._gizmos.add( gizmoY );
1890
+
1891
+ this._gizmos.add( gizmoZ );
1892
+
1893
+ };
1894
+
1895
+ this.onFocusAnim = ( time, point, cameraMatrix, gizmoMatrix ) => {
1896
+
1897
+ if ( this._timeStart == - 1 ) {
1898
+
1899
+ //animation start
1900
+ this._timeStart = time;
1901
+
1902
+ }
1903
+
1904
+ if ( this._state == STATE.ANIMATION_FOCUS ) {
1905
+
1906
+ const deltaTime = time - this._timeStart;
1907
+ const animTime = deltaTime / this.focusAnimationTime;
1908
+
1909
+ this._gizmoMatrixState.copy( gizmoMatrix );
1910
+
1911
+ if ( animTime >= 1 ) {
1912
+
1913
+ //animation end
1914
+ this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1915
+
1916
+ this.focus( point, this.scaleFactor );
1917
+ this._timeStart = - 1;
1918
+ this.updateTbState( STATE.IDLE, false );
1919
+ this.activateGizmos( false );
1920
+ this.dispatchEvent( _changeEvent );
1921
+
1922
+ } else {
1923
+
1924
+ const amount = this.easeOutCubic( animTime );
1925
+ const size = 1 - amount + this.scaleFactor * amount;
1926
+
1927
+ this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
1928
+
1929
+ this.focus( point, size, amount );
1930
+ this.dispatchEvent( _changeEvent );
1931
+ const self = this;
1932
+ this._animationId = window.requestAnimationFrame( function ( t ) {
1933
+
1934
+ self.onFocusAnim( t, point, cameraMatrix, gizmoMatrix.clone() );
1935
+
1936
+ } );
1937
+
1938
+ }
1939
+
1940
+ } else {
1941
+
1942
+ //interrupt animation
1943
+ this._animationId = - 1;
1944
+ this._timeStart = - 1;
1945
+
1946
+ }
1947
+
1948
+ };
1949
+
1950
+ this.onRotationAnim = ( time, rotationAxis, w0 ) => {
1951
+
1952
+ if ( this._timeStart == - 1 ) {
1953
+
1954
+ //animation start
1955
+ this._anglePrev = 0;
1956
+ this._angleCurrent = 0;
1957
+ this._timeStart = time;
1958
+
1959
+ }
1960
+
1961
+ if ( this._state == STATE.ANIMATION_ROTATE ) {
1962
+
1963
+ //w = w0 + alpha * t
1964
+ const deltaTime = ( time - this._timeStart ) / 1000;
1965
+ const w = w0 + - this.dampingFactor * deltaTime;
1966
+
1967
+ if ( w > 0 ) {
1968
+
1969
+ //tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
1970
+ this._angleCurrent = 0.5 * - this.dampingFactor * Math.pow( deltaTime, 2 ) + w0 * deltaTime + 0;
1971
+ this.applyTransformMatrix( this.rotate( rotationAxis, this._angleCurrent ) );
1972
+ this.dispatchEvent( _changeEvent );
1973
+ const self = this;
1974
+ this._animationId = window.requestAnimationFrame( function ( t ) {
1975
+
1976
+ self.onRotationAnim( t, rotationAxis, w0 );
1977
+
1978
+ } );
1979
+
1980
+ } else {
1981
+
1982
+ this._animationId = - 1;
1983
+ this._timeStart = - 1;
1984
+ this.updateTbState( STATE.IDLE, false );
1985
+ this.activateGizmos( false );
1986
+ this.dispatchEvent( _changeEvent );
1987
+
1988
+ }
1989
+
1990
+ } else {
1991
+
1992
+ //interrupt animation
1993
+ this._animationId = - 1;
1994
+ this._timeStart = - 1;
1995
+
1996
+ if ( this._state != STATE.ROTATE ) {
1997
+
1998
+ this.activateGizmos( false );
1999
+ this.dispatchEvent( _changeEvent );
2000
+
2001
+ }
2002
+
2003
+ }
2004
+
2005
+ };
2006
+
2007
+ this.pan = ( p0, p1, adjust = false ) => {
2008
+
2009
+ const movement = p0.clone().sub( p1 );
2010
+
2011
+ if ( this.camera.isOrthographicCamera ) {
2012
+
2013
+ //adjust movement amount
2014
+ movement.multiplyScalar( 1 / this.camera.zoom );
2015
+
2016
+ } else if ( this.camera.isPerspectiveCamera && adjust ) {
2017
+
2018
+ //adjust movement amount
2019
+ this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ); //camera's initial position
2020
+
2021
+
2022
+ this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ); //gizmo's initial position
2023
+
2024
+
2025
+ const distanceFactor = this._v3_1.distanceTo( this._v3_2 ) / this.camera.position.distanceTo( this._gizmos.position );
2026
+ movement.multiplyScalar( 1 / distanceFactor );
2027
+
2028
+ }
2029
+
2030
+ this._v3_1.set( movement.x, movement.y, 0 ).applyQuaternion( this.camera.quaternion );
2031
+
2032
+ this._m4_1.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z );
2033
+
2034
+ this.setTransformationMatrices( this._m4_1, this._m4_1 );
2035
+ return _transformation;
2036
+
2037
+ };
2038
+
2039
+ this.reset = () => {
2040
+
2041
+ this.camera.zoom = this._zoom0;
2042
+
2043
+ if ( this.camera.isPerspectiveCamera ) {
2044
+
2045
+ this.camera.fov = this._fov0;
2046
+
2047
+ }
2048
+
2049
+ this.camera.near = this._nearPos;
2050
+ this.camera.far = this._farPos;
2051
+
2052
+ this._cameraMatrixState.copy( this._cameraMatrixState0 );
2053
+
2054
+ this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
2055
+
2056
+ this.camera.up.copy( this._up0 );
2057
+ this.camera.updateMatrix();
2058
+ this.camera.updateProjectionMatrix();
2059
+
2060
+ this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
2061
+
2062
+ this._gizmoMatrixState0.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
2063
+
2064
+ this._gizmos.updateMatrix();
2065
+
2066
+ this._tbRadius = this.calculateTbRadius( this.camera );
2067
+ this.makeGizmos( this._gizmos.position, this._tbRadius );
2068
+ this.camera.lookAt( this._gizmos.position );
2069
+ this.updateTbState( STATE.IDLE, false );
2070
+ this.dispatchEvent( _changeEvent );
2071
+
2072
+ };
2073
+
2074
+ this.rotate = ( axis, angle ) => {
2075
+
2076
+ const point = this._gizmos.position; //rotation center
2077
+
2078
+ this._translationMatrix.makeTranslation( - point.x, - point.y, - point.z );
2079
+
2080
+ this._rotationMatrix.makeRotationAxis( axis, - angle ); //rotate camera
2081
+
2082
+
2083
+ this._m4_1.makeTranslation( point.x, point.y, point.z );
2084
+
2085
+ this._m4_1.multiply( this._rotationMatrix );
2086
+
2087
+ this._m4_1.multiply( this._translationMatrix );
2088
+
2089
+ this.setTransformationMatrices( this._m4_1 );
2090
+ return _transformation;
2091
+
2092
+ };
2093
+
2094
+ this.copyState = () => {
2095
+
2096
+ let state;
2097
+
2098
+ if ( this.camera.isOrthographicCamera ) {
2099
+
2100
+ state = JSON.stringify( {
2101
+ arcballState: {
2102
+ cameraFar: this.camera.far,
2103
+ cameraMatrix: this.camera.matrix,
2104
+ cameraNear: this.camera.near,
2105
+ cameraUp: this.camera.up,
2106
+ cameraZoom: this.camera.zoom,
2107
+ gizmoMatrix: this._gizmos.matrix
2108
+ }
2109
+ } );
2110
+
2111
+ } else if ( this.camera.isPerspectiveCamera ) {
2112
+
2113
+ state = JSON.stringify( {
2114
+ arcballState: {
2115
+ cameraFar: this.camera.far,
2116
+ cameraFov: this.camera.fov,
2117
+ cameraMatrix: this.camera.matrix,
2118
+ cameraNear: this.camera.near,
2119
+ cameraUp: this.camera.up,
2120
+ cameraZoom: this.camera.zoom,
2121
+ gizmoMatrix: this._gizmos.matrix
2122
+ }
2123
+ } );
2124
+
2125
+ }
2126
+
2127
+ navigator.clipboard.writeText( state );
2128
+
2129
+ };
2130
+
2131
+ this.pasteState = () => {
2132
+
2133
+ const self = this;
2134
+ navigator.clipboard.readText().then( function resolved( value ) {
2135
+
2136
+ self.setStateFromJSON( value );
2137
+
2138
+ } );
2139
+
2140
+ };
2141
+
2142
+ this.saveState = () => {
2143
+
2144
+ this._cameraMatrixState0.copy( this.camera.matrix );
2145
+
2146
+ this._gizmoMatrixState0.copy( this._gizmos.matrix );
2147
+
2148
+ this._nearPos = this.camera.near;
2149
+ this._farPos = this.camera.far;
2150
+ this._zoom0 = this.camera.zoom;
2151
+
2152
+ this._up0.copy( this.camera.up );
2153
+
2154
+ if ( this.camera.isPerspectiveCamera ) {
2155
+
2156
+ this._fov0 = this.camera.fov;
2157
+
2158
+ }
2159
+
2160
+ };
2161
+
2162
+ this.scale = ( size, point, scaleGizmos = true ) => {
2163
+
2164
+ _scalePointTemp.copy( point );
2165
+
2166
+ let sizeInverse = 1 / size;
2167
+
2168
+ if ( this.camera.isOrthographicCamera ) {
2169
+
2170
+ //camera zoom
2171
+ this.camera.zoom = this._zoomState;
2172
+ this.camera.zoom *= size; //check min and max zoom
2173
+
2174
+ if ( this.camera.zoom > this.maxZoom ) {
2175
+
2176
+ this.camera.zoom = this.maxZoom;
2177
+ sizeInverse = this._zoomState / this.maxZoom;
2178
+
2179
+ } else if ( this.camera.zoom < this.minZoom ) {
2180
+
2181
+ this.camera.zoom = this.minZoom;
2182
+ sizeInverse = this._zoomState / this.minZoom;
2183
+
2184
+ }
2185
+
2186
+ this.camera.updateProjectionMatrix();
2187
+
2188
+ this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ); //gizmos position
2189
+ //scale gizmos so they appear in the same spot having the same dimension
2190
+
2191
+
2192
+ this._scaleMatrix.makeScale( sizeInverse, sizeInverse, sizeInverse );
2193
+
2194
+ this._translationMatrix.makeTranslation( - this._v3_1.x, - this._v3_1.y, - this._v3_1.z );
2195
+
2196
+ this._m4_2.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z ).multiply( this._scaleMatrix );
2197
+
2198
+ this._m4_2.multiply( this._translationMatrix ); //move camera and gizmos to obtain pinch effect
2199
+
2200
+
2201
+ _scalePointTemp.sub( this._v3_1 );
2202
+
2203
+ const amount = _scalePointTemp.clone().multiplyScalar( sizeInverse );
2204
+
2205
+ _scalePointTemp.sub( amount );
2206
+
2207
+ this._m4_1.makeTranslation( _scalePointTemp.x, _scalePointTemp.y, _scalePointTemp.z );
2208
+
2209
+ this._m4_2.premultiply( this._m4_1 );
2210
+
2211
+ this.setTransformationMatrices( this._m4_1, this._m4_2 );
2212
+ return _transformation;
2213
+
2214
+ } else if ( this.camera.isPerspectiveCamera ) {
2215
+
2216
+ this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
2217
+
2218
+ this._v3_2.setFromMatrixPosition( this._gizmoMatrixState ); //move camera
2219
+
2220
+
2221
+ let distance = this._v3_1.distanceTo( _scalePointTemp );
2222
+
2223
+ let amount = distance - distance * sizeInverse; //check min and max distance
2224
+
2225
+ const newDistance = distance - amount;
2226
+
2227
+ if ( newDistance < this.minDistance ) {
2228
+
2229
+ sizeInverse = this.minDistance / distance;
2230
+ amount = distance - distance * sizeInverse;
2231
+
2232
+ } else if ( newDistance > this.maxDistance ) {
2233
+
2234
+ sizeInverse = this.maxDistance / distance;
2235
+ amount = distance - distance * sizeInverse;
2236
+
2237
+ }
2238
+
2239
+ _offset.copy( _scalePointTemp ).sub( this._v3_1 ).normalize().multiplyScalar( amount );
2240
+
2241
+ this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
2242
+
2243
+ if ( scaleGizmos ) {
2244
+
2245
+ //scale gizmos so they appear in the same spot having the same dimension
2246
+ const pos = this._v3_2;
2247
+ distance = pos.distanceTo( _scalePointTemp );
2248
+ amount = distance - distance * sizeInverse;
2249
+
2250
+ _offset.copy( _scalePointTemp ).sub( this._v3_2 ).normalize().multiplyScalar( amount );
2251
+
2252
+ this._translationMatrix.makeTranslation( pos.x, pos.y, pos.z );
2253
+
2254
+ this._scaleMatrix.makeScale( sizeInverse, sizeInverse, sizeInverse );
2255
+
2256
+ this._m4_2.makeTranslation( _offset.x, _offset.y, _offset.z ).multiply( this._translationMatrix );
2257
+
2258
+ this._m4_2.multiply( this._scaleMatrix );
2259
+
2260
+ this._translationMatrix.makeTranslation( - pos.x, - pos.y, - pos.z );
2261
+
2262
+ this._m4_2.multiply( this._translationMatrix );
2263
+
2264
+ this.setTransformationMatrices( this._m4_1, this._m4_2 );
2265
+
2266
+ } else {
2267
+
2268
+ this.setTransformationMatrices( this._m4_1 );
2269
+
2270
+ }
2271
+
2272
+ return _transformation;
2273
+
2274
+ }
2275
+
2276
+ };
2277
+
2278
+ this.setFov = value => {
2279
+
2280
+ if ( this.camera.isPerspectiveCamera ) {
2281
+
2282
+ this.camera.fov = THREE.MathUtils.clamp( value, this.minFov, this.maxFov );
2283
+ this.camera.updateProjectionMatrix();
2284
+
2285
+ }
2286
+
2287
+ };
2288
+
2289
+ this.zRotate = ( point, angle ) => {
2290
+
2291
+ this._rotationMatrix.makeRotationAxis( this._rotationAxis, angle );
2292
+
2293
+ this._translationMatrix.makeTranslation( - point.x, - point.y, - point.z );
2294
+
2295
+ this._m4_1.makeTranslation( point.x, point.y, point.z );
2296
+
2297
+ this._m4_1.multiply( this._rotationMatrix );
2298
+
2299
+ this._m4_1.multiply( this._translationMatrix );
2300
+
2301
+ this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ).sub( point ); //vector from rotation center to gizmos position
2302
+
2303
+
2304
+ this._v3_2.copy( this._v3_1 ).applyAxisAngle( this._rotationAxis, angle ); //apply rotation
2305
+
2306
+
2307
+ this._v3_2.sub( this._v3_1 );
2308
+
2309
+ this._m4_2.makeTranslation( this._v3_2.x, this._v3_2.y, this._v3_2.z );
2310
+
2311
+ this.setTransformationMatrices( this._m4_1, this._m4_2 );
2312
+ return _transformation;
2313
+
2314
+ };
2315
+
2316
+ this.unprojectOnObj = ( cursor, camera ) => {
2317
+
2318
+ const raycaster = this.getRaycaster();
2319
+ raycaster.near = camera.near;
2320
+ raycaster.far = camera.far;
2321
+ raycaster.setFromCamera( cursor, camera );
2322
+ const intersect = raycaster.intersectObjects( this.scene.children, true );
2323
+
2324
+ for ( let i = 0; i < intersect.length; i ++ ) {
2325
+
2326
+ if ( intersect[ i ].object.uuid != this._gizmos.uuid && intersect[ i ].face != null ) {
2327
+
2328
+ return intersect[ i ].point.clone();
2329
+
2330
+ }
2331
+
2332
+ }
2333
+
2334
+ return null;
2335
+
2336
+ };
2337
+
2338
+ this.unprojectOnTbSurface = ( camera, cursorX, cursorY, canvas, tbRadius ) => {
2339
+
2340
+ if ( camera.type == 'OrthographicCamera' ) {
2341
+
2342
+ this._v2_1.copy( this.getCursorPosition( cursorX, cursorY, canvas ) );
2343
+
2344
+ this._v3_1.set( this._v2_1.x, this._v2_1.y, 0 );
2345
+
2346
+ const x2 = Math.pow( this._v2_1.x, 2 );
2347
+ const y2 = Math.pow( this._v2_1.y, 2 );
2348
+ const r2 = Math.pow( this._tbRadius, 2 );
2349
+
2350
+ if ( x2 + y2 <= r2 * 0.5 ) {
2351
+
2352
+ //intersection with sphere
2353
+ this._v3_1.setZ( Math.sqrt( r2 - ( x2 + y2 ) ) );
2354
+
2355
+ } else {
2356
+
2357
+ //intersection with hyperboloid
2358
+ this._v3_1.setZ( r2 * 0.5 / Math.sqrt( x2 + y2 ) );
2359
+
2360
+ }
2361
+
2362
+ return this._v3_1;
2363
+
2364
+ } else if ( camera.type == 'PerspectiveCamera' ) {
2365
+
2366
+ //unproject cursor on the near plane
2367
+ this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
2368
+
2369
+ this._v3_1.set( this._v2_1.x, this._v2_1.y, - 1 );
2370
+
2371
+ this._v3_1.applyMatrix4( camera.projectionMatrixInverse );
2372
+
2373
+ const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
2374
+
2375
+
2376
+ const cameraGizmoDistance = camera.position.distanceTo( this._gizmos.position );
2377
+ const radius2 = Math.pow( tbRadius, 2 ); // camera
2378
+ // |\
2379
+ // | \
2380
+ // | \
2381
+ // h | \
2382
+ // | \
2383
+ // | \
2384
+ // _ _ | _ _ _\ _ _ near plane
2385
+ // l
2386
+
2387
+ const h = this._v3_1.z;
2388
+ const l = Math.sqrt( Math.pow( this._v3_1.x, 2 ) + Math.pow( this._v3_1.y, 2 ) );
2389
+
2390
+ if ( l == 0 ) {
2391
+
2392
+ //ray aligned with camera
2393
+ rayDir.set( this._v3_1.x, this._v3_1.y, tbRadius );
2394
+ return rayDir;
2395
+
2396
+ }
2397
+
2398
+ const m = h / l;
2399
+ const q = cameraGizmoDistance;
2400
+ /*
2401
+ * calculate intersection point between unprojected ray and trackball surface
2402
+ *|y = m * x + q
2403
+ *|x^2 + y^2 = r^2
2404
+ *
2405
+ * (m^2 + 1) * x^2 + (2 * m * q) * x + q^2 - r^2 = 0
2406
+ */
2407
+
2408
+ let a = Math.pow( m, 2 ) + 1;
2409
+ let b = 2 * m * q;
2410
+ let c = Math.pow( q, 2 ) - radius2;
2411
+ let delta = Math.pow( b, 2 ) - 4 * a * c;
2412
+
2413
+ if ( delta >= 0 ) {
2414
+
2415
+ //intersection with sphere
2416
+ this._v2_1.setX( ( - b - Math.sqrt( delta ) ) / ( 2 * a ) );
2417
+
2418
+ this._v2_1.setY( m * this._v2_1.x + q );
2419
+
2420
+ const angle = THREE.MathUtils.RAD2DEG * this._v2_1.angle();
2421
+
2422
+ if ( angle >= 45 ) {
2423
+
2424
+ //if angle between intersection point and X' axis is >= 45°, return that point
2425
+ //otherwise, calculate intersection point with hyperboloid
2426
+ const rayLength = Math.sqrt( Math.pow( this._v2_1.x, 2 ) + Math.pow( cameraGizmoDistance - this._v2_1.y, 2 ) );
2427
+ rayDir.multiplyScalar( rayLength );
2428
+ rayDir.z += cameraGizmoDistance;
2429
+ return rayDir;
2430
+
2431
+ }
2432
+
2433
+ } //intersection with hyperboloid
2434
+
2435
+ /*
2436
+ *|y = m * x + q
2437
+ *|y = (1 / x) * (r^2 / 2)
2438
+ *
2439
+ * m * x^2 + q * x - r^2 / 2 = 0
2440
+ */
2441
+
2442
+
2443
+ a = m;
2444
+ b = q;
2445
+ c = - radius2 * 0.5;
2446
+ delta = Math.pow( b, 2 ) - 4 * a * c;
2447
+
2448
+ this._v2_1.setX( ( - b - Math.sqrt( delta ) ) / ( 2 * a ) );
2449
+
2450
+ this._v2_1.setY( m * this._v2_1.x + q );
2451
+
2452
+ const rayLength = Math.sqrt( Math.pow( this._v2_1.x, 2 ) + Math.pow( cameraGizmoDistance - this._v2_1.y, 2 ) );
2453
+ rayDir.multiplyScalar( rayLength );
2454
+ rayDir.z += cameraGizmoDistance;
2455
+ return rayDir;
2456
+
2457
+ }
2458
+
2459
+ };
2460
+
2461
+ this.unprojectOnTbPlane = ( camera, cursorX, cursorY, canvas, initialDistance = false ) => {
2462
+
2463
+ if ( camera.type == 'OrthographicCamera' ) {
2464
+
2465
+ this._v2_1.copy( this.getCursorPosition( cursorX, cursorY, canvas ) );
2466
+
2467
+ this._v3_1.set( this._v2_1.x, this._v2_1.y, 0 );
2468
+
2469
+ return this._v3_1.clone();
2470
+
2471
+ } else if ( camera.type == 'PerspectiveCamera' ) {
2472
+
2473
+ this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) ); //unproject cursor on the near plane
2474
+
2475
+
2476
+ this._v3_1.set( this._v2_1.x, this._v2_1.y, - 1 );
2477
+
2478
+ this._v3_1.applyMatrix4( camera.projectionMatrixInverse );
2479
+
2480
+ const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
2481
+ // camera
2482
+ // |\
2483
+ // | \
2484
+ // | \
2485
+ // h | \
2486
+ // | \
2487
+ // | \
2488
+ // _ _ | _ _ _\ _ _ near plane
2489
+ // l
2490
+
2491
+
2492
+ const h = this._v3_1.z;
2493
+ const l = Math.sqrt( Math.pow( this._v3_1.x, 2 ) + Math.pow( this._v3_1.y, 2 ) );
2494
+ let cameraGizmoDistance;
2495
+
2496
+ if ( initialDistance ) {
2497
+
2498
+ cameraGizmoDistance = this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ).distanceTo( this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ) );
2499
+
2500
+ } else {
2501
+
2502
+ cameraGizmoDistance = camera.position.distanceTo( this._gizmos.position );
2503
+
2504
+ }
2505
+ /*
2506
+ * calculate intersection point between unprojected ray and the plane
2507
+ *|y = mx + q
2508
+ *|y = 0
2509
+ *
2510
+ * x = -q/m
2511
+ */
2512
+
2513
+
2514
+ if ( l == 0 ) {
2515
+
2516
+ //ray aligned with camera
2517
+ rayDir.set( 0, 0, 0 );
2518
+ return rayDir;
2519
+
2520
+ }
2521
+
2522
+ const m = h / l;
2523
+ const q = cameraGizmoDistance;
2524
+ const x = - q / m;
2525
+ const rayLength = Math.sqrt( Math.pow( q, 2 ) + Math.pow( x, 2 ) );
2526
+ rayDir.multiplyScalar( rayLength );
2527
+ rayDir.z = 0;
2528
+ return rayDir;
2529
+
2530
+ }
2531
+
2532
+ };
2533
+
2534
+ this.updateMatrixState = () => {
2535
+
2536
+ //update camera and gizmos state
2537
+ this._cameraMatrixState.copy( this.camera.matrix );
2538
+
2539
+ this._gizmoMatrixState.copy( this._gizmos.matrix );
2540
+
2541
+ if ( this.camera.isOrthographicCamera ) {
2542
+
2543
+ this._cameraProjectionState.copy( this.camera.projectionMatrix );
2544
+
2545
+ this.camera.updateProjectionMatrix();
2546
+ this._zoomState = this.camera.zoom;
2547
+
2548
+ } else if ( this.camera.isPerspectiveCamera ) {
2549
+
2550
+ this._fovState = this.camera.fov;
2551
+
2552
+ }
2553
+
2554
+ };
2555
+
2556
+ this.updateTbState = ( newState, updateMatrices ) => {
2557
+
2558
+ this._state = newState;
2559
+
2560
+ if ( updateMatrices ) {
2561
+
2562
+ this.updateMatrixState();
2563
+
2564
+ }
2565
+
2566
+ };
2567
+
2568
+ this.update = () => {
2569
+
2570
+ const EPS = 0.000001;
2571
+
2572
+ if ( this.target.equals( this._currentTarget ) === false ) {
2573
+
2574
+ this._gizmos.position.copy( this.target ); //for correct radius calculation
2575
+
2576
+
2577
+ this._tbRadius = this.calculateTbRadius( this.camera );
2578
+ this.makeGizmos( this.target, this._tbRadius );
2579
+
2580
+ this._currentTarget.copy( this.target );
2581
+
2582
+ } //check min/max parameters
2583
+
2584
+
2585
+ if ( this.camera.isOrthographicCamera ) {
2586
+
2587
+ //check zoom
2588
+ if ( this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom ) {
2589
+
2590
+ const newZoom = THREE.MathUtils.clamp( this.camera.zoom, this.minZoom, this.maxZoom );
2591
+ this.applyTransformMatrix( this.scale( newZoom / this.camera.zoom, this._gizmos.position, true ) );
2592
+
2593
+ }
2594
+
2595
+ } else if ( this.camera.isPerspectiveCamera ) {
2596
+
2597
+ //check distance
2598
+ const distance = this.camera.position.distanceTo( this._gizmos.position );
2599
+
2600
+ if ( distance > this.maxDistance + EPS || distance < this.minDistance - EPS ) {
2601
+
2602
+ const newDistance = THREE.MathUtils.clamp( distance, this.minDistance, this.maxDistance );
2603
+ this.applyTransformMatrix( this.scale( newDistance / distance, this._gizmos.position ) );
2604
+ this.updateMatrixState();
2605
+
2606
+ } //check fov
2607
+
2608
+
2609
+ if ( this.camera.fov < this.minFov || this.camera.fov > this.maxFov ) {
2610
+
2611
+ this.camera.fov = THREE.MathUtils.clamp( this.camera.fov, this.minFov, this.maxFov );
2612
+ this.camera.updateProjectionMatrix();
2613
+
2614
+ }
2615
+
2616
+ const oldRadius = this._tbRadius;
2617
+ this._tbRadius = this.calculateTbRadius( this.camera );
2618
+
2619
+ if ( oldRadius < this._tbRadius - EPS || oldRadius > this._tbRadius + EPS ) {
2620
+
2621
+ const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
2622
+ const newRadius = this._tbRadius / scale;
2623
+ const curve = new THREE.EllipseCurve( 0, 0, newRadius, newRadius );
2624
+ const points = curve.getPoints( this._curvePts );
2625
+ const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
2626
+
2627
+ for ( const gizmo in this._gizmos.children ) {
2628
+
2629
+ this._gizmos.children[ gizmo ].geometry = curveGeometry;
2630
+
2631
+ }
2632
+
2633
+ }
2634
+
2635
+ }
2636
+
2637
+ this.camera.lookAt( this._gizmos.position );
2638
+
2639
+ };
2640
+
2641
+ this.setStateFromJSON = json => {
2642
+
2643
+ const state = JSON.parse( json );
2644
+
2645
+ if ( state.arcballState != undefined ) {
2646
+
2647
+ this._cameraMatrixState.fromArray( state.arcballState.cameraMatrix.elements );
2648
+
2649
+ this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
2650
+
2651
+ this.camera.up.copy( state.arcballState.cameraUp );
2652
+ this.camera.near = state.arcballState.cameraNear;
2653
+ this.camera.far = state.arcballState.cameraFar;
2654
+ this.camera.zoom = state.arcballState.cameraZoom;
2655
+
2656
+ if ( this.camera.isPerspectiveCamera ) {
2657
+
2658
+ this.camera.fov = state.arcballState.cameraFov;
2659
+
2660
+ }
2661
+
2662
+ this._gizmoMatrixState.fromArray( state.arcballState.gizmoMatrix.elements );
2663
+
2664
+ this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
2665
+
2666
+ this.camera.updateMatrix();
2667
+ this.camera.updateProjectionMatrix();
2668
+
2669
+ this._gizmos.updateMatrix();
2670
+
2671
+ this._tbRadius = this.calculateTbRadius( this.camera );
2672
+ const gizmoTmp = new THREE.Matrix4().copy( this._gizmoMatrixState0 );
2673
+ this.makeGizmos( this._gizmos.position, this._tbRadius );
2674
+
2675
+ this._gizmoMatrixState0.copy( gizmoTmp );
2676
+
2677
+ this.camera.lookAt( this._gizmos.position );
2678
+ this.updateTbState( STATE.IDLE, false );
2679
+ this.dispatchEvent( _changeEvent );
2680
+
2681
+ }
2682
+
2683
+ };
2684
+
2685
+ this.camera = null;
2686
+ this.domElement = domElement;
2687
+ this.scene = scene;
2688
+ this.target = new THREE.Vector3();
2689
+ this._currentTarget = new THREE.Vector3();
2690
+ this.radiusFactor = 0.67;
2691
+ this.mouseActions = [];
2692
+ this._mouseOp = null; //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
2693
+
2694
+ this._v2_1 = new THREE.Vector2();
2695
+ this._v3_1 = new THREE.Vector3();
2696
+ this._v3_2 = new THREE.Vector3();
2697
+ this._m4_1 = new THREE.Matrix4();
2698
+ this._m4_2 = new THREE.Matrix4();
2699
+ this._quat = new THREE.Quaternion(); //transformation matrices
2700
+
2701
+ this._translationMatrix = new THREE.Matrix4(); //matrix for translation operation
2702
+
2703
+ this._rotationMatrix = new THREE.Matrix4(); //matrix for rotation operation
2704
+
2705
+ this._scaleMatrix = new THREE.Matrix4(); //matrix for scaling operation
2706
+
2707
+ this._rotationAxis = new THREE.Vector3(); //axis for rotate operation
2708
+ //camera state
2709
+
2710
+ this._cameraMatrixState = new THREE.Matrix4();
2711
+ this._cameraProjectionState = new THREE.Matrix4();
2712
+ this._fovState = 1;
2713
+ this._upState = new THREE.Vector3();
2714
+ this._zoomState = 1;
2715
+ this._nearPos = 0;
2716
+ this._farPos = 0;
2717
+ this._gizmoMatrixState = new THREE.Matrix4(); //initial values
2718
+
2719
+ this._up0 = new THREE.Vector3();
2720
+ this._zoom0 = 1;
2721
+ this._fov0 = 0;
2722
+ this._initialNear = 0;
2723
+ this._nearPos0 = 0;
2724
+ this._initialFar = 0;
2725
+ this._farPos0 = 0;
2726
+ this._cameraMatrixState0 = new THREE.Matrix4();
2727
+ this._gizmoMatrixState0 = new THREE.Matrix4(); //pointers array
2728
+
2729
+ this._button = - 1;
2730
+ this._touchStart = [];
2731
+ this._touchCurrent = [];
2732
+ this._input = INPUT.NONE; //two fingers touch interaction
2733
+
2734
+ this._switchSensibility = 32; //minimum movement to be performed to fire single pan start after the second finger has been released
2735
+
2736
+ this._startFingerDistance = 0; //distance between two fingers
2737
+
2738
+ this._currentFingerDistance = 0;
2739
+ this._startFingerRotation = 0; //amount of rotation performed with two fingers
2740
+
2741
+ this._currentFingerRotation = 0; //double tap
2742
+
2743
+ this._devPxRatio = 0;
2744
+ this._downValid = true;
2745
+ this._nclicks = 0;
2746
+ this._downEvents = [];
2747
+ this._downStart = 0; //pointerDown time
2748
+
2749
+ this._clickStart = 0; //first click time
2750
+
2751
+ this._maxDownTime = 250;
2752
+ this._maxInterval = 300;
2753
+ this._posThreshold = 24;
2754
+ this._movementThreshold = 24; //cursor positions
2755
+
2756
+ this._currentCursorPosition = new THREE.Vector3();
2757
+ this._startCursorPosition = new THREE.Vector3(); //grid
2758
+
2759
+ this._grid = null; //grid to be visualized during pan operation
2760
+
2761
+ this._gridPosition = new THREE.Vector3(); //gizmos
2762
+
2763
+ this._gizmos = new THREE.Group();
2764
+ this._curvePts = 128; //animations
2765
+
2766
+ this._timeStart = - 1; //initial time
2767
+
2768
+ this._animationId = - 1; //focus animation
2769
+
2770
+ this.focusAnimationTime = 500; //duration of focus animation in ms
2771
+ //rotate animation
2772
+
2773
+ this._timePrev = 0; //time at which previous rotate operation has been detected
2774
+
2775
+ this._timeCurrent = 0; //time at which current rotate operation has been detected
2776
+
2777
+ this._anglePrev = 0; //angle of previous rotation
2778
+
2779
+ this._angleCurrent = 0; //angle of current rotation
2780
+
2781
+ this._cursorPosPrev = new THREE.Vector3(); //cursor position when previous rotate operation has been detected
2782
+
2783
+ this._cursorPosCurr = new THREE.Vector3(); //cursor position when current rotate operation has been detected
2784
+
2785
+ this._wPrev = 0; //angular velocity of the previous rotate operation
2786
+
2787
+ this._wCurr = 0; //angular velocity of the current rotate operation
2788
+ //parameters
2789
+
2790
+ this.adjustNearFar = false;
2791
+ this.scaleFactor = 1.1; //zoom/distance multiplier
2792
+
2793
+ this.dampingFactor = 25;
2794
+ this.wMax = 20; //maximum angular velocity allowed
2795
+
2796
+ this.enableAnimations = true; //if animations should be performed
2797
+
2798
+ this.enableGrid = false; //if grid should be showed during pan operation
2799
+
2800
+ this.cursorZoom = false; //if wheel zoom should be cursor centered
2801
+
2802
+ this.minFov = 5;
2803
+ this.maxFov = 90;
2804
+ this.enabled = true;
2805
+ this.enablePan = true;
2806
+ this.enableRotate = true;
2807
+ this.enableZoom = true;
2808
+ this.enableGizmos = true;
2809
+ this.minDistance = 0;
2810
+ this.maxDistance = Infinity;
2811
+ this.minZoom = 0;
2812
+ this.maxZoom = Infinity; //trackball parameters
2813
+
2814
+ this._tbRadius = 1; //FSA
2815
+
2816
+ this._state = STATE.IDLE;
2817
+ this.setCamera( _camera );
2818
+
2819
+ if ( this.scene != null ) {
2820
+
2821
+ this.scene.add( this._gizmos );
2822
+
2823
+ }
2824
+
2825
+ this.domElement.style.touchAction = 'none';
2826
+ this._devPxRatio = window.devicePixelRatio;
2827
+ this.initializeMouseActions();
2828
+ this.domElement.addEventListener( 'contextmenu', this.onContextMenu );
2829
+ this.domElement.addEventListener( 'wheel', this.onWheel );
2830
+ this.domElement.addEventListener( 'pointerdown', this.onPointerDown );
2831
+ this.domElement.addEventListener( 'pointercancel', this.onPointerCancel );
2832
+ window.addEventListener( 'resize', this.onWindowResize );
2833
+
2834
+ } //listeners
2835
+
2836
+
2837
+ /**
2838
+ * Apply a transformation matrix, to the camera and gizmos
2839
+ * @param {Object} transformation Object containing matrices to apply to camera and gizmos
2840
+ */
2841
+ applyTransformMatrix( transformation ) {
2842
+
2843
+ if ( transformation.camera != null ) {
2844
+
2845
+ this._m4_1.copy( this._cameraMatrixState ).premultiply( transformation.camera );
2846
+
2847
+ this._m4_1.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
2848
+
2849
+ this.camera.updateMatrix(); //update camera up vector
2850
+
2851
+ if ( this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE ) {
2852
+
2853
+ this.camera.up.copy( this._upState ).applyQuaternion( this.camera.quaternion );
2854
+
2855
+ }
2856
+
2857
+ }
2858
+
2859
+ if ( transformation.gizmos != null ) {
2860
+
2861
+ this._m4_1.copy( this._gizmoMatrixState ).premultiply( transformation.gizmos );
2862
+
2863
+ this._m4_1.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
2864
+
2865
+ this._gizmos.updateMatrix();
2866
+
2867
+ }
2868
+
2869
+ if ( this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS ) {
2870
+
2871
+ this._tbRadius = this.calculateTbRadius( this.camera );
2872
+
2873
+ if ( this.adjustNearFar ) {
2874
+
2875
+ const cameraDistance = this.camera.position.distanceTo( this._gizmos.position );
2876
+ const bb = new THREE.Box3();
2877
+ bb.setFromObject( this._gizmos );
2878
+ const sphere = new THREE.Sphere();
2879
+ bb.getBoundingSphere( sphere );
2880
+ const adjustedNearPosition = Math.max( this._nearPos0, sphere.radius + sphere.center.length() );
2881
+ const regularNearPosition = cameraDistance - this._initialNear;
2882
+ const minNearPos = Math.min( adjustedNearPosition, regularNearPosition );
2883
+ this.camera.near = cameraDistance - minNearPos;
2884
+ const adjustedFarPosition = Math.min( this._farPos0, - sphere.radius + sphere.center.length() );
2885
+ const regularFarPosition = cameraDistance - this._initialFar;
2886
+ const minFarPos = Math.min( adjustedFarPosition, regularFarPosition );
2887
+ this.camera.far = cameraDistance - minFarPos;
2888
+ this.camera.updateProjectionMatrix();
2889
+
2890
+ } else {
2891
+
2892
+ let update = false;
2893
+
2894
+ if ( this.camera.near != this._initialNear ) {
2895
+
2896
+ this.camera.near = this._initialNear;
2897
+ update = true;
2898
+
2899
+ }
2900
+
2901
+ if ( this.camera.far != this._initialFar ) {
2902
+
2903
+ this.camera.far = this._initialFar;
2904
+ update = true;
2905
+
2906
+ }
2907
+
2908
+ if ( update ) {
2909
+
2910
+ this.camera.updateProjectionMatrix();
2911
+
2912
+ }
2913
+
2914
+ }
2915
+
2916
+ }
2917
+
2918
+ }
2919
+ /**
2920
+ * Calculate the angular speed
2921
+ * @param {Number} p0 Position at t0
2922
+ * @param {Number} p1 Position at t1
2923
+ * @param {Number} t0 Initial time in milliseconds
2924
+ * @param {Number} t1 Ending time in milliseconds
2925
+ */
2926
+
2927
+
2928
+ /**
2929
+ * Set gizmos visibility
2930
+ * @param {Boolean} value Value of gizmos visibility
2931
+ */
2932
+ setGizmosVisible( value ) {
2933
+
2934
+ this._gizmos.visible = value;
2935
+ this.dispatchEvent( _changeEvent );
2936
+
2937
+ }
2938
+ /**
2939
+ * Set gizmos radius factor and redraws gizmos
2940
+ * @param {Float} value Value of radius factor
2941
+ */
2942
+
2943
+
2944
+ setTbRadius( value ) {
2945
+
2946
+ this.radiusFactor = value;
2947
+ this._tbRadius = this.calculateTbRadius( this.camera );
2948
+ const curve = new THREE.EllipseCurve( 0, 0, this._tbRadius, this._tbRadius );
2949
+ const points = curve.getPoints( this._curvePts );
2950
+ const curveGeometry = new THREE.BufferGeometry().setFromPoints( points );
2951
+
2952
+ for ( const gizmo in this._gizmos.children ) {
2953
+
2954
+ this._gizmos.children[ gizmo ].geometry = curveGeometry;
2955
+
2956
+ }
2957
+
2958
+ this.dispatchEvent( _changeEvent );
2959
+
2960
+ }
2961
+ /**
2962
+ * Creates the rotation gizmos matching trackball center and radius
2963
+ * @param {Vector3} tbCenter The trackball center
2964
+ * @param {number} tbRadius The trackball radius
2965
+ */
2966
+
2967
+
2968
+ /**
2969
+ * Set values in transformation object
2970
+ * @param {Matrix4} camera Transformation to be applied to the camera
2971
+ * @param {Matrix4} gizmos Transformation to be applied to gizmos
2972
+ */
2973
+ setTransformationMatrices( camera = null, gizmos = null ) {
2974
+
2975
+ if ( camera != null ) {
2976
+
2977
+ if ( _transformation.camera != null ) {
2978
+
2979
+ _transformation.camera.copy( camera );
2980
+
2981
+ } else {
2982
+
2983
+ _transformation.camera = camera.clone();
2984
+
2985
+ }
2986
+
2987
+ } else {
2988
+
2989
+ _transformation.camera = null;
2990
+
2991
+ }
2992
+
2993
+ if ( gizmos != null ) {
2994
+
2995
+ if ( _transformation.gizmos != null ) {
2996
+
2997
+ _transformation.gizmos.copy( gizmos );
2998
+
2999
+ } else {
3000
+
3001
+ _transformation.gizmos = gizmos.clone();
3002
+
3003
+ }
3004
+
3005
+ } else {
3006
+
3007
+ _transformation.gizmos = null;
3008
+
3009
+ }
3010
+
3011
+ }
3012
+ /**
3013
+ * Rotate camera around its direction axis passing by a given point by a given angle
3014
+ * @param {Vector3} point The point where the rotation axis is passing trough
3015
+ * @param {Number} angle Angle in radians
3016
+ * @returns The computed transormation matix
3017
+ */
3018
+
3019
+
3020
+ getRaycaster() {
3021
+
3022
+ return _raycaster;
3023
+
3024
+ }
3025
+ /**
3026
+ * Unproject the cursor on the 3D object surface
3027
+ * @param {Vector2} cursor Cursor coordinates in NDC
3028
+ * @param {Camera} camera Virtual camera
3029
+ * @returns {Vector3} The point of intersection with the model, if exist, null otherwise
3030
+ */
3031
+
3032
+
3033
+ }
3034
+
3035
+ THREE.ArcballControls = ArcballControls;
3036
+
3037
+ } )();