super-three 0.167.0 → 0.168.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +32 -31
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/ClippingContext.js +14 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
Controls,
|
|
3
3
|
MathUtils,
|
|
4
4
|
MOUSE,
|
|
5
5
|
Quaternion,
|
|
@@ -11,18 +11,25 @@ const _changeEvent = { type: 'change' };
|
|
|
11
11
|
const _startEvent = { type: 'start' };
|
|
12
12
|
const _endEvent = { type: 'end' };
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const _EPS = 0.000001;
|
|
15
|
+
const _STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
const _v2 = new Vector2();
|
|
18
|
+
const _mouseChange = new Vector2();
|
|
19
|
+
const _objectUp = new Vector3();
|
|
20
|
+
const _pan = new Vector3();
|
|
21
|
+
const _axis = new Vector3();
|
|
22
|
+
const _quaternion = new Quaternion();
|
|
23
|
+
const _eyeDirection = new Vector3();
|
|
24
|
+
const _objectUpDirection = new Vector3();
|
|
25
|
+
const _objectSidewaysDirection = new Vector3();
|
|
26
|
+
const _moveDirection = new Vector3();
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
class TrackballControls extends Controls {
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
const STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
|
|
30
|
+
constructor( object, domElement = null ) {
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
this.domElement = domElement;
|
|
25
|
-
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
32
|
+
super( object, domElement );
|
|
26
33
|
|
|
27
34
|
// API
|
|
28
35
|
|
|
@@ -50,779 +57,773 @@ class TrackballControls extends EventDispatcher {
|
|
|
50
57
|
this.keys = [ 'KeyA' /*A*/, 'KeyS' /*S*/, 'KeyD' /*D*/ ];
|
|
51
58
|
|
|
52
59
|
this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
this.state = _STATE.NONE;
|
|
61
|
+
this.keyState = _STATE.NONE;
|
|
55
62
|
|
|
56
63
|
this.target = new Vector3();
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const lastPosition = new Vector3();
|
|
61
|
-
let lastZoom = 1;
|
|
62
|
-
|
|
63
|
-
let _state = STATE.NONE,
|
|
64
|
-
_keyState = STATE.NONE,
|
|
65
|
-
|
|
66
|
-
_touchZoomDistanceStart = 0,
|
|
67
|
-
_touchZoomDistanceEnd = 0,
|
|
65
|
+
// internals
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
this._lastPosition = new Vector3();
|
|
68
|
+
this._lastZoom = 1;
|
|
69
|
+
this._touchZoomDistanceStart = 0;
|
|
70
|
+
this._touchZoomDistanceEnd = 0;
|
|
71
|
+
this._lastAngle = 0;
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
this._eye = new Vector3();
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
this._movePrev = new Vector2();
|
|
76
|
+
this._moveCurr = new Vector2();
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
this._lastAxis = new Vector3();
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
this._zoomStart = new Vector2();
|
|
81
|
+
this._zoomEnd = new Vector2();
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
this._panStart = new Vector2();
|
|
84
|
+
this._panEnd = new Vector2();
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
this._pointers = [];
|
|
87
|
+
this._pointerPositions = {};
|
|
86
88
|
|
|
87
|
-
//
|
|
89
|
+
// event listeners
|
|
88
90
|
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
91
|
+
this._onPointerMove = onPointerMove.bind( this );
|
|
92
|
+
this._onPointerDown = onPointerDown.bind( this );
|
|
93
|
+
this._onPointerUp = onPointerUp.bind( this );
|
|
94
|
+
this._onPointerCancel = onPointerCancel.bind( this );
|
|
95
|
+
this._onContextMenu = onContextMenu.bind( this );
|
|
96
|
+
this._onMouseWheel = onMouseWheel.bind( this );
|
|
97
|
+
this._onKeyDown = onKeyDown.bind( this );
|
|
98
|
+
this._onKeyUp = onKeyUp.bind( this );
|
|
93
99
|
|
|
94
|
-
|
|
100
|
+
this._onTouchStart = onTouchStart.bind( this );
|
|
101
|
+
this._onTouchMove = onTouchMove.bind( this );
|
|
102
|
+
this._onTouchEnd = onTouchEnd.bind( this );
|
|
95
103
|
|
|
96
|
-
this.
|
|
104
|
+
this._onMouseDown = onMouseDown.bind( this );
|
|
105
|
+
this._onMouseMove = onMouseMove.bind( this );
|
|
106
|
+
this._onMouseUp = onMouseUp.bind( this );
|
|
97
107
|
|
|
98
|
-
|
|
99
|
-
// adjustments come from similar code in the jquery offset() function
|
|
100
|
-
const d = scope.domElement.ownerDocument.documentElement;
|
|
101
|
-
scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
|
102
|
-
scope.screen.top = box.top + window.pageYOffset - d.clientTop;
|
|
103
|
-
scope.screen.width = box.width;
|
|
104
|
-
scope.screen.height = box.height;
|
|
108
|
+
// for reset
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
this._target0 = this.target.clone();
|
|
111
|
+
this._position0 = this.object.position.clone();
|
|
112
|
+
this._up0 = this.object.up.clone();
|
|
113
|
+
this._zoom0 = this.object.zoom;
|
|
107
114
|
|
|
108
|
-
|
|
115
|
+
if ( domElement !== null ) {
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
this.connect();
|
|
111
118
|
|
|
112
|
-
|
|
119
|
+
this.handleResize();
|
|
113
120
|
|
|
114
|
-
|
|
115
|
-
( pageX - scope.screen.left ) / scope.screen.width,
|
|
116
|
-
( pageY - scope.screen.top ) / scope.screen.height
|
|
117
|
-
);
|
|
121
|
+
}
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
// force an update at start
|
|
124
|
+
this.update();
|
|
120
125
|
|
|
121
|
-
|
|
126
|
+
}
|
|
122
127
|
|
|
123
|
-
|
|
128
|
+
connect() {
|
|
124
129
|
|
|
125
|
-
|
|
130
|
+
window.addEventListener( 'keydown', this._onKeyDown );
|
|
131
|
+
window.addEventListener( 'keyup', this._onKeyUp );
|
|
126
132
|
|
|
127
|
-
|
|
133
|
+
this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
|
|
134
|
+
this.domElement.addEventListener( 'pointercancel', this._onPointerCancel );
|
|
135
|
+
this.domElement.addEventListener( 'wheel', this._onMouseWheel, { passive: false } );
|
|
136
|
+
this.domElement.addEventListener( 'contextmenu', this._onContextMenu );
|
|
128
137
|
|
|
129
|
-
|
|
138
|
+
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
130
139
|
|
|
131
|
-
|
|
132
|
-
( ( pageX - scope.screen.width * 0.5 - scope.screen.left ) / ( scope.screen.width * 0.5 ) ),
|
|
133
|
-
( ( scope.screen.height + 2 * ( scope.screen.top - pageY ) ) / scope.screen.width ) // screen.width intentional
|
|
134
|
-
);
|
|
140
|
+
}
|
|
135
141
|
|
|
136
|
-
|
|
142
|
+
disconnect() {
|
|
137
143
|
|
|
138
|
-
|
|
144
|
+
window.removeEventListener( 'keydown', this._onKeyDown );
|
|
145
|
+
window.removeEventListener( 'keyup', this._onKeyUp );
|
|
139
146
|
|
|
140
|
-
|
|
147
|
+
this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
|
|
148
|
+
this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
|
|
149
|
+
this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
|
|
150
|
+
this.domElement.removeEventListener( 'pointercancel', this._onPointerCancel );
|
|
151
|
+
this.domElement.removeEventListener( 'wheel', this._onMouseWheel );
|
|
152
|
+
this.domElement.removeEventListener( 'contextmenu', this._onContextMenu );
|
|
141
153
|
|
|
142
|
-
this.
|
|
154
|
+
this.domElement.style.touchAction = 'auto'; // disable touch scroll
|
|
143
155
|
|
|
144
|
-
|
|
145
|
-
quaternion = new Quaternion(),
|
|
146
|
-
eyeDirection = new Vector3(),
|
|
147
|
-
objectUpDirection = new Vector3(),
|
|
148
|
-
objectSidewaysDirection = new Vector3(),
|
|
149
|
-
moveDirection = new Vector3();
|
|
156
|
+
}
|
|
150
157
|
|
|
151
|
-
|
|
158
|
+
dispose() {
|
|
152
159
|
|
|
153
|
-
|
|
154
|
-
let angle = moveDirection.length();
|
|
160
|
+
this.disconnect();
|
|
155
161
|
|
|
156
|
-
|
|
162
|
+
}
|
|
157
163
|
|
|
158
|
-
|
|
164
|
+
handleResize() {
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
const box = this.domElement.getBoundingClientRect();
|
|
167
|
+
// adjustments come from similar code in the jquery offset() function
|
|
168
|
+
const d = this.domElement.ownerDocument.documentElement;
|
|
163
169
|
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
this.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
|
171
|
+
this.screen.top = box.top + window.pageYOffset - d.clientTop;
|
|
172
|
+
this.screen.width = box.width;
|
|
173
|
+
this.screen.height = box.height;
|
|
166
174
|
|
|
167
|
-
|
|
175
|
+
}
|
|
168
176
|
|
|
169
|
-
|
|
177
|
+
update() {
|
|
170
178
|
|
|
171
|
-
|
|
172
|
-
quaternion.setFromAxisAngle( axis, angle );
|
|
179
|
+
this._eye.subVectors( this.object.position, this.target );
|
|
173
180
|
|
|
174
|
-
|
|
175
|
-
scope.object.up.applyQuaternion( quaternion );
|
|
181
|
+
if ( ! this.noRotate ) {
|
|
176
182
|
|
|
177
|
-
|
|
178
|
-
_lastAngle = angle;
|
|
183
|
+
this._rotateCamera();
|
|
179
184
|
|
|
180
|
-
|
|
185
|
+
}
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
_eye.copy( scope.object.position ).sub( scope.target );
|
|
184
|
-
quaternion.setFromAxisAngle( _lastAxis, _lastAngle );
|
|
185
|
-
_eye.applyQuaternion( quaternion );
|
|
186
|
-
scope.object.up.applyQuaternion( quaternion );
|
|
187
|
+
if ( ! this.noZoom ) {
|
|
187
188
|
|
|
188
|
-
|
|
189
|
+
this._zoomCamera();
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
}
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
if ( ! this.noPan ) {
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
this._panCamera();
|
|
195
196
|
|
|
197
|
+
}
|
|
196
198
|
|
|
197
|
-
this.
|
|
199
|
+
this.object.position.addVectors( this.target, this._eye );
|
|
198
200
|
|
|
199
|
-
|
|
201
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
this._checkDistances();
|
|
202
204
|
|
|
203
|
-
|
|
204
|
-
_touchZoomDistanceStart = _touchZoomDistanceEnd;
|
|
205
|
+
this.object.lookAt( this.target );
|
|
205
206
|
|
|
206
|
-
|
|
207
|
+
if ( this._lastPosition.distanceToSquared( this.object.position ) > _EPS ) {
|
|
207
208
|
|
|
208
|
-
|
|
209
|
+
this.dispatchEvent( _changeEvent );
|
|
209
210
|
|
|
210
|
-
|
|
211
|
+
this._lastPosition.copy( this.object.position );
|
|
211
212
|
|
|
212
|
-
|
|
213
|
+
}
|
|
213
214
|
|
|
214
|
-
|
|
215
|
+
} else if ( this.object.isOrthographicCamera ) {
|
|
215
216
|
|
|
216
|
-
|
|
217
|
+
this.object.lookAt( this.target );
|
|
217
218
|
|
|
218
|
-
|
|
219
|
+
if ( this._lastPosition.distanceToSquared( this.object.position ) > _EPS || this._lastZoom !== this.object.zoom ) {
|
|
219
220
|
|
|
220
|
-
|
|
221
|
+
this.dispatchEvent( _changeEvent );
|
|
221
222
|
|
|
222
|
-
|
|
223
|
+
this._lastPosition.copy( this.object.position );
|
|
224
|
+
this._lastZoom = this.object.zoom;
|
|
223
225
|
|
|
224
|
-
|
|
226
|
+
}
|
|
225
227
|
|
|
226
|
-
|
|
228
|
+
} else {
|
|
227
229
|
|
|
228
|
-
|
|
230
|
+
console.warn( 'THREE.TrackballControls: Unsupported camera type.' );
|
|
229
231
|
|
|
230
|
-
|
|
232
|
+
}
|
|
231
233
|
|
|
232
|
-
|
|
234
|
+
}
|
|
233
235
|
|
|
234
|
-
|
|
236
|
+
reset() {
|
|
235
237
|
|
|
236
|
-
|
|
238
|
+
this.state = _STATE.NONE;
|
|
239
|
+
this.keyState = _STATE.NONE;
|
|
237
240
|
|
|
238
|
-
|
|
241
|
+
this.target.copy( this._target0 );
|
|
242
|
+
this.object.position.copy( this._position0 );
|
|
243
|
+
this.object.up.copy( this._up0 );
|
|
244
|
+
this.object.zoom = this._zoom0;
|
|
239
245
|
|
|
240
|
-
|
|
246
|
+
this.object.updateProjectionMatrix();
|
|
241
247
|
|
|
242
|
-
|
|
248
|
+
this._eye.subVectors( this.object.position, this.target );
|
|
243
249
|
|
|
244
|
-
|
|
250
|
+
this.object.lookAt( this.target );
|
|
245
251
|
|
|
246
|
-
|
|
252
|
+
this.dispatchEvent( _changeEvent );
|
|
247
253
|
|
|
248
|
-
|
|
254
|
+
this._lastPosition.copy( this.object.position );
|
|
255
|
+
this._lastZoom = this.object.zoom;
|
|
249
256
|
|
|
250
|
-
|
|
257
|
+
}
|
|
251
258
|
|
|
252
|
-
|
|
259
|
+
_panCamera() {
|
|
253
260
|
|
|
254
|
-
|
|
261
|
+
_mouseChange.copy( this._panEnd ).sub( this._panStart );
|
|
255
262
|
|
|
256
|
-
|
|
263
|
+
if ( _mouseChange.lengthSq() ) {
|
|
257
264
|
|
|
258
|
-
|
|
265
|
+
if ( this.object.isOrthographicCamera ) {
|
|
259
266
|
|
|
260
|
-
|
|
267
|
+
const scale_x = ( this.object.right - this.object.left ) / this.object.zoom / this.domElement.clientWidth;
|
|
268
|
+
const scale_y = ( this.object.top - this.object.bottom ) / this.object.zoom / this.domElement.clientWidth;
|
|
261
269
|
|
|
262
|
-
|
|
270
|
+
_mouseChange.x *= scale_x;
|
|
271
|
+
_mouseChange.y *= scale_y;
|
|
263
272
|
|
|
264
273
|
}
|
|
265
274
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
this.panCamera = ( function () {
|
|
269
|
-
|
|
270
|
-
const mouseChange = new Vector2(),
|
|
271
|
-
objectUp = new Vector3(),
|
|
272
|
-
pan = new Vector3();
|
|
275
|
+
_mouseChange.multiplyScalar( this._eye.length() * this.panSpeed );
|
|
273
276
|
|
|
274
|
-
|
|
277
|
+
_pan.copy( this._eye ).cross( this.object.up ).setLength( _mouseChange.x );
|
|
278
|
+
_pan.add( _objectUp.copy( this.object.up ).setLength( _mouseChange.y ) );
|
|
275
279
|
|
|
276
|
-
|
|
280
|
+
this.object.position.add( _pan );
|
|
281
|
+
this.target.add( _pan );
|
|
277
282
|
|
|
278
|
-
|
|
283
|
+
if ( this.staticMoving ) {
|
|
279
284
|
|
|
280
|
-
|
|
285
|
+
this._panStart.copy( this._panEnd );
|
|
281
286
|
|
|
282
|
-
|
|
283
|
-
const scale_y = ( scope.object.top - scope.object.bottom ) / scope.object.zoom / scope.domElement.clientWidth;
|
|
287
|
+
} else {
|
|
284
288
|
|
|
285
|
-
|
|
286
|
-
mouseChange.y *= scale_y;
|
|
289
|
+
this._panStart.add( _mouseChange.subVectors( this._panEnd, this._panStart ).multiplyScalar( this.dynamicDampingFactor ) );
|
|
287
290
|
|
|
288
|
-
|
|
291
|
+
}
|
|
289
292
|
|
|
290
|
-
|
|
293
|
+
}
|
|
291
294
|
|
|
292
|
-
|
|
293
|
-
pan.add( objectUp.copy( scope.object.up ).setLength( mouseChange.y ) );
|
|
295
|
+
}
|
|
294
296
|
|
|
295
|
-
|
|
296
|
-
scope.target.add( pan );
|
|
297
|
+
_rotateCamera() {
|
|
297
298
|
|
|
298
|
-
|
|
299
|
+
_moveDirection.set( this._moveCurr.x - this._movePrev.x, this._moveCurr.y - this._movePrev.y, 0 );
|
|
300
|
+
let angle = _moveDirection.length();
|
|
299
301
|
|
|
300
|
-
|
|
302
|
+
if ( angle ) {
|
|
301
303
|
|
|
302
|
-
|
|
304
|
+
this._eye.copy( this.object.position ).sub( this.target );
|
|
303
305
|
|
|
304
|
-
|
|
306
|
+
_eyeDirection.copy( this._eye ).normalize();
|
|
307
|
+
_objectUpDirection.copy( this.object.up ).normalize();
|
|
308
|
+
_objectSidewaysDirection.crossVectors( _objectUpDirection, _eyeDirection ).normalize();
|
|
305
309
|
|
|
306
|
-
|
|
310
|
+
_objectUpDirection.setLength( this._moveCurr.y - this._movePrev.y );
|
|
311
|
+
_objectSidewaysDirection.setLength( this._moveCurr.x - this._movePrev.x );
|
|
307
312
|
|
|
308
|
-
|
|
313
|
+
_moveDirection.copy( _objectUpDirection.add( _objectSidewaysDirection ) );
|
|
309
314
|
|
|
310
|
-
|
|
315
|
+
_axis.crossVectors( _moveDirection, this._eye ).normalize();
|
|
311
316
|
|
|
312
|
-
|
|
317
|
+
angle *= this.rotateSpeed;
|
|
318
|
+
_quaternion.setFromAxisAngle( _axis, angle );
|
|
313
319
|
|
|
314
|
-
|
|
320
|
+
this._eye.applyQuaternion( _quaternion );
|
|
321
|
+
this.object.up.applyQuaternion( _quaternion );
|
|
315
322
|
|
|
316
|
-
|
|
323
|
+
this._lastAxis.copy( _axis );
|
|
324
|
+
this._lastAngle = angle;
|
|
317
325
|
|
|
318
|
-
|
|
326
|
+
} else if ( ! this.staticMoving && this._lastAngle ) {
|
|
319
327
|
|
|
320
|
-
|
|
321
|
-
|
|
328
|
+
this._lastAngle *= Math.sqrt( 1.0 - this.dynamicDampingFactor );
|
|
329
|
+
this._eye.copy( this.object.position ).sub( this.target );
|
|
330
|
+
_quaternion.setFromAxisAngle( this._lastAxis, this._lastAngle );
|
|
331
|
+
this._eye.applyQuaternion( _quaternion );
|
|
332
|
+
this.object.up.applyQuaternion( _quaternion );
|
|
322
333
|
|
|
323
|
-
|
|
334
|
+
}
|
|
324
335
|
|
|
325
|
-
|
|
336
|
+
this._movePrev.copy( this._moveCurr );
|
|
326
337
|
|
|
327
|
-
|
|
328
|
-
_zoomStart.copy( _zoomEnd );
|
|
338
|
+
}
|
|
329
339
|
|
|
330
|
-
|
|
340
|
+
_zoomCamera() {
|
|
331
341
|
|
|
332
|
-
|
|
342
|
+
let factor;
|
|
333
343
|
|
|
334
|
-
|
|
344
|
+
if ( this.state === _STATE.TOUCH_ZOOM_PAN ) {
|
|
335
345
|
|
|
336
|
-
|
|
346
|
+
factor = this._touchZoomDistanceStart / this._touchZoomDistanceEnd;
|
|
347
|
+
this._touchZoomDistanceStart = this._touchZoomDistanceEnd;
|
|
337
348
|
|
|
338
|
-
|
|
349
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
339
350
|
|
|
340
|
-
|
|
351
|
+
this._eye.multiplyScalar( factor );
|
|
341
352
|
|
|
342
|
-
|
|
353
|
+
} else if ( this.object.isOrthographicCamera ) {
|
|
343
354
|
|
|
344
|
-
|
|
355
|
+
this.object.zoom = MathUtils.clamp( this.object.zoom / factor, this.minZoom, this.maxZoom );
|
|
345
356
|
|
|
346
|
-
|
|
357
|
+
if ( this._lastZoom !== this.object.zoom ) {
|
|
347
358
|
|
|
348
|
-
|
|
359
|
+
this.object.updateProjectionMatrix();
|
|
349
360
|
|
|
350
|
-
|
|
361
|
+
}
|
|
351
362
|
|
|
352
|
-
|
|
363
|
+
} else {
|
|
353
364
|
|
|
354
|
-
|
|
365
|
+
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
|
355
366
|
|
|
356
367
|
}
|
|
357
368
|
|
|
358
|
-
|
|
369
|
+
} else {
|
|
359
370
|
|
|
360
|
-
|
|
371
|
+
factor = 1.0 + ( this._zoomEnd.y - this._zoomStart.y ) * this.zoomSpeed;
|
|
361
372
|
|
|
362
|
-
|
|
373
|
+
if ( factor !== 1.0 && factor > 0.0 ) {
|
|
363
374
|
|
|
364
|
-
|
|
375
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
365
376
|
|
|
366
|
-
|
|
377
|
+
this._eye.multiplyScalar( factor );
|
|
367
378
|
|
|
368
|
-
|
|
379
|
+
} else if ( this.object.isOrthographicCamera ) {
|
|
369
380
|
|
|
370
|
-
|
|
381
|
+
this.object.zoom = MathUtils.clamp( this.object.zoom / factor, this.minZoom, this.maxZoom );
|
|
371
382
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
} else if ( scope.object.isOrthographicCamera ) {
|
|
383
|
+
if ( this._lastZoom !== this.object.zoom ) {
|
|
375
384
|
|
|
376
|
-
|
|
385
|
+
this.object.updateProjectionMatrix();
|
|
377
386
|
|
|
378
|
-
|
|
387
|
+
}
|
|
379
388
|
|
|
380
|
-
|
|
389
|
+
} else {
|
|
381
390
|
|
|
382
|
-
|
|
383
|
-
lastZoom = scope.object.zoom;
|
|
391
|
+
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
|
384
392
|
|
|
385
393
|
}
|
|
386
394
|
|
|
387
|
-
} else {
|
|
388
|
-
|
|
389
|
-
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
|
390
|
-
|
|
391
395
|
}
|
|
392
396
|
|
|
393
|
-
|
|
397
|
+
if ( this.staticMoving ) {
|
|
394
398
|
|
|
395
|
-
|
|
399
|
+
this._zoomStart.copy( this._zoomEnd );
|
|
396
400
|
|
|
397
|
-
|
|
398
|
-
_keyState = STATE.NONE;
|
|
401
|
+
} else {
|
|
399
402
|
|
|
400
|
-
|
|
401
|
-
scope.object.position.copy( scope.position0 );
|
|
402
|
-
scope.object.up.copy( scope.up0 );
|
|
403
|
-
scope.object.zoom = scope.zoom0;
|
|
403
|
+
this._zoomStart.y += ( this._zoomEnd.y - this._zoomStart.y ) * this.dynamicDampingFactor;
|
|
404
404
|
|
|
405
|
-
|
|
405
|
+
}
|
|
406
406
|
|
|
407
|
-
|
|
407
|
+
}
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
}
|
|
410
410
|
|
|
411
|
-
|
|
411
|
+
_getMouseOnScreen( pageX, pageY ) {
|
|
412
412
|
|
|
413
|
-
|
|
414
|
-
|
|
413
|
+
_v2.set(
|
|
414
|
+
( pageX - this.screen.left ) / this.screen.width,
|
|
415
|
+
( pageY - this.screen.top ) / this.screen.height
|
|
416
|
+
);
|
|
415
417
|
|
|
416
|
-
|
|
418
|
+
return _v2;
|
|
417
419
|
|
|
418
|
-
|
|
420
|
+
}
|
|
419
421
|
|
|
420
|
-
|
|
422
|
+
_getMouseOnCircle( pageX, pageY ) {
|
|
421
423
|
|
|
422
|
-
|
|
424
|
+
_v2.set(
|
|
425
|
+
( ( pageX - this.screen.width * 0.5 - this.screen.left ) / ( this.screen.width * 0.5 ) ),
|
|
426
|
+
( ( this.screen.height + 2 * ( this.screen.top - pageY ) ) / this.screen.width ) // screen.width intentional
|
|
427
|
+
);
|
|
423
428
|
|
|
424
|
-
|
|
429
|
+
return _v2;
|
|
425
430
|
|
|
426
|
-
|
|
431
|
+
}
|
|
427
432
|
|
|
428
|
-
|
|
429
|
-
scope.domElement.addEventListener( 'pointerup', onPointerUp );
|
|
433
|
+
_addPointer( event ) {
|
|
430
434
|
|
|
431
|
-
|
|
435
|
+
this._pointers.push( event );
|
|
432
436
|
|
|
433
|
-
|
|
437
|
+
}
|
|
434
438
|
|
|
435
|
-
|
|
439
|
+
_removePointer( event ) {
|
|
436
440
|
|
|
437
|
-
|
|
441
|
+
delete this._pointerPositions[ event.pointerId ];
|
|
438
442
|
|
|
439
|
-
|
|
443
|
+
for ( let i = 0; i < this._pointers.length; i ++ ) {
|
|
440
444
|
|
|
441
|
-
|
|
445
|
+
if ( this._pointers[ i ].pointerId == event.pointerId ) {
|
|
442
446
|
|
|
443
|
-
|
|
447
|
+
this._pointers.splice( i, 1 );
|
|
448
|
+
return;
|
|
444
449
|
|
|
445
450
|
}
|
|
446
451
|
|
|
447
452
|
}
|
|
448
453
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if ( scope.enabled === false ) return;
|
|
454
|
+
}
|
|
452
455
|
|
|
453
|
-
|
|
456
|
+
_trackPointer( event ) {
|
|
454
457
|
|
|
455
|
-
|
|
458
|
+
let position = this._pointerPositions[ event.pointerId ];
|
|
456
459
|
|
|
457
|
-
|
|
460
|
+
if ( position === undefined ) {
|
|
458
461
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
+
position = new Vector2();
|
|
463
|
+
this._pointerPositions[ event.pointerId ] = position;
|
|
462
464
|
|
|
463
465
|
}
|
|
464
466
|
|
|
465
|
-
|
|
467
|
+
position.set( event.pageX, event.pageY );
|
|
468
|
+
|
|
469
|
+
}
|
|
466
470
|
|
|
467
|
-
|
|
471
|
+
_getSecondPointerPosition( event ) {
|
|
468
472
|
|
|
469
|
-
|
|
473
|
+
const pointer = ( event.pointerId === this._pointers[ 0 ].pointerId ) ? this._pointers[ 1 ] : this._pointers[ 0 ];
|
|
470
474
|
|
|
471
|
-
|
|
475
|
+
return this._pointerPositions[ pointer.pointerId ];
|
|
472
476
|
|
|
473
|
-
|
|
477
|
+
}
|
|
474
478
|
|
|
475
|
-
|
|
479
|
+
_checkDistances() {
|
|
476
480
|
|
|
477
|
-
|
|
481
|
+
if ( ! this.noZoom || ! this.noPan ) {
|
|
478
482
|
|
|
479
|
-
|
|
483
|
+
if ( this._eye.lengthSq() > this.maxDistance * this.maxDistance ) {
|
|
480
484
|
|
|
481
|
-
|
|
485
|
+
this.object.position.addVectors( this.target, this._eye.setLength( this.maxDistance ) );
|
|
486
|
+
this._zoomStart.copy( this._zoomEnd );
|
|
482
487
|
|
|
483
|
-
|
|
488
|
+
}
|
|
484
489
|
|
|
485
|
-
|
|
490
|
+
if ( this._eye.lengthSq() < this.minDistance * this.minDistance ) {
|
|
486
491
|
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
this.object.position.addVectors( this.target, this._eye.setLength( this.minDistance ) );
|
|
493
|
+
this._zoomStart.copy( this._zoomEnd );
|
|
489
494
|
|
|
490
495
|
}
|
|
491
496
|
|
|
492
|
-
|
|
493
497
|
}
|
|
494
498
|
|
|
495
|
-
|
|
499
|
+
}
|
|
496
500
|
|
|
497
|
-
|
|
501
|
+
}
|
|
498
502
|
|
|
499
|
-
|
|
503
|
+
function onPointerDown( event ) {
|
|
500
504
|
|
|
501
|
-
|
|
505
|
+
if ( this.enabled === false ) return;
|
|
502
506
|
|
|
503
|
-
|
|
507
|
+
if ( this._pointers.length === 0 ) {
|
|
504
508
|
|
|
505
|
-
|
|
509
|
+
this.domElement.setPointerCapture( event.pointerId );
|
|
506
510
|
|
|
507
|
-
|
|
511
|
+
this.domElement.addEventListener( 'pointermove', this._onPointerMove );
|
|
512
|
+
this.domElement.addEventListener( 'pointerup', this._onPointerUp );
|
|
508
513
|
|
|
509
|
-
|
|
514
|
+
}
|
|
510
515
|
|
|
511
|
-
|
|
516
|
+
//
|
|
512
517
|
|
|
513
|
-
|
|
518
|
+
this._addPointer( event );
|
|
514
519
|
|
|
515
|
-
|
|
520
|
+
if ( event.pointerType === 'touch' ) {
|
|
516
521
|
|
|
517
|
-
|
|
522
|
+
this._onTouchStart( event );
|
|
518
523
|
|
|
519
|
-
|
|
524
|
+
} else {
|
|
520
525
|
|
|
521
|
-
|
|
526
|
+
this._onMouseDown( event );
|
|
522
527
|
|
|
523
|
-
|
|
528
|
+
}
|
|
524
529
|
|
|
525
|
-
|
|
530
|
+
}
|
|
526
531
|
|
|
527
|
-
|
|
532
|
+
function onPointerMove( event ) {
|
|
528
533
|
|
|
529
|
-
|
|
534
|
+
if ( this.enabled === false ) return;
|
|
530
535
|
|
|
531
|
-
|
|
536
|
+
if ( event.pointerType === 'touch' ) {
|
|
532
537
|
|
|
533
|
-
|
|
538
|
+
this._onTouchMove( event );
|
|
534
539
|
|
|
535
|
-
|
|
540
|
+
} else {
|
|
536
541
|
|
|
537
|
-
|
|
542
|
+
this._onMouseMove( event );
|
|
538
543
|
|
|
539
|
-
|
|
544
|
+
}
|
|
540
545
|
|
|
541
|
-
|
|
546
|
+
}
|
|
542
547
|
|
|
543
|
-
|
|
544
|
-
_state = STATE.ROTATE;
|
|
545
|
-
break;
|
|
548
|
+
function onPointerUp( event ) {
|
|
546
549
|
|
|
547
|
-
|
|
548
|
-
_state = STATE.ZOOM;
|
|
549
|
-
break;
|
|
550
|
+
if ( this.enabled === false ) return;
|
|
550
551
|
|
|
551
|
-
|
|
552
|
-
_state = STATE.PAN;
|
|
553
|
-
break;
|
|
552
|
+
if ( event.pointerType === 'touch' ) {
|
|
554
553
|
|
|
555
|
-
|
|
554
|
+
this._onTouchEnd( event );
|
|
556
555
|
|
|
557
|
-
|
|
556
|
+
} else {
|
|
558
557
|
|
|
559
|
-
|
|
558
|
+
this._onMouseUp();
|
|
560
559
|
|
|
561
|
-
|
|
560
|
+
}
|
|
562
561
|
|
|
563
|
-
|
|
564
|
-
_movePrev.copy( _moveCurr );
|
|
562
|
+
//
|
|
565
563
|
|
|
566
|
-
|
|
564
|
+
this._removePointer( event );
|
|
567
565
|
|
|
568
|
-
|
|
569
|
-
_zoomEnd.copy( _zoomStart );
|
|
566
|
+
if ( this._pointers.length === 0 ) {
|
|
570
567
|
|
|
571
|
-
|
|
568
|
+
this.domElement.releasePointerCapture( event.pointerId );
|
|
572
569
|
|
|
573
|
-
|
|
574
|
-
|
|
570
|
+
this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
|
|
571
|
+
this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
|
|
575
572
|
|
|
576
|
-
|
|
573
|
+
}
|
|
577
574
|
|
|
578
|
-
|
|
575
|
+
}
|
|
579
576
|
|
|
580
|
-
|
|
577
|
+
function onPointerCancel( event ) {
|
|
581
578
|
|
|
582
|
-
|
|
579
|
+
this._removePointer( event );
|
|
583
580
|
|
|
584
|
-
|
|
581
|
+
}
|
|
585
582
|
|
|
586
|
-
|
|
583
|
+
function onKeyUp() {
|
|
587
584
|
|
|
588
|
-
|
|
589
|
-
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
585
|
+
if ( this.enabled === false ) return;
|
|
590
586
|
|
|
591
|
-
|
|
587
|
+
this.keyState = _STATE.NONE;
|
|
592
588
|
|
|
593
|
-
|
|
589
|
+
window.addEventListener( 'keydown', this._onKeyDown );
|
|
594
590
|
|
|
595
|
-
|
|
591
|
+
}
|
|
596
592
|
|
|
597
|
-
|
|
593
|
+
function onKeyDown( event ) {
|
|
598
594
|
|
|
599
|
-
|
|
595
|
+
if ( this.enabled === false ) return;
|
|
600
596
|
|
|
601
|
-
|
|
597
|
+
window.removeEventListener( 'keydown', this._onKeyDown );
|
|
602
598
|
|
|
603
|
-
|
|
599
|
+
if ( this.keyState !== _STATE.NONE ) {
|
|
604
600
|
|
|
605
|
-
|
|
601
|
+
return;
|
|
606
602
|
|
|
607
|
-
|
|
603
|
+
} else if ( event.code === this.keys[ _STATE.ROTATE ] && ! this.noRotate ) {
|
|
608
604
|
|
|
609
|
-
|
|
605
|
+
this.keyState = _STATE.ROTATE;
|
|
610
606
|
|
|
611
|
-
|
|
607
|
+
} else if ( event.code === this.keys[ _STATE.ZOOM ] && ! this.noZoom ) {
|
|
612
608
|
|
|
613
|
-
|
|
609
|
+
this.keyState = _STATE.ZOOM;
|
|
614
610
|
|
|
615
|
-
|
|
611
|
+
} else if ( event.code === this.keys[ _STATE.PAN ] && ! this.noPan ) {
|
|
616
612
|
|
|
617
|
-
|
|
613
|
+
this.keyState = _STATE.PAN;
|
|
618
614
|
|
|
619
|
-
|
|
615
|
+
}
|
|
620
616
|
|
|
621
|
-
|
|
622
|
-
// Zoom in pages
|
|
623
|
-
_zoomStart.y -= event.deltaY * 0.025;
|
|
624
|
-
break;
|
|
617
|
+
}
|
|
625
618
|
|
|
626
|
-
|
|
627
|
-
// Zoom in lines
|
|
628
|
-
_zoomStart.y -= event.deltaY * 0.01;
|
|
629
|
-
break;
|
|
619
|
+
function onMouseDown( event ) {
|
|
630
620
|
|
|
631
|
-
|
|
632
|
-
// undefined, 0, assume pixels
|
|
633
|
-
_zoomStart.y -= event.deltaY * 0.00025;
|
|
634
|
-
break;
|
|
621
|
+
if ( this.state === _STATE.NONE ) {
|
|
635
622
|
|
|
636
|
-
|
|
623
|
+
switch ( event.button ) {
|
|
637
624
|
|
|
638
|
-
|
|
639
|
-
|
|
625
|
+
case this.mouseButtons.LEFT:
|
|
626
|
+
this.state = _STATE.ROTATE;
|
|
627
|
+
break;
|
|
640
628
|
|
|
641
|
-
|
|
629
|
+
case this.mouseButtons.MIDDLE:
|
|
630
|
+
this.state = _STATE.ZOOM;
|
|
631
|
+
break;
|
|
642
632
|
|
|
643
|
-
|
|
633
|
+
case this.mouseButtons.RIGHT:
|
|
634
|
+
this.state = _STATE.PAN;
|
|
635
|
+
break;
|
|
644
636
|
|
|
645
|
-
|
|
637
|
+
}
|
|
646
638
|
|
|
647
|
-
|
|
639
|
+
}
|
|
648
640
|
|
|
649
|
-
|
|
650
|
-
_state = STATE.TOUCH_ROTATE;
|
|
651
|
-
_moveCurr.copy( getMouseOnCircle( _pointers[ 0 ].pageX, _pointers[ 0 ].pageY ) );
|
|
652
|
-
_movePrev.copy( _moveCurr );
|
|
653
|
-
break;
|
|
641
|
+
const state = ( this.keyState !== _STATE.NONE ) ? this.keyState : this.state;
|
|
654
642
|
|
|
655
|
-
|
|
656
|
-
_state = STATE.TOUCH_ZOOM_PAN;
|
|
657
|
-
const dx = _pointers[ 0 ].pageX - _pointers[ 1 ].pageX;
|
|
658
|
-
const dy = _pointers[ 0 ].pageY - _pointers[ 1 ].pageY;
|
|
659
|
-
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
|
643
|
+
if ( state === _STATE.ROTATE && ! this.noRotate ) {
|
|
660
644
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
_panStart.copy( getMouseOnScreen( x, y ) );
|
|
664
|
-
_panEnd.copy( _panStart );
|
|
665
|
-
break;
|
|
645
|
+
this._moveCurr.copy( this._getMouseOnCircle( event.pageX, event.pageY ) );
|
|
646
|
+
this._movePrev.copy( this._moveCurr );
|
|
666
647
|
|
|
667
|
-
|
|
648
|
+
} else if ( state === _STATE.ZOOM && ! this.noZoom ) {
|
|
668
649
|
|
|
669
|
-
|
|
650
|
+
this._zoomStart.copy( this._getMouseOnScreen( event.pageX, event.pageY ) );
|
|
651
|
+
this._zoomEnd.copy( this._zoomStart );
|
|
670
652
|
|
|
671
|
-
|
|
653
|
+
} else if ( state === _STATE.PAN && ! this.noPan ) {
|
|
672
654
|
|
|
673
|
-
|
|
655
|
+
this._panStart.copy( this._getMouseOnScreen( event.pageX, event.pageY ) );
|
|
656
|
+
this._panEnd.copy( this._panStart );
|
|
674
657
|
|
|
675
|
-
|
|
658
|
+
}
|
|
676
659
|
|
|
677
|
-
|
|
660
|
+
this.dispatchEvent( _startEvent );
|
|
678
661
|
|
|
679
|
-
|
|
680
|
-
_movePrev.copy( _moveCurr );
|
|
681
|
-
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
682
|
-
break;
|
|
662
|
+
}
|
|
683
663
|
|
|
684
|
-
|
|
664
|
+
function onMouseMove( event ) {
|
|
685
665
|
|
|
686
|
-
|
|
666
|
+
const state = ( this.keyState !== _STATE.NONE ) ? this.keyState : this.state;
|
|
687
667
|
|
|
688
|
-
|
|
689
|
-
const dy = event.pageY - position.y;
|
|
690
|
-
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
|
668
|
+
if ( state === _STATE.ROTATE && ! this.noRotate ) {
|
|
691
669
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
_panEnd.copy( getMouseOnScreen( x, y ) );
|
|
695
|
-
break;
|
|
670
|
+
this._movePrev.copy( this._moveCurr );
|
|
671
|
+
this._moveCurr.copy( this._getMouseOnCircle( event.pageX, event.pageY ) );
|
|
696
672
|
|
|
697
|
-
|
|
673
|
+
} else if ( state === _STATE.ZOOM && ! this.noZoom ) {
|
|
698
674
|
|
|
699
|
-
|
|
675
|
+
this._zoomEnd.copy( this._getMouseOnScreen( event.pageX, event.pageY ) );
|
|
700
676
|
|
|
701
|
-
|
|
677
|
+
} else if ( state === _STATE.PAN && ! this.noPan ) {
|
|
702
678
|
|
|
703
|
-
|
|
679
|
+
this._panEnd.copy( this._getMouseOnScreen( event.pageX, event.pageY ) );
|
|
704
680
|
|
|
705
|
-
|
|
706
|
-
_state = STATE.NONE;
|
|
707
|
-
break;
|
|
681
|
+
}
|
|
708
682
|
|
|
709
|
-
|
|
710
|
-
_state = STATE.TOUCH_ROTATE;
|
|
711
|
-
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
712
|
-
_movePrev.copy( _moveCurr );
|
|
713
|
-
break;
|
|
683
|
+
}
|
|
714
684
|
|
|
715
|
-
|
|
716
|
-
_state = STATE.TOUCH_ZOOM_PAN;
|
|
685
|
+
function onMouseUp() {
|
|
717
686
|
|
|
718
|
-
|
|
687
|
+
this.state = _STATE.NONE;
|
|
719
688
|
|
|
720
|
-
|
|
689
|
+
this.dispatchEvent( _endEvent );
|
|
721
690
|
|
|
722
|
-
|
|
723
|
-
_moveCurr.copy( getMouseOnCircle( position.x, position.y ) );
|
|
724
|
-
_movePrev.copy( _moveCurr );
|
|
725
|
-
break;
|
|
691
|
+
}
|
|
726
692
|
|
|
727
|
-
|
|
693
|
+
function onMouseWheel( event ) {
|
|
728
694
|
|
|
729
|
-
|
|
695
|
+
if ( this.enabled === false ) return;
|
|
730
696
|
|
|
731
|
-
|
|
697
|
+
if ( this.noZoom === true ) return;
|
|
732
698
|
|
|
733
|
-
|
|
699
|
+
event.preventDefault();
|
|
734
700
|
|
|
735
|
-
|
|
701
|
+
switch ( event.deltaMode ) {
|
|
736
702
|
|
|
737
|
-
|
|
703
|
+
case 2:
|
|
704
|
+
// Zoom in pages
|
|
705
|
+
this._zoomStart.y -= event.deltaY * 0.025;
|
|
706
|
+
break;
|
|
738
707
|
|
|
739
|
-
|
|
708
|
+
case 1:
|
|
709
|
+
// Zoom in lines
|
|
710
|
+
this._zoomStart.y -= event.deltaY * 0.01;
|
|
711
|
+
break;
|
|
740
712
|
|
|
741
|
-
|
|
713
|
+
default:
|
|
714
|
+
// undefined, 0, assume pixels
|
|
715
|
+
this._zoomStart.y -= event.deltaY * 0.00025;
|
|
716
|
+
break;
|
|
742
717
|
|
|
743
|
-
|
|
718
|
+
}
|
|
744
719
|
|
|
745
|
-
|
|
720
|
+
this.dispatchEvent( _startEvent );
|
|
721
|
+
this.dispatchEvent( _endEvent );
|
|
746
722
|
|
|
747
|
-
|
|
723
|
+
}
|
|
748
724
|
|
|
749
|
-
|
|
725
|
+
function onContextMenu( event ) {
|
|
750
726
|
|
|
751
|
-
|
|
727
|
+
if ( this.enabled === false ) return;
|
|
752
728
|
|
|
753
|
-
|
|
729
|
+
event.preventDefault();
|
|
754
730
|
|
|
755
|
-
|
|
731
|
+
}
|
|
756
732
|
|
|
757
|
-
|
|
733
|
+
function onTouchStart( event ) {
|
|
758
734
|
|
|
759
|
-
|
|
735
|
+
this._trackPointer( event );
|
|
760
736
|
|
|
761
|
-
|
|
762
|
-
return;
|
|
737
|
+
switch ( this._pointers.length ) {
|
|
763
738
|
|
|
764
|
-
|
|
739
|
+
case 1:
|
|
740
|
+
this.state = _STATE.TOUCH_ROTATE;
|
|
741
|
+
this._moveCurr.copy( this._getMouseOnCircle( this._pointers[ 0 ].pageX, this._pointers[ 0 ].pageY ) );
|
|
742
|
+
this._movePrev.copy( this._moveCurr );
|
|
743
|
+
break;
|
|
765
744
|
|
|
766
|
-
|
|
745
|
+
default: // 2 or more
|
|
746
|
+
this.state = _STATE.TOUCH_ZOOM_PAN;
|
|
747
|
+
const dx = this._pointers[ 0 ].pageX - this._pointers[ 1 ].pageX;
|
|
748
|
+
const dy = this._pointers[ 0 ].pageY - this._pointers[ 1 ].pageY;
|
|
749
|
+
this._touchZoomDistanceEnd = this._touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
|
767
750
|
|
|
768
|
-
|
|
751
|
+
const x = ( this._pointers[ 0 ].pageX + this._pointers[ 1 ].pageX ) / 2;
|
|
752
|
+
const y = ( this._pointers[ 0 ].pageY + this._pointers[ 1 ].pageY ) / 2;
|
|
753
|
+
this._panStart.copy( this._getMouseOnScreen( x, y ) );
|
|
754
|
+
this._panEnd.copy( this._panStart );
|
|
755
|
+
break;
|
|
769
756
|
|
|
770
|
-
|
|
757
|
+
}
|
|
771
758
|
|
|
772
|
-
|
|
759
|
+
this.dispatchEvent( _startEvent );
|
|
773
760
|
|
|
774
|
-
|
|
761
|
+
}
|
|
775
762
|
|
|
776
|
-
|
|
777
|
-
_pointerPositions[ event.pointerId ] = position;
|
|
763
|
+
function onTouchMove( event ) {
|
|
778
764
|
|
|
779
|
-
|
|
765
|
+
this._trackPointer( event );
|
|
780
766
|
|
|
781
|
-
|
|
767
|
+
switch ( this._pointers.length ) {
|
|
782
768
|
|
|
783
|
-
|
|
769
|
+
case 1:
|
|
770
|
+
this._movePrev.copy( this._moveCurr );
|
|
771
|
+
this._moveCurr.copy( this._getMouseOnCircle( event.pageX, event.pageY ) );
|
|
772
|
+
break;
|
|
784
773
|
|
|
785
|
-
|
|
774
|
+
default: // 2 or more
|
|
786
775
|
|
|
787
|
-
const
|
|
776
|
+
const position = this._getSecondPointerPosition( event );
|
|
788
777
|
|
|
789
|
-
|
|
778
|
+
const dx = event.pageX - position.x;
|
|
779
|
+
const dy = event.pageY - position.y;
|
|
780
|
+
this._touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
|
790
781
|
|
|
791
|
-
|
|
782
|
+
const x = ( event.pageX + position.x ) / 2;
|
|
783
|
+
const y = ( event.pageY + position.y ) / 2;
|
|
784
|
+
this._panEnd.copy( this._getMouseOnScreen( x, y ) );
|
|
785
|
+
break;
|
|
792
786
|
|
|
793
|
-
|
|
787
|
+
}
|
|
794
788
|
|
|
795
|
-
|
|
789
|
+
}
|
|
796
790
|
|
|
797
|
-
|
|
798
|
-
scope.domElement.removeEventListener( 'pointercancel', onPointerCancel );
|
|
799
|
-
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
791
|
+
function onTouchEnd( event ) {
|
|
800
792
|
|
|
801
|
-
|
|
802
|
-
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
793
|
+
switch ( this._pointers.length ) {
|
|
803
794
|
|
|
804
|
-
|
|
805
|
-
|
|
795
|
+
case 0:
|
|
796
|
+
this.state = _STATE.NONE;
|
|
797
|
+
break;
|
|
806
798
|
|
|
807
|
-
|
|
799
|
+
case 1:
|
|
800
|
+
this.state = _STATE.TOUCH_ROTATE;
|
|
801
|
+
this._moveCurr.copy( this._getMouseOnCircle( event.pageX, event.pageY ) );
|
|
802
|
+
this._movePrev.copy( this._moveCurr );
|
|
803
|
+
break;
|
|
808
804
|
|
|
809
|
-
|
|
805
|
+
case 2:
|
|
806
|
+
this.state = _STATE.TOUCH_ZOOM_PAN;
|
|
810
807
|
|
|
811
|
-
|
|
812
|
-
this.domElement.addEventListener( 'pointercancel', onPointerCancel );
|
|
813
|
-
this.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
808
|
+
for ( let i = 0; i < this._pointers.length; i ++ ) {
|
|
814
809
|
|
|
810
|
+
if ( this._pointers[ i ].pointerId !== event.pointerId ) {
|
|
811
|
+
|
|
812
|
+
const position = this._pointerPositions[ this._pointers[ i ].pointerId ];
|
|
813
|
+
this._moveCurr.copy( this._getMouseOnCircle( position.x, position.y ) );
|
|
814
|
+
this._movePrev.copy( this._moveCurr );
|
|
815
|
+
break;
|
|
815
816
|
|
|
816
|
-
|
|
817
|
-
window.addEventListener( 'keyup', keyup );
|
|
817
|
+
}
|
|
818
818
|
|
|
819
|
-
|
|
819
|
+
}
|
|
820
820
|
|
|
821
|
-
|
|
822
|
-
this.update();
|
|
821
|
+
break;
|
|
823
822
|
|
|
824
823
|
}
|
|
825
824
|
|
|
825
|
+
this.dispatchEvent( _endEvent );
|
|
826
|
+
|
|
826
827
|
}
|
|
827
828
|
|
|
828
829
|
export { TrackballControls };
|