three-stdlib 2.16.0 → 2.16.2
Sign up to get free protection for your applications and to get access to all the features.
- package/BufferGeometryUtils-1a7a235c.js +655 -0
- package/BufferGeometryUtils-971dfde3.js +1 -0
- package/Nodes-4f766d71.js +471 -0
- package/Nodes-9aa16d74.js +1 -0
- package/animation/AnimationClipCreator.cjs.js +1 -0
- package/animation/AnimationClipCreator.js +52 -32
- package/animation/CCDIKSolver.cjs.js +1 -0
- package/animation/CCDIKSolver.js +143 -64
- package/animation/MMDAnimationHelper.cjs.js +1 -0
- package/animation/MMDAnimationHelper.js +341 -150
- package/animation/MMDPhysics.cjs.js +1 -0
- package/animation/MMDPhysics.js +361 -154
- package/cameras/CinematicCamera.cjs.js +1 -0
- package/cameras/CinematicCamera.js +77 -67
- package/controls/ArcballControls.cjs.js +1 -0
- package/controls/ArcballControls.js +1449 -544
- package/controls/DeviceOrientationControls.cjs.js +1 -0
- package/controls/DeviceOrientationControls.js +97 -52
- package/controls/DragControls.cjs.js +1 -0
- package/controls/DragControls.js +187 -85
- package/controls/FirstPersonControls.cjs.js +1 -0
- package/controls/FirstPersonControls.js +193 -123
- package/controls/FlyControls.cjs.js +1 -0
- package/controls/FlyControls.d.ts +5 -4
- package/controls/FlyControls.js +160 -90
- package/controls/OrbitControls.cjs.js +1 -0
- package/controls/OrbitControls.js +481 -232
- package/controls/PointerLockControls.cjs.js +1 -0
- package/controls/PointerLockControls.js +99 -63
- package/controls/TrackballControls.cjs.js +1 -0
- package/controls/TrackballControls.js +383 -211
- package/controls/TransformControls.cjs.js +1 -0
- package/controls/TransformControls.js +782 -575
- package/controls/experimental/CameraControls.cjs.js +1 -0
- package/controls/experimental/CameraControls.js +609 -329
- package/csm/CSM.cjs.js +1 -0
- package/csm/CSM.js +108 -47
- package/csm/CSMFrustum.cjs.js +1 -0
- package/csm/CSMFrustum.js +29 -14
- package/csm/CSMHelper.cjs.js +1 -0
- package/csm/CSMHelper.js +34 -20
- package/csm/CSMShader.cjs.js +1 -0
- package/csm/CSMShader.js +11 -7
- package/curves/CurveExtras.cjs.js +1 -0
- package/curves/CurveExtras.js +115 -73
- package/curves/NURBSCurve.cjs.js +1 -0
- package/curves/NURBSCurve.js +43 -15
- package/curves/NURBSSurface.cjs.js +1 -0
- package/curves/NURBSSurface.js +27 -11
- package/curves/NURBSUtils.cjs.js +1 -0
- package/curves/NURBSUtils.js +203 -54
- package/custom.d.cjs.js +1 -0
- package/{shaders/types.mjs → custom.d.js} +0 -0
- package/deprecated/Geometry.cjs.js +1 -0
- package/deprecated/Geometry.js +486 -191
- package/effects/AnaglyphEffect.cjs.js +1 -0
- package/effects/AnaglyphEffect.js +60 -95
- package/effects/AsciiEffect.cjs.js +1 -0
- package/effects/AsciiEffect.js +110 -80
- package/effects/OutlineEffect.cjs.js +1 -0
- package/effects/OutlineEffect.js +204 -121
- package/effects/ParallaxBarrierEffect.cjs.js +1 -0
- package/effects/ParallaxBarrierEffect.js +38 -39
- package/effects/PeppersGhostEffect.cjs.js +1 -0
- package/effects/PeppersGhostEffect.js +68 -19
- package/effects/StereoEffect.cjs.js +1 -0
- package/effects/StereoEffect.js +16 -12
- package/environments/RoomEnvironment.cjs.js +1 -0
- package/environments/RoomEnvironment.js +47 -52
- package/exporters/ColladaExporter.cjs.js +1 -0
- package/exporters/ColladaExporter.js +241 -115
- package/exporters/DRACOExporter.cjs.js +1 -0
- package/exporters/DRACOExporter.js +121 -67
- package/exporters/GLTFExporter.cjs.js +1 -0
- package/exporters/GLTFExporter.js +1014 -463
- package/exporters/MMDExporter.cjs.js +1 -0
- package/exporters/MMDExporter.js +102 -44
- package/exporters/OBJExporter.cjs.js +1 -0
- package/exporters/OBJExporter.js +140 -78
- package/exporters/PLYExporter.cjs.js +1 -0
- package/exporters/PLYExporter.js +154 -93
- package/exporters/STLExporter.cjs.js +1 -0
- package/exporters/STLExporter.js +81 -30
- package/exporters/USDZExporter.cjs.js +1 -0
- package/exporters/USDZExporter.js +144 -84
- package/geometries/BoxLineGeometry.cjs.js +1 -0
- package/geometries/BoxLineGeometry.js +14 -7
- package/geometries/ConvexGeometry.cjs.js +1 -0
- package/geometries/ConvexGeometry.js +23 -14
- package/geometries/DecalGeometry.cjs.js +1 -0
- package/geometries/DecalGeometry.js +162 -108
- package/geometries/LightningStrike.cjs.js +1 -0
- package/geometries/LightningStrike.js +294 -101
- package/geometries/ParametricGeometries.cjs.js +1 -0
- package/geometries/ParametricGeometries.js +76 -26
- package/geometries/ParametricGeometry.cjs.js +1 -0
- package/geometries/ParametricGeometry.js +48 -24
- package/geometries/RoundedBoxGeometry.cjs.js +1 -0
- package/geometries/RoundedBoxGeometry.js +64 -33
- package/geometries/TeapotGeometry.cjs.js +1 -0
- package/geometries/TeapotGeometry.js +174 -1434
- package/geometries/TextGeometry.cjs.js +1 -0
- package/geometries/TextGeometry.js +17 -9
- package/helpers/LightProbeHelper.cjs.js +1 -0
- package/helpers/LightProbeHelper.js +21 -53
- package/helpers/PositionalAudioHelper.cjs.js +1 -0
- package/helpers/PositionalAudioHelper.js +30 -23
- package/helpers/RectAreaLightHelper.cjs.js +1 -0
- package/helpers/RectAreaLightHelper.js +33 -17
- package/helpers/VertexNormalsHelper.cjs.js +1 -0
- package/helpers/VertexNormalsHelper.js +41 -20
- package/helpers/VertexTangentsHelper.cjs.js +1 -0
- package/helpers/VertexTangentsHelper.js +36 -18
- package/index.cjs.js +1 -0
- package/index.js +333 -969
- package/interactive/InteractiveGroup.cjs.js +1 -0
- package/interactive/InteractiveGroup.d.ts +5 -0
- package/interactive/InteractiveGroup.js +87 -0
- package/interactive/SelectionBox.cjs.js +1 -0
- package/interactive/SelectionBox.js +46 -31
- package/interactive/SelectionHelper.cjs.js +1 -0
- package/interactive/SelectionHelper.js +21 -16
- package/libs/MeshoptDecoder.cjs.js +1 -0
- package/libs/MeshoptDecoder.js +58 -147
- package/libs/MotionControllers.cjs.js +1 -0
- package/libs/MotionControllers.js +208 -66
- package/lights/LightProbeGenerator.cjs.js +1 -0
- package/lights/LightProbeGenerator.js +96 -40
- package/lights/RectAreaLightUniformsLib.cjs.js +1 -0
- package/lights/RectAreaLightUniformsLib.js +9 -32842
- package/lines/Line2.cjs.js +1 -0
- package/lines/Line2.js +12 -9
- package/lines/LineGeometry.cjs.js +1 -0
- package/lines/LineGeometry.js +19 -7
- package/lines/LineMaterial.cjs.js +1 -0
- package/lines/LineMaterial.js +89 -51
- package/lines/LineSegments2.cjs.js +1 -0
- package/lines/LineSegments2.js +165 -56
- package/lines/LineSegmentsGeometry.cjs.js +1 -0
- package/lines/LineSegmentsGeometry.js +71 -29
- package/lines/Wireframe.cjs.js +1 -0
- package/lines/Wireframe.js +29 -15
- package/lines/WireframeGeometry2.cjs.js +1 -0
- package/lines/WireframeGeometry2.js +9 -8
- package/loaders/3DMLoader.cjs.js +1 -0
- package/loaders/3DMLoader.js +469 -234
- package/loaders/3MFLoader.cjs.js +1 -0
- package/loaders/3MFLoader.js +555 -340
- package/loaders/AMFLoader.cjs.js +1 -0
- package/loaders/AMFLoader.js +219 -114
- package/loaders/AssimpLoader.cjs.js +1 -0
- package/loaders/AssimpLoader.js +725 -328
- package/loaders/BVHLoader.cjs.js +1 -0
- package/loaders/BVHLoader.js +200 -94
- package/loaders/BasisTextureLoader.cjs.js +1 -0
- package/loaders/BasisTextureLoader.js +357 -229
- package/loaders/ColladaLoader.cjs.js +1 -0
- package/loaders/ColladaLoader.js +1522 -932
- package/loaders/DDSLoader.cjs.js +1 -0
- package/loaders/DDSLoader.js +108 -42
- package/loaders/DRACOLoader.cjs.js +1 -0
- package/loaders/DRACOLoader.js +210 -103
- package/loaders/EXRLoader.cjs.js +1 -0
- package/loaders/EXRLoader.js +809 -461
- package/loaders/FBXLoader.cjs.js +1 -0
- package/loaders/FBXLoader.js +1397 -842
- package/loaders/FontLoader.cjs.js +1 -0
- package/loaders/FontLoader.js +66 -33
- package/loaders/GCodeLoader.cjs.js +1 -0
- package/loaders/GCodeLoader.js +111 -63
- package/loaders/GLTFLoader.cjs.js +1 -0
- package/loaders/GLTFLoader.js +1484 -771
- package/loaders/HDRCubeTextureLoader.cjs.js +1 -0
- package/loaders/HDRCubeTextureLoader.js +50 -45
- package/loaders/KMZLoader.cjs.js +1 -0
- package/loaders/KMZLoader.js +55 -42
- package/loaders/KTX2Loader.cjs.js +1 -0
- package/loaders/KTX2Loader.js +362 -229
- package/loaders/KTXLoader.cjs.js +1 -0
- package/loaders/KTXLoader.js +99 -37
- package/loaders/LDrawLoader.cjs.js +1 -0
- package/loaders/LDrawLoader.js +746 -313
- package/loaders/LUT3dlLoader.cjs.js +1 -0
- package/loaders/LUT3dlLoader.js +62 -50
- package/loaders/LUTCubeLoader.cjs.js +1 -0
- package/loaders/LUTCubeLoader.js +56 -45
- package/loaders/LWOLoader.cjs.js +1 -0
- package/loaders/LWOLoader.js +339 -227
- package/loaders/LottieLoader.cjs.js +1 -0
- package/loaders/LottieLoader.js +38 -36
- package/loaders/MD2Loader.cjs.js +1 -0
- package/loaders/MD2Loader.js +91 -248
- package/loaders/MDDLoader.cjs.js +1 -0
- package/loaders/MDDLoader.js +45 -25
- package/loaders/MMDLoader.cjs.js +1 -0
- package/loaders/MMDLoader.js +795 -359
- package/loaders/MTLLoader.cjs.js +1 -0
- package/loaders/MTLLoader.js +201 -91
- package/loaders/NRRDLoader.cjs.js +1 -0
- package/loaders/NRRDLoader.js +263 -182
- package/loaders/NodeMaterialLoader.cjs.js +1 -0
- package/loaders/NodeMaterialLoader.js +14 -121
- package/loaders/OBJLoader.cjs.js +1 -0
- package/loaders/OBJLoader.js +283 -161
- package/loaders/PCDLoader.cjs.js +1 -0
- package/loaders/PCDLoader.js +164 -145
- package/loaders/PDBLoader.cjs.js +1 -0
- package/loaders/PDBLoader.js +63 -45
- package/loaders/PLYLoader.cjs.js +1 -0
- package/loaders/PLYLoader.js +203 -106
- package/loaders/PRWMLoader.cjs.js +1 -0
- package/loaders/PRWMLoader.js +110 -73
- package/loaders/PVRLoader.cjs.js +1 -0
- package/loaders/PVRLoader.js +93 -32
- package/loaders/RGBELoader.cjs.js +1 -0
- package/loaders/RGBELoader.js +233 -96
- package/loaders/RGBMLoader.cjs.js +1 -0
- package/loaders/RGBMLoader.js +514 -344
- package/loaders/STLLoader.cjs.js +1 -0
- package/loaders/STLLoader.js +165 -59
- package/loaders/SVGLoader.cjs.js +1 -0
- package/loaders/SVGLoader.js +851 -481
- package/loaders/TDSLoader.cjs.js +1 -0
- package/loaders/TDSLoader.js +527 -137
- package/loaders/TGALoader.cjs.js +1 -0
- package/loaders/TGALoader.js +205 -94
- package/loaders/TTFLoader.cjs.js +1 -0
- package/loaders/TTFLoader.js +79 -58
- package/loaders/TiltLoader.cjs.js +1 -0
- package/loaders/TiltLoader.js +167 -129
- package/loaders/VOXLoader.cjs.js +1 -0
- package/loaders/VOXLoader.js +84 -320
- package/loaders/VRMLLoader.cjs.js +1 -0
- package/loaders/VRMLLoader.js +1268 -786
- package/loaders/VRMLoader.cjs.js +1 -0
- package/loaders/VRMLoader.js +31 -23
- package/loaders/VTKLoader.cjs.js +1 -0
- package/loaders/VTKLoader.js +407 -219
- package/loaders/XLoader.cjs.js +1 -0
- package/loaders/XLoader.js +1259 -1083
- package/loaders/XYZLoader.cjs.js +1 -0
- package/loaders/XYZLoader.js +34 -28
- package/loaders/lwo/IFFParser.cjs.js +1 -0
- package/loaders/lwo/IFFParser.js +492 -238
- package/loaders/lwo/LWO2Parser.cjs.js +1 -0
- package/loaders/lwo/LWO2Parser.js +279 -176
- package/loaders/lwo/LWO3Parser.cjs.js +1 -0
- package/loaders/lwo/LWO3Parser.js +247 -160
- package/math/Capsule.cjs.js +1 -0
- package/math/Capsule.js +43 -56
- package/math/ColorConverter.cjs.js +1 -0
- package/math/ColorConverter.js +32 -18
- package/math/ConvexHull.cjs.js +1 -0
- package/math/ConvexHull.js +357 -97
- package/math/ImprovedNoise.cjs.js +1 -0
- package/math/ImprovedNoise.js +32 -282
- package/math/Lut.cjs.js +1 -0
- package/math/Lut.js +35 -51
- package/math/MeshSurfaceSampler.cjs.js +1 -0
- package/math/MeshSurfaceSampler.js +68 -25
- package/math/OBB.cjs.js +1 -0
- package/math/OBB.js +152 -91
- package/math/Octree.cjs.js +1 -0
- package/math/Octree.js +139 -76
- package/math/SimplexNoise.cjs.js +1 -0
- package/math/SimplexNoise.js +238 -217
- package/misc/ConvexObjectBreaker.cjs.js +1 -0
- package/misc/ConvexObjectBreaker.js +185 -79
- package/misc/GPUComputationRenderer.cjs.js +1 -0
- package/misc/GPUComputationRenderer.js +194 -69
- package/misc/Gyroscope.cjs.js +1 -0
- package/misc/Gyroscope.js +22 -16
- package/misc/MD2Character.cjs.js +1 -0
- package/misc/MD2Character.js +74 -52
- package/misc/MD2CharacterComplex.cjs.js +1 -0
- package/misc/MD2CharacterComplex.js +163 -112
- package/misc/MorphAnimMesh.cjs.js +1 -0
- package/misc/MorphAnimMesh.js +28 -20
- package/misc/MorphBlendMesh.cjs.js +1 -0
- package/misc/MorphBlendMesh.js +69 -45
- package/misc/ProgressiveLightmap.cjs.js +1 -0
- package/misc/ProgressiveLightmap.js +187 -70
- package/misc/RollerCoaster.cjs.js +1 -0
- package/misc/RollerCoaster.js +135 -106
- package/misc/TubePainter.cjs.js +1 -0
- package/misc/TubePainter.js +92 -74
- package/misc/Volume.cjs.js +1 -0
- package/misc/Volume.js +270 -108
- package/misc/VolumeSlice.cjs.js +1 -0
- package/misc/VolumeSlice.js +122 -34
- package/misc/WebGL.cjs.js +1 -0
- package/misc/WebGL.js +34 -37
- package/modifiers/CurveModifier.cjs.js +1 -0
- package/modifiers/CurveModifier.js +151 -46
- package/modifiers/EdgeSplitModifier.cjs.js +1 -0
- package/modifiers/EdgeSplitModifier.js +90 -46
- package/modifiers/SimplifyModifier.cjs.js +1 -0
- package/modifiers/SimplifyModifier.js +202 -77
- package/modifiers/TessellateModifier.cjs.js +1 -0
- package/modifiers/TessellateModifier.js +90 -65
- package/nodes/Nodes.cjs.js +1 -0
- package/nodes/Nodes.js +140 -274
- package/nodes/ShaderNode.cjs.js +1 -0
- package/nodes/ShaderNode.js +196 -296
- package/nodes/accessors/BufferNode.cjs.js +1 -0
- package/nodes/accessors/BufferNode.js +8 -4
- package/nodes/accessors/CameraNode.cjs.js +1 -0
- package/nodes/accessors/CameraNode.js +25 -20
- package/nodes/accessors/CubeTextureNode.cjs.js +1 -0
- package/nodes/accessors/CubeTextureNode.js +26 -14
- package/nodes/accessors/MaterialNode.cjs.js +1 -0
- package/nodes/accessors/MaterialNode.js +53 -43
- package/nodes/accessors/MaterialReferenceNode.cjs.js +1 -0
- package/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/nodes/accessors/ModelNode.cjs.js +1 -0
- package/nodes/accessors/ModelNode.js +5 -3
- package/nodes/accessors/ModelViewProjectionNode.cjs.js +1 -0
- package/nodes/accessors/ModelViewProjectionNode.js +13 -14
- package/nodes/accessors/NormalNode.cjs.js +1 -0
- package/nodes/accessors/NormalNode.js +39 -40
- package/nodes/accessors/Object3DNode.cjs.js +1 -0
- package/nodes/accessors/Object3DNode.js +50 -40
- package/nodes/accessors/PointUVNode.cjs.js +1 -0
- package/nodes/accessors/PointUVNode.js +9 -5
- package/nodes/accessors/PositionNode.cjs.js +1 -0
- package/nodes/accessors/PositionNode.js +41 -42
- package/nodes/accessors/ReferenceNode.cjs.js +1 -0
- package/nodes/accessors/ReferenceNode.js +17 -10
- package/nodes/accessors/ReflectNode.cjs.js +1 -0
- package/nodes/accessors/ReflectNode.js +26 -23
- package/nodes/accessors/SkinningNode.cjs.js +1 -0
- package/nodes/accessors/SkinningNode.js +48 -46
- package/nodes/accessors/TextureNode.cjs.js +1 -0
- package/nodes/accessors/TextureNode.js +29 -14
- package/nodes/accessors/UVNode.cjs.js +1 -0
- package/nodes/accessors/UVNode.js +11 -5
- package/nodes/core/ArrayUniformNode.cjs.js +1 -0
- package/nodes/core/ArrayUniformNode.js +7 -3
- package/nodes/core/AttributeNode.cjs.js +1 -0
- package/nodes/core/AttributeNode.js +12 -5
- package/nodes/core/BypassNode.cjs.js +1 -0
- package/nodes/core/BypassNode.js +12 -5
- package/nodes/core/CodeNode.cjs.js +1 -0
- package/nodes/core/CodeNode.js +12 -4
- package/nodes/core/ConstNode.cjs.js +1 -0
- package/nodes/core/ConstNode.js +7 -3
- package/nodes/core/ContextNode.cjs.js +1 -0
- package/nodes/core/ContextNode.js +8 -3
- package/nodes/core/ExpressionNode.cjs.js +1 -0
- package/nodes/core/ExpressionNode.js +9 -5
- package/nodes/core/FunctionCallNode.cjs.js +1 -0
- package/nodes/core/FunctionCallNode.js +15 -6
- package/nodes/core/FunctionNode.cjs.js +1 -0
- package/nodes/core/FunctionNode.js +25 -10
- package/nodes/core/InputNode.cjs.js +1 -0
- package/nodes/core/InputNode.js +23 -12
- package/nodes/core/Node.cjs.js +1 -0
- package/nodes/core/Node.js +75 -35
- package/nodes/core/NodeAttribute.cjs.js +1 -0
- package/nodes/core/NodeAttribute.js +4 -2
- package/nodes/core/NodeBuilder.cjs.js +1 -0
- package/nodes/core/NodeBuilder.js +224 -110
- package/nodes/core/NodeCode.cjs.js +1 -0
- package/nodes/core/NodeCode.js +7 -4
- package/nodes/core/NodeFrame.cjs.js +1 -0
- package/nodes/core/NodeFrame.js +12 -9
- package/nodes/core/NodeFunction.cjs.js +1 -0
- package/nodes/core/NodeFunction.js +17 -0
- package/nodes/core/NodeFunctionInput.cjs.js +1 -0
- package/nodes/core/NodeFunctionInput.js +5 -3
- package/nodes/core/NodeKeywords.cjs.js +1 -0
- package/nodes/core/NodeKeywords.js +16 -5
- package/nodes/core/NodeParser.cjs.js +1 -0
- package/nodes/core/NodeParser.js +8 -0
- package/nodes/core/NodeUniform.cjs.js +1 -0
- package/nodes/core/NodeUniform.js +7 -3
- package/nodes/core/NodeUtils.cjs.js +1 -0
- package/nodes/core/NodeUtils.js +43 -39
- package/nodes/core/NodeVar.cjs.js +1 -0
- package/nodes/core/NodeVar.js +4 -2
- package/nodes/core/NodeVary.cjs.js +1 -0
- package/nodes/core/NodeVary.js +4 -2
- package/nodes/core/PropertyNode.cjs.js +1 -0
- package/nodes/core/PropertyNode.js +10 -4
- package/nodes/core/TempNode.cjs.js +1 -0
- package/nodes/core/TempNode.js +11 -5
- package/nodes/core/UniformNode.cjs.js +1 -0
- package/nodes/core/UniformNode.js +10 -4
- package/nodes/core/VarNode.cjs.js +1 -0
- package/nodes/core/VarNode.js +11 -3
- package/nodes/core/VaryNode.cjs.js +1 -0
- package/nodes/core/VaryNode.js +15 -6
- package/nodes/core/constants.cjs.js +1 -0
- package/nodes/core/constants.js +7 -20
- package/nodes/display/ColorSpaceNode.cjs.js +1 -0
- package/nodes/display/ColorSpaceNode.js +38 -34
- package/nodes/display/NormalMapNode.cjs.js +1 -0
- package/nodes/display/NormalMapNode.js +53 -35
- package/nodes/fog/FogNode.cjs.js +1 -0
- package/nodes/fog/FogNode.js +9 -5
- package/nodes/fog/FogRangeNode.cjs.js +1 -0
- package/nodes/fog/FogRangeNode.js +9 -5
- package/nodes/functions/BSDFs.cjs.js +1 -0
- package/nodes/functions/BSDFs.js +118 -61
- package/nodes/functions/PhysicalMaterialFunctions.cjs.js +1 -0
- package/nodes/functions/PhysicalMaterialFunctions.js +57 -0
- package/nodes/lights/LightContextNode.cjs.js +1 -0
- package/nodes/lights/LightContextNode.js +23 -14
- package/nodes/lights/LightNode.cjs.js +1 -0
- package/nodes/lights/LightNode.js +31 -27
- package/nodes/lights/LightsNode.cjs.js +1 -0
- package/nodes/lights/LightsNode.js +28 -9
- package/nodes/loaders/NodeLoader.cjs.js +1 -0
- package/nodes/loaders/NodeLoader.js +42 -27
- package/nodes/loaders/NodeMaterialLoader.cjs.js +1 -0
- package/nodes/loaders/NodeMaterialLoader.js +10 -4
- package/nodes/loaders/NodeObjectLoader.cjs.js +1 -0
- package/nodes/loaders/NodeObjectLoader.js +19 -9
- package/nodes/materials/LineBasicNodeMaterial.cjs.js +1 -0
- package/nodes/materials/LineBasicNodeMaterial.js +10 -5
- package/nodes/materials/Materials.cjs.js +1 -0
- package/nodes/materials/Materials.js +17 -14
- package/nodes/materials/MeshBasicNodeMaterial.cjs.js +1 -0
- package/nodes/materials/MeshBasicNodeMaterial.js +10 -5
- package/nodes/materials/MeshStandardNodeMaterial.cjs.js +1 -0
- package/nodes/materials/MeshStandardNodeMaterial.js +8 -5
- package/nodes/materials/NodeMaterial.cjs.js +1 -0
- package/nodes/materials/NodeMaterial.js +36 -20
- package/nodes/materials/PointsNodeMaterial.cjs.js +1 -0
- package/nodes/materials/PointsNodeMaterial.js +10 -5
- package/nodes/math/CondNode.cjs.js +1 -0
- package/nodes/math/CondNode.js +23 -11
- package/nodes/math/MathNode.cjs.js +1 -0
- package/nodes/math/MathNode.js +142 -98
- package/nodes/math/OperatorNode.cjs.js +1 -0
- package/nodes/math/OperatorNode.js +46 -24
- package/nodes/parsers/GLSLNodeFunction.cjs.js +1 -0
- package/nodes/parsers/GLSLNodeFunction.js +101 -0
- package/nodes/parsers/GLSLNodeParser.cjs.js +1 -0
- package/nodes/parsers/GLSLNodeParser.js +13 -0
- package/nodes/parsers/WGSLNodeFunction.cjs.js +1 -0
- package/nodes/parsers/WGSLNodeFunction.js +71 -0
- package/nodes/parsers/WGSLNodeParser.cjs.js +1 -0
- package/nodes/parsers/WGSLNodeParser.js +13 -0
- package/nodes/procedural/CheckerNode.cjs.js +1 -0
- package/nodes/procedural/CheckerNode.js +19 -13
- package/nodes/utils/ArrayElementNode.cjs.js +1 -0
- package/nodes/utils/ArrayElementNode.js +8 -4
- package/nodes/utils/ConvertNode.cjs.js +1 -0
- package/nodes/utils/ConvertNode.js +8 -3
- package/nodes/utils/JoinNode.cjs.js +1 -0
- package/nodes/utils/JoinNode.js +11 -7
- package/nodes/utils/MatcapUVNode.cjs.js +1 -0
- package/nodes/utils/MatcapUVNode.js +11 -8
- package/nodes/utils/OscNode.cjs.js +1 -0
- package/nodes/utils/OscNode.js +33 -27
- package/nodes/utils/SplitNode.cjs.js +1 -0
- package/nodes/utils/SplitNode.js +20 -6
- package/nodes/utils/SpriteSheetUVNode.cjs.js +1 -0
- package/nodes/utils/SpriteSheetUVNode.js +23 -23
- package/nodes/utils/TimerNode.cjs.js +1 -0
- package/nodes/utils/TimerNode.js +24 -20
- package/objects/GroundProjectedEnv.cjs.js +1 -0
- package/objects/GroundProjectedEnv.js +37 -22
- package/objects/Lensflare.cjs.js +1 -0
- package/objects/Lensflare.js +156 -86
- package/objects/LightningStorm.cjs.js +1 -0
- package/objects/LightningStorm.js +102 -38
- package/objects/MarchingCubes.cjs.js +1 -0
- package/objects/MarchingCubes.js +303 -150
- package/objects/Reflector.cjs.js +1 -0
- package/objects/Reflector.js +72 -50
- package/objects/ReflectorForSSRPass.cjs.js +1 -0
- package/objects/ReflectorForSSRPass.js +131 -80
- package/objects/ReflectorRTT.cjs.js +1 -0
- package/objects/ReflectorRTT.js +7 -6
- package/objects/Refractor.cjs.js +1 -0
- package/objects/Refractor.js +106 -64
- package/objects/ShadowMesh.cjs.js +1 -0
- package/objects/ShadowMesh.js +17 -8
- package/objects/Sky.cjs.js +1 -0
- package/objects/Sky.js +80 -119
- package/objects/Water.cjs.js +1 -0
- package/objects/Water.js +127 -83
- package/objects/Water2.cjs.js +1 -0
- package/objects/Water2.js +108 -72
- package/offscreen/jank.cjs.js +1 -0
- package/offscreen/jank.js +14 -10
- package/offscreen/offscreen.cjs.js +1 -0
- package/offscreen/offscreen.js +5 -4
- package/offscreen/scene.cjs.js +1 -0
- package/offscreen/scene.js +48 -45
- package/package.json +3 -3
- package/physics/AmmoPhysics.cjs.js +1 -0
- package/physics/AmmoPhysics.js +71 -30
- package/postprocessing/AdaptiveToneMappingPass.cjs.js +1 -0
- package/postprocessing/AdaptiveToneMappingPass.js +123 -97
- package/postprocessing/AfterimagePass.cjs.js +1 -0
- package/postprocessing/AfterimagePass.js +49 -28
- package/postprocessing/BloomPass.cjs.js +1 -0
- package/postprocessing/BloomPass.js +69 -43
- package/postprocessing/BokehPass.cjs.js +1 -0
- package/postprocessing/BokehPass.js +69 -39
- package/postprocessing/ClearPass.cjs.js +1 -0
- package/postprocessing/ClearPass.js +25 -10
- package/postprocessing/CubeTexturePass.cjs.js +1 -0
- package/postprocessing/CubeTexturePass.js +27 -28
- package/postprocessing/DotScreenPass.cjs.js +1 -0
- package/postprocessing/DotScreenPass.js +32 -24
- package/postprocessing/EffectComposer.cjs.js +1 -0
- package/postprocessing/EffectComposer.js +86 -39
- package/postprocessing/FilmPass.cjs.js +1 -0
- package/postprocessing/FilmPass.js +30 -25
- package/postprocessing/GlitchPass.cjs.js +1 -0
- package/postprocessing/GlitchPass.js +61 -38
- package/postprocessing/HalftonePass.cjs.js +1 -0
- package/postprocessing/HalftonePass.js +39 -19
- package/postprocessing/LUTPass.cjs.js +1 -0
- package/postprocessing/LUTPass.js +38 -13
- package/postprocessing/MaskPass.cjs.js +1 -0
- package/postprocessing/MaskPass.js +38 -19
- package/postprocessing/OutlinePass.cjs.js +1 -0
- package/postprocessing/OutlinePass.js +277 -135
- package/postprocessing/Pass.cjs.js +1 -0
- package/postprocessing/Pass.js +44 -20
- package/postprocessing/RenderPass.cjs.js +1 -0
- package/postprocessing/RenderPass.js +36 -13
- package/postprocessing/RenderPixelatedPass.cjs.js +1 -0
- package/postprocessing/RenderPixelatedPass.js +58 -44
- package/postprocessing/SAOPass.cjs.js +1 -0
- package/postprocessing/SAOPass.js +189 -154
- package/postprocessing/SMAAPass.cjs.js +1 -0
- package/postprocessing/SMAAPass.js +84 -64
- package/postprocessing/SSAARenderPass.cjs.js +1 -0
- package/postprocessing/SSAARenderPass.js +69 -121
- package/postprocessing/SSAOPass.cjs.js +1 -0
- package/postprocessing/SSAOPass.js +172 -123
- package/postprocessing/SSRPass.cjs.js +1 -0
- package/postprocessing/SSRPass.js +280 -211
- package/postprocessing/SavePass.cjs.js +1 -0
- package/postprocessing/SavePass.js +25 -20
- package/postprocessing/ShaderPass.cjs.js +1 -0
- package/postprocessing/ShaderPass.js +30 -14
- package/postprocessing/TAARenderPass.cjs.js +1 -0
- package/postprocessing/TAARenderPass.js +61 -42
- package/postprocessing/TexturePass.cjs.js +1 -0
- package/postprocessing/TexturePass.js +22 -21
- package/postprocessing/UnrealBloomPass.cjs.js +1 -0
- package/postprocessing/UnrealBloomPass.js +213 -105
- package/renderers/CSS2DRenderer.cjs.js +1 -0
- package/renderers/CSS2DRenderer.js +56 -44
- package/renderers/CSS3DRenderer.cjs.js +1 -0
- package/renderers/CSS3DRenderer.js +86 -53
- package/renderers/Projector.cjs.js +1 -0
- package/renderers/Projector.js +274 -107
- package/renderers/SVGRenderer.cjs.js +1 -0
- package/renderers/SVGRenderer.js +182 -72
- package/renderers/nodes/accessors/CameraNode.cjs.js +1 -0
- package/renderers/nodes/accessors/CameraNode.js +40 -29
- package/renderers/nodes/accessors/ModelNode.cjs.js +1 -0
- package/renderers/nodes/accessors/ModelNode.js +37 -28
- package/renderers/nodes/accessors/ModelViewProjectionNode.cjs.js +1 -0
- package/renderers/nodes/accessors/ModelViewProjectionNode.js +23 -10
- package/renderers/nodes/accessors/NormalNode.cjs.js +1 -0
- package/renderers/nodes/accessors/NormalNode.js +45 -35
- package/renderers/nodes/accessors/PositionNode.cjs.js +1 -0
- package/renderers/nodes/accessors/PositionNode.js +19 -18
- package/renderers/nodes/accessors/UVNode.cjs.js +1 -0
- package/renderers/nodes/accessors/UVNode.js +10 -5
- package/renderers/nodes/core/AttributeNode.cjs.js +1 -0
- package/renderers/nodes/core/AttributeNode.js +14 -5
- package/renderers/nodes/core/InputNode.cjs.js +1 -0
- package/renderers/nodes/core/InputNode.js +14 -4
- package/renderers/nodes/core/Node.cjs.js +1 -0
- package/renderers/nodes/core/Node.js +17 -7
- package/renderers/nodes/core/NodeAttribute.cjs.js +1 -0
- package/renderers/nodes/core/NodeAttribute.js +6 -3
- package/renderers/nodes/core/NodeBuilder.cjs.js +1 -0
- package/renderers/nodes/core/NodeBuilder.js +154 -87
- package/renderers/nodes/core/NodeFrame.cjs.js +1 -0
- package/renderers/nodes/core/NodeFrame.js +12 -9
- package/renderers/nodes/core/NodeSlot.cjs.js +1 -0
- package/renderers/nodes/core/NodeSlot.js +3 -2
- package/renderers/nodes/core/NodeUniform.cjs.js +1 -0
- package/renderers/nodes/core/NodeUniform.js +9 -4
- package/renderers/nodes/core/NodeVary.cjs.js +1 -0
- package/renderers/nodes/core/NodeVary.js +7 -4
- package/renderers/nodes/core/VaryNode.cjs.js +1 -0
- package/renderers/nodes/core/VaryNode.js +12 -6
- package/renderers/nodes/core/constants.cjs.js +1 -0
- package/renderers/nodes/core/constants.js +13 -16
- package/renderers/nodes/inputs/ColorNode.cjs.js +1 -0
- package/renderers/nodes/inputs/ColorNode.js +11 -5
- package/renderers/nodes/inputs/FloatNode.cjs.js +1 -0
- package/renderers/nodes/inputs/FloatNode.js +11 -5
- package/renderers/nodes/inputs/Matrix3Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Matrix3Node.js +13 -7
- package/renderers/nodes/inputs/Matrix4Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Matrix4Node.js +13 -7
- package/renderers/nodes/inputs/TextureNode.cjs.js +1 -0
- package/renderers/nodes/inputs/TextureNode.js +15 -7
- package/renderers/nodes/inputs/Vector2Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Vector2Node.js +11 -5
- package/renderers/nodes/inputs/Vector3Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Vector3Node.js +13 -7
- package/renderers/nodes/inputs/Vector4Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Vector4Node.js +13 -7
- package/renderers/nodes/math/MathNode.cjs.js +1 -0
- package/renderers/nodes/math/MathNode.js +30 -20
- package/renderers/nodes/math/OperatorNode.cjs.js +1 -0
- package/renderers/nodes/math/OperatorNode.js +20 -4
- package/renderers/nodes/utils/SwitchNode.cjs.js +1 -0
- package/renderers/nodes/utils/SwitchNode.js +9 -4
- package/renderers/nodes/utils/TimerNode.cjs.js +1 -0
- package/renderers/nodes/utils/TimerNode.js +10 -5
- package/renderers/webgpu/WebGPU.cjs.js +1 -0
- package/renderers/webgpu/WebGPU.js +16 -14
- package/renderers/webgpu/WebGPUAttributes.cjs.js +1 -0
- package/renderers/webgpu/WebGPUAttributes.js +23 -16
- package/renderers/webgpu/WebGPUBackground.cjs.js +1 -0
- package/renderers/webgpu/WebGPUBackground.js +30 -13
- package/renderers/webgpu/WebGPUBinding.cjs.js +1 -0
- package/renderers/webgpu/WebGPUBinding.js +7 -4
- package/renderers/webgpu/WebGPUBindings.cjs.js +1 -0
- package/renderers/webgpu/WebGPUBindings.js +57 -21
- package/renderers/webgpu/WebGPUComputePipelines.cjs.js +1 -0
- package/renderers/webgpu/WebGPUComputePipelines.js +25 -14
- package/renderers/webgpu/WebGPUGeometries.cjs.js +1 -0
- package/renderers/webgpu/WebGPUGeometries.js +15 -5
- package/renderers/webgpu/WebGPUInfo.cjs.js +1 -0
- package/renderers/webgpu/WebGPUInfo.js +8 -3
- package/renderers/webgpu/WebGPUObjects.cjs.js +1 -0
- package/renderers/webgpu/WebGPUObjects.js +10 -5
- package/renderers/webgpu/WebGPUProperties.cjs.js +1 -0
- package/renderers/webgpu/WebGPUProperties.js +11 -5
- package/renderers/webgpu/WebGPURenderLists.cjs.js +1 -0
- package/renderers/webgpu/WebGPURenderLists.js +36 -20
- package/renderers/webgpu/WebGPURenderPipelines.cjs.js +1 -0
- package/renderers/webgpu/WebGPURenderPipelines.js +387 -260
- package/renderers/webgpu/WebGPURenderer.cjs.js +1 -0
- package/renderers/webgpu/WebGPURenderer.js +262 -124
- package/renderers/webgpu/WebGPUSampledTexture.cjs.js +1 -0
- package/renderers/webgpu/WebGPUSampledTexture.js +31 -18
- package/renderers/webgpu/WebGPUSampler.cjs.js +1 -0
- package/renderers/webgpu/WebGPUSampler.js +12 -7
- package/renderers/webgpu/WebGPUStorageBuffer.cjs.js +1 -0
- package/renderers/webgpu/WebGPUStorageBuffer.js +12 -7
- package/renderers/webgpu/WebGPUTextureRenderer.cjs.js +1 -0
- package/renderers/webgpu/WebGPUTextureRenderer.js +11 -5
- package/renderers/webgpu/WebGPUTextureUtils.cjs.js +1 -0
- package/renderers/webgpu/WebGPUTextureUtils.js +40 -29
- package/renderers/webgpu/WebGPUTextures.cjs.js +1 -0
- package/renderers/webgpu/WebGPUTextures.js +333 -186
- package/renderers/webgpu/WebGPUUniform.cjs.js +1 -0
- package/renderers/webgpu/WebGPUUniform.js +51 -25
- package/renderers/webgpu/WebGPUUniformsGroup.cjs.js +1 -0
- package/renderers/webgpu/WebGPUUniformsGroup.js +72 -32
- package/renderers/webgpu/constants.cjs.js +1 -0
- package/renderers/webgpu/constants.js +181 -190
- package/renderers/webgpu/nodes/ShaderLib.cjs.js +1 -0
- package/renderers/webgpu/nodes/ShaderLib.js +2 -2
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.js +124 -53
- package/renderers/webgpu/nodes/WebGPUNodeUniform.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodeUniform.js +31 -17
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +9 -8
- package/renderers/webgpu/nodes/WebGPUNodes.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodes.js +45 -7
- package/shaders/ACESFilmicToneMappingShader.cjs.js +1 -0
- package/shaders/ACESFilmicToneMappingShader.js +24 -44
- package/shaders/AfterimageShader.cjs.js +1 -0
- package/shaders/AfterimageShader.js +18 -28
- package/shaders/BasicShader.cjs.js +1 -0
- package/shaders/BasicShader.js +7 -9
- package/shaders/BleachBypassShader.cjs.js +1 -0
- package/shaders/BleachBypassShader.js +15 -31
- package/shaders/BlendShader.cjs.js +1 -0
- package/shaders/BlendShader.js +19 -26
- package/shaders/BokehShader.cjs.js +1 -0
- package/shaders/BokehShader.js +36 -98
- package/shaders/BokehShader2.cjs.js +1 -0
- package/shaders/BokehShader2.js +90 -261
- package/shaders/BrightnessContrastShader.cjs.js +1 -0
- package/shaders/BrightnessContrastShader.js +19 -28
- package/shaders/ColorCorrectionShader.cjs.js +1 -0
- package/shaders/ColorCorrectionShader.js +22 -26
- package/shaders/ColorifyShader.cjs.js +1 -0
- package/shaders/ColorifyShader.js +16 -24
- package/shaders/ConvolutionShader.cjs.js +1 -0
- package/shaders/ConvolutionShader.js +36 -40
- package/shaders/CopyShader.cjs.js +1 -0
- package/shaders/CopyShader.js +13 -21
- package/shaders/DOFMipMapShader.cjs.js +1 -0
- package/shaders/DOFMipMapShader.js +21 -28
- package/shaders/DepthLimitedBlurShader.cjs.js +1 -0
- package/shaders/DepthLimitedBlurShader.js +40 -85
- package/shaders/DigitalGlitch.cjs.js +1 -0
- package/shaders/DigitalGlitch.js +46 -74
- package/shaders/DotScreenShader.cjs.js +1 -0
- package/shaders/DotScreenShader.js +27 -35
- package/shaders/FXAAShader.cjs.js +1 -0
- package/shaders/FXAAShader.js +19 -1094
- package/shaders/FilmShader.cjs.js +1 -0
- package/shaders/FilmShader.js +52 -38
- package/shaders/FocusShader.cjs.js +1 -0
- package/shaders/FocusShader.js +24 -51
- package/shaders/FreiChenShader.cjs.js +1 -0
- package/shaders/FreiChenShader.js +24 -57
- package/shaders/FresnelShader.cjs.js +1 -0
- package/shaders/FresnelShader.js +22 -43
- package/shaders/GammaCorrectionShader.cjs.js +1 -0
- package/shaders/GammaCorrectionShader.js +11 -19
- package/shaders/GodRaysShader.cjs.js +1 -0
- package/shaders/GodRaysShader.js +94 -103
- package/shaders/HalftoneShader.cjs.js +1 -0
- package/shaders/HalftoneShader.js +65 -208
- package/shaders/HorizontalBlurShader.cjs.js +1 -0
- package/shaders/HorizontalBlurShader.js +23 -7
- package/shaders/HorizontalTiltShiftShader.cjs.js +1 -0
- package/shaders/HorizontalTiltShiftShader.js +21 -33
- package/shaders/HueSaturationShader.cjs.js +1 -0
- package/shaders/HueSaturationShader.js +21 -37
- package/shaders/KaleidoShader.cjs.js +1 -0
- package/shaders/KaleidoShader.js +22 -30
- package/shaders/LuminosityHighPassShader.cjs.js +1 -0
- package/shaders/LuminosityHighPassShader.js +27 -33
- package/shaders/LuminosityShader.cjs.js +1 -0
- package/shaders/LuminosityShader.js +11 -21
- package/shaders/MirrorShader.cjs.js +1 -0
- package/shaders/MirrorShader.js +16 -31
- package/shaders/NormalMapShader.cjs.js +1 -0
- package/shaders/NormalMapShader.js +23 -27
- package/shaders/ParallaxShader.cjs.js +1 -0
- package/shaders/ParallaxShader.js +48 -107
- package/shaders/PixelShader.cjs.js +1 -0
- package/shaders/PixelShader.js +16 -24
- package/shaders/RGBShiftShader.cjs.js +1 -0
- package/shaders/RGBShiftShader.js +22 -26
- package/shaders/SAOShader.cjs.js +1 -0
- package/shaders/SAOShader.js +48 -132
- package/shaders/SMAAShader.cjs.js +1 -0
- package/shaders/SMAAShader.js +135 -256
- package/shaders/SSAOShader.cjs.js +1 -0
- package/shaders/SSAOShader.js +81 -153
- package/shaders/SSRShader.cjs.js +1 -0
- package/shaders/SSRShader.js +87 -32
- package/shaders/SepiaShader.cjs.js +1 -0
- package/shaders/SepiaShader.js +15 -25
- package/shaders/SobelOperatorShader.cjs.js +1 -0
- package/shaders/SobelOperatorShader.js +29 -40
- package/shaders/SubsurfaceScatteringShader.cjs.js +1 -0
- package/shaders/SubsurfaceScatteringShader.js +39 -53
- package/shaders/TechnicolorShader.cjs.js +1 -0
- package/shaders/TechnicolorShader.js +13 -20
- package/shaders/ToneMapShader.cjs.js +1 -0
- package/shaders/ToneMapShader.js +28 -44
- package/shaders/ToonShader.cjs.js +1 -0
- package/shaders/ToonShader.js +96 -172
- package/shaders/TriangleBlurShader.cjs.js +1 -0
- package/shaders/TriangleBlurShader.js +23 -32
- package/shaders/UnpackDepthRGBAShader.cjs.js +1 -0
- package/shaders/UnpackDepthRGBAShader.js +14 -22
- package/shaders/VerticalBlurShader.cjs.js +1 -0
- package/shaders/VerticalBlurShader.js +23 -7
- package/shaders/VerticalTiltShiftShader.cjs.js +1 -0
- package/shaders/VerticalTiltShiftShader.js +21 -33
- package/shaders/VignetteShader.cjs.js +1 -0
- package/shaders/VignetteShader.js +28 -24
- package/shaders/VolumeShader.cjs.js +1 -0
- package/shaders/VolumeShader.js +77 -174
- package/shaders/WaterRefractionShader.cjs.js +1 -0
- package/shaders/WaterRefractionShader.js +6 -38
- package/shaders/types.cjs.js +1 -0
- package/shaders/types.js +1 -1
- package/textures/FlakesTexture.cjs.js +1 -0
- package/textures/FlakesTexture.js +10 -8
- package/types/helpers.cjs.js +1 -0
- package/types/helpers.js +2 -3
- package/types/shared.cjs.js +1 -0
- package/types/shared.js +1 -0
- package/types/utils.cjs.js +1 -0
- package/types/utils.js +1 -0
- package/utils/BufferGeometryUtils.cjs.js +1 -0
- package/utils/BufferGeometryUtils.js +325 -251
- package/utils/GeometryCompressionUtils.cjs.js +1 -0
- package/utils/GeometryCompressionUtils.js +239 -241
- package/utils/GeometryUtils.cjs.js +1 -0
- package/utils/GeometryUtils.js +94 -41
- package/utils/LDrawUtils.cjs.js +1 -0
- package/utils/LDrawUtils.d.ts +5 -0
- package/utils/LDrawUtils.js +144 -0
- package/utils/RoughnessMipmapper.cjs.js +1 -0
- package/utils/RoughnessMipmapper.js +82 -38
- package/utils/SceneUtils.cjs.js +1 -0
- package/utils/SceneUtils.js +20 -15
- package/utils/ShadowMapViewer.cjs.js +1 -0
- package/utils/ShadowMapViewer.js +95 -49
- package/utils/SkeletonUtils.cjs.js +1 -0
- package/utils/SkeletonUtils.js +165 -74
- package/utils/UVsDebug.cjs.js +1 -0
- package/utils/UVsDebug.js +62 -32
- package/utils/WorkerPool.cjs.js +1 -0
- package/utils/WorkerPool.js +33 -13
- package/webxr/ARButton.cjs.js +1 -0
- package/webxr/ARButton.js +98 -72
- package/webxr/OculusHandModel.cjs.js +1 -0
- package/webxr/OculusHandModel.js +37 -18
- package/webxr/OculusHandPointerModel.cjs.js +1 -0
- package/webxr/OculusHandPointerModel.js +80 -58
- package/webxr/Text2D.cjs.js +1 -0
- package/webxr/Text2D.js +19 -37
- package/webxr/VRButton.cjs.js +1 -0
- package/webxr/VRButton.js +90 -59
- package/webxr/XRControllerModelFactory.cjs.js +1 -0
- package/webxr/XRControllerModelFactory.js +116 -58
- package/webxr/XREstimatedLight.cjs.js +1 -0
- package/webxr/XREstimatedLight.js +66 -39
- package/webxr/XRHandMeshModel.cjs.js +1 -0
- package/webxr/XRHandMeshModel.js +29 -40
- package/webxr/XRHandModelFactory.cjs.js +1 -0
- package/webxr/XRHandModelFactory.js +31 -28
- package/webxr/XRHandPrimitiveModel.cjs.js +1 -0
- package/webxr/XRHandPrimitiveModel.js +27 -41
- package/animation/AnimationClipCreator.mjs +0 -57
- package/animation/CCDIKSolver.mjs +0 -223
- package/animation/MMDAnimationHelper.mjs +0 -514
- package/animation/MMDPhysics.mjs +0 -769
- package/cameras/CinematicCamera.mjs +0 -129
- package/controls/ArcballControls.mjs +0 -1737
- package/controls/DeviceOrientationControls.mjs +0 -74
- package/controls/DragControls.mjs +0 -172
- package/controls/FirstPersonControls.mjs +0 -220
- package/controls/FlyControls.mjs +0 -239
- package/controls/OrbitControls.mjs +0 -731
- package/controls/PointerLockControls.mjs +0 -88
- package/controls/TrackballControls.mjs +0 -481
- package/controls/TransformControls.mjs +0 -1068
- package/controls/experimental/CameraControls.mjs +0 -673
- package/csm/CSM.mjs +0 -244
- package/csm/CSMFrustum.mjs +0 -75
- package/csm/CSMHelper.mjs +0 -114
- package/csm/CSMShader.mjs +0 -251
- package/curves/CurveExtras.mjs +0 -224
- package/curves/NURBSCurve.mjs +0 -35
- package/curves/NURBSSurface.mjs +0 -28
- package/curves/NURBSUtils.mjs +0 -226
- package/deprecated/Geometry.mjs +0 -966
- package/effects/AnaglyphEffect.mjs +0 -120
- package/effects/AsciiEffect.mjs +0 -173
- package/effects/OutlineEffect.mjs +0 -295
- package/effects/ParallaxBarrierEffect.mjs +0 -64
- package/effects/PeppersGhostEffect.mjs +0 -85
- package/effects/StereoEffect.mjs +0 -32
- package/environments/RoomEnvironment.mjs +0 -78
- package/exporters/ColladaExporter.mjs +0 -299
- package/exporters/DRACOExporter.mjs +0 -132
- package/exporters/GLTFExporter.mjs +0 -1381
- package/exporters/MMDExporter.mjs +0 -102
- package/exporters/OBJExporter.mjs +0 -166
- package/exporters/PLYExporter.mjs +0 -278
- package/exporters/STLExporter.mjs +0 -129
- package/exporters/USDZExporter.mjs +0 -328
- package/geometries/BoxLineGeometry.mjs +0 -45
- package/geometries/ConvexGeometry.mjs +0 -29
- package/geometries/DecalGeometry.mjs +0 -184
- package/geometries/LightningStrike.mjs +0 -547
- package/geometries/ParametricGeometries.mjs +0 -129
- package/geometries/ParametricGeometry.mjs +0 -63
- package/geometries/RoundedBoxGeometry.mjs +0 -91
- package/geometries/TeapotGeometry.mjs +0 -1557
- package/geometries/TextGeometry.mjs +0 -23
- package/helpers/LightProbeHelper.mjs +0 -72
- package/helpers/PositionalAudioHelper.mjs +0 -68
- package/helpers/RectAreaLightHelper.mjs +0 -44
- package/helpers/VertexNormalsHelper.mjs +0 -54
- package/helpers/VertexTangentsHelper.mjs +0 -45
- package/index.mjs +0 -969
- package/interactive/SelectionBox.mjs +0 -137
- package/interactive/SelectionHelper.mjs +0 -54
- package/libs/MeshoptDecoder.mjs +0 -210
- package/libs/MotionControllers.mjs +0 -261
- package/lights/LightProbeGenerator.mjs +0 -145
- package/lights/RectAreaLightUniformsLib.mjs +0 -32842
- package/lines/Line2.mjs +0 -13
- package/lines/LineGeometry.mjs +0 -44
- package/lines/LineMaterial.mjs +0 -539
- package/lines/LineSegments2.mjs +0 -202
- package/lines/LineSegmentsGeometry.mjs +0 -124
- package/lines/Wireframe.mjs +0 -31
- package/lines/WireframeGeometry2.mjs +0 -13
- package/loaders/3DMLoader.mjs +0 -802
- package/loaders/3MFLoader.mjs +0 -837
- package/loaders/AMFLoader.mjs +0 -284
- package/loaders/AssimpLoader.mjs +0 -1396
- package/loaders/BVHLoader.mjs +0 -207
- package/loaders/BasisTextureLoader.mjs +0 -474
- package/loaders/ColladaLoader.mjs +0 -2403
- package/loaders/DDSLoader.mjs +0 -148
- package/loaders/DRACOLoader.mjs +0 -340
- package/loaders/EXRLoader.mjs +0 -1351
- package/loaders/FBXLoader.mjs +0 -2362
- package/loaders/FontLoader.mjs +0 -111
- package/loaders/GCodeLoader.mjs +0 -141
- package/loaders/GLTFLoader.mjs +0 -2316
- package/loaders/HDRCubeTextureLoader.mjs +0 -77
- package/loaders/KMZLoader.mjs +0 -75
- package/loaders/KTX2Loader.mjs +0 -427
- package/loaders/KTXLoader.mjs +0 -87
- package/loaders/LDrawLoader.mjs +0 -1409
- package/loaders/LUT3dlLoader.mjs +0 -100
- package/loaders/LUTCubeLoader.mjs +0 -104
- package/loaders/LWOLoader.mjs +0 -625
- package/loaders/LottieLoader.mjs +0 -47
- package/loaders/MD2Loader.mjs +0 -359
- package/loaders/MDDLoader.mjs +0 -58
- package/loaders/MMDLoader.mjs +0 -998
- package/loaders/MTLLoader.mjs +0 -280
- package/loaders/NRRDLoader.mjs +0 -401
- package/loaders/NodeMaterialLoader.mjs +0 -146
- package/loaders/OBJLoader.mjs +0 -487
- package/loaders/PCDLoader.mjs +0 -248
- package/loaders/PDBLoader.mjs +0 -246
- package/loaders/PLYLoader.mjs +0 -317
- package/loaders/PRWMLoader.mjs +0 -160
- package/loaders/PVRLoader.mjs +0 -131
- package/loaders/RGBELoader.mjs +0 -244
- package/loaders/RGBMLoader.mjs +0 -998
- package/loaders/STLLoader.mjs +0 -190
- package/loaders/SVGLoader.mjs +0 -1709
- package/loaders/TDSLoader.mjs +0 -480
- package/loaders/TGALoader.mjs +0 -285
- package/loaders/TTFLoader.mjs +0 -131
- package/loaders/TiltLoader.mjs +0 -373
- package/loaders/VOXLoader.mjs +0 -431
- package/loaders/VRMLLoader.mjs +0 -2093
- package/loaders/VRMLoader.mjs +0 -38
- package/loaders/VTKLoader.mjs +0 -646
- package/loaders/XLoader.mjs +0 -1258
- package/loaders/XYZLoader.mjs +0 -60
- package/loaders/lwo/IFFParser.mjs +0 -697
- package/loaders/lwo/LWO2Parser.mjs +0 -327
- package/loaders/lwo/LWO3Parser.mjs +0 -298
- package/math/Capsule.mjs +0 -100
- package/math/ColorConverter.mjs +0 -51
- package/math/ConvexHull.mjs +0 -574
- package/math/ImprovedNoise.mjs +0 -302
- package/math/Lut.mjs +0 -135
- package/math/MeshSurfaceSampler.mjs +0 -107
- package/math/OBB.mjs +0 -235
- package/math/Octree.mjs +0 -278
- package/math/SimplexNoise.mjs +0 -425
- package/misc/ConvexObjectBreaker.mjs +0 -292
- package/misc/GPUComputationRenderer.mjs +0 -171
- package/misc/Gyroscope.mjs +0 -35
- package/misc/MD2Character.mjs +0 -162
- package/misc/MD2CharacterComplex.mjs +0 -328
- package/misc/MorphAnimMesh.mjs +0 -40
- package/misc/MorphBlendMesh.mjs +0 -179
- package/misc/ProgressiveLightmap.mjs +0 -166
- package/misc/RollerCoaster.mjs +0 -346
- package/misc/TubePainter.mjs +0 -123
- package/misc/Volume.mjs +0 -244
- package/misc/VolumeSlice.mjs +0 -106
- package/misc/WebGL.mjs +0 -74
- package/modifiers/CurveModifier.mjs +0 -182
- package/modifiers/EdgeSplitModifier.mjs +0 -162
- package/modifiers/SimplifyModifier.mjs +0 -282
- package/modifiers/TessellateModifier.mjs +0 -206
- package/nodes/Nodes.mjs +0 -400
- package/nodes/ShaderNode.mjs +0 -408
- package/nodes/accessors/BufferNode.mjs +0 -15
- package/nodes/accessors/CameraNode.mjs +0 -44
- package/nodes/accessors/CubeTextureNode.mjs +0 -42
- package/nodes/accessors/MaterialNode.mjs +0 -71
- package/nodes/accessors/MaterialReferenceNode.mjs +0 -14
- package/nodes/accessors/ModelNode.mjs +0 -9
- package/nodes/accessors/ModelViewProjectionNode.mjs +0 -24
- package/nodes/accessors/NormalNode.mjs +0 -62
- package/nodes/accessors/Object3DNode.mjs +0 -76
- package/nodes/accessors/PointUVNode.mjs +0 -13
- package/nodes/accessors/PositionNode.mjs +0 -65
- package/nodes/accessors/ReferenceNode.mjs +0 -37
- package/nodes/accessors/ReflectNode.mjs +0 -43
- package/nodes/accessors/SkinningNode.mjs +0 -58
- package/nodes/accessors/TextureNode.mjs +0 -54
- package/nodes/accessors/UVNode.mjs +0 -23
- package/nodes/core/ArrayUniformNode.mjs +0 -14
- package/nodes/core/AttributeNode.mjs +0 -30
- package/nodes/core/BypassNode.mjs +0 -22
- package/nodes/core/CodeNode.mjs +0 -28
- package/nodes/core/ConstNode.mjs +0 -14
- package/nodes/core/ContextNode.mjs +0 -22
- package/nodes/core/ExpressionNode.mjs +0 -19
- package/nodes/core/FunctionCallNode.mjs +0 -37
- package/nodes/core/FunctionNode.mjs +0 -56
- package/nodes/core/InputNode.mjs +0 -38
- package/nodes/core/Node.mjs +0 -139
- package/nodes/core/NodeAttribute.mjs +0 -10
- package/nodes/core/NodeBuilder.mjs +0 -395
- package/nodes/core/NodeCode.mjs +0 -11
- package/nodes/core/NodeFrame.mjs +0 -35
- package/nodes/core/NodeFunctionInput.mjs +0 -13
- package/nodes/core/NodeKeywords.mjs +0 -44
- package/nodes/core/NodeUniform.mjs +0 -18
- package/nodes/core/NodeUtils.mjs +0 -57
- package/nodes/core/NodeVar.mjs +0 -10
- package/nodes/core/NodeVary.mjs +0 -10
- package/nodes/core/PropertyNode.mjs +0 -21
- package/nodes/core/TempNode.mjs +0 -25
- package/nodes/core/UniformNode.mjs +0 -23
- package/nodes/core/VarNode.mjs +0 -31
- package/nodes/core/VaryNode.mjs +0 -30
- package/nodes/core/constants.mjs +0 -24
- package/nodes/display/ColorSpaceNode.mjs +0 -63
- package/nodes/display/NormalMapNode.mjs +0 -54
- package/nodes/fog/FogNode.mjs +0 -15
- package/nodes/fog/FogRangeNode.mjs +0 -17
- package/nodes/functions/BSDFs.mjs +0 -64
- package/nodes/lights/LightContextNode.mjs +0 -35
- package/nodes/lights/LightNode.mjs +0 -58
- package/nodes/lights/LightsNode.mjs +0 -59
- package/nodes/loaders/NodeLoader.mjs +0 -66
- package/nodes/loaders/NodeMaterialLoader.mjs +0 -24
- package/nodes/loaders/NodeObjectLoader.mjs +0 -40
- package/nodes/materials/LineBasicNodeMaterial.mjs +0 -27
- package/nodes/materials/Materials.mjs +0 -28
- package/nodes/materials/MeshBasicNodeMaterial.mjs +0 -28
- package/nodes/materials/MeshStandardNodeMaterial.mjs +0 -41
- package/nodes/materials/NodeMaterial.mjs +0 -64
- package/nodes/materials/PointsNodeMaterial.mjs +0 -30
- package/nodes/math/CondNode.mjs +0 -38
- package/nodes/math/MathNode.mjs +0 -163
- package/nodes/math/OperatorNode.mjs +0 -103
- package/nodes/procedural/CheckerNode.mjs +0 -21
- package/nodes/utils/ArrayElementNode.mjs +0 -19
- package/nodes/utils/ConvertNode.mjs +0 -25
- package/nodes/utils/JoinNode.mjs +0 -26
- package/nodes/utils/MatcapUVNode.mjs +0 -16
- package/nodes/utils/OscNode.mjs +0 -50
- package/nodes/utils/SplitNode.mjs +0 -45
- package/nodes/utils/SpriteSheetUVNode.mjs +0 -40
- package/nodes/utils/TimerNode.mjs +0 -44
- package/objects/GroundProjectedEnv.mjs +0 -130
- package/objects/Lensflare.mjs +0 -262
- package/objects/LightningStorm.mjs +0 -110
- package/objects/MarchingCubes.mjs +0 -457
- package/objects/Reflector.mjs +0 -166
- package/objects/ReflectorForSSRPass.mjs +0 -247
- package/objects/ReflectorRTT.mjs +0 -10
- package/objects/Refractor.mjs +0 -178
- package/objects/ShadowMesh.mjs +0 -41
- package/objects/Sky.mjs +0 -124
- package/objects/Water.mjs +0 -235
- package/objects/Water2.mjs +0 -252
- package/offscreen/jank.mjs +0 -27
- package/offscreen/offscreen.mjs +0 -5
- package/offscreen/scene.mjs +0 -52
- package/physics/AmmoPhysics.mjs +0 -165
- package/postprocessing/AdaptiveToneMappingPass.mjs +0 -221
- package/postprocessing/AfterimagePass.mjs +0 -55
- package/postprocessing/BloomPass.mjs +0 -90
- package/postprocessing/BokehPass.mjs +0 -76
- package/postprocessing/ClearPass.mjs +0 -27
- package/postprocessing/CubeTexturePass.mjs +0 -49
- package/postprocessing/DotScreenPass.mjs +0 -40
- package/postprocessing/EffectComposer.mjs +0 -139
- package/postprocessing/FilmPass.mjs +0 -42
- package/postprocessing/GlitchPass.mjs +0 -75
- package/postprocessing/HalftonePass.mjs +0 -44
- package/postprocessing/LUTPass.mjs +0 -136
- package/postprocessing/MaskPass.mjs +0 -60
- package/postprocessing/OutlinePass.mjs +0 -438
- package/postprocessing/Pass.mjs +0 -37
- package/postprocessing/RenderPass.mjs +0 -48
- package/postprocessing/RenderPixelatedPass.mjs +0 -199
- package/postprocessing/SAOPass.mjs +0 -282
- package/postprocessing/SMAAPass.mjs +0 -112
- package/postprocessing/SSAARenderPass.mjs +0 -170
- package/postprocessing/SSAOPass.mjs +0 -265
- package/postprocessing/SSRPass.mjs +0 -432
- package/postprocessing/SavePass.mjs +0 -37
- package/postprocessing/ShaderPass.mjs +0 -39
- package/postprocessing/TAARenderPass.mjs +0 -88
- package/postprocessing/TexturePass.mjs +0 -39
- package/postprocessing/UnrealBloomPass.mjs +0 -220
- package/renderers/CSS2DRenderer.mjs +0 -112
- package/renderers/CSS3DRenderer.mjs +0 -133
- package/renderers/Projector.mjs +0 -511
- package/renderers/SVGRenderer.mjs +0 -306
- package/renderers/nodes/accessors/CameraNode.mjs +0 -63
- package/renderers/nodes/accessors/ModelNode.mjs +0 -61
- package/renderers/nodes/accessors/ModelViewProjectionNode.mjs +0 -21
- package/renderers/nodes/accessors/NormalNode.mjs +0 -61
- package/renderers/nodes/accessors/PositionNode.mjs +0 -30
- package/renderers/nodes/accessors/UVNode.mjs +0 -13
- package/renderers/nodes/core/AttributeNode.mjs +0 -35
- package/renderers/nodes/core/InputNode.mjs +0 -31
- package/renderers/nodes/core/Node.mjs +0 -34
- package/renderers/nodes/core/NodeAttribute.mjs +0 -10
- package/renderers/nodes/core/NodeBuilder.mjs +0 -243
- package/renderers/nodes/core/NodeFrame.mjs +0 -35
- package/renderers/nodes/core/NodeSlot.mjs +0 -10
- package/renderers/nodes/core/NodeUniform.mjs +0 -18
- package/renderers/nodes/core/NodeVary.mjs +0 -11
- package/renderers/nodes/core/VaryNode.mjs +0 -22
- package/renderers/nodes/core/constants.mjs +0 -22
- package/renderers/nodes/inputs/ColorNode.mjs +0 -11
- package/renderers/nodes/inputs/FloatNode.mjs +0 -11
- package/renderers/nodes/inputs/Matrix3Node.mjs +0 -12
- package/renderers/nodes/inputs/Matrix4Node.mjs +0 -12
- package/renderers/nodes/inputs/TextureNode.mjs +0 -20
- package/renderers/nodes/inputs/Vector2Node.mjs +0 -11
- package/renderers/nodes/inputs/Vector3Node.mjs +0 -12
- package/renderers/nodes/inputs/Vector4Node.mjs +0 -12
- package/renderers/nodes/math/MathNode.mjs +0 -55
- package/renderers/nodes/math/OperatorNode.mjs +0 -42
- package/renderers/nodes/utils/SwitchNode.mjs +0 -20
- package/renderers/nodes/utils/TimerNode.mjs +0 -14
- package/renderers/webgpu/WebGPU.mjs +0 -24
- package/renderers/webgpu/WebGPUAttributes.mjs +0 -69
- package/renderers/webgpu/WebGPUBackground.mjs +0 -61
- package/renderers/webgpu/WebGPUBinding.mjs +0 -14
- package/renderers/webgpu/WebGPUBindings.mjs +0 -155
- package/renderers/webgpu/WebGPUComputePipelines.mjs +0 -44
- package/renderers/webgpu/WebGPUGeometries.mjs +0 -41
- package/renderers/webgpu/WebGPUInfo.mjs +0 -46
- package/renderers/webgpu/WebGPUObjects.mjs +0 -25
- package/renderers/webgpu/WebGPUProperties.mjs +0 -22
- package/renderers/webgpu/WebGPURenderLists.mjs +0 -119
- package/renderers/webgpu/WebGPURenderPipelines.mjs +0 -545
- package/renderers/webgpu/WebGPURenderer.mjs +0 -574
- package/renderers/webgpu/WebGPUSampledTexture.mjs +0 -40
- package/renderers/webgpu/WebGPUSampler.mjs +0 -15
- package/renderers/webgpu/WebGPUStorageBuffer.mjs +0 -15
- package/renderers/webgpu/WebGPUTextureRenderer.mjs +0 -23
- package/renderers/webgpu/WebGPUTextureUtils.mjs +0 -98
- package/renderers/webgpu/WebGPUTextures.mjs +0 -484
- package/renderers/webgpu/WebGPUUniform.mjs +0 -81
- package/renderers/webgpu/WebGPUUniformsGroup.mjs +0 -176
- package/renderers/webgpu/constants.mjs +0 -230
- package/renderers/webgpu/nodes/ShaderLib.mjs +0 -42
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.mjs +0 -165
- package/renderers/webgpu/nodes/WebGPUNodeUniform.mjs +0 -73
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.mjs +0 -15
- package/renderers/webgpu/nodes/WebGPUNodes.mjs +0 -40
- package/shaders/ACESFilmicToneMappingShader.mjs +0 -48
- package/shaders/AfterimageShader.mjs +0 -32
- package/shaders/BasicShader.mjs +0 -12
- package/shaders/BleachBypassShader.mjs +0 -35
- package/shaders/BlendShader.mjs +0 -30
- package/shaders/BokehShader.mjs +0 -106
- package/shaders/BokehShader2.mjs +0 -269
- package/shaders/BrightnessContrastShader.mjs +0 -32
- package/shaders/ColorCorrectionShader.mjs +0 -30
- package/shaders/ColorifyShader.mjs +0 -28
- package/shaders/ConvolutionShader.mjs +0 -55
- package/shaders/CopyShader.mjs +0 -25
- package/shaders/DOFMipMapShader.mjs +0 -32
- package/shaders/DepthLimitedBlurShader.mjs +0 -114
- package/shaders/DigitalGlitch.mjs +0 -78
- package/shaders/DotScreenShader.mjs +0 -39
- package/shaders/FXAAShader.mjs +0 -1098
- package/shaders/FilmShader.mjs +0 -42
- package/shaders/FocusShader.mjs +0 -55
- package/shaders/FreiChenShader.mjs +0 -61
- package/shaders/FresnelShader.mjs +0 -47
- package/shaders/GammaCorrectionShader.mjs +0 -23
- package/shaders/GodRaysShader.mjs +0 -146
- package/shaders/HalftoneShader.mjs +0 -212
- package/shaders/HorizontalBlurShader.mjs +0 -43
- package/shaders/HorizontalTiltShiftShader.mjs +0 -37
- package/shaders/HueSaturationShader.mjs +0 -41
- package/shaders/KaleidoShader.mjs +0 -34
- package/shaders/LuminosityHighPassShader.mjs +0 -37
- package/shaders/LuminosityShader.mjs +0 -25
- package/shaders/MirrorShader.mjs +0 -35
- package/shaders/NormalMapShader.mjs +0 -31
- package/shaders/ParallaxShader.mjs +0 -113
- package/shaders/PixelShader.mjs +0 -28
- package/shaders/RGBShiftShader.mjs +0 -30
- package/shaders/SAOShader.mjs +0 -144
- package/shaders/SMAAShader.mjs +0 -272
- package/shaders/SSAOShader.mjs +0 -172
- package/shaders/SSRShader.mjs +0 -324
- package/shaders/SepiaShader.mjs +0 -29
- package/shaders/SobelOperatorShader.mjs +0 -44
- package/shaders/SubsurfaceScatteringShader.mjs +0 -59
- package/shaders/TechnicolorShader.mjs +0 -24
- package/shaders/ToneMapShader.mjs +0 -48
- package/shaders/ToonShader.mjs +0 -188
- package/shaders/TriangleBlurShader.mjs +0 -36
- package/shaders/UnpackDepthRGBAShader.mjs +0 -26
- package/shaders/VerticalBlurShader.mjs +0 -44
- package/shaders/VerticalTiltShiftShader.mjs +0 -37
- package/shaders/VignetteShader.mjs +0 -28
- package/shaders/VolumeShader.mjs +0 -178
- package/shaders/WaterRefractionShader.mjs +0 -57
- package/textures/FlakesTexture.mjs +0 -30
- package/types/helpers.mjs +0 -4
- package/utils/BufferGeometryUtils.mjs +0 -570
- package/utils/GeometryCompressionUtils.mjs +0 -547
- package/utils/GeometryUtils.mjs +0 -108
- package/utils/RoughnessMipmapper.mjs +0 -213
- package/utils/SceneUtils.mjs +0 -36
- package/utils/ShadowMapViewer.mjs +0 -114
- package/utils/SkeletonUtils.mjs +0 -292
- package/utils/UVsDebug.mjs +0 -85
- package/utils/WorkerPool.mjs +0 -62
- package/webxr/ARButton.mjs +0 -119
- package/webxr/OculusHandModel.mjs +0 -71
- package/webxr/OculusHandPointerModel.mjs +0 -207
- package/webxr/Text2D.mjs +0 -31
- package/webxr/VRButton.mjs +0 -105
- package/webxr/XRControllerModelFactory.mjs +0 -146
- package/webxr/XREstimatedLight.mjs +0 -126
- package/webxr/XRHandMeshModel.mjs +0 -73
- package/webxr/XRHandModelFactory.mjs +0 -61
- package/webxr/XRHandPrimitiveModel.mjs +0 -68
@@ -1,6 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
2
|
+
import { Matrix4, EventDispatcher, EllipseCurve, BufferGeometry, MathUtils, Vector3, GridHelper, LineBasicMaterial, Line, Raycaster, Vector2, Quaternion, Group, Box3, Sphere } from 'three';
|
3
|
+
|
4
|
+
//trackball state
|
4
5
|
const STATE = {
|
5
6
|
IDLE: Symbol(),
|
6
7
|
ROTATE: Symbol(),
|
@@ -20,300 +21,604 @@ const INPUT = {
|
|
20
21
|
TWO_FINGER: Symbol(),
|
21
22
|
MULT_FINGER: Symbol(),
|
22
23
|
CURSOR: Symbol()
|
23
|
-
};
|
24
|
+
}; //cursor center coordinates
|
25
|
+
|
24
26
|
const _center = {
|
25
27
|
x: 0,
|
26
28
|
y: 0
|
27
|
-
};
|
29
|
+
}; //transformation matrices for gizmos and camera
|
30
|
+
|
28
31
|
const _transformation = {
|
29
|
-
camera: new
|
30
|
-
gizmos: new
|
32
|
+
camera: new Matrix4(),
|
33
|
+
gizmos: new Matrix4()
|
34
|
+
}; //events
|
35
|
+
|
36
|
+
const _changeEvent = {
|
37
|
+
type: 'change'
|
38
|
+
};
|
39
|
+
const _startEvent = {
|
40
|
+
type: 'start'
|
41
|
+
};
|
42
|
+
const _endEvent = {
|
43
|
+
type: 'end'
|
31
44
|
};
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
45
|
+
/**
|
46
|
+
*
|
47
|
+
* @param {CamOrthographicCamera | PerspectiveCameraera} camera Virtual camera used in the scene
|
48
|
+
* @param {HTMLElement=null} domElement Renderer's dom element
|
49
|
+
* @param {Scene=null} scene The scene to be rendered
|
50
|
+
*/
|
51
|
+
|
52
|
+
class ArcballControls extends EventDispatcher {
|
53
|
+
constructor(_camera, _domElement = null, scene = null) {
|
37
54
|
super();
|
38
|
-
|
55
|
+
|
56
|
+
_defineProperty(this, "camera", void 0);
|
57
|
+
|
58
|
+
_defineProperty(this, "domElement", void 0);
|
59
|
+
|
60
|
+
_defineProperty(this, "scene", void 0);
|
61
|
+
|
62
|
+
_defineProperty(this, "mouseActions", void 0);
|
63
|
+
|
64
|
+
_defineProperty(this, "_mouseOp", void 0);
|
65
|
+
|
66
|
+
_defineProperty(this, "_v2_1", void 0);
|
67
|
+
|
68
|
+
_defineProperty(this, "_v3_1", void 0);
|
69
|
+
|
70
|
+
_defineProperty(this, "_v3_2", void 0);
|
71
|
+
|
72
|
+
_defineProperty(this, "_m4_1", void 0);
|
73
|
+
|
74
|
+
_defineProperty(this, "_m4_2", void 0);
|
75
|
+
|
76
|
+
_defineProperty(this, "_quat", void 0);
|
77
|
+
|
78
|
+
_defineProperty(this, "_translationMatrix", void 0);
|
79
|
+
|
80
|
+
_defineProperty(this, "_rotationMatrix", void 0);
|
81
|
+
|
82
|
+
_defineProperty(this, "_scaleMatrix", void 0);
|
83
|
+
|
84
|
+
_defineProperty(this, "_rotationAxis", void 0);
|
85
|
+
|
86
|
+
_defineProperty(this, "_cameraMatrixState", void 0);
|
87
|
+
|
88
|
+
_defineProperty(this, "_cameraProjectionState", void 0);
|
89
|
+
|
90
|
+
_defineProperty(this, "_fovState", void 0);
|
91
|
+
|
92
|
+
_defineProperty(this, "_upState", void 0);
|
93
|
+
|
94
|
+
_defineProperty(this, "_zoomState", void 0);
|
95
|
+
|
96
|
+
_defineProperty(this, "_nearPos", void 0);
|
97
|
+
|
98
|
+
_defineProperty(this, "_farPos", void 0);
|
99
|
+
|
100
|
+
_defineProperty(this, "_gizmoMatrixState", void 0);
|
101
|
+
|
102
|
+
_defineProperty(this, "_up0", void 0);
|
103
|
+
|
104
|
+
_defineProperty(this, "_zoom0", void 0);
|
105
|
+
|
106
|
+
_defineProperty(this, "_fov0", void 0);
|
107
|
+
|
108
|
+
_defineProperty(this, "_initialNear", void 0);
|
109
|
+
|
110
|
+
_defineProperty(this, "_nearPos0", void 0);
|
111
|
+
|
112
|
+
_defineProperty(this, "_initialFar", void 0);
|
113
|
+
|
114
|
+
_defineProperty(this, "_farPos0", void 0);
|
115
|
+
|
116
|
+
_defineProperty(this, "_cameraMatrixState0", void 0);
|
117
|
+
|
118
|
+
_defineProperty(this, "_gizmoMatrixState0", void 0);
|
119
|
+
|
120
|
+
_defineProperty(this, "_button", void 0);
|
121
|
+
|
122
|
+
_defineProperty(this, "_touchStart", void 0);
|
123
|
+
|
124
|
+
_defineProperty(this, "_touchCurrent", void 0);
|
125
|
+
|
126
|
+
_defineProperty(this, "_input", void 0);
|
127
|
+
|
128
|
+
_defineProperty(this, "_switchSensibility", void 0);
|
129
|
+
|
130
|
+
_defineProperty(this, "_startFingerDistance", void 0);
|
131
|
+
|
132
|
+
_defineProperty(this, "_currentFingerDistance", void 0);
|
133
|
+
|
134
|
+
_defineProperty(this, "_startFingerRotation", void 0);
|
135
|
+
|
136
|
+
_defineProperty(this, "_currentFingerRotation", void 0);
|
137
|
+
|
138
|
+
_defineProperty(this, "_devPxRatio", void 0);
|
139
|
+
|
140
|
+
_defineProperty(this, "_downValid", void 0);
|
141
|
+
|
142
|
+
_defineProperty(this, "_nclicks", void 0);
|
143
|
+
|
144
|
+
_defineProperty(this, "_downEvents", void 0);
|
145
|
+
|
146
|
+
_defineProperty(this, "_clickStart", void 0);
|
147
|
+
|
148
|
+
_defineProperty(this, "_maxDownTime", void 0);
|
149
|
+
|
150
|
+
_defineProperty(this, "_maxInterval", void 0);
|
151
|
+
|
152
|
+
_defineProperty(this, "_posThreshold", void 0);
|
153
|
+
|
154
|
+
_defineProperty(this, "_movementThreshold", void 0);
|
155
|
+
|
156
|
+
_defineProperty(this, "_currentCursorPosition", void 0);
|
157
|
+
|
158
|
+
_defineProperty(this, "_startCursorPosition", void 0);
|
159
|
+
|
160
|
+
_defineProperty(this, "_grid", void 0);
|
161
|
+
|
162
|
+
_defineProperty(this, "_gridPosition", void 0);
|
163
|
+
|
164
|
+
_defineProperty(this, "_gizmos", void 0);
|
165
|
+
|
166
|
+
_defineProperty(this, "_curvePts", void 0);
|
167
|
+
|
168
|
+
_defineProperty(this, "_timeStart", void 0);
|
169
|
+
|
170
|
+
_defineProperty(this, "_animationId", void 0);
|
171
|
+
|
172
|
+
_defineProperty(this, "focusAnimationTime", void 0);
|
173
|
+
|
174
|
+
_defineProperty(this, "_timePrev", void 0);
|
175
|
+
|
176
|
+
_defineProperty(this, "_timeCurrent", void 0);
|
177
|
+
|
178
|
+
_defineProperty(this, "_anglePrev", void 0);
|
179
|
+
|
180
|
+
_defineProperty(this, "_angleCurrent", void 0);
|
181
|
+
|
182
|
+
_defineProperty(this, "_cursorPosPrev", void 0);
|
183
|
+
|
184
|
+
_defineProperty(this, "_cursorPosCurr", void 0);
|
185
|
+
|
186
|
+
_defineProperty(this, "_wPrev", void 0);
|
187
|
+
|
188
|
+
_defineProperty(this, "_wCurr", void 0);
|
189
|
+
|
190
|
+
_defineProperty(this, "adjustNearFar", void 0);
|
191
|
+
|
192
|
+
_defineProperty(this, "scaleFactor", void 0);
|
193
|
+
|
194
|
+
_defineProperty(this, "dampingFactor", void 0);
|
195
|
+
|
196
|
+
_defineProperty(this, "wMax", void 0);
|
197
|
+
|
198
|
+
_defineProperty(this, "enableAnimations", void 0);
|
199
|
+
|
200
|
+
_defineProperty(this, "enableGrid", void 0);
|
201
|
+
|
202
|
+
_defineProperty(this, "cursorZoom", void 0);
|
203
|
+
|
204
|
+
_defineProperty(this, "minFov", void 0);
|
205
|
+
|
206
|
+
_defineProperty(this, "maxFov", void 0);
|
207
|
+
|
208
|
+
_defineProperty(this, "enabled", void 0);
|
209
|
+
|
210
|
+
_defineProperty(this, "enablePan", void 0);
|
211
|
+
|
212
|
+
_defineProperty(this, "enableRotate", void 0);
|
213
|
+
|
214
|
+
_defineProperty(this, "enableZoom", void 0);
|
215
|
+
|
216
|
+
_defineProperty(this, "minDistance", void 0);
|
217
|
+
|
218
|
+
_defineProperty(this, "maxDistance", void 0);
|
219
|
+
|
220
|
+
_defineProperty(this, "minZoom", void 0);
|
221
|
+
|
222
|
+
_defineProperty(this, "maxZoom", void 0);
|
223
|
+
|
224
|
+
_defineProperty(this, "target", void 0);
|
225
|
+
|
226
|
+
_defineProperty(this, "_currentTarget", void 0);
|
227
|
+
|
228
|
+
_defineProperty(this, "_tbRadius", void 0);
|
229
|
+
|
230
|
+
_defineProperty(this, "_state", void 0);
|
231
|
+
|
232
|
+
_defineProperty(this, "onWindowResize", () => {
|
39
233
|
const scale = (this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z) / 3;
|
234
|
+
|
40
235
|
if (this.camera) {
|
41
236
|
const tbRadius = this.calculateTbRadius(this.camera);
|
42
|
-
|
237
|
+
|
238
|
+
if (tbRadius !== undefined) {
|
43
239
|
this._tbRadius = tbRadius;
|
44
240
|
}
|
45
241
|
}
|
46
|
-
|
47
|
-
const
|
242
|
+
|
243
|
+
const newRadius = this._tbRadius / scale; // @ts-expect-error
|
244
|
+
|
245
|
+
const curve = new EllipseCurve(0, 0, newRadius, newRadius);
|
48
246
|
const points = curve.getPoints(this._curvePts);
|
49
|
-
const curveGeometry = new
|
247
|
+
const curveGeometry = new BufferGeometry().setFromPoints(points);
|
248
|
+
|
50
249
|
for (const gizmo in this._gizmos.children) {
|
51
250
|
const child = this._gizmos.children[gizmo];
|
52
251
|
child.geometry = curveGeometry;
|
53
252
|
}
|
253
|
+
|
54
254
|
this.dispatchEvent(_changeEvent);
|
55
|
-
};
|
56
|
-
|
255
|
+
});
|
256
|
+
|
257
|
+
_defineProperty(this, "onContextMenu", event => {
|
57
258
|
if (!this.enabled) {
|
58
259
|
return;
|
59
260
|
}
|
261
|
+
|
60
262
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
61
263
|
if (this.mouseActions[i].mouse == 2) {
|
264
|
+
//prevent only if button 2 is actually used
|
62
265
|
event.preventDefault();
|
63
266
|
break;
|
64
267
|
}
|
65
268
|
}
|
66
|
-
};
|
67
|
-
|
269
|
+
});
|
270
|
+
|
271
|
+
_defineProperty(this, "onPointerCancel", () => {
|
68
272
|
this._touchStart.splice(0, this._touchStart.length);
|
273
|
+
|
69
274
|
this._touchCurrent.splice(0, this._touchCurrent.length);
|
275
|
+
|
70
276
|
this._input = INPUT.NONE;
|
71
|
-
};
|
72
|
-
|
277
|
+
});
|
278
|
+
|
279
|
+
_defineProperty(this, "onPointerDown", event => {
|
73
280
|
if (event.button == 0 && event.isPrimary) {
|
74
281
|
this._downValid = true;
|
282
|
+
|
75
283
|
this._downEvents.push(event);
|
76
284
|
} else {
|
77
285
|
this._downValid = false;
|
78
286
|
}
|
79
|
-
|
287
|
+
|
288
|
+
if (event.pointerType == 'touch' && this._input != INPUT.CURSOR) {
|
80
289
|
this._touchStart.push(event);
|
290
|
+
|
81
291
|
this._touchCurrent.push(event);
|
292
|
+
|
82
293
|
switch (this._input) {
|
83
294
|
case INPUT.NONE:
|
295
|
+
//singleStart
|
84
296
|
this._input = INPUT.ONE_FINGER;
|
85
|
-
this.onSinglePanStart(event,
|
86
|
-
window.addEventListener(
|
87
|
-
window.addEventListener(
|
297
|
+
this.onSinglePanStart(event, 'ROTATE');
|
298
|
+
window.addEventListener('pointermove', this.onPointerMove);
|
299
|
+
window.addEventListener('pointerup', this.onPointerUp);
|
88
300
|
break;
|
301
|
+
|
89
302
|
case INPUT.ONE_FINGER:
|
90
303
|
case INPUT.ONE_FINGER_SWITCHED:
|
304
|
+
//doubleStart
|
91
305
|
this._input = INPUT.TWO_FINGER;
|
92
306
|
this.onRotateStart();
|
93
307
|
this.onPinchStart();
|
94
308
|
this.onDoublePanStart();
|
95
309
|
break;
|
310
|
+
|
96
311
|
case INPUT.TWO_FINGER:
|
312
|
+
//multipleStart
|
97
313
|
this._input = INPUT.MULT_FINGER;
|
98
314
|
this.onTriplePanStart();
|
99
315
|
break;
|
100
316
|
}
|
101
|
-
} else if (event.pointerType !=
|
317
|
+
} else if (event.pointerType != 'touch' && this._input == INPUT.NONE) {
|
102
318
|
let modifier = null;
|
319
|
+
|
103
320
|
if (event.ctrlKey || event.metaKey) {
|
104
|
-
modifier =
|
321
|
+
modifier = 'CTRL';
|
105
322
|
} else if (event.shiftKey) {
|
106
|
-
modifier =
|
323
|
+
modifier = 'SHIFT';
|
107
324
|
}
|
325
|
+
|
108
326
|
this._mouseOp = this.getOpFromAction(event.button, modifier);
|
327
|
+
|
109
328
|
if (this._mouseOp) {
|
110
|
-
window.addEventListener(
|
111
|
-
window.addEventListener(
|
329
|
+
window.addEventListener('pointermove', this.onPointerMove);
|
330
|
+
window.addEventListener('pointerup', this.onPointerUp); //singleStart
|
331
|
+
|
112
332
|
this._input = INPUT.CURSOR;
|
113
333
|
this._button = event.button;
|
114
334
|
this.onSinglePanStart(event, this._mouseOp);
|
115
335
|
}
|
116
336
|
}
|
117
|
-
};
|
118
|
-
|
119
|
-
|
337
|
+
});
|
338
|
+
|
339
|
+
_defineProperty(this, "onPointerMove", event => {
|
340
|
+
if (event.pointerType == 'touch' && this._input != INPUT.CURSOR) {
|
120
341
|
switch (this._input) {
|
121
342
|
case INPUT.ONE_FINGER:
|
343
|
+
//singleMove
|
122
344
|
this.updateTouchEvent(event);
|
123
345
|
this.onSinglePanMove(event, STATE.ROTATE);
|
124
346
|
break;
|
347
|
+
|
125
348
|
case INPUT.ONE_FINGER_SWITCHED:
|
126
349
|
const movement = this.calculatePointersDistance(this._touchCurrent[0], event) * this._devPxRatio;
|
350
|
+
|
127
351
|
if (movement >= this._switchSensibility) {
|
352
|
+
//singleMove
|
128
353
|
this._input = INPUT.ONE_FINGER;
|
129
354
|
this.updateTouchEvent(event);
|
130
|
-
this.onSinglePanStart(event,
|
355
|
+
this.onSinglePanStart(event, 'ROTATE');
|
131
356
|
break;
|
132
357
|
}
|
358
|
+
|
133
359
|
break;
|
360
|
+
|
134
361
|
case INPUT.TWO_FINGER:
|
362
|
+
//rotate/pan/pinchMove
|
135
363
|
this.updateTouchEvent(event);
|
136
364
|
this.onRotateMove();
|
137
365
|
this.onPinchMove();
|
138
366
|
this.onDoublePanMove();
|
139
367
|
break;
|
368
|
+
|
140
369
|
case INPUT.MULT_FINGER:
|
370
|
+
//multMove
|
141
371
|
this.updateTouchEvent(event);
|
142
372
|
this.onTriplePanMove();
|
143
373
|
break;
|
144
374
|
}
|
145
|
-
} else if (event.pointerType !=
|
375
|
+
} else if (event.pointerType != 'touch' && this._input == INPUT.CURSOR) {
|
146
376
|
let modifier = null;
|
377
|
+
|
147
378
|
if (event.ctrlKey || event.metaKey) {
|
148
|
-
modifier =
|
379
|
+
modifier = 'CTRL';
|
149
380
|
} else if (event.shiftKey) {
|
150
|
-
modifier =
|
381
|
+
modifier = 'SHIFT';
|
151
382
|
}
|
383
|
+
|
152
384
|
const mouseOpState = this.getOpStateFromAction(this._button, modifier);
|
385
|
+
|
153
386
|
if (mouseOpState) {
|
154
387
|
this.onSinglePanMove(event, mouseOpState);
|
155
388
|
}
|
156
|
-
}
|
389
|
+
} //checkDistance
|
390
|
+
|
391
|
+
|
157
392
|
if (this._downValid) {
|
158
393
|
const movement = this.calculatePointersDistance(this._downEvents[this._downEvents.length - 1], event) * this._devPxRatio;
|
394
|
+
|
159
395
|
if (movement > this._movementThreshold) {
|
160
396
|
this._downValid = false;
|
161
397
|
}
|
162
398
|
}
|
163
|
-
};
|
164
|
-
|
165
|
-
|
399
|
+
});
|
400
|
+
|
401
|
+
_defineProperty(this, "onPointerUp", event => {
|
402
|
+
if (event.pointerType == 'touch' && this._input != INPUT.CURSOR) {
|
166
403
|
const nTouch = this._touchCurrent.length;
|
404
|
+
|
167
405
|
for (let i = 0; i < nTouch; i++) {
|
168
406
|
if (this._touchCurrent[i].pointerId == event.pointerId) {
|
169
407
|
this._touchCurrent.splice(i, 1);
|
408
|
+
|
170
409
|
this._touchStart.splice(i, 1);
|
410
|
+
|
171
411
|
break;
|
172
412
|
}
|
173
413
|
}
|
414
|
+
|
174
415
|
switch (this._input) {
|
175
416
|
case INPUT.ONE_FINGER:
|
176
417
|
case INPUT.ONE_FINGER_SWITCHED:
|
177
|
-
|
178
|
-
window.removeEventListener(
|
418
|
+
//singleEnd
|
419
|
+
window.removeEventListener('pointermove', this.onPointerMove);
|
420
|
+
window.removeEventListener('pointerup', this.onPointerUp);
|
179
421
|
this._input = INPUT.NONE;
|
180
422
|
this.onSinglePanEnd();
|
181
423
|
break;
|
424
|
+
|
182
425
|
case INPUT.TWO_FINGER:
|
426
|
+
//doubleEnd
|
183
427
|
this.onDoublePanEnd();
|
184
428
|
this.onPinchEnd();
|
185
|
-
this.onRotateEnd();
|
429
|
+
this.onRotateEnd(); //switching to singleStart
|
430
|
+
|
186
431
|
this._input = INPUT.ONE_FINGER_SWITCHED;
|
187
432
|
break;
|
433
|
+
|
188
434
|
case INPUT.MULT_FINGER:
|
189
435
|
if (this._touchCurrent.length == 0) {
|
190
|
-
window.removeEventListener(
|
191
|
-
window.removeEventListener(
|
436
|
+
window.removeEventListener('pointermove', this.onPointerMove);
|
437
|
+
window.removeEventListener('pointerup', this.onPointerUp); //multCancel
|
438
|
+
|
192
439
|
this._input = INPUT.NONE;
|
193
440
|
this.onTriplePanEnd();
|
194
441
|
}
|
442
|
+
|
195
443
|
break;
|
196
444
|
}
|
197
|
-
} else if (event.pointerType !=
|
198
|
-
window.removeEventListener(
|
199
|
-
window.removeEventListener(
|
445
|
+
} else if (event.pointerType != 'touch' && this._input == INPUT.CURSOR) {
|
446
|
+
window.removeEventListener('pointermove', this.onPointerMove);
|
447
|
+
window.removeEventListener('pointerup', this.onPointerUp);
|
200
448
|
this._input = INPUT.NONE;
|
201
449
|
this.onSinglePanEnd();
|
202
450
|
this._button = -1;
|
203
451
|
}
|
452
|
+
|
204
453
|
if (event.isPrimary) {
|
205
454
|
if (this._downValid) {
|
206
455
|
const downTime = event.timeStamp - this._downEvents[this._downEvents.length - 1].timeStamp;
|
456
|
+
|
207
457
|
if (downTime <= this._maxDownTime) {
|
208
458
|
if (this._nclicks == 0) {
|
459
|
+
//first valid click detected
|
209
460
|
this._nclicks = 1;
|
210
461
|
this._clickStart = performance.now();
|
211
462
|
} else {
|
212
463
|
const clickInterval = event.timeStamp - this._clickStart;
|
464
|
+
|
213
465
|
const movement = this.calculatePointersDistance(this._downEvents[1], this._downEvents[0]) * this._devPxRatio;
|
466
|
+
|
214
467
|
if (clickInterval <= this._maxInterval && movement <= this._posThreshold) {
|
468
|
+
//second valid click detected
|
469
|
+
//fire double tap and reset values
|
215
470
|
this._nclicks = 0;
|
471
|
+
|
216
472
|
this._downEvents.splice(0, this._downEvents.length);
|
473
|
+
|
217
474
|
this.onDoubleTap(event);
|
218
475
|
} else {
|
476
|
+
//new 'first click'
|
219
477
|
this._nclicks = 1;
|
478
|
+
|
220
479
|
this._downEvents.shift();
|
480
|
+
|
221
481
|
this._clickStart = performance.now();
|
222
482
|
}
|
223
483
|
}
|
224
484
|
} else {
|
225
485
|
this._downValid = false;
|
226
486
|
this._nclicks = 0;
|
487
|
+
|
227
488
|
this._downEvents.splice(0, this._downEvents.length);
|
228
489
|
}
|
229
490
|
} else {
|
230
491
|
this._nclicks = 0;
|
492
|
+
|
231
493
|
this._downEvents.splice(0, this._downEvents.length);
|
232
494
|
}
|
233
495
|
}
|
234
|
-
};
|
235
|
-
|
236
|
-
|
496
|
+
});
|
497
|
+
|
498
|
+
_defineProperty(this, "onWheel", event => {
|
499
|
+
var _this$camera3;
|
500
|
+
|
237
501
|
if (this.enabled && this.enableZoom && this.domElement) {
|
238
502
|
let modifier = null;
|
503
|
+
|
239
504
|
if (event.ctrlKey || event.metaKey) {
|
240
|
-
modifier =
|
505
|
+
modifier = 'CTRL';
|
241
506
|
} else if (event.shiftKey) {
|
242
|
-
modifier =
|
507
|
+
modifier = 'SHIFT';
|
243
508
|
}
|
244
|
-
|
509
|
+
|
510
|
+
const mouseOp = this.getOpFromAction('WHEEL', modifier);
|
511
|
+
|
245
512
|
if (mouseOp) {
|
246
513
|
event.preventDefault();
|
247
514
|
this.dispatchEvent(_startEvent);
|
248
|
-
const notchDeltaY = 125;
|
515
|
+
const notchDeltaY = 125; //distance of one notch of mouse wheel
|
516
|
+
|
249
517
|
let sgn = event.deltaY / notchDeltaY;
|
250
518
|
let size = 1;
|
519
|
+
|
251
520
|
if (sgn > 0) {
|
252
521
|
size = 1 / this.scaleFactor;
|
253
522
|
} else if (sgn < 0) {
|
254
523
|
size = this.scaleFactor;
|
255
524
|
}
|
525
|
+
|
256
526
|
switch (mouseOp) {
|
257
|
-
case
|
527
|
+
case 'ZOOM':
|
258
528
|
this.updateTbState(STATE.SCALE, true);
|
529
|
+
|
259
530
|
if (sgn > 0) {
|
260
531
|
size = 1 / Math.pow(this.scaleFactor, sgn);
|
261
532
|
} else if (sgn < 0) {
|
262
533
|
size = Math.pow(this.scaleFactor, -sgn);
|
263
534
|
}
|
535
|
+
|
264
536
|
if (this.cursorZoom && this.enablePan) {
|
537
|
+
var _this$camera, _this$camera2;
|
538
|
+
|
265
539
|
let scalePoint;
|
266
|
-
|
267
|
-
|
540
|
+
|
541
|
+
if (((_this$camera = this.camera) === null || _this$camera === void 0 ? void 0 : _this$camera.type) === 'OrthographicCamera') {
|
542
|
+
var _this$unprojectOnTbPl;
|
543
|
+
|
544
|
+
scalePoint = (_this$unprojectOnTbPl = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement)) === null || _this$unprojectOnTbPl === void 0 ? void 0 : _this$unprojectOnTbPl.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._gizmos.position);
|
268
545
|
}
|
269
|
-
|
270
|
-
|
546
|
+
|
547
|
+
if (((_this$camera2 = this.camera) === null || _this$camera2 === void 0 ? void 0 : _this$camera2.type) === 'PerspectiveCamera') {
|
548
|
+
var _this$unprojectOnTbPl2;
|
549
|
+
|
550
|
+
scalePoint = (_this$unprojectOnTbPl2 = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement)) === null || _this$unprojectOnTbPl2 === void 0 ? void 0 : _this$unprojectOnTbPl2.applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
|
271
551
|
}
|
272
|
-
|
273
|
-
|
552
|
+
|
553
|
+
if (scalePoint !== undefined) this.applyTransformMatrix(this.applyScale(size, scalePoint));
|
274
554
|
} else {
|
275
555
|
this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
|
276
556
|
}
|
557
|
+
|
277
558
|
if (this._grid) {
|
278
559
|
this.disposeGrid();
|
279
560
|
this.drawGrid();
|
280
561
|
}
|
562
|
+
|
281
563
|
this.updateTbState(STATE.IDLE, false);
|
282
564
|
this.dispatchEvent(_changeEvent);
|
283
565
|
this.dispatchEvent(_endEvent);
|
284
566
|
break;
|
285
|
-
|
286
|
-
|
287
|
-
|
567
|
+
|
568
|
+
case 'FOV':
|
569
|
+
if (((_this$camera3 = this.camera) === null || _this$camera3 === void 0 ? void 0 : _this$camera3.type) === 'PerspectiveCamera') {
|
570
|
+
this.updateTbState(STATE.FOV, true); //Vertigo effect
|
571
|
+
// fov / 2
|
572
|
+
// |\
|
573
|
+
// | \
|
574
|
+
// | \
|
575
|
+
// x | \
|
576
|
+
// | \
|
577
|
+
// | \
|
578
|
+
// | _ _ _\
|
579
|
+
// y
|
580
|
+
//check for iOs shift shortcut
|
581
|
+
|
288
582
|
if (event.deltaX != 0) {
|
289
583
|
sgn = event.deltaX / notchDeltaY;
|
290
584
|
size = 1;
|
585
|
+
|
291
586
|
if (sgn > 0) {
|
292
587
|
size = 1 / Math.pow(this.scaleFactor, sgn);
|
293
588
|
} else if (sgn < 0) {
|
294
589
|
size = Math.pow(this.scaleFactor, -sgn);
|
295
590
|
}
|
296
591
|
}
|
592
|
+
|
297
593
|
this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
|
594
|
+
|
298
595
|
const x = this._v3_1.distanceTo(this._gizmos.position);
|
299
|
-
|
300
|
-
xNew =
|
301
|
-
|
302
|
-
|
596
|
+
|
597
|
+
let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
|
598
|
+
//check min and max distance
|
599
|
+
|
600
|
+
xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);
|
601
|
+
const y = x * Math.tan(MathUtils.DEG2RAD * this.camera.fov * 0.5); //calculate new fov
|
602
|
+
|
603
|
+
let newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2); //check min and max fov
|
604
|
+
|
303
605
|
if (newFov > this.maxFov) {
|
304
606
|
newFov = this.maxFov;
|
305
607
|
} else if (newFov < this.minFov) {
|
306
608
|
newFov = this.minFov;
|
307
609
|
}
|
308
|
-
|
610
|
+
|
611
|
+
const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
|
309
612
|
size = x / newDistance;
|
310
613
|
this.setFov(newFov);
|
311
614
|
this.applyTransformMatrix(this.applyScale(size, this._gizmos.position, false));
|
312
615
|
}
|
616
|
+
|
313
617
|
if (this._grid) {
|
314
618
|
this.disposeGrid();
|
315
619
|
this.drawGrid();
|
316
620
|
}
|
621
|
+
|
317
622
|
this.updateTbState(STATE.IDLE, false);
|
318
623
|
this.dispatchEvent(_changeEvent);
|
319
624
|
this.dispatchEvent(_endEvent);
|
@@ -321,16 +626,19 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
321
626
|
}
|
322
627
|
}
|
323
628
|
}
|
324
|
-
};
|
325
|
-
|
326
|
-
|
629
|
+
});
|
630
|
+
|
631
|
+
_defineProperty(this, "onSinglePanStart", (event, operation) => {
|
632
|
+
var _this$camera4;
|
633
|
+
|
327
634
|
if (this.enabled && this.domElement) {
|
328
635
|
this.dispatchEvent(_startEvent);
|
329
636
|
this.setCenter(event.clientX, event.clientY);
|
637
|
+
|
330
638
|
switch (operation) {
|
331
|
-
case
|
332
|
-
if (!this.enablePan)
|
333
|
-
|
639
|
+
case 'PAN':
|
640
|
+
if (!this.enablePan) return;
|
641
|
+
|
334
642
|
if (this._animationId != -1) {
|
335
643
|
cancelAnimationFrame(this._animationId);
|
336
644
|
this._animationId = -1;
|
@@ -338,48 +646,62 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
338
646
|
this.activateGizmos(false);
|
339
647
|
this.dispatchEvent(_changeEvent);
|
340
648
|
}
|
649
|
+
|
341
650
|
if (this.camera) {
|
342
651
|
this.updateTbState(STATE.PAN, true);
|
343
652
|
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
|
344
|
-
|
653
|
+
|
654
|
+
if (rayDir !== undefined) {
|
345
655
|
this._startCursorPosition.copy(rayDir);
|
346
656
|
}
|
657
|
+
|
347
658
|
if (this.enableGrid) {
|
348
659
|
this.drawGrid();
|
349
660
|
this.dispatchEvent(_changeEvent);
|
350
661
|
}
|
351
662
|
}
|
663
|
+
|
352
664
|
break;
|
353
|
-
|
354
|
-
|
355
|
-
|
665
|
+
|
666
|
+
case 'ROTATE':
|
667
|
+
if (!this.enableRotate) return;
|
668
|
+
|
356
669
|
if (this._animationId != -1) {
|
357
670
|
cancelAnimationFrame(this._animationId);
|
358
671
|
this._animationId = -1;
|
359
672
|
this._timeStart = -1;
|
360
673
|
}
|
674
|
+
|
361
675
|
if (this.camera) {
|
362
676
|
this.updateTbState(STATE.ROTATE, true);
|
363
677
|
const rayDir = this.unprojectOnTbSurface(this.camera, _center.x, _center.y, this.domElement, this._tbRadius);
|
364
|
-
|
678
|
+
|
679
|
+
if (rayDir !== undefined) {
|
365
680
|
this._startCursorPosition.copy(rayDir);
|
366
681
|
}
|
682
|
+
|
367
683
|
this.activateGizmos(true);
|
684
|
+
|
368
685
|
if (this.enableAnimations) {
|
369
686
|
this._timePrev = this._timeCurrent = performance.now();
|
370
687
|
this._angleCurrent = this._anglePrev = 0;
|
688
|
+
|
371
689
|
this._cursorPosPrev.copy(this._startCursorPosition);
|
690
|
+
|
372
691
|
this._cursorPosCurr.copy(this._cursorPosPrev);
|
692
|
+
|
373
693
|
this._wCurr = 0;
|
374
694
|
this._wPrev = this._wCurr;
|
375
695
|
}
|
376
696
|
}
|
697
|
+
|
377
698
|
this.dispatchEvent(_changeEvent);
|
378
699
|
break;
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
700
|
+
|
701
|
+
case 'FOV':
|
702
|
+
if (!this.enableZoom) return;
|
703
|
+
|
704
|
+
if (((_this$camera4 = this.camera) === null || _this$camera4 === void 0 ? void 0 : _this$camera4.type) === 'PerspectiveCamera') {
|
383
705
|
if (this._animationId != -1) {
|
384
706
|
cancelAnimationFrame(this._animationId);
|
385
707
|
this._animationId = -1;
|
@@ -387,14 +709,19 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
387
709
|
this.activateGizmos(false);
|
388
710
|
this.dispatchEvent(_changeEvent);
|
389
711
|
}
|
712
|
+
|
390
713
|
this.updateTbState(STATE.FOV, true);
|
714
|
+
|
391
715
|
this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
716
|
+
|
392
717
|
this._currentCursorPosition.copy(this._startCursorPosition);
|
393
718
|
}
|
719
|
+
|
394
720
|
break;
|
395
|
-
|
396
|
-
|
397
|
-
|
721
|
+
|
722
|
+
case 'ZOOM':
|
723
|
+
if (!this.enableZoom) return;
|
724
|
+
|
398
725
|
if (this._animationId != -1) {
|
399
726
|
cancelAnimationFrame(this._animationId);
|
400
727
|
this._animationId = -1;
|
@@ -402,182 +729,234 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
402
729
|
this.activateGizmos(false);
|
403
730
|
this.dispatchEvent(_changeEvent);
|
404
731
|
}
|
732
|
+
|
405
733
|
this.updateTbState(STATE.SCALE, true);
|
734
|
+
|
406
735
|
this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
736
|
+
|
407
737
|
this._currentCursorPosition.copy(this._startCursorPosition);
|
738
|
+
|
408
739
|
break;
|
409
740
|
}
|
410
741
|
}
|
411
|
-
};
|
412
|
-
|
413
|
-
|
742
|
+
});
|
743
|
+
|
744
|
+
_defineProperty(this, "onSinglePanMove", (event, opState) => {
|
745
|
+
var _this$camera5;
|
746
|
+
|
414
747
|
if (this.enabled && this.domElement) {
|
415
748
|
const restart = opState != this._state;
|
416
749
|
this.setCenter(event.clientX, event.clientY);
|
750
|
+
|
417
751
|
switch (opState) {
|
418
752
|
case STATE.PAN:
|
419
753
|
if (this.enablePan && this.camera) {
|
420
754
|
if (restart) {
|
755
|
+
//switch to pan operation
|
421
756
|
this.dispatchEvent(_endEvent);
|
422
757
|
this.dispatchEvent(_startEvent);
|
423
758
|
this.updateTbState(opState, true);
|
424
759
|
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
|
425
|
-
|
760
|
+
|
761
|
+
if (rayDir !== undefined) {
|
426
762
|
this._startCursorPosition.copy(rayDir);
|
427
763
|
}
|
764
|
+
|
428
765
|
if (this.enableGrid) {
|
429
766
|
this.drawGrid();
|
430
767
|
}
|
768
|
+
|
431
769
|
this.activateGizmos(false);
|
432
770
|
} else {
|
771
|
+
//continue with pan operation
|
433
772
|
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement);
|
434
|
-
|
773
|
+
|
774
|
+
if (rayDir !== undefined) {
|
435
775
|
this._currentCursorPosition.copy(rayDir);
|
436
776
|
}
|
777
|
+
|
437
778
|
this.applyTransformMatrix(this.pan(this._startCursorPosition, this._currentCursorPosition));
|
438
779
|
}
|
439
780
|
}
|
781
|
+
|
440
782
|
break;
|
783
|
+
|
441
784
|
case STATE.ROTATE:
|
442
785
|
if (this.enableRotate && this.camera) {
|
443
786
|
if (restart) {
|
787
|
+
//switch to rotate operation
|
444
788
|
this.dispatchEvent(_endEvent);
|
445
789
|
this.dispatchEvent(_startEvent);
|
446
790
|
this.updateTbState(opState, true);
|
447
|
-
const rayDir = this.unprojectOnTbSurface(
|
448
|
-
|
449
|
-
|
450
|
-
_center.y,
|
451
|
-
this.domElement,
|
452
|
-
this._tbRadius
|
453
|
-
);
|
454
|
-
if (rayDir !== void 0) {
|
791
|
+
const rayDir = this.unprojectOnTbSurface(this.camera, _center.x, _center.y, this.domElement, this._tbRadius);
|
792
|
+
|
793
|
+
if (rayDir !== undefined) {
|
455
794
|
this._startCursorPosition.copy(rayDir);
|
456
795
|
}
|
796
|
+
|
457
797
|
if (this.enableGrid) {
|
458
798
|
this.disposeGrid();
|
459
799
|
}
|
800
|
+
|
460
801
|
this.activateGizmos(true);
|
461
802
|
} else {
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
this.domElement,
|
467
|
-
this._tbRadius
|
468
|
-
);
|
469
|
-
if (rayDir !== void 0) {
|
803
|
+
//continue with rotate operation
|
804
|
+
const rayDir = this.unprojectOnTbSurface(this.camera, _center.x, _center.y, this.domElement, this._tbRadius);
|
805
|
+
|
806
|
+
if (rayDir !== undefined) {
|
470
807
|
this._currentCursorPosition.copy(rayDir);
|
471
808
|
}
|
809
|
+
|
472
810
|
const distance = this._startCursorPosition.distanceTo(this._currentCursorPosition);
|
811
|
+
|
473
812
|
const angle = this._startCursorPosition.angleTo(this._currentCursorPosition);
|
474
|
-
|
475
|
-
this.
|
476
|
-
|
477
|
-
);
|
813
|
+
|
814
|
+
const amount = Math.max(distance / this._tbRadius, angle); //effective rotation angle
|
815
|
+
|
816
|
+
this.applyTransformMatrix(this.rotate(this.calculateRotationAxis(this._startCursorPosition, this._currentCursorPosition), amount));
|
817
|
+
|
478
818
|
if (this.enableAnimations) {
|
479
819
|
this._timePrev = this._timeCurrent;
|
480
820
|
this._timeCurrent = performance.now();
|
481
821
|
this._anglePrev = this._angleCurrent;
|
482
822
|
this._angleCurrent = amount;
|
823
|
+
|
483
824
|
this._cursorPosPrev.copy(this._cursorPosCurr);
|
825
|
+
|
484
826
|
this._cursorPosCurr.copy(this._currentCursorPosition);
|
827
|
+
|
485
828
|
this._wPrev = this._wCurr;
|
486
|
-
this._wCurr = this.calculateAngularSpeed(
|
487
|
-
this._anglePrev,
|
488
|
-
this._angleCurrent,
|
489
|
-
this._timePrev,
|
490
|
-
this._timeCurrent
|
491
|
-
);
|
829
|
+
this._wCurr = this.calculateAngularSpeed(this._anglePrev, this._angleCurrent, this._timePrev, this._timeCurrent);
|
492
830
|
}
|
493
831
|
}
|
494
832
|
}
|
833
|
+
|
495
834
|
break;
|
835
|
+
|
496
836
|
case STATE.SCALE:
|
497
837
|
if (this.enableZoom) {
|
498
838
|
if (restart) {
|
839
|
+
//switch to zoom operation
|
499
840
|
this.dispatchEvent(_endEvent);
|
500
841
|
this.dispatchEvent(_startEvent);
|
501
842
|
this.updateTbState(opState, true);
|
843
|
+
|
502
844
|
this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
845
|
+
|
503
846
|
this._currentCursorPosition.copy(this._startCursorPosition);
|
847
|
+
|
504
848
|
if (this.enableGrid) {
|
505
849
|
this.disposeGrid();
|
506
850
|
}
|
851
|
+
|
507
852
|
this.activateGizmos(false);
|
508
853
|
} else {
|
509
|
-
|
854
|
+
//continue with zoom operation
|
855
|
+
const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
|
856
|
+
|
510
857
|
this._currentCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
858
|
+
|
511
859
|
const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
|
512
860
|
let size = 1;
|
861
|
+
|
513
862
|
if (movement < 0) {
|
514
863
|
size = 1 / Math.pow(this.scaleFactor, -movement * screenNotches);
|
515
864
|
} else if (movement > 0) {
|
516
865
|
size = Math.pow(this.scaleFactor, movement * screenNotches);
|
517
866
|
}
|
867
|
+
|
518
868
|
this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
|
519
869
|
}
|
520
870
|
}
|
871
|
+
|
521
872
|
break;
|
873
|
+
|
522
874
|
case STATE.FOV:
|
523
|
-
if (this.enableZoom && ((
|
875
|
+
if (this.enableZoom && ((_this$camera5 = this.camera) === null || _this$camera5 === void 0 ? void 0 : _this$camera5.type) === 'PerspectiveCamera') {
|
524
876
|
if (restart) {
|
877
|
+
//switch to fov operation
|
525
878
|
this.dispatchEvent(_endEvent);
|
526
879
|
this.dispatchEvent(_startEvent);
|
527
880
|
this.updateTbState(opState, true);
|
881
|
+
|
528
882
|
this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
883
|
+
|
529
884
|
this._currentCursorPosition.copy(this._startCursorPosition);
|
885
|
+
|
530
886
|
if (this.enableGrid) {
|
531
887
|
this.disposeGrid();
|
532
888
|
}
|
889
|
+
|
533
890
|
this.activateGizmos(false);
|
534
891
|
} else {
|
535
|
-
|
892
|
+
//continue with fov operation
|
893
|
+
const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
|
894
|
+
|
536
895
|
this._currentCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
896
|
+
|
537
897
|
const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
|
538
898
|
let size = 1;
|
899
|
+
|
539
900
|
if (movement < 0) {
|
540
901
|
size = 1 / Math.pow(this.scaleFactor, -movement * screenNotches);
|
541
902
|
} else if (movement > 0) {
|
542
903
|
size = Math.pow(this.scaleFactor, movement * screenNotches);
|
543
904
|
}
|
905
|
+
|
544
906
|
this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
|
907
|
+
|
545
908
|
const x = this._v3_1.distanceTo(this._gizmos.position);
|
546
|
-
|
547
|
-
xNew =
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
const
|
909
|
+
|
910
|
+
let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
|
911
|
+
//check min and max distance
|
912
|
+
|
913
|
+
xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);
|
914
|
+
const y = x * Math.tan(MathUtils.DEG2RAD * this._fovState * 0.5); //calculate new fov
|
915
|
+
|
916
|
+
let newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2); //check min and max fov
|
917
|
+
|
918
|
+
newFov = MathUtils.clamp(newFov, this.minFov, this.maxFov);
|
919
|
+
const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
|
552
920
|
size = x / newDistance;
|
921
|
+
|
553
922
|
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
|
923
|
+
|
554
924
|
this.setFov(newFov);
|
555
|
-
this.applyTransformMatrix(this.applyScale(size, this._v3_2, false));
|
925
|
+
this.applyTransformMatrix(this.applyScale(size, this._v3_2, false)); //adjusting distance
|
926
|
+
|
556
927
|
const direction = this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(newDistance / x);
|
928
|
+
|
557
929
|
this._m4_1.makeTranslation(direction.x, direction.y, direction.z);
|
558
930
|
}
|
559
931
|
}
|
932
|
+
|
560
933
|
break;
|
561
934
|
}
|
935
|
+
|
562
936
|
this.dispatchEvent(_changeEvent);
|
563
937
|
}
|
564
|
-
};
|
565
|
-
|
938
|
+
});
|
939
|
+
|
940
|
+
_defineProperty(this, "onSinglePanEnd", () => {
|
566
941
|
if (this._state == STATE.ROTATE) {
|
567
942
|
if (!this.enableRotate) {
|
568
943
|
return;
|
569
944
|
}
|
945
|
+
|
570
946
|
if (this.enableAnimations) {
|
947
|
+
//perform rotation animation
|
571
948
|
const deltaTime = performance.now() - this._timeCurrent;
|
949
|
+
|
572
950
|
if (deltaTime < 120) {
|
573
951
|
const w = Math.abs((this._wPrev + this._wCurr) / 2);
|
574
952
|
const self = this;
|
575
|
-
this._animationId = window.requestAnimationFrame(function(t) {
|
953
|
+
this._animationId = window.requestAnimationFrame(function (t) {
|
576
954
|
self.updateTbState(STATE.ANIMATION_ROTATE, true);
|
577
955
|
const rotationAxis = self.calculateRotationAxis(self._cursorPosPrev, self._cursorPosCurr);
|
578
956
|
self.onRotationAnim(t, rotationAxis, Math.min(w, self.wMax));
|
579
957
|
});
|
580
958
|
} else {
|
959
|
+
//cursor has been standing still for over 120 ms since last movement
|
581
960
|
this.updateTbState(STATE.IDLE, false);
|
582
961
|
this.activateGizmos(false);
|
583
962
|
this.dispatchEvent(_changeEvent);
|
@@ -589,26 +968,33 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
589
968
|
}
|
590
969
|
} else if (this._state == STATE.PAN || this._state == STATE.IDLE) {
|
591
970
|
this.updateTbState(STATE.IDLE, false);
|
971
|
+
|
592
972
|
if (this.enableGrid) {
|
593
973
|
this.disposeGrid();
|
594
974
|
}
|
975
|
+
|
595
976
|
this.activateGizmos(false);
|
596
977
|
this.dispatchEvent(_changeEvent);
|
597
978
|
}
|
979
|
+
|
598
980
|
this.dispatchEvent(_endEvent);
|
599
|
-
};
|
600
|
-
|
981
|
+
});
|
982
|
+
|
983
|
+
_defineProperty(this, "onDoubleTap", event => {
|
601
984
|
if (this.enabled && this.enablePan && this.scene && this.camera && this.domElement) {
|
602
985
|
this.dispatchEvent(_startEvent);
|
603
986
|
this.setCenter(event.clientX, event.clientY);
|
604
987
|
const hitP = this.unprojectOnObj(this.getCursorNDC(_center.x, _center.y, this.domElement), this.camera);
|
988
|
+
|
605
989
|
if (hitP && this.enableAnimations) {
|
606
990
|
const self = this;
|
991
|
+
|
607
992
|
if (this._animationId != -1) {
|
608
993
|
window.cancelAnimationFrame(this._animationId);
|
609
994
|
}
|
995
|
+
|
610
996
|
this._timeStart = -1;
|
611
|
-
this._animationId = window.requestAnimationFrame(function(t) {
|
997
|
+
this._animationId = window.requestAnimationFrame(function (t) {
|
612
998
|
self.updateTbState(STATE.ANIMATION_FOCUS, true);
|
613
999
|
self.onFocusAnim(t, hitP, self._cameraMatrixState, self._gizmoMatrixState);
|
614
1000
|
});
|
@@ -619,90 +1005,106 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
619
1005
|
this.dispatchEvent(_changeEvent);
|
620
1006
|
}
|
621
1007
|
}
|
1008
|
+
|
622
1009
|
this.dispatchEvent(_endEvent);
|
623
|
-
};
|
624
|
-
|
1010
|
+
});
|
1011
|
+
|
1012
|
+
_defineProperty(this, "onDoublePanStart", () => {
|
625
1013
|
if (this.enabled && this.enablePan && this.camera && this.domElement) {
|
626
1014
|
this.dispatchEvent(_startEvent);
|
627
1015
|
this.updateTbState(STATE.PAN, true);
|
628
|
-
this.setCenter(
|
629
|
-
(this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2,
|
630
|
-
(this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
|
631
|
-
);
|
1016
|
+
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
632
1017
|
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement, true);
|
633
|
-
|
1018
|
+
|
1019
|
+
if (rayDir !== undefined) {
|
634
1020
|
this._startCursorPosition.copy(rayDir);
|
635
1021
|
}
|
1022
|
+
|
636
1023
|
this._currentCursorPosition.copy(this._startCursorPosition);
|
1024
|
+
|
637
1025
|
this.activateGizmos(false);
|
638
1026
|
}
|
639
|
-
};
|
640
|
-
|
1027
|
+
});
|
1028
|
+
|
1029
|
+
_defineProperty(this, "onDoublePanMove", () => {
|
641
1030
|
if (this.enabled && this.enablePan && this.camera && this.domElement) {
|
642
|
-
this.setCenter(
|
643
|
-
|
644
|
-
(this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
|
645
|
-
);
|
1031
|
+
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
1032
|
+
|
646
1033
|
if (this._state != STATE.PAN) {
|
647
1034
|
this.updateTbState(STATE.PAN, true);
|
1035
|
+
|
648
1036
|
this._startCursorPosition.copy(this._currentCursorPosition);
|
649
1037
|
}
|
1038
|
+
|
650
1039
|
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement, true);
|
651
|
-
if (rayDir !==
|
652
|
-
this._currentCursorPosition.copy(rayDir);
|
1040
|
+
if (rayDir !== undefined) this._currentCursorPosition.copy(rayDir);
|
653
1041
|
this.applyTransformMatrix(this.pan(this._startCursorPosition, this._currentCursorPosition, true));
|
654
1042
|
this.dispatchEvent(_changeEvent);
|
655
1043
|
}
|
656
|
-
};
|
657
|
-
|
1044
|
+
});
|
1045
|
+
|
1046
|
+
_defineProperty(this, "onDoublePanEnd", () => {
|
658
1047
|
this.updateTbState(STATE.IDLE, false);
|
659
1048
|
this.dispatchEvent(_endEvent);
|
660
|
-
};
|
661
|
-
|
662
|
-
|
1049
|
+
});
|
1050
|
+
|
1051
|
+
_defineProperty(this, "onRotateStart", () => {
|
663
1052
|
if (this.enabled && this.enableRotate) {
|
1053
|
+
var _this$camera6;
|
1054
|
+
|
664
1055
|
this.dispatchEvent(_startEvent);
|
665
|
-
this.updateTbState(STATE.ZROTATE, true);
|
1056
|
+
this.updateTbState(STATE.ZROTATE, true); //this._startFingerRotation = event.rotation;
|
1057
|
+
|
666
1058
|
this._startFingerRotation = this.getAngle(this._touchCurrent[1], this._touchCurrent[0]) + this.getAngle(this._touchStart[1], this._touchStart[0]);
|
667
1059
|
this._currentFingerRotation = this._startFingerRotation;
|
668
|
-
(
|
1060
|
+
(_this$camera6 = this.camera) === null || _this$camera6 === void 0 ? void 0 : _this$camera6.getWorldDirection(this._rotationAxis); //rotation axis
|
1061
|
+
|
669
1062
|
if (!this.enablePan && !this.enableZoom) {
|
670
1063
|
this.activateGizmos(true);
|
671
1064
|
}
|
672
1065
|
}
|
673
|
-
};
|
674
|
-
|
675
|
-
|
1066
|
+
});
|
1067
|
+
|
1068
|
+
_defineProperty(this, "onRotateMove", () => {
|
676
1069
|
if (this.enabled && this.enableRotate && this.camera && this.domElement) {
|
677
|
-
this.setCenter(
|
678
|
-
(this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2,
|
679
|
-
(this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2
|
680
|
-
);
|
1070
|
+
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
681
1071
|
let rotationPoint;
|
1072
|
+
|
682
1073
|
if (this._state != STATE.ZROTATE) {
|
683
1074
|
this.updateTbState(STATE.ZROTATE, true);
|
684
1075
|
this._startFingerRotation = this._currentFingerRotation;
|
685
|
-
}
|
1076
|
+
} //this._currentFingerRotation = event.rotation;
|
1077
|
+
|
1078
|
+
|
686
1079
|
this._currentFingerRotation = this.getAngle(this._touchCurrent[1], this._touchCurrent[0]) + this.getAngle(this._touchStart[1], this._touchStart[0]);
|
1080
|
+
|
687
1081
|
if (!this.enablePan) {
|
688
|
-
rotationPoint = new
|
1082
|
+
rotationPoint = new Vector3().setFromMatrixPosition(this._gizmoMatrixState);
|
689
1083
|
} else if (this.camera) {
|
1084
|
+
var _this$unprojectOnTbPl3;
|
1085
|
+
|
690
1086
|
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
|
691
|
-
|
1087
|
+
|
1088
|
+
rotationPoint = (_this$unprojectOnTbPl3 = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) === null || _this$unprojectOnTbPl3 === void 0 ? void 0 : _this$unprojectOnTbPl3.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._v3_2);
|
692
1089
|
}
|
693
|
-
|
694
|
-
|
1090
|
+
|
1091
|
+
const amount = MathUtils.DEG2RAD * (this._startFingerRotation - this._currentFingerRotation);
|
1092
|
+
|
1093
|
+
if (rotationPoint !== undefined) {
|
695
1094
|
this.applyTransformMatrix(this.zRotate(rotationPoint, amount));
|
696
1095
|
}
|
1096
|
+
|
697
1097
|
this.dispatchEvent(_changeEvent);
|
698
1098
|
}
|
699
|
-
};
|
700
|
-
|
1099
|
+
});
|
1100
|
+
|
1101
|
+
_defineProperty(this, "onRotateEnd", () => {
|
701
1102
|
this.updateTbState(STATE.IDLE, false);
|
702
1103
|
this.activateGizmos(false);
|
703
1104
|
this.dispatchEvent(_endEvent);
|
704
|
-
};
|
705
|
-
|
1105
|
+
});
|
1106
|
+
|
1107
|
+
_defineProperty(this, "onPinchStart", () => {
|
706
1108
|
if (this.enabled && this.enableZoom) {
|
707
1109
|
this.dispatchEvent(_startEvent);
|
708
1110
|
this.updateTbState(STATE.SCALE, true);
|
@@ -710,407 +1112,583 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
710
1112
|
this._currentFingerDistance = this._startFingerDistance;
|
711
1113
|
this.activateGizmos(false);
|
712
1114
|
}
|
713
|
-
};
|
714
|
-
|
715
|
-
|
1115
|
+
});
|
1116
|
+
|
1117
|
+
_defineProperty(this, "onPinchMove", () => {
|
716
1118
|
if (this.enabled && this.enableZoom && this.domElement) {
|
717
|
-
this.setCenter(
|
718
|
-
|
719
|
-
|
720
|
-
);
|
721
|
-
const minDistance = 12;
|
1119
|
+
this.setCenter((this._touchCurrent[0].clientX + this._touchCurrent[1].clientX) / 2, (this._touchCurrent[0].clientY + this._touchCurrent[1].clientY) / 2);
|
1120
|
+
const minDistance = 12; //minimum distance between fingers (in css pixels)
|
1121
|
+
|
722
1122
|
if (this._state != STATE.SCALE) {
|
723
1123
|
this._startFingerDistance = this._currentFingerDistance;
|
724
1124
|
this.updateTbState(STATE.SCALE, true);
|
725
1125
|
}
|
726
|
-
|
727
|
-
|
728
|
-
minDistance * this._devPxRatio
|
729
|
-
);
|
1126
|
+
|
1127
|
+
this._currentFingerDistance = Math.max(this.calculatePointersDistance(this._touchCurrent[0], this._touchCurrent[1]), minDistance * this._devPxRatio);
|
730
1128
|
const amount = this._currentFingerDistance / this._startFingerDistance;
|
731
1129
|
let scalePoint;
|
1130
|
+
|
732
1131
|
if (!this.enablePan) {
|
733
1132
|
scalePoint = this._gizmos.position;
|
734
1133
|
} else {
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
1134
|
+
var _this$camera7, _this$camera8;
|
1135
|
+
|
1136
|
+
if (((_this$camera7 = this.camera) === null || _this$camera7 === void 0 ? void 0 : _this$camera7.type) === 'OrthographicCamera') {
|
1137
|
+
var _this$unprojectOnTbPl4;
|
1138
|
+
|
1139
|
+
scalePoint = (_this$unprojectOnTbPl4 = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) === null || _this$unprojectOnTbPl4 === void 0 ? void 0 : _this$unprojectOnTbPl4.applyQuaternion(this.camera.quaternion).multiplyScalar(1 / this.camera.zoom).add(this._gizmos.position);
|
1140
|
+
} else if (((_this$camera8 = this.camera) === null || _this$camera8 === void 0 ? void 0 : _this$camera8.type) === 'PerspectiveCamera') {
|
1141
|
+
var _this$unprojectOnTbPl5;
|
1142
|
+
|
1143
|
+
scalePoint = (_this$unprojectOnTbPl5 = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement)) === null || _this$unprojectOnTbPl5 === void 0 ? void 0 : _this$unprojectOnTbPl5.applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
|
739
1144
|
}
|
740
1145
|
}
|
741
|
-
|
1146
|
+
|
1147
|
+
if (scalePoint !== undefined) {
|
742
1148
|
this.applyTransformMatrix(this.applyScale(amount, scalePoint));
|
743
1149
|
}
|
1150
|
+
|
744
1151
|
this.dispatchEvent(_changeEvent);
|
745
1152
|
}
|
746
|
-
};
|
747
|
-
|
1153
|
+
});
|
1154
|
+
|
1155
|
+
_defineProperty(this, "onPinchEnd", () => {
|
748
1156
|
this.updateTbState(STATE.IDLE, false);
|
749
1157
|
this.dispatchEvent(_endEvent);
|
750
|
-
};
|
751
|
-
|
1158
|
+
});
|
1159
|
+
|
1160
|
+
_defineProperty(this, "onTriplePanStart", () => {
|
752
1161
|
if (this.enabled && this.enableZoom && this.domElement) {
|
753
1162
|
this.dispatchEvent(_startEvent);
|
754
|
-
this.updateTbState(STATE.SCALE, true);
|
1163
|
+
this.updateTbState(STATE.SCALE, true); //const center = event.center;
|
1164
|
+
|
755
1165
|
let clientX = 0;
|
756
1166
|
let clientY = 0;
|
757
1167
|
const nFingers = this._touchCurrent.length;
|
1168
|
+
|
758
1169
|
for (let i = 0; i < nFingers; i++) {
|
759
1170
|
clientX += this._touchCurrent[i].clientX;
|
760
1171
|
clientY += this._touchCurrent[i].clientY;
|
761
1172
|
}
|
1173
|
+
|
762
1174
|
this.setCenter(clientX / nFingers, clientY / nFingers);
|
1175
|
+
|
763
1176
|
this._startCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
1177
|
+
|
764
1178
|
this._currentCursorPosition.copy(this._startCursorPosition);
|
765
1179
|
}
|
766
|
-
};
|
767
|
-
|
1180
|
+
});
|
1181
|
+
|
1182
|
+
_defineProperty(this, "onTriplePanMove", () => {
|
768
1183
|
if (this.enabled && this.enableZoom && this.camera && this.domElement) {
|
1184
|
+
// fov / 2
|
1185
|
+
// |\
|
1186
|
+
// | \
|
1187
|
+
// | \
|
1188
|
+
// x | \
|
1189
|
+
// | \
|
1190
|
+
// | \
|
1191
|
+
// | _ _ _\
|
1192
|
+
// y
|
1193
|
+
//const center = event.center;
|
769
1194
|
let clientX = 0;
|
770
1195
|
let clientY = 0;
|
771
1196
|
const nFingers = this._touchCurrent.length;
|
1197
|
+
|
772
1198
|
for (let i = 0; i < nFingers; i++) {
|
773
1199
|
clientX += this._touchCurrent[i].clientX;
|
774
1200
|
clientY += this._touchCurrent[i].clientY;
|
775
1201
|
}
|
1202
|
+
|
776
1203
|
this.setCenter(clientX / nFingers, clientY / nFingers);
|
777
|
-
const screenNotches = 8;
|
1204
|
+
const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
|
1205
|
+
|
778
1206
|
this._currentCursorPosition.setY(this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
|
1207
|
+
|
779
1208
|
const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
|
780
1209
|
let size = 1;
|
1210
|
+
|
781
1211
|
if (movement < 0) {
|
782
1212
|
size = 1 / Math.pow(this.scaleFactor, -movement * screenNotches);
|
783
1213
|
} else if (movement > 0) {
|
784
1214
|
size = Math.pow(this.scaleFactor, movement * screenNotches);
|
785
1215
|
}
|
1216
|
+
|
786
1217
|
this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
|
1218
|
+
|
787
1219
|
const x = this._v3_1.distanceTo(this._gizmos.position);
|
788
|
-
|
789
|
-
xNew =
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
const
|
1220
|
+
|
1221
|
+
let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
|
1222
|
+
//check min and max distance
|
1223
|
+
|
1224
|
+
xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);
|
1225
|
+
const y = x * Math.tan(MathUtils.DEG2RAD * this._fovState * 0.5); //calculate new fov
|
1226
|
+
|
1227
|
+
let newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2); //check min and max fov
|
1228
|
+
|
1229
|
+
newFov = MathUtils.clamp(newFov, this.minFov, this.maxFov);
|
1230
|
+
const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
|
794
1231
|
size = x / newDistance;
|
1232
|
+
|
795
1233
|
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
|
1234
|
+
|
796
1235
|
this.setFov(newFov);
|
797
|
-
this.applyTransformMatrix(this.applyScale(size, this._v3_2, false));
|
1236
|
+
this.applyTransformMatrix(this.applyScale(size, this._v3_2, false)); //adjusting distance
|
1237
|
+
|
798
1238
|
const direction = this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(newDistance / x);
|
1239
|
+
|
799
1240
|
this._m4_1.makeTranslation(direction.x, direction.y, direction.z);
|
1241
|
+
|
800
1242
|
this.dispatchEvent(_changeEvent);
|
801
1243
|
}
|
802
|
-
};
|
803
|
-
|
1244
|
+
});
|
1245
|
+
|
1246
|
+
_defineProperty(this, "onTriplePanEnd", () => {
|
804
1247
|
this.updateTbState(STATE.IDLE, false);
|
805
|
-
this.dispatchEvent(_endEvent);
|
806
|
-
};
|
807
|
-
|
1248
|
+
this.dispatchEvent(_endEvent); //this.dispatchEvent( _changeEvent );
|
1249
|
+
});
|
1250
|
+
|
1251
|
+
_defineProperty(this, "setCenter", (clientX, clientY) => {
|
808
1252
|
_center.x = clientX;
|
809
1253
|
_center.y = clientY;
|
810
|
-
};
|
811
|
-
|
812
|
-
|
813
|
-
this.setMouseAction(
|
814
|
-
this.setMouseAction(
|
815
|
-
this.setMouseAction(
|
816
|
-
this.setMouseAction(
|
817
|
-
this.setMouseAction(
|
818
|
-
this.setMouseAction(
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
const
|
1254
|
+
});
|
1255
|
+
|
1256
|
+
_defineProperty(this, "initializeMouseActions", () => {
|
1257
|
+
this.setMouseAction('PAN', 0, 'CTRL');
|
1258
|
+
this.setMouseAction('PAN', 2);
|
1259
|
+
this.setMouseAction('ROTATE', 0);
|
1260
|
+
this.setMouseAction('ZOOM', 'WHEEL');
|
1261
|
+
this.setMouseAction('ZOOM', 1);
|
1262
|
+
this.setMouseAction('FOV', 'WHEEL', 'SHIFT');
|
1263
|
+
this.setMouseAction('FOV', 1, 'SHIFT');
|
1264
|
+
});
|
1265
|
+
|
1266
|
+
_defineProperty(this, "setMouseAction", (operation, mouse, key = null) => {
|
1267
|
+
const operationInput = ['PAN', 'ROTATE', 'ZOOM', 'FOV'];
|
1268
|
+
const mouseInput = [0, 1, 2, 'WHEEL'];
|
1269
|
+
const keyInput = ['CTRL', 'SHIFT', null];
|
824
1270
|
let state;
|
1271
|
+
|
825
1272
|
if (!operationInput.includes(operation) || !mouseInput.includes(mouse) || !keyInput.includes(key)) {
|
1273
|
+
//invalid parameters
|
826
1274
|
return false;
|
827
1275
|
}
|
828
|
-
|
829
|
-
|
1276
|
+
|
1277
|
+
if (mouse == 'WHEEL') {
|
1278
|
+
if (operation != 'ZOOM' && operation != 'FOV') {
|
1279
|
+
//cannot associate 2D operation to 1D input
|
830
1280
|
return false;
|
831
1281
|
}
|
832
1282
|
}
|
1283
|
+
|
833
1284
|
switch (operation) {
|
834
|
-
case
|
1285
|
+
case 'PAN':
|
835
1286
|
state = STATE.PAN;
|
836
1287
|
break;
|
837
|
-
|
1288
|
+
|
1289
|
+
case 'ROTATE':
|
838
1290
|
state = STATE.ROTATE;
|
839
1291
|
break;
|
840
|
-
|
1292
|
+
|
1293
|
+
case 'ZOOM':
|
841
1294
|
state = STATE.SCALE;
|
842
1295
|
break;
|
843
|
-
|
1296
|
+
|
1297
|
+
case 'FOV':
|
844
1298
|
state = STATE.FOV;
|
845
1299
|
break;
|
846
1300
|
}
|
1301
|
+
|
847
1302
|
const action = {
|
848
|
-
operation,
|
849
|
-
mouse,
|
850
|
-
key,
|
851
|
-
state
|
1303
|
+
operation: operation,
|
1304
|
+
mouse: mouse,
|
1305
|
+
key: key,
|
1306
|
+
state: state
|
852
1307
|
};
|
1308
|
+
|
853
1309
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
854
1310
|
if (this.mouseActions[i].mouse == action.mouse && this.mouseActions[i].key == action.key) {
|
855
1311
|
this.mouseActions.splice(i, 1, action);
|
856
1312
|
return true;
|
857
1313
|
}
|
858
1314
|
}
|
1315
|
+
|
859
1316
|
this.mouseActions.push(action);
|
860
1317
|
return true;
|
861
|
-
};
|
862
|
-
|
1318
|
+
});
|
1319
|
+
|
1320
|
+
_defineProperty(this, "getOpFromAction", (mouse, key) => {
|
863
1321
|
let action;
|
1322
|
+
|
864
1323
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
865
1324
|
action = this.mouseActions[i];
|
1325
|
+
|
866
1326
|
if (action.mouse == mouse && action.key == key) {
|
867
1327
|
return action.operation;
|
868
1328
|
}
|
869
1329
|
}
|
1330
|
+
|
870
1331
|
if (key) {
|
871
1332
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
872
1333
|
action = this.mouseActions[i];
|
1334
|
+
|
873
1335
|
if (action.mouse == mouse && action.key == null) {
|
874
1336
|
return action.operation;
|
875
1337
|
}
|
876
1338
|
}
|
877
1339
|
}
|
1340
|
+
|
878
1341
|
return null;
|
879
|
-
};
|
880
|
-
|
1342
|
+
});
|
1343
|
+
|
1344
|
+
_defineProperty(this, "getOpStateFromAction", (mouse, key) => {
|
881
1345
|
let action;
|
1346
|
+
|
882
1347
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
883
1348
|
action = this.mouseActions[i];
|
1349
|
+
|
884
1350
|
if (action.mouse == mouse && action.key == key) {
|
885
1351
|
return action.state;
|
886
1352
|
}
|
887
1353
|
}
|
1354
|
+
|
888
1355
|
if (key) {
|
889
1356
|
for (let i = 0; i < this.mouseActions.length; i++) {
|
890
1357
|
action = this.mouseActions[i];
|
1358
|
+
|
891
1359
|
if (action.mouse == mouse && action.key == null) {
|
892
1360
|
return action.state;
|
893
1361
|
}
|
894
1362
|
}
|
895
1363
|
}
|
1364
|
+
|
896
1365
|
return null;
|
897
|
-
};
|
898
|
-
|
1366
|
+
});
|
1367
|
+
|
1368
|
+
_defineProperty(this, "getAngle", (p1, p2) => {
|
899
1369
|
return Math.atan2(p2.clientY - p1.clientY, p2.clientX - p1.clientX) * 180 / Math.PI;
|
900
|
-
};
|
901
|
-
|
1370
|
+
});
|
1371
|
+
|
1372
|
+
_defineProperty(this, "updateTouchEvent", event => {
|
902
1373
|
for (let i = 0; i < this._touchCurrent.length; i++) {
|
903
1374
|
if (this._touchCurrent[i].pointerId == event.pointerId) {
|
904
1375
|
this._touchCurrent.splice(i, 1, event);
|
1376
|
+
|
905
1377
|
break;
|
906
1378
|
}
|
907
1379
|
}
|
908
|
-
};
|
909
|
-
|
1380
|
+
});
|
1381
|
+
|
1382
|
+
_defineProperty(this, "calculateAngularSpeed", (p0, p1, t0, t1) => {
|
910
1383
|
const s = p1 - p0;
|
911
|
-
const t = (t1 - t0) /
|
1384
|
+
const t = (t1 - t0) / 1000;
|
1385
|
+
|
912
1386
|
if (t == 0) {
|
913
1387
|
return 0;
|
914
1388
|
}
|
1389
|
+
|
915
1390
|
return s / t;
|
916
|
-
};
|
917
|
-
|
1391
|
+
});
|
1392
|
+
|
1393
|
+
_defineProperty(this, "calculatePointersDistance", (p0, p1) => {
|
918
1394
|
return Math.sqrt(Math.pow(p1.clientX - p0.clientX, 2) + Math.pow(p1.clientY - p0.clientY, 2));
|
919
|
-
};
|
920
|
-
|
1395
|
+
});
|
1396
|
+
|
1397
|
+
_defineProperty(this, "calculateRotationAxis", (vec1, vec2) => {
|
921
1398
|
this._rotationMatrix.extractRotation(this._cameraMatrixState);
|
1399
|
+
|
922
1400
|
this._quat.setFromRotationMatrix(this._rotationMatrix);
|
1401
|
+
|
923
1402
|
this._rotationAxis.crossVectors(vec1, vec2).applyQuaternion(this._quat);
|
1403
|
+
|
924
1404
|
return this._rotationAxis.normalize().clone();
|
925
|
-
};
|
926
|
-
|
1405
|
+
});
|
1406
|
+
|
1407
|
+
_defineProperty(this, "calculateTbRadius", camera => {
|
927
1408
|
const factor = 0.67;
|
928
|
-
const distance =
|
929
|
-
|
930
|
-
|
931
|
-
const
|
1409
|
+
const distance = camera.position.distanceTo(this._gizmos.position);
|
1410
|
+
|
1411
|
+
if (camera.type == 'PerspectiveCamera') {
|
1412
|
+
const halfFovV = MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
|
1413
|
+
|
1414
|
+
const halfFovH = Math.atan(camera.aspect * Math.tan(halfFovV)); //horizontal fov/2 in radians
|
1415
|
+
|
932
1416
|
return Math.tan(Math.min(halfFovV, halfFovH)) * distance * factor;
|
933
|
-
} else if (
|
934
|
-
return Math.min(
|
1417
|
+
} else if (camera.type == 'OrthographicCamera') {
|
1418
|
+
return Math.min(camera.top, camera.right) * factor;
|
935
1419
|
}
|
936
|
-
};
|
937
|
-
|
1420
|
+
});
|
1421
|
+
|
1422
|
+
_defineProperty(this, "focus", (point, size, amount = 1) => {
|
938
1423
|
if (this.camera) {
|
939
|
-
const focusPoint = point.clone();
|
1424
|
+
const focusPoint = point.clone(); //move center of camera (along with gizmos) towards point of interest
|
1425
|
+
|
940
1426
|
focusPoint.sub(this._gizmos.position).multiplyScalar(amount);
|
1427
|
+
|
941
1428
|
this._translationMatrix.makeTranslation(focusPoint.x, focusPoint.y, focusPoint.z);
|
1429
|
+
|
942
1430
|
const gizmoStateTemp = this._gizmoMatrixState.clone();
|
1431
|
+
|
943
1432
|
this._gizmoMatrixState.premultiply(this._translationMatrix);
|
1433
|
+
|
944
1434
|
this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
1435
|
+
|
945
1436
|
const cameraStateTemp = this._cameraMatrixState.clone();
|
1437
|
+
|
946
1438
|
this._cameraMatrixState.premultiply(this._translationMatrix);
|
947
|
-
|
1439
|
+
|
1440
|
+
this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale); //apply zoom
|
1441
|
+
|
1442
|
+
|
948
1443
|
if (this.enableZoom) {
|
949
1444
|
this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
|
950
1445
|
}
|
1446
|
+
|
951
1447
|
this._gizmoMatrixState.copy(gizmoStateTemp);
|
1448
|
+
|
952
1449
|
this._cameraMatrixState.copy(cameraStateTemp);
|
953
1450
|
}
|
954
|
-
};
|
955
|
-
|
956
|
-
|
1451
|
+
});
|
1452
|
+
|
1453
|
+
_defineProperty(this, "drawGrid", () => {
|
957
1454
|
if (this.scene) {
|
958
|
-
|
1455
|
+
var _this$camera9, _this$camera10;
|
1456
|
+
|
1457
|
+
const color = 0x888888;
|
959
1458
|
const multiplier = 3;
|
960
1459
|
let size, divisions, maxLength, tick;
|
961
|
-
|
1460
|
+
|
1461
|
+
if (((_this$camera9 = this.camera) === null || _this$camera9 === void 0 ? void 0 : _this$camera9.type) === 'OrthographicCamera') {
|
962
1462
|
const width = this.camera.right - this.camera.left;
|
963
1463
|
const height = this.camera.bottom - this.camera.top;
|
964
1464
|
maxLength = Math.max(width, height);
|
965
1465
|
tick = maxLength / 20;
|
966
1466
|
size = maxLength / this.camera.zoom * multiplier;
|
967
1467
|
divisions = size / tick * this.camera.zoom;
|
968
|
-
} else if (((
|
1468
|
+
} else if (((_this$camera10 = this.camera) === null || _this$camera10 === void 0 ? void 0 : _this$camera10.type) === 'PerspectiveCamera') {
|
969
1469
|
const distance = this.camera.position.distanceTo(this._gizmos.position);
|
970
|
-
const halfFovV =
|
1470
|
+
const halfFovV = MathUtils.DEG2RAD * this.camera.fov * 0.5;
|
971
1471
|
const halfFovH = Math.atan(this.camera.aspect * Math.tan(halfFovV));
|
972
1472
|
maxLength = Math.tan(Math.max(halfFovV, halfFovH)) * distance * 2;
|
973
1473
|
tick = maxLength / 20;
|
974
1474
|
size = maxLength * multiplier;
|
975
1475
|
divisions = size / tick;
|
976
1476
|
}
|
1477
|
+
|
977
1478
|
if (this._grid == null && this.camera) {
|
978
|
-
this._grid = new
|
1479
|
+
this._grid = new GridHelper(size, divisions, color, color);
|
1480
|
+
|
979
1481
|
this._grid.position.copy(this._gizmos.position);
|
1482
|
+
|
980
1483
|
this._gridPosition.copy(this._grid.position);
|
1484
|
+
|
981
1485
|
this._grid.quaternion.copy(this.camera.quaternion);
|
1486
|
+
|
982
1487
|
this._grid.rotateX(Math.PI * 0.5);
|
1488
|
+
|
983
1489
|
this.scene.add(this._grid);
|
984
1490
|
}
|
985
1491
|
}
|
986
|
-
};
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
);
|
992
|
-
}
|
993
|
-
|
994
|
-
this.domElement
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
this.domElement.
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1492
|
+
});
|
1493
|
+
|
1494
|
+
_defineProperty(this, "connect", domElement => {
|
1495
|
+
// https://github.com/mrdoob/three.js/issues/20575
|
1496
|
+
if (domElement === document) {
|
1497
|
+
console.error('THREE.ArcballControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
this.domElement = domElement; // disables touch scroll
|
1501
|
+
// touch-action needs to be defined for pointer events to work on mobile
|
1502
|
+
// https://stackoverflow.com/a/48254578
|
1503
|
+
|
1504
|
+
this.domElement.style.touchAction = 'none';
|
1505
|
+
this.domElement.addEventListener('contextmenu', this.onContextMenu);
|
1506
|
+
this.domElement.addEventListener('pointerdown', this.onPointerDown);
|
1507
|
+
this.domElement.addEventListener('pointercancel', this.onPointerCancel);
|
1508
|
+
this.domElement.addEventListener('wheel', this.onWheel);
|
1509
|
+
});
|
1510
|
+
|
1511
|
+
_defineProperty(this, "dispose", () => {
|
1512
|
+
var _this$domElement, _this$domElement2, _this$domElement3, _this$domElement4, _this$scene;
|
1513
|
+
|
1002
1514
|
if (this._animationId != -1) {
|
1003
1515
|
window.cancelAnimationFrame(this._animationId);
|
1004
1516
|
}
|
1005
|
-
|
1006
|
-
(
|
1007
|
-
(
|
1008
|
-
(
|
1009
|
-
|
1010
|
-
window.removeEventListener(
|
1011
|
-
window.removeEventListener(
|
1012
|
-
(
|
1517
|
+
|
1518
|
+
(_this$domElement = this.domElement) === null || _this$domElement === void 0 ? void 0 : _this$domElement.removeEventListener('pointerdown', this.onPointerDown);
|
1519
|
+
(_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.removeEventListener('pointercancel', this.onPointerCancel);
|
1520
|
+
(_this$domElement3 = this.domElement) === null || _this$domElement3 === void 0 ? void 0 : _this$domElement3.removeEventListener('wheel', this.onWheel);
|
1521
|
+
(_this$domElement4 = this.domElement) === null || _this$domElement4 === void 0 ? void 0 : _this$domElement4.removeEventListener('contextmenu', this.onContextMenu);
|
1522
|
+
window.removeEventListener('pointermove', this.onPointerMove);
|
1523
|
+
window.removeEventListener('pointerup', this.onPointerUp);
|
1524
|
+
window.removeEventListener('resize', this.onWindowResize);
|
1525
|
+
(_this$scene = this.scene) === null || _this$scene === void 0 ? void 0 : _this$scene.remove(this._gizmos);
|
1013
1526
|
this.disposeGrid();
|
1014
|
-
};
|
1015
|
-
|
1527
|
+
});
|
1528
|
+
|
1529
|
+
_defineProperty(this, "disposeGrid", () => {
|
1016
1530
|
if (this._grid && this.scene) {
|
1017
1531
|
this.scene.remove(this._grid);
|
1018
1532
|
this._grid = null;
|
1019
1533
|
}
|
1020
|
-
};
|
1021
|
-
|
1534
|
+
});
|
1535
|
+
|
1536
|
+
_defineProperty(this, "easeOutCubic", t => {
|
1022
1537
|
return 1 - Math.pow(1 - t, 3);
|
1023
|
-
};
|
1024
|
-
|
1538
|
+
});
|
1539
|
+
|
1540
|
+
_defineProperty(this, "activateGizmos", isActive => {
|
1025
1541
|
for (const gizmo of this._gizmos.children) {
|
1026
|
-
|
1027
|
-
|
1542
|
+
gizmo.material.setValues({
|
1543
|
+
opacity: isActive ? 1 : 0.6
|
1544
|
+
});
|
1028
1545
|
}
|
1029
|
-
};
|
1030
|
-
|
1546
|
+
});
|
1547
|
+
|
1548
|
+
_defineProperty(this, "getCursorNDC", (cursorX, cursorY, canvas) => {
|
1031
1549
|
const canvasRect = canvas.getBoundingClientRect();
|
1550
|
+
|
1032
1551
|
this._v2_1.setX((cursorX - canvasRect.left) / canvasRect.width * 2 - 1);
|
1552
|
+
|
1033
1553
|
this._v2_1.setY((canvasRect.bottom - cursorY) / canvasRect.height * 2 - 1);
|
1554
|
+
|
1034
1555
|
return this._v2_1.clone();
|
1035
|
-
};
|
1036
|
-
|
1037
|
-
|
1556
|
+
});
|
1557
|
+
|
1558
|
+
_defineProperty(this, "getCursorPosition", (cursorX, cursorY, canvas) => {
|
1559
|
+
var _this$camera11;
|
1560
|
+
|
1038
1561
|
this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
|
1039
|
-
|
1562
|
+
|
1563
|
+
if (((_this$camera11 = this.camera) === null || _this$camera11 === void 0 ? void 0 : _this$camera11.type) === 'OrthographicCamera') {
|
1040
1564
|
this._v2_1.x *= (this.camera.right - this.camera.left) * 0.5;
|
1041
1565
|
this._v2_1.y *= (this.camera.top - this.camera.bottom) * 0.5;
|
1042
1566
|
}
|
1567
|
+
|
1043
1568
|
return this._v2_1.clone();
|
1044
|
-
};
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1569
|
+
});
|
1570
|
+
|
1571
|
+
_defineProperty(this, "setCamera", camera => {
|
1572
|
+
if (camera) {
|
1573
|
+
camera.lookAt(this.target);
|
1574
|
+
camera.updateMatrix(); //setting state
|
1575
|
+
|
1576
|
+
if ((camera === null || camera === void 0 ? void 0 : camera.type) == 'PerspectiveCamera') {
|
1577
|
+
this._fov0 = camera.fov;
|
1578
|
+
this._fovState = camera.fov;
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
this._cameraMatrixState0.copy(camera.matrix);
|
1582
|
+
|
1054
1583
|
this._cameraMatrixState.copy(this._cameraMatrixState0);
|
1055
|
-
|
1056
|
-
this.
|
1584
|
+
|
1585
|
+
this._cameraProjectionState.copy(camera.projectionMatrix);
|
1586
|
+
|
1587
|
+
this._zoom0 = camera.zoom;
|
1057
1588
|
this._zoomState = this._zoom0;
|
1058
|
-
this._initialNear =
|
1059
|
-
this._nearPos0 =
|
1589
|
+
this._initialNear = camera.near;
|
1590
|
+
this._nearPos0 = camera.position.distanceTo(this.target) - camera.near;
|
1060
1591
|
this._nearPos = this._initialNear;
|
1061
|
-
this._initialFar =
|
1062
|
-
this._farPos0 =
|
1592
|
+
this._initialFar = camera.far;
|
1593
|
+
this._farPos0 = camera.position.distanceTo(this.target) - camera.far;
|
1063
1594
|
this._farPos = this._initialFar;
|
1064
|
-
|
1065
|
-
this.
|
1066
|
-
|
1067
|
-
this.camera.
|
1068
|
-
|
1069
|
-
|
1595
|
+
|
1596
|
+
this._up0.copy(camera.up);
|
1597
|
+
|
1598
|
+
this._upState.copy(camera.up);
|
1599
|
+
|
1600
|
+
this.camera = camera;
|
1601
|
+
this.camera.updateProjectionMatrix(); //making gizmos
|
1602
|
+
|
1603
|
+
const tbRadius = this.calculateTbRadius(camera);
|
1604
|
+
|
1605
|
+
if (tbRadius !== undefined) {
|
1070
1606
|
this._tbRadius = tbRadius;
|
1071
1607
|
}
|
1608
|
+
|
1072
1609
|
this.makeGizmos(this.target, this._tbRadius);
|
1073
1610
|
}
|
1074
|
-
};
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
const
|
1079
|
-
const
|
1080
|
-
|
1081
|
-
const
|
1082
|
-
|
1083
|
-
const
|
1084
|
-
|
1611
|
+
});
|
1612
|
+
|
1613
|
+
_defineProperty(this, "makeGizmos", (tbCenter, tbRadius) => {
|
1614
|
+
// @ts-expect-error
|
1615
|
+
const curve = new EllipseCurve(0, 0, tbRadius, tbRadius);
|
1616
|
+
const points = curve.getPoints(this._curvePts); //geometry
|
1617
|
+
|
1618
|
+
const curveGeometry = new BufferGeometry().setFromPoints(points); //material
|
1619
|
+
|
1620
|
+
const curveMaterialX = new LineBasicMaterial({
|
1621
|
+
color: 0xff8080,
|
1622
|
+
fog: false,
|
1623
|
+
transparent: true,
|
1624
|
+
opacity: 0.6
|
1625
|
+
});
|
1626
|
+
const curveMaterialY = new LineBasicMaterial({
|
1627
|
+
color: 0x80ff80,
|
1628
|
+
fog: false,
|
1629
|
+
transparent: true,
|
1630
|
+
opacity: 0.6
|
1631
|
+
});
|
1632
|
+
const curveMaterialZ = new LineBasicMaterial({
|
1633
|
+
color: 0x8080ff,
|
1634
|
+
fog: false,
|
1635
|
+
transparent: true,
|
1636
|
+
opacity: 0.6
|
1637
|
+
}); //line
|
1638
|
+
|
1639
|
+
const gizmoX = new Line(curveGeometry, curveMaterialX);
|
1640
|
+
const gizmoY = new Line(curveGeometry, curveMaterialY);
|
1641
|
+
const gizmoZ = new Line(curveGeometry, curveMaterialZ);
|
1085
1642
|
const rotation = Math.PI * 0.5;
|
1086
1643
|
gizmoX.rotation.x = rotation;
|
1087
|
-
gizmoY.rotation.y = rotation;
|
1644
|
+
gizmoY.rotation.y = rotation; //setting state
|
1645
|
+
|
1088
1646
|
this._gizmoMatrixState0.identity().setPosition(tbCenter);
|
1647
|
+
|
1089
1648
|
this._gizmoMatrixState.copy(this._gizmoMatrixState0);
|
1649
|
+
|
1090
1650
|
if (this.camera && this.camera.zoom != 1) {
|
1651
|
+
//adapt gizmos size to camera zoom
|
1091
1652
|
const size = 1 / this.camera.zoom;
|
1653
|
+
|
1092
1654
|
this._scaleMatrix.makeScale(size, size, size);
|
1655
|
+
|
1093
1656
|
this._translationMatrix.makeTranslation(-tbCenter.x, -tbCenter.y, -tbCenter.z);
|
1657
|
+
|
1094
1658
|
this._gizmoMatrixState.premultiply(this._translationMatrix).premultiply(this._scaleMatrix);
|
1659
|
+
|
1095
1660
|
this._translationMatrix.makeTranslation(tbCenter.x, tbCenter.y, tbCenter.z);
|
1661
|
+
|
1096
1662
|
this._gizmoMatrixState.premultiply(this._translationMatrix);
|
1097
1663
|
}
|
1664
|
+
|
1098
1665
|
this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
1666
|
+
|
1099
1667
|
this._gizmos.clear();
|
1668
|
+
|
1100
1669
|
this._gizmos.add(gizmoX);
|
1670
|
+
|
1101
1671
|
this._gizmos.add(gizmoY);
|
1672
|
+
|
1102
1673
|
this._gizmos.add(gizmoZ);
|
1103
|
-
};
|
1104
|
-
|
1674
|
+
});
|
1675
|
+
|
1676
|
+
_defineProperty(this, "onFocusAnim", (time, point, cameraMatrix, gizmoMatrix) => {
|
1105
1677
|
if (this._timeStart == -1) {
|
1678
|
+
//animation start
|
1106
1679
|
this._timeStart = time;
|
1107
1680
|
}
|
1681
|
+
|
1108
1682
|
if (this._state == STATE.ANIMATION_FOCUS) {
|
1109
1683
|
const deltaTime = time - this._timeStart;
|
1110
1684
|
const animTime = deltaTime / this.focusAnimationTime;
|
1685
|
+
|
1111
1686
|
this._gizmoMatrixState.copy(gizmoMatrix);
|
1687
|
+
|
1112
1688
|
if (animTime >= 1) {
|
1689
|
+
//animation end
|
1113
1690
|
this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
1691
|
+
|
1114
1692
|
this.focus(point, this.scaleFactor);
|
1115
1693
|
this._timeStart = -1;
|
1116
1694
|
this.updateTbState(STATE.IDLE, false);
|
@@ -1119,34 +1697,43 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1119
1697
|
} else {
|
1120
1698
|
const amount = this.easeOutCubic(animTime);
|
1121
1699
|
const size = 1 - amount + this.scaleFactor * amount;
|
1700
|
+
|
1122
1701
|
this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
1702
|
+
|
1123
1703
|
this.focus(point, size, amount);
|
1124
1704
|
this.dispatchEvent(_changeEvent);
|
1125
1705
|
const self = this;
|
1126
|
-
this._animationId = window.requestAnimationFrame(function(t) {
|
1706
|
+
this._animationId = window.requestAnimationFrame(function (t) {
|
1127
1707
|
self.onFocusAnim(t, point, cameraMatrix, gizmoMatrix.clone());
|
1128
1708
|
});
|
1129
1709
|
}
|
1130
1710
|
} else {
|
1711
|
+
//interrupt animation
|
1131
1712
|
this._animationId = -1;
|
1132
1713
|
this._timeStart = -1;
|
1133
1714
|
}
|
1134
|
-
};
|
1135
|
-
|
1715
|
+
});
|
1716
|
+
|
1717
|
+
_defineProperty(this, "onRotationAnim", (time, rotationAxis, w0) => {
|
1136
1718
|
if (this._timeStart == -1) {
|
1719
|
+
//animation start
|
1137
1720
|
this._anglePrev = 0;
|
1138
1721
|
this._angleCurrent = 0;
|
1139
1722
|
this._timeStart = time;
|
1140
1723
|
}
|
1724
|
+
|
1141
1725
|
if (this._state == STATE.ANIMATION_ROTATE) {
|
1142
|
-
|
1726
|
+
//w = w0 + alpha * t
|
1727
|
+
const deltaTime = (time - this._timeStart) / 1000;
|
1143
1728
|
const w = w0 + -this.dampingFactor * deltaTime;
|
1729
|
+
|
1144
1730
|
if (w > 0) {
|
1731
|
+
//tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
|
1145
1732
|
this._angleCurrent = 0.5 * -this.dampingFactor * Math.pow(deltaTime, 2) + w0 * deltaTime + 0;
|
1146
1733
|
this.applyTransformMatrix(this.rotate(rotationAxis, this._angleCurrent));
|
1147
1734
|
this.dispatchEvent(_changeEvent);
|
1148
1735
|
const self = this;
|
1149
|
-
this._animationId = window.requestAnimationFrame(function(t) {
|
1736
|
+
this._animationId = window.requestAnimationFrame(function (t) {
|
1150
1737
|
self.onRotationAnim(t, rotationAxis, w0);
|
1151
1738
|
});
|
1152
1739
|
} else {
|
@@ -1157,123 +1744,167 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1157
1744
|
this.dispatchEvent(_changeEvent);
|
1158
1745
|
}
|
1159
1746
|
} else {
|
1747
|
+
//interrupt animation
|
1160
1748
|
this._animationId = -1;
|
1161
1749
|
this._timeStart = -1;
|
1750
|
+
|
1162
1751
|
if (this._state != STATE.ROTATE) {
|
1163
1752
|
this.activateGizmos(false);
|
1164
1753
|
this.dispatchEvent(_changeEvent);
|
1165
1754
|
}
|
1166
1755
|
}
|
1167
|
-
};
|
1168
|
-
|
1756
|
+
});
|
1757
|
+
|
1758
|
+
_defineProperty(this, "pan", (p0, p1, adjust = false) => {
|
1169
1759
|
if (this.camera) {
|
1170
1760
|
const movement = p0.clone().sub(p1);
|
1171
|
-
|
1761
|
+
|
1762
|
+
if (this.camera.type === 'OrthographicCamera') {
|
1763
|
+
//adjust movement amount
|
1172
1764
|
movement.multiplyScalar(1 / this.camera.zoom);
|
1173
1765
|
}
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1766
|
+
|
1767
|
+
if (this.camera.type === 'PerspectiveCamera' && adjust) {
|
1768
|
+
//adjust movement amount
|
1769
|
+
this._v3_1.setFromMatrixPosition(this._cameraMatrixState0); //camera's initial position
|
1770
|
+
|
1771
|
+
|
1772
|
+
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0); //gizmo's initial position
|
1773
|
+
|
1774
|
+
|
1177
1775
|
const distanceFactor = this._v3_1.distanceTo(this._v3_2) / this.camera.position.distanceTo(this._gizmos.position);
|
1178
1776
|
movement.multiplyScalar(1 / distanceFactor);
|
1179
1777
|
}
|
1778
|
+
|
1180
1779
|
this._v3_1.set(movement.x, movement.y, 0).applyQuaternion(this.camera.quaternion);
|
1780
|
+
|
1181
1781
|
this._m4_1.makeTranslation(this._v3_1.x, this._v3_1.y, this._v3_1.z);
|
1782
|
+
|
1182
1783
|
this.setTransformationMatrices(this._m4_1, this._m4_1);
|
1183
1784
|
}
|
1785
|
+
|
1184
1786
|
return _transformation;
|
1185
|
-
};
|
1186
|
-
|
1787
|
+
});
|
1788
|
+
|
1789
|
+
_defineProperty(this, "reset", () => {
|
1187
1790
|
if (this.camera) {
|
1188
1791
|
this.camera.zoom = this._zoom0;
|
1189
|
-
|
1792
|
+
|
1793
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1190
1794
|
this.camera.fov = this._fov0;
|
1191
1795
|
}
|
1796
|
+
|
1192
1797
|
this.camera.near = this._nearPos;
|
1193
1798
|
this.camera.far = this._farPos;
|
1799
|
+
|
1194
1800
|
this._cameraMatrixState.copy(this._cameraMatrixState0);
|
1801
|
+
|
1195
1802
|
this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
|
1803
|
+
|
1196
1804
|
this.camera.up.copy(this._up0);
|
1197
1805
|
this.camera.updateMatrix();
|
1198
1806
|
this.camera.updateProjectionMatrix();
|
1807
|
+
|
1199
1808
|
this._gizmoMatrixState.copy(this._gizmoMatrixState0);
|
1809
|
+
|
1200
1810
|
this._gizmoMatrixState0.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
1811
|
+
|
1201
1812
|
this._gizmos.updateMatrix();
|
1813
|
+
|
1202
1814
|
const tbRadius = this.calculateTbRadius(this.camera);
|
1203
|
-
|
1815
|
+
|
1816
|
+
if (tbRadius !== undefined) {
|
1204
1817
|
this._tbRadius = tbRadius;
|
1205
1818
|
}
|
1819
|
+
|
1206
1820
|
this.makeGizmos(this._gizmos.position, this._tbRadius);
|
1207
1821
|
this.camera.lookAt(this._gizmos.position);
|
1208
1822
|
this.updateTbState(STATE.IDLE, false);
|
1209
1823
|
this.dispatchEvent(_changeEvent);
|
1210
1824
|
}
|
1211
|
-
};
|
1212
|
-
|
1213
|
-
|
1825
|
+
});
|
1826
|
+
|
1827
|
+
_defineProperty(this, "rotate", (axis, angle) => {
|
1828
|
+
const point = this._gizmos.position; //rotation center
|
1829
|
+
|
1214
1830
|
this._translationMatrix.makeTranslation(-point.x, -point.y, -point.z);
|
1215
|
-
|
1831
|
+
|
1832
|
+
this._rotationMatrix.makeRotationAxis(axis, -angle); //rotate camera
|
1833
|
+
|
1834
|
+
|
1216
1835
|
this._m4_1.makeTranslation(point.x, point.y, point.z);
|
1836
|
+
|
1217
1837
|
this._m4_1.multiply(this._rotationMatrix);
|
1838
|
+
|
1218
1839
|
this._m4_1.multiply(this._translationMatrix);
|
1840
|
+
|
1219
1841
|
this.setTransformationMatrices(this._m4_1);
|
1220
1842
|
return _transformation;
|
1221
|
-
};
|
1222
|
-
|
1223
|
-
|
1843
|
+
});
|
1844
|
+
|
1845
|
+
_defineProperty(this, "copyState", () => {
|
1224
1846
|
if (this.camera) {
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
} : {
|
1236
|
-
arcballState: {
|
1237
|
-
cameraFar: this.camera.far,
|
1238
|
-
cameraFov: this.camera.fov,
|
1239
|
-
cameraMatrix: this.camera.matrix,
|
1240
|
-
cameraNear: this.camera.near,
|
1241
|
-
cameraUp: this.camera.up,
|
1242
|
-
cameraZoom: this.camera.zoom,
|
1243
|
-
gizmoMatrix: this._gizmos.matrix
|
1244
|
-
}
|
1847
|
+
var _this$camera12;
|
1848
|
+
|
1849
|
+
const state = JSON.stringify(((_this$camera12 = this.camera) === null || _this$camera12 === void 0 ? void 0 : _this$camera12.type) === 'OrthographicCamera' ? {
|
1850
|
+
arcballState: {
|
1851
|
+
cameraFar: this.camera.far,
|
1852
|
+
cameraMatrix: this.camera.matrix,
|
1853
|
+
cameraNear: this.camera.near,
|
1854
|
+
cameraUp: this.camera.up,
|
1855
|
+
cameraZoom: this.camera.zoom,
|
1856
|
+
gizmoMatrix: this._gizmos.matrix
|
1245
1857
|
}
|
1246
|
-
|
1858
|
+
} : {
|
1859
|
+
arcballState: {
|
1860
|
+
cameraFar: this.camera.far,
|
1861
|
+
cameraFov: this.camera.fov,
|
1862
|
+
cameraMatrix: this.camera.matrix,
|
1863
|
+
cameraNear: this.camera.near,
|
1864
|
+
cameraUp: this.camera.up,
|
1865
|
+
cameraZoom: this.camera.zoom,
|
1866
|
+
gizmoMatrix: this._gizmos.matrix
|
1867
|
+
}
|
1868
|
+
});
|
1247
1869
|
navigator.clipboard.writeText(state);
|
1248
1870
|
}
|
1249
|
-
};
|
1250
|
-
|
1871
|
+
});
|
1872
|
+
|
1873
|
+
_defineProperty(this, "pasteState", () => {
|
1251
1874
|
const self = this;
|
1252
1875
|
navigator.clipboard.readText().then(function resolved(value) {
|
1253
1876
|
self.setStateFromJSON(value);
|
1254
1877
|
});
|
1255
|
-
};
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1878
|
+
});
|
1879
|
+
|
1880
|
+
_defineProperty(this, "saveState", () => {
|
1881
|
+
if (!this.camera) return;
|
1882
|
+
|
1259
1883
|
this._cameraMatrixState0.copy(this.camera.matrix);
|
1884
|
+
|
1260
1885
|
this._gizmoMatrixState0.copy(this._gizmos.matrix);
|
1886
|
+
|
1261
1887
|
this._nearPos = this.camera.near;
|
1262
1888
|
this._farPos = this.camera.far;
|
1263
1889
|
this._zoom0 = this.camera.zoom;
|
1890
|
+
|
1264
1891
|
this._up0.copy(this.camera.up);
|
1265
|
-
|
1892
|
+
|
1893
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1266
1894
|
this._fov0 = this.camera.fov;
|
1267
1895
|
}
|
1268
|
-
};
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1896
|
+
});
|
1897
|
+
|
1898
|
+
_defineProperty(this, "applyScale", (size, point, scaleGizmos = true) => {
|
1899
|
+
if (!this.camera) return;
|
1272
1900
|
const scalePoint = point.clone();
|
1273
1901
|
let sizeInverse = 1 / size;
|
1274
|
-
|
1902
|
+
|
1903
|
+
if (this.camera.type === 'OrthographicCamera') {
|
1904
|
+
//camera zoom
|
1275
1905
|
this.camera.zoom = this._zoomState;
|
1276
|
-
this.camera.zoom *= size;
|
1906
|
+
this.camera.zoom *= size; //check min and max zoom
|
1907
|
+
|
1277
1908
|
if (this.camera.zoom > this.maxZoom) {
|
1278
1909
|
this.camera.zoom = this.maxZoom;
|
1279
1910
|
sizeInverse = this._zoomState / this.maxZoom;
|
@@ -1281,26 +1912,46 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1281
1912
|
this.camera.zoom = this.minZoom;
|
1282
1913
|
sizeInverse = this._zoomState / this.minZoom;
|
1283
1914
|
}
|
1915
|
+
|
1284
1916
|
this.camera.updateProjectionMatrix();
|
1285
|
-
|
1917
|
+
|
1918
|
+
this._v3_1.setFromMatrixPosition(this._gizmoMatrixState); //gizmos position
|
1919
|
+
//scale gizmos so they appear in the same spot having the same dimension
|
1920
|
+
|
1921
|
+
|
1286
1922
|
this._scaleMatrix.makeScale(sizeInverse, sizeInverse, sizeInverse);
|
1923
|
+
|
1287
1924
|
this._translationMatrix.makeTranslation(-this._v3_1.x, -this._v3_1.y, -this._v3_1.z);
|
1925
|
+
|
1288
1926
|
this._m4_2.makeTranslation(this._v3_1.x, this._v3_1.y, this._v3_1.z).multiply(this._scaleMatrix);
|
1289
|
-
|
1927
|
+
|
1928
|
+
this._m4_2.multiply(this._translationMatrix); //move camera and gizmos to obtain pinch effect
|
1929
|
+
|
1930
|
+
|
1290
1931
|
scalePoint.sub(this._v3_1);
|
1291
1932
|
const amount = scalePoint.clone().multiplyScalar(sizeInverse);
|
1292
1933
|
scalePoint.sub(amount);
|
1934
|
+
|
1293
1935
|
this._m4_1.makeTranslation(scalePoint.x, scalePoint.y, scalePoint.z);
|
1936
|
+
|
1294
1937
|
this._m4_2.premultiply(this._m4_1);
|
1938
|
+
|
1295
1939
|
this.setTransformationMatrices(this._m4_1, this._m4_2);
|
1296
1940
|
return _transformation;
|
1297
1941
|
}
|
1298
|
-
|
1942
|
+
|
1943
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1299
1944
|
this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
|
1300
|
-
|
1945
|
+
|
1946
|
+
this._v3_2.setFromMatrixPosition(this._gizmoMatrixState); //move camera
|
1947
|
+
|
1948
|
+
|
1301
1949
|
let distance = this._v3_1.distanceTo(scalePoint);
|
1302
|
-
|
1950
|
+
|
1951
|
+
let amount = distance - distance * sizeInverse; //check min and max distance
|
1952
|
+
|
1303
1953
|
const newDistance = distance - amount;
|
1954
|
+
|
1304
1955
|
if (newDistance < this.minDistance) {
|
1305
1956
|
sizeInverse = this.minDistance / distance;
|
1306
1957
|
amount = distance - distance * sizeInverse;
|
@@ -1308,152 +1959,270 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1308
1959
|
sizeInverse = this.maxDistance / distance;
|
1309
1960
|
amount = distance - distance * sizeInverse;
|
1310
1961
|
}
|
1962
|
+
|
1311
1963
|
let direction = scalePoint.clone().sub(this._v3_1).normalize().multiplyScalar(amount);
|
1964
|
+
|
1312
1965
|
this._m4_1.makeTranslation(direction.x, direction.y, direction.z);
|
1966
|
+
|
1313
1967
|
if (scaleGizmos) {
|
1968
|
+
//scale gizmos so they appear in the same spot having the same dimension
|
1314
1969
|
const pos = this._v3_2;
|
1315
1970
|
distance = pos.distanceTo(scalePoint);
|
1316
1971
|
amount = distance - distance * sizeInverse;
|
1317
1972
|
direction = scalePoint.clone().sub(this._v3_2).normalize().multiplyScalar(amount);
|
1973
|
+
|
1318
1974
|
this._translationMatrix.makeTranslation(pos.x, pos.y, pos.z);
|
1975
|
+
|
1319
1976
|
this._scaleMatrix.makeScale(sizeInverse, sizeInverse, sizeInverse);
|
1977
|
+
|
1320
1978
|
this._m4_2.makeTranslation(direction.x, direction.y, direction.z).multiply(this._translationMatrix);
|
1979
|
+
|
1321
1980
|
this._m4_2.multiply(this._scaleMatrix);
|
1981
|
+
|
1322
1982
|
this._translationMatrix.makeTranslation(-pos.x, -pos.y, -pos.z);
|
1983
|
+
|
1323
1984
|
this._m4_2.multiply(this._translationMatrix);
|
1985
|
+
|
1324
1986
|
this.setTransformationMatrices(this._m4_1, this._m4_2);
|
1325
1987
|
} else {
|
1326
1988
|
this.setTransformationMatrices(this._m4_1);
|
1327
1989
|
}
|
1990
|
+
|
1328
1991
|
return _transformation;
|
1329
1992
|
}
|
1330
|
-
};
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1993
|
+
});
|
1994
|
+
|
1995
|
+
_defineProperty(this, "setFov", value => {
|
1996
|
+
var _this$camera13;
|
1997
|
+
|
1998
|
+
if (((_this$camera13 = this.camera) === null || _this$camera13 === void 0 ? void 0 : _this$camera13.type) === 'PerspectiveCamera') {
|
1999
|
+
this.camera.fov = MathUtils.clamp(value, this.minFov, this.maxFov);
|
1335
2000
|
this.camera.updateProjectionMatrix();
|
1336
2001
|
}
|
1337
|
-
};
|
1338
|
-
|
2002
|
+
});
|
2003
|
+
|
2004
|
+
_defineProperty(this, "setTarget", (x, y, z) => {
|
1339
2005
|
if (this.camera) {
|
1340
2006
|
this.target.set(x, y, z);
|
1341
|
-
|
2007
|
+
|
2008
|
+
this._gizmos.position.set(x, y, z); //for correct radius calculation
|
2009
|
+
|
2010
|
+
|
1342
2011
|
const tbRadius = this.calculateTbRadius(this.camera);
|
1343
|
-
|
2012
|
+
|
2013
|
+
if (tbRadius !== undefined) {
|
1344
2014
|
this._tbRadius = tbRadius;
|
1345
2015
|
}
|
2016
|
+
|
1346
2017
|
this.makeGizmos(this.target, this._tbRadius);
|
1347
2018
|
this.camera.lookAt(this.target);
|
1348
2019
|
}
|
1349
|
-
};
|
1350
|
-
|
2020
|
+
});
|
2021
|
+
|
2022
|
+
_defineProperty(this, "zRotate", (point, angle) => {
|
1351
2023
|
this._rotationMatrix.makeRotationAxis(this._rotationAxis, angle);
|
2024
|
+
|
1352
2025
|
this._translationMatrix.makeTranslation(-point.x, -point.y, -point.z);
|
2026
|
+
|
1353
2027
|
this._m4_1.makeTranslation(point.x, point.y, point.z);
|
2028
|
+
|
1354
2029
|
this._m4_1.multiply(this._rotationMatrix);
|
2030
|
+
|
1355
2031
|
this._m4_1.multiply(this._translationMatrix);
|
1356
|
-
|
1357
|
-
this.
|
2032
|
+
|
2033
|
+
this._v3_1.setFromMatrixPosition(this._gizmoMatrixState).sub(point); //vector from rotation center to gizmos position
|
2034
|
+
|
2035
|
+
|
2036
|
+
this._v3_2.copy(this._v3_1).applyAxisAngle(this._rotationAxis, angle); //apply rotation
|
2037
|
+
|
2038
|
+
|
1358
2039
|
this._v3_2.sub(this._v3_1);
|
2040
|
+
|
1359
2041
|
this._m4_2.makeTranslation(this._v3_2.x, this._v3_2.y, this._v3_2.z);
|
2042
|
+
|
1360
2043
|
this.setTransformationMatrices(this._m4_1, this._m4_2);
|
1361
2044
|
return _transformation;
|
1362
|
-
};
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
const raycaster = new
|
1367
|
-
raycaster.near =
|
1368
|
-
raycaster.far =
|
1369
|
-
raycaster.setFromCamera(cursor,
|
2045
|
+
});
|
2046
|
+
|
2047
|
+
_defineProperty(this, "unprojectOnObj", (cursor, camera) => {
|
2048
|
+
if (!this.scene) return null;
|
2049
|
+
const raycaster = new Raycaster();
|
2050
|
+
raycaster.near = camera.near;
|
2051
|
+
raycaster.far = camera.far;
|
2052
|
+
raycaster.setFromCamera(cursor, camera);
|
1370
2053
|
const intersect = raycaster.intersectObjects(this.scene.children, true);
|
2054
|
+
|
1371
2055
|
for (let i = 0; i < intersect.length; i++) {
|
1372
2056
|
if (intersect[i].object.uuid != this._gizmos.uuid && intersect[i].face) {
|
1373
2057
|
return intersect[i].point.clone();
|
1374
2058
|
}
|
1375
2059
|
}
|
2060
|
+
|
1376
2061
|
return null;
|
1377
|
-
};
|
1378
|
-
|
1379
|
-
|
2062
|
+
});
|
2063
|
+
|
2064
|
+
_defineProperty(this, "unprojectOnTbSurface", (camera, cursorX, cursorY, canvas, tbRadius) => {
|
2065
|
+
if (camera.type == 'OrthographicCamera') {
|
1380
2066
|
this._v2_1.copy(this.getCursorPosition(cursorX, cursorY, canvas));
|
2067
|
+
|
1381
2068
|
this._v3_1.set(this._v2_1.x, this._v2_1.y, 0);
|
2069
|
+
|
1382
2070
|
const x2 = Math.pow(this._v2_1.x, 2);
|
1383
2071
|
const y2 = Math.pow(this._v2_1.y, 2);
|
1384
2072
|
const r2 = Math.pow(this._tbRadius, 2);
|
2073
|
+
|
1385
2074
|
if (x2 + y2 <= r2 * 0.5) {
|
2075
|
+
//intersection with sphere
|
1386
2076
|
this._v3_1.setZ(Math.sqrt(r2 - (x2 + y2)));
|
1387
2077
|
} else {
|
2078
|
+
//intersection with hyperboloid
|
1388
2079
|
this._v3_1.setZ(r2 * 0.5 / Math.sqrt(x2 + y2));
|
1389
2080
|
}
|
2081
|
+
|
1390
2082
|
return this._v3_1;
|
1391
2083
|
}
|
1392
|
-
|
2084
|
+
|
2085
|
+
if (camera.type == 'PerspectiveCamera') {
|
2086
|
+
//unproject cursor on the near plane
|
1393
2087
|
this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas));
|
2088
|
+
|
1394
2089
|
this._v3_1.set(this._v2_1.x, this._v2_1.y, -1);
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
const
|
2090
|
+
|
2091
|
+
this._v3_1.applyMatrix4(camera.projectionMatrixInverse);
|
2092
|
+
|
2093
|
+
const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
|
2094
|
+
|
2095
|
+
|
2096
|
+
const cameraGizmoDistance = camera.position.distanceTo(this._gizmos.position);
|
2097
|
+
const radius2 = Math.pow(tbRadius, 2); // camera
|
2098
|
+
// |\
|
2099
|
+
// | \
|
2100
|
+
// | \
|
2101
|
+
// h | \
|
2102
|
+
// | \
|
2103
|
+
// | \
|
2104
|
+
// _ _ | _ _ _\ _ _ near plane
|
2105
|
+
// l
|
2106
|
+
|
1399
2107
|
const h = this._v3_1.z;
|
1400
2108
|
const l = Math.sqrt(Math.pow(this._v3_1.x, 2) + Math.pow(this._v3_1.y, 2));
|
2109
|
+
|
1401
2110
|
if (l == 0) {
|
2111
|
+
//ray aligned with camera
|
1402
2112
|
rayDir.set(this._v3_1.x, this._v3_1.y, tbRadius);
|
1403
2113
|
return rayDir;
|
1404
2114
|
}
|
2115
|
+
|
1405
2116
|
const m = h / l;
|
1406
2117
|
const q = cameraGizmoDistance;
|
2118
|
+
/*
|
2119
|
+
* calculate intersection point between unprojected ray and trackball surface
|
2120
|
+
*|y = m * x + q
|
2121
|
+
*|x^2 + y^2 = r^2
|
2122
|
+
*
|
2123
|
+
* (m^2 + 1) * x^2 + (2 * m * q) * x + q^2 - r^2 = 0
|
2124
|
+
*/
|
2125
|
+
|
1407
2126
|
let a = Math.pow(m, 2) + 1;
|
1408
2127
|
let b = 2 * m * q;
|
1409
2128
|
let c = Math.pow(q, 2) - radius2;
|
1410
2129
|
let delta = Math.pow(b, 2) - 4 * a * c;
|
2130
|
+
|
1411
2131
|
if (delta >= 0) {
|
2132
|
+
//intersection with sphere
|
1412
2133
|
this._v2_1.setX((-b - Math.sqrt(delta)) / (2 * a));
|
2134
|
+
|
1413
2135
|
this._v2_1.setY(m * this._v2_1.x + q);
|
1414
|
-
|
2136
|
+
|
2137
|
+
const angle = MathUtils.RAD2DEG * this._v2_1.angle();
|
2138
|
+
|
1415
2139
|
if (angle >= 45) {
|
1416
|
-
|
1417
|
-
|
2140
|
+
//if angle between intersection point and X' axis is >= 45°, return that point
|
2141
|
+
//otherwise, calculate intersection point with hyperboloid
|
2142
|
+
const rayLength = Math.sqrt(Math.pow(this._v2_1.x, 2) + Math.pow(cameraGizmoDistance - this._v2_1.y, 2));
|
2143
|
+
rayDir.multiplyScalar(rayLength);
|
1418
2144
|
rayDir.z += cameraGizmoDistance;
|
1419
2145
|
return rayDir;
|
1420
2146
|
}
|
1421
|
-
}
|
2147
|
+
} //intersection with hyperboloid
|
2148
|
+
|
2149
|
+
/*
|
2150
|
+
*|y = m * x + q
|
2151
|
+
*|y = (1 / x) * (r^2 / 2)
|
2152
|
+
*
|
2153
|
+
* m * x^2 + q * x - r^2 / 2 = 0
|
2154
|
+
*/
|
2155
|
+
|
2156
|
+
|
1422
2157
|
a = m;
|
1423
2158
|
b = q;
|
1424
2159
|
c = -radius2 * 0.5;
|
1425
2160
|
delta = Math.pow(b, 2) - 4 * a * c;
|
2161
|
+
|
1426
2162
|
this._v2_1.setX((-b - Math.sqrt(delta)) / (2 * a));
|
2163
|
+
|
1427
2164
|
this._v2_1.setY(m * this._v2_1.x + q);
|
2165
|
+
|
1428
2166
|
const rayLength = Math.sqrt(Math.pow(this._v2_1.x, 2) + Math.pow(cameraGizmoDistance - this._v2_1.y, 2));
|
1429
2167
|
rayDir.multiplyScalar(rayLength);
|
1430
2168
|
rayDir.z += cameraGizmoDistance;
|
1431
2169
|
return rayDir;
|
1432
2170
|
}
|
1433
|
-
};
|
1434
|
-
|
1435
|
-
|
2171
|
+
});
|
2172
|
+
|
2173
|
+
_defineProperty(this, "unprojectOnTbPlane", (camera, cursorX, cursorY, canvas, initialDistance = false) => {
|
2174
|
+
if (camera.type == 'OrthographicCamera') {
|
1436
2175
|
this._v2_1.copy(this.getCursorPosition(cursorX, cursorY, canvas));
|
2176
|
+
|
1437
2177
|
this._v3_1.set(this._v2_1.x, this._v2_1.y, 0);
|
2178
|
+
|
1438
2179
|
return this._v3_1.clone();
|
1439
2180
|
}
|
1440
|
-
|
1441
|
-
|
2181
|
+
|
2182
|
+
if (camera.type == 'PerspectiveCamera') {
|
2183
|
+
this._v2_1.copy(this.getCursorNDC(cursorX, cursorY, canvas)); //unproject cursor on the near plane
|
2184
|
+
|
2185
|
+
|
1442
2186
|
this._v3_1.set(this._v2_1.x, this._v2_1.y, -1);
|
1443
|
-
|
1444
|
-
|
2187
|
+
|
2188
|
+
this._v3_1.applyMatrix4(camera.projectionMatrixInverse);
|
2189
|
+
|
2190
|
+
const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
|
2191
|
+
// camera
|
2192
|
+
// |\
|
2193
|
+
// | \
|
2194
|
+
// | \
|
2195
|
+
// h | \
|
2196
|
+
// | \
|
2197
|
+
// | \
|
2198
|
+
// _ _ | _ _ _\ _ _ near plane
|
2199
|
+
// l
|
2200
|
+
|
2201
|
+
|
1445
2202
|
const h = this._v3_1.z;
|
1446
2203
|
const l = Math.sqrt(Math.pow(this._v3_1.x, 2) + Math.pow(this._v3_1.y, 2));
|
1447
2204
|
let cameraGizmoDistance;
|
2205
|
+
|
1448
2206
|
if (initialDistance) {
|
1449
2207
|
cameraGizmoDistance = this._v3_1.setFromMatrixPosition(this._cameraMatrixState0).distanceTo(this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0));
|
1450
2208
|
} else {
|
1451
|
-
cameraGizmoDistance =
|
1452
|
-
}
|
2209
|
+
cameraGizmoDistance = camera.position.distanceTo(this._gizmos.position);
|
2210
|
+
}
|
2211
|
+
/*
|
2212
|
+
* calculate intersection point between unprojected ray and the plane
|
2213
|
+
*|y = mx + q
|
2214
|
+
*|y = 0
|
2215
|
+
*
|
2216
|
+
* x = -q/m
|
2217
|
+
*/
|
2218
|
+
|
2219
|
+
|
1453
2220
|
if (l == 0) {
|
2221
|
+
//ray aligned with camera
|
1454
2222
|
rayDir.set(0, 0, 0);
|
1455
2223
|
return rayDir;
|
1456
2224
|
}
|
2225
|
+
|
1457
2226
|
const m = h / l;
|
1458
2227
|
const q = cameraGizmoDistance;
|
1459
2228
|
const x = -q / m;
|
@@ -1462,179 +2231,259 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1462
2231
|
rayDir.z = 0;
|
1463
2232
|
return rayDir;
|
1464
2233
|
}
|
1465
|
-
};
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
2234
|
+
});
|
2235
|
+
|
2236
|
+
_defineProperty(this, "updateMatrixState", () => {
|
2237
|
+
if (!this.camera) return; //update camera and gizmos state
|
2238
|
+
|
1469
2239
|
this._cameraMatrixState.copy(this.camera.matrix);
|
2240
|
+
|
1470
2241
|
this._gizmoMatrixState.copy(this._gizmos.matrix);
|
1471
|
-
|
2242
|
+
|
2243
|
+
if (this.camera.type === 'OrthographicCamera') {
|
1472
2244
|
this._cameraProjectionState.copy(this.camera.projectionMatrix);
|
2245
|
+
|
1473
2246
|
this.camera.updateProjectionMatrix();
|
1474
2247
|
this._zoomState = this.camera.zoom;
|
1475
2248
|
}
|
1476
|
-
|
2249
|
+
|
2250
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1477
2251
|
this._fovState = this.camera.fov;
|
1478
2252
|
}
|
1479
|
-
};
|
1480
|
-
|
2253
|
+
});
|
2254
|
+
|
2255
|
+
_defineProperty(this, "updateTbState", (newState, updateMatrices) => {
|
1481
2256
|
this._state = newState;
|
2257
|
+
|
1482
2258
|
if (updateMatrices) {
|
1483
2259
|
this.updateMatrixState();
|
1484
2260
|
}
|
1485
|
-
};
|
1486
|
-
|
1487
|
-
|
2261
|
+
});
|
2262
|
+
|
2263
|
+
_defineProperty(this, "update", () => {
|
2264
|
+
const EPS = 0.000001; // Update target and gizmos state
|
2265
|
+
|
1488
2266
|
if (!this.target.equals(this._currentTarget) && this.camera) {
|
1489
|
-
this._gizmos.position.set(this.target.x, this.target.y, this.target.z);
|
2267
|
+
this._gizmos.position.set(this.target.x, this.target.y, this.target.z); //for correct radius calculation
|
2268
|
+
|
2269
|
+
|
1490
2270
|
const tbRadius = this.calculateTbRadius(this.camera);
|
1491
|
-
|
2271
|
+
|
2272
|
+
if (tbRadius !== undefined) {
|
1492
2273
|
this._tbRadius = tbRadius;
|
1493
2274
|
}
|
2275
|
+
|
1494
2276
|
this.makeGizmos(this.target, this._tbRadius);
|
2277
|
+
|
1495
2278
|
this._currentTarget.copy(this.target);
|
1496
2279
|
}
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
2280
|
+
|
2281
|
+
if (!this.camera) return; //check min/max parameters
|
2282
|
+
|
2283
|
+
if (this.camera.type === 'OrthographicCamera') {
|
2284
|
+
//check zoom
|
1500
2285
|
if (this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom) {
|
1501
|
-
const newZoom =
|
2286
|
+
const newZoom = MathUtils.clamp(this.camera.zoom, this.minZoom, this.maxZoom);
|
1502
2287
|
this.applyTransformMatrix(this.applyScale(newZoom / this.camera.zoom, this._gizmos.position, true));
|
1503
2288
|
}
|
1504
2289
|
}
|
1505
|
-
|
2290
|
+
|
2291
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
2292
|
+
//check distance
|
1506
2293
|
const distance = this.camera.position.distanceTo(this._gizmos.position);
|
2294
|
+
|
1507
2295
|
if (distance > this.maxDistance + EPS || distance < this.minDistance - EPS) {
|
1508
|
-
const newDistance =
|
2296
|
+
const newDistance = MathUtils.clamp(distance, this.minDistance, this.maxDistance);
|
1509
2297
|
this.applyTransformMatrix(this.applyScale(newDistance / distance, this._gizmos.position));
|
1510
2298
|
this.updateMatrixState();
|
1511
|
-
}
|
2299
|
+
} //check fov
|
2300
|
+
|
2301
|
+
|
1512
2302
|
if (this.camera.fov < this.minFov || this.camera.fov > this.maxFov) {
|
1513
|
-
this.camera.fov =
|
2303
|
+
this.camera.fov = MathUtils.clamp(this.camera.fov, this.minFov, this.maxFov);
|
1514
2304
|
this.camera.updateProjectionMatrix();
|
1515
2305
|
}
|
2306
|
+
|
1516
2307
|
const oldRadius = this._tbRadius;
|
1517
2308
|
const tbRadius = this.calculateTbRadius(this.camera);
|
1518
|
-
|
2309
|
+
|
2310
|
+
if (tbRadius !== undefined) {
|
1519
2311
|
this._tbRadius = tbRadius;
|
1520
2312
|
}
|
2313
|
+
|
1521
2314
|
if (oldRadius < this._tbRadius - EPS || oldRadius > this._tbRadius + EPS) {
|
1522
2315
|
const scale = (this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z) / 3;
|
1523
|
-
const newRadius = this._tbRadius / scale;
|
1524
|
-
|
2316
|
+
const newRadius = this._tbRadius / scale; // @ts-expect-error
|
2317
|
+
|
2318
|
+
const curve = new EllipseCurve(0, 0, newRadius, newRadius);
|
1525
2319
|
const points = curve.getPoints(this._curvePts);
|
1526
|
-
const curveGeometry = new
|
2320
|
+
const curveGeometry = new BufferGeometry().setFromPoints(points);
|
2321
|
+
|
1527
2322
|
for (const gizmo in this._gizmos.children) {
|
1528
2323
|
const child = this._gizmos.children[gizmo];
|
1529
2324
|
child.geometry = curveGeometry;
|
1530
2325
|
}
|
1531
2326
|
}
|
1532
2327
|
}
|
2328
|
+
|
1533
2329
|
this.camera.lookAt(this._gizmos.position);
|
1534
|
-
};
|
1535
|
-
|
2330
|
+
});
|
2331
|
+
|
2332
|
+
_defineProperty(this, "setStateFromJSON", json => {
|
1536
2333
|
const state = JSON.parse(json);
|
2334
|
+
|
1537
2335
|
if (state.arcballState && this.camera) {
|
1538
2336
|
this._cameraMatrixState.fromArray(state.arcballState.cameraMatrix.elements);
|
2337
|
+
|
1539
2338
|
this._cameraMatrixState.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
|
2339
|
+
|
1540
2340
|
this.camera.up.copy(state.arcballState.cameraUp);
|
1541
2341
|
this.camera.near = state.arcballState.cameraNear;
|
1542
2342
|
this.camera.far = state.arcballState.cameraFar;
|
1543
2343
|
this.camera.zoom = state.arcballState.cameraZoom;
|
1544
|
-
|
2344
|
+
|
2345
|
+
if (this.camera.type === 'PerspectiveCamera') {
|
1545
2346
|
this.camera.fov = state.arcballState.cameraFov;
|
1546
2347
|
}
|
2348
|
+
|
1547
2349
|
this._gizmoMatrixState.fromArray(state.arcballState.gizmoMatrix.elements);
|
2350
|
+
|
1548
2351
|
this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
2352
|
+
|
1549
2353
|
this.camera.updateMatrix();
|
1550
2354
|
this.camera.updateProjectionMatrix();
|
2355
|
+
|
1551
2356
|
this._gizmos.updateMatrix();
|
2357
|
+
|
1552
2358
|
const tbRadius = this.calculateTbRadius(this.camera);
|
1553
|
-
|
2359
|
+
|
2360
|
+
if (tbRadius !== undefined) {
|
1554
2361
|
this._tbRadius = tbRadius;
|
1555
2362
|
}
|
1556
|
-
|
2363
|
+
|
2364
|
+
const gizmoTmp = new Matrix4().copy(this._gizmoMatrixState0);
|
1557
2365
|
this.makeGizmos(this._gizmos.position, this._tbRadius);
|
2366
|
+
|
1558
2367
|
this._gizmoMatrixState0.copy(gizmoTmp);
|
2368
|
+
|
1559
2369
|
this.camera.lookAt(this._gizmos.position);
|
1560
2370
|
this.updateTbState(STATE.IDLE, false);
|
1561
2371
|
this.dispatchEvent(_changeEvent);
|
1562
2372
|
}
|
1563
|
-
};
|
2373
|
+
});
|
2374
|
+
|
1564
2375
|
this.camera = null;
|
1565
|
-
this.domElement =
|
2376
|
+
this.domElement = _domElement;
|
1566
2377
|
this.scene = scene;
|
1567
2378
|
this.mouseActions = [];
|
1568
|
-
this._mouseOp = null;
|
1569
|
-
|
1570
|
-
this.
|
1571
|
-
this.
|
1572
|
-
this.
|
1573
|
-
this.
|
1574
|
-
this.
|
1575
|
-
this.
|
1576
|
-
|
1577
|
-
this.
|
1578
|
-
|
1579
|
-
this.
|
1580
|
-
|
2379
|
+
this._mouseOp = null; //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
|
2380
|
+
|
2381
|
+
this._v2_1 = new Vector2();
|
2382
|
+
this._v3_1 = new Vector3();
|
2383
|
+
this._v3_2 = new Vector3();
|
2384
|
+
this._m4_1 = new Matrix4();
|
2385
|
+
this._m4_2 = new Matrix4();
|
2386
|
+
this._quat = new Quaternion(); //transformation matrices
|
2387
|
+
|
2388
|
+
this._translationMatrix = new Matrix4(); //matrix for translation operation
|
2389
|
+
|
2390
|
+
this._rotationMatrix = new Matrix4(); //matrix for rotation operation
|
2391
|
+
|
2392
|
+
this._scaleMatrix = new Matrix4(); //matrix for scaling operation
|
2393
|
+
|
2394
|
+
this._rotationAxis = new Vector3(); //axis for rotate operation
|
2395
|
+
//camera state
|
2396
|
+
|
2397
|
+
this._cameraMatrixState = new Matrix4();
|
2398
|
+
this._cameraProjectionState = new Matrix4();
|
1581
2399
|
this._fovState = 1;
|
1582
|
-
this._upState = new
|
2400
|
+
this._upState = new Vector3();
|
1583
2401
|
this._zoomState = 1;
|
1584
2402
|
this._nearPos = 0;
|
1585
2403
|
this._farPos = 0;
|
1586
|
-
this._gizmoMatrixState = new
|
1587
|
-
|
2404
|
+
this._gizmoMatrixState = new Matrix4(); //initial values
|
2405
|
+
|
2406
|
+
this._up0 = new Vector3();
|
1588
2407
|
this._zoom0 = 1;
|
1589
2408
|
this._fov0 = 0;
|
1590
2409
|
this._initialNear = 0;
|
1591
2410
|
this._nearPos0 = 0;
|
1592
2411
|
this._initialFar = 0;
|
1593
2412
|
this._farPos0 = 0;
|
1594
|
-
this._cameraMatrixState0 = new
|
1595
|
-
this._gizmoMatrixState0 = new
|
2413
|
+
this._cameraMatrixState0 = new Matrix4();
|
2414
|
+
this._gizmoMatrixState0 = new Matrix4(); //pointers array
|
2415
|
+
|
1596
2416
|
this._button = -1;
|
1597
2417
|
this._touchStart = [];
|
1598
2418
|
this._touchCurrent = [];
|
1599
|
-
this._input = INPUT.NONE;
|
1600
|
-
|
1601
|
-
this.
|
2419
|
+
this._input = INPUT.NONE; //two fingers touch interaction
|
2420
|
+
|
2421
|
+
this._switchSensibility = 32; //minimum movement to be performed to fire single pan start after the second finger has been released
|
2422
|
+
|
2423
|
+
this._startFingerDistance = 0; //distance between two fingers
|
2424
|
+
|
1602
2425
|
this._currentFingerDistance = 0;
|
1603
|
-
this._startFingerRotation = 0;
|
1604
|
-
|
2426
|
+
this._startFingerRotation = 0; //amount of rotation performed with two fingers
|
2427
|
+
|
2428
|
+
this._currentFingerRotation = 0; //double tap
|
2429
|
+
|
1605
2430
|
this._devPxRatio = 0;
|
1606
2431
|
this._downValid = true;
|
1607
2432
|
this._nclicks = 0;
|
1608
2433
|
this._downEvents = [];
|
1609
|
-
this._clickStart = 0;
|
2434
|
+
this._clickStart = 0; //first click time
|
2435
|
+
|
1610
2436
|
this._maxDownTime = 250;
|
1611
2437
|
this._maxInterval = 300;
|
1612
2438
|
this._posThreshold = 24;
|
1613
|
-
this._movementThreshold = 24;
|
1614
|
-
|
1615
|
-
this.
|
1616
|
-
this.
|
1617
|
-
|
1618
|
-
this.
|
1619
|
-
|
1620
|
-
this.
|
1621
|
-
|
1622
|
-
this.
|
1623
|
-
this.
|
1624
|
-
|
1625
|
-
this.
|
1626
|
-
|
1627
|
-
this.
|
1628
|
-
|
1629
|
-
this.
|
1630
|
-
|
2439
|
+
this._movementThreshold = 24; //cursor positions
|
2440
|
+
|
2441
|
+
this._currentCursorPosition = new Vector3();
|
2442
|
+
this._startCursorPosition = new Vector3(); //grid
|
2443
|
+
|
2444
|
+
this._grid = null; //grid to be visualized during pan operation
|
2445
|
+
|
2446
|
+
this._gridPosition = new Vector3(); //gizmos
|
2447
|
+
|
2448
|
+
this._gizmos = new Group();
|
2449
|
+
this._curvePts = 128; //animations
|
2450
|
+
|
2451
|
+
this._timeStart = -1; //initial time
|
2452
|
+
|
2453
|
+
this._animationId = -1; //focus animation
|
2454
|
+
|
2455
|
+
this.focusAnimationTime = 500; //duration of focus animation in ms
|
2456
|
+
//rotate animation
|
2457
|
+
|
2458
|
+
this._timePrev = 0; //time at which previous rotate operation has been detected
|
2459
|
+
|
2460
|
+
this._timeCurrent = 0; //time at which current rotate operation has been detected
|
2461
|
+
|
2462
|
+
this._anglePrev = 0; //angle of previous rotation
|
2463
|
+
|
2464
|
+
this._angleCurrent = 0; //angle of current rotation
|
2465
|
+
|
2466
|
+
this._cursorPosPrev = new Vector3(); //cursor position when previous rotate operation has been detected
|
2467
|
+
|
2468
|
+
this._cursorPosCurr = new Vector3(); //cursor position when current rotate operation has been detected
|
2469
|
+
|
2470
|
+
this._wPrev = 0; //angular velocity of the previous rotate operation
|
2471
|
+
|
2472
|
+
this._wCurr = 0; //angular velocity of the current rotate operation
|
2473
|
+
//parameters
|
2474
|
+
|
1631
2475
|
this.adjustNearFar = false;
|
1632
|
-
this.scaleFactor = 1.1;
|
2476
|
+
this.scaleFactor = 1.1; //zoom/distance multiplier
|
2477
|
+
|
1633
2478
|
this.dampingFactor = 25;
|
1634
|
-
this.wMax = 20;
|
1635
|
-
|
1636
|
-
this.
|
1637
|
-
|
2479
|
+
this.wMax = 20; //maximum angular velocity allowed
|
2480
|
+
|
2481
|
+
this.enableAnimations = true; //if animations should be performed
|
2482
|
+
|
2483
|
+
this.enableGrid = false; //if grid should be showed during pan operation
|
2484
|
+
|
2485
|
+
this.cursorZoom = false; //if wheel zoom should be cursor centered
|
2486
|
+
|
1638
2487
|
this.minFov = 5;
|
1639
2488
|
this.maxFov = 90;
|
1640
2489
|
this.enabled = true;
|
@@ -1644,45 +2493,63 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1644
2493
|
this.minDistance = 0;
|
1645
2494
|
this.maxDistance = Infinity;
|
1646
2495
|
this.minZoom = 0;
|
1647
|
-
this.maxZoom = Infinity;
|
1648
|
-
|
1649
|
-
this.
|
1650
|
-
this.
|
2496
|
+
this.maxZoom = Infinity; //trackball parameters
|
2497
|
+
|
2498
|
+
this.target = new Vector3(0, 0, 0);
|
2499
|
+
this._currentTarget = new Vector3(0, 0, 0);
|
2500
|
+
this._tbRadius = 1; //FSA
|
2501
|
+
|
1651
2502
|
this._state = STATE.IDLE;
|
1652
|
-
this.setCamera(
|
2503
|
+
this.setCamera(_camera);
|
2504
|
+
|
1653
2505
|
if (this.scene) {
|
1654
2506
|
this.scene.add(this._gizmos);
|
1655
2507
|
}
|
2508
|
+
|
1656
2509
|
this._devPxRatio = window.devicePixelRatio;
|
1657
2510
|
this.initializeMouseActions();
|
1658
|
-
if (this.domElement)
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
2511
|
+
if (this.domElement) this.connect(this.domElement);
|
2512
|
+
window.addEventListener('resize', this.onWindowResize);
|
2513
|
+
} //listeners
|
2514
|
+
|
2515
|
+
|
2516
|
+
/**
|
2517
|
+
* Apply a transformation matrix, to the camera and gizmos
|
2518
|
+
* @param {Object} transformation Object containing matrices to apply to camera and gizmos
|
2519
|
+
*/
|
1662
2520
|
applyTransformMatrix(transformation) {
|
1663
|
-
if (
|
2521
|
+
if (transformation !== null && transformation !== void 0 && transformation.camera && this.camera) {
|
1664
2522
|
this._m4_1.copy(this._cameraMatrixState).premultiply(transformation.camera);
|
2523
|
+
|
1665
2524
|
this._m4_1.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
|
1666
|
-
|
2525
|
+
|
2526
|
+
this.camera.updateMatrix(); //update camera up vector
|
2527
|
+
|
1667
2528
|
if (this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE) {
|
1668
2529
|
this.camera.up.copy(this._upState).applyQuaternion(this.camera.quaternion);
|
1669
2530
|
}
|
1670
2531
|
}
|
1671
|
-
|
2532
|
+
|
2533
|
+
if (transformation !== null && transformation !== void 0 && transformation.gizmos) {
|
1672
2534
|
this._m4_1.copy(this._gizmoMatrixState).premultiply(transformation.gizmos);
|
2535
|
+
|
1673
2536
|
this._m4_1.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
|
2537
|
+
|
1674
2538
|
this._gizmos.updateMatrix();
|
1675
2539
|
}
|
2540
|
+
|
1676
2541
|
if ((this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) && this.camera) {
|
1677
2542
|
const tbRadius = this.calculateTbRadius(this.camera);
|
1678
|
-
|
2543
|
+
|
2544
|
+
if (tbRadius !== undefined) {
|
1679
2545
|
this._tbRadius = tbRadius;
|
1680
2546
|
}
|
2547
|
+
|
1681
2548
|
if (this.adjustNearFar) {
|
1682
2549
|
const cameraDistance = this.camera.position.distanceTo(this._gizmos.position);
|
1683
|
-
const bb = new
|
2550
|
+
const bb = new Box3();
|
1684
2551
|
bb.setFromObject(this._gizmos);
|
1685
|
-
const sphere = new
|
2552
|
+
const sphere = new Sphere();
|
1686
2553
|
bb.getBoundingSphere(sphere);
|
1687
2554
|
const adjustedNearPosition = Math.max(this._nearPos0, sphere.radius + sphere.center.length());
|
1688
2555
|
const regularNearPosition = cameraDistance - this._initialNear;
|
@@ -1695,24 +2562,52 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1695
2562
|
this.camera.updateProjectionMatrix();
|
1696
2563
|
} else {
|
1697
2564
|
let update = false;
|
2565
|
+
|
1698
2566
|
if (this.camera.near != this._initialNear) {
|
1699
2567
|
this.camera.near = this._initialNear;
|
1700
2568
|
update = true;
|
1701
2569
|
}
|
2570
|
+
|
1702
2571
|
if (this.camera.far != this._initialFar) {
|
1703
2572
|
this.camera.far = this._initialFar;
|
1704
2573
|
update = true;
|
1705
2574
|
}
|
2575
|
+
|
1706
2576
|
if (update) {
|
1707
2577
|
this.camera.updateProjectionMatrix();
|
1708
2578
|
}
|
1709
2579
|
}
|
1710
2580
|
}
|
1711
2581
|
}
|
2582
|
+
/**
|
2583
|
+
* Calculate the angular speed
|
2584
|
+
* @param {Number} p0 Position at t0
|
2585
|
+
* @param {Number} p1 Position at t1
|
2586
|
+
* @param {Number} t0 Initial time in milliseconds
|
2587
|
+
* @param {Number} t1 Ending time in milliseconds
|
2588
|
+
*/
|
2589
|
+
|
2590
|
+
|
2591
|
+
/**
|
2592
|
+
* Set gizmos visibility
|
2593
|
+
* @param {Boolean} value Value of gizmos visibility
|
2594
|
+
*/
|
1712
2595
|
setGizmosVisible(value) {
|
1713
2596
|
this._gizmos.visible = value;
|
1714
2597
|
this.dispatchEvent(_changeEvent);
|
1715
2598
|
}
|
2599
|
+
/**
|
2600
|
+
* Creates the rotation gizmos matching trackball center and radius
|
2601
|
+
* @param {Vector3} tbCenter The trackball center
|
2602
|
+
* @param {number} tbRadius The trackball radius
|
2603
|
+
*/
|
2604
|
+
|
2605
|
+
|
2606
|
+
/**
|
2607
|
+
* Set values in transformation object
|
2608
|
+
* @param {Matrix4} camera Transformation to be applied to the camera
|
2609
|
+
* @param {Matrix4} gizmos Transformation to be applied to gizmos
|
2610
|
+
*/
|
1716
2611
|
setTransformationMatrices(camera = null, gizmos = null) {
|
1717
2612
|
if (camera) {
|
1718
2613
|
if (_transformation.camera) {
|
@@ -1723,6 +2618,7 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1723
2618
|
} else {
|
1724
2619
|
_transformation.camera = null;
|
1725
2620
|
}
|
2621
|
+
|
1726
2622
|
if (gizmos) {
|
1727
2623
|
if (_transformation.gizmos) {
|
1728
2624
|
_transformation.gizmos.copy(gizmos);
|
@@ -1733,5 +2629,14 @@ class ArcballControls extends THREE.EventDispatcher {
|
|
1733
2629
|
_transformation.gizmos = null;
|
1734
2630
|
}
|
1735
2631
|
}
|
2632
|
+
/**
|
2633
|
+
* Rotate camera around its direction axis passing by a given point by a given angle
|
2634
|
+
* @param {Vector3} point The point where the rotation axis is passing trough
|
2635
|
+
* @param {Number} angle Angle in radians
|
2636
|
+
* @returns The computed transormation matix
|
2637
|
+
*/
|
2638
|
+
|
2639
|
+
|
1736
2640
|
}
|
1737
|
-
|
2641
|
+
|
2642
|
+
export { ArcballControls };
|