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