super-three 0.141.0 → 0.144.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/README.md +8 -8
- package/build/three.cjs +1558 -1034
- package/build/three.js +1558 -1034
- package/build/three.min.js +1 -1
- package/build/three.module.js +2012 -1243
- package/examples/js/animation/MMDPhysics.js +1 -16
- package/examples/js/controls/ArcballControls.js +16 -3
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +0 -8
- package/examples/js/controls/TrackballControls.js +0 -2
- package/examples/js/controls/TransformControls.js +20 -16
- package/examples/js/effects/AnaglyphEffect.js +2 -2
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +4 -13
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/GLTFExporter.js +28 -29
- package/examples/js/exporters/OBJExporter.js +2 -23
- package/examples/js/exporters/PLYExporter.js +12 -24
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +6 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/interactive/SelectionHelper.js +2 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/loaders/ColladaLoader.js +1 -0
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +2 -13
- package/examples/js/loaders/FBXLoader.js +10 -3
- package/examples/js/loaders/FontLoader.js +3 -16
- package/examples/js/loaders/GLTFLoader.js +52 -36
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/LDrawLoader.js +139 -74
- package/examples/js/loaders/OBJLoader.js +7 -13
- package/examples/js/loaders/PCDLoader.js +59 -14
- package/examples/js/loaders/PLYLoader.js +3 -3
- package/examples/js/loaders/SVGLoader.js +4 -3
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +1 -1
- package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
- package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/Volume.js +198 -190
- package/examples/js/misc/VolumeSlice.js +90 -88
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Reflector.js +9 -2
- package/examples/js/objects/ReflectorForSSRPass.js +3 -4
- package/examples/js/objects/Refractor.js +10 -4
- package/examples/js/objects/ShadowMesh.js +5 -1
- package/examples/js/postprocessing/OutlinePass.js +5 -3
- package/examples/js/renderers/CSS2DRenderer.js +2 -2
- package/examples/js/renderers/CSS3DRenderer.js +2 -2
- package/examples/js/renderers/Projector.js +2 -23
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +0 -16
- package/examples/jsm/animation/MMDPhysics.js +3 -22
- package/examples/jsm/controls/ArcballControls.js +17 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +0 -7
- package/examples/jsm/controls/TrackballControls.js +0 -3
- package/examples/jsm/controls/TransformControls.js +18 -16
- package/examples/jsm/effects/AnaglyphEffect.js +2 -2
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +4 -13
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/GLTFExporter.js +29 -31
- package/examples/jsm/exporters/KTX2Exporter.js +29 -29
- package/examples/jsm/exporters/OBJExporter.js +0 -18
- package/examples/jsm/exporters/PLYExporter.js +14 -22
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +14 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/interactive/HTMLMesh.js +9 -9
- package/examples/jsm/interactive/SelectionHelper.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +3 -13
- package/examples/jsm/loaders/FBXLoader.js +10 -3
- package/examples/jsm/loaders/FontLoader.js +3 -16
- package/examples/jsm/loaders/GLTFLoader.js +52 -36
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KTX2Loader.js +192 -30
- package/examples/jsm/loaders/LDrawLoader.js +135 -74
- package/examples/jsm/loaders/OBJLoader.js +6 -14
- package/examples/jsm/loaders/PCDLoader.js +59 -13
- package/examples/jsm/loaders/PLYLoader.js +3 -3
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VRMLLoader.js +23 -25
- package/examples/jsm/loaders/VTKLoader.js +1 -1
- package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
- package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/Volume.js +169 -171
- package/examples/jsm/misc/VolumeSlice.js +78 -80
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
- package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
- package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
- package/examples/jsm/node-editor/math/DotEditor.js +1 -1
- package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
- package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
- package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
- package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
- package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
- package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
- package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
- package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
- package/examples/jsm/nodes/Nodes.js +43 -13
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
- package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
- package/examples/jsm/nodes/core/FunctionNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +14 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
- package/examples/jsm/nodes/core/NodeUtils.js +23 -1
- package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
- package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
- package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
- package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
- package/examples/jsm/nodes/materials/Materials.js +13 -25
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -12
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
- package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
- package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
- package/examples/jsm/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +21 -5
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Reflector.js +12 -5
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
- package/examples/jsm/objects/Refractor.js +12 -6
- package/examples/jsm/objects/ShadowMesh.js +8 -2
- package/examples/jsm/postprocessing/OutlinePass.js +5 -3
- package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
- package/examples/jsm/renderers/Projector.js +2 -24
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +1 -21
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
- package/examples/jsm/webxr/VRButton.js +1 -7
- package/package.json +18 -14
- package/src/Three.Legacy.js +262 -36
- package/src/Three.js +3 -2
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +1 -1
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +24 -5
- package/src/cameras/CubeCamera.js +0 -7
- package/src/constants.js +2 -4
- package/src/core/BufferAttribute.js +81 -111
- package/src/core/BufferGeometry.js +3 -41
- package/src/core/InstancedBufferAttribute.js +0 -10
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +56 -7
- package/src/core/Object3D.js +22 -5
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +104 -88
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +1 -4
- package/src/extras/curves/CatmullRomCurve3.js +4 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +2 -11
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +2 -1
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/SpotLight.js +2 -0
- package/src/loaders/FileLoader.js +12 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +49 -7
- package/src/loaders/ObjectLoader.js +4 -41
- package/src/materials/Material.js +1 -33
- package/src/materials/Materials.js +0 -27
- package/src/materials/MeshLambertMaterial.js +28 -1
- package/src/materials/ShaderMaterial.js +3 -7
- package/src/math/Color.js +3 -13
- package/src/math/MathUtils.js +1 -7
- package/src/math/Matrix3.js +1 -7
- package/src/math/Matrix4.js +3 -27
- package/src/math/Quaternion.js +1 -21
- package/src/math/Vector2.js +4 -24
- package/src/math/Vector3.js +7 -46
- package/src/math/Vector4.js +4 -24
- package/src/renderers/WebGLRenderer.js +84 -8
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib.js +31 -31
- package/src/renderers/shaders/UniformsLib.js +12 -11
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -13
- package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
- package/src/renderers/webgl/WebGLProgram.js +6 -11
- package/src/renderers/webgl/WebGLPrograms.js +30 -26
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +10 -15
- package/src/renderers/webgl/WebGLState.js +47 -0
- package/src/renderers/webgl/WebGLUniforms.js +4 -4
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +2 -0
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +58 -33
- package/src/scenes/Scene.js +16 -3
- package/src/textures/Source.js +1 -1
- package/src/utils.js +1 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1048
- package/examples/js/loaders/KTX2Loader.js +0 -558
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -1,1248 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EventDispatcher,
|
|
3
|
-
MOUSE,
|
|
4
|
-
Quaternion,
|
|
5
|
-
Spherical,
|
|
6
|
-
TOUCH,
|
|
7
|
-
Vector2,
|
|
8
|
-
Vector3
|
|
9
|
-
} from 'three';
|
|
10
|
-
|
|
11
|
-
var CameraControls = function ( object, domElement ) {
|
|
12
|
-
|
|
13
|
-
if ( domElement === undefined ) console.warn( 'THREE.CameraControls: The second parameter "domElement" is now mandatory.' );
|
|
14
|
-
if ( domElement === document ) console.error( 'THREE.CameraControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' );
|
|
15
|
-
|
|
16
|
-
this.object = object;
|
|
17
|
-
this.domElement = domElement;
|
|
18
|
-
|
|
19
|
-
// Set to false to disable this control
|
|
20
|
-
this.enabled = true;
|
|
21
|
-
|
|
22
|
-
// "target" sets the location of focus, where the object orbits around
|
|
23
|
-
this.target = new Vector3();
|
|
24
|
-
|
|
25
|
-
// Set to true to enable trackball behavior
|
|
26
|
-
this.trackball = false;
|
|
27
|
-
|
|
28
|
-
// How far you can dolly in and out ( PerspectiveCamera only )
|
|
29
|
-
this.minDistance = 0;
|
|
30
|
-
this.maxDistance = Infinity;
|
|
31
|
-
|
|
32
|
-
// How far you can zoom in and out ( OrthographicCamera only )
|
|
33
|
-
this.minZoom = 0;
|
|
34
|
-
this.maxZoom = Infinity;
|
|
35
|
-
|
|
36
|
-
// How far you can orbit vertically, upper and lower limits.
|
|
37
|
-
// Range is 0 to Math.PI radians.
|
|
38
|
-
this.minPolarAngle = 0; // radians
|
|
39
|
-
this.maxPolarAngle = Math.PI; // radians
|
|
40
|
-
|
|
41
|
-
// How far you can orbit horizontally, upper and lower limits.
|
|
42
|
-
// If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
|
|
43
|
-
this.minAzimuthAngle = - Infinity; // radians
|
|
44
|
-
this.maxAzimuthAngle = Infinity; // radians
|
|
45
|
-
|
|
46
|
-
// Set to true to enable damping (inertia)
|
|
47
|
-
// If damping is enabled, you must call controls.update() in your animation loop
|
|
48
|
-
this.enableDamping = false;
|
|
49
|
-
this.dampingFactor = 0.05;
|
|
50
|
-
|
|
51
|
-
// This option enables dollying in and out; property named as "zoom" for backwards compatibility
|
|
52
|
-
// Set to false to disable zooming
|
|
53
|
-
this.enableZoom = true;
|
|
54
|
-
this.zoomSpeed = 1.0;
|
|
55
|
-
|
|
56
|
-
// Set to false to disable rotating
|
|
57
|
-
this.enableRotate = true;
|
|
58
|
-
this.rotateSpeed = 1.0;
|
|
59
|
-
|
|
60
|
-
// Set to false to disable panning
|
|
61
|
-
this.enablePan = true;
|
|
62
|
-
this.panSpeed = 1.0;
|
|
63
|
-
this.screenSpacePanning = false; // if true, pan in screen-space
|
|
64
|
-
this.keyPanSpeed = 7.0; // pixels moved per arrow key push
|
|
65
|
-
|
|
66
|
-
// Set to true to automatically rotate around the target
|
|
67
|
-
// If auto-rotate is enabled, you must call controls.update() in your animation loop
|
|
68
|
-
// auto-rotate is not supported for trackball behavior
|
|
69
|
-
this.autoRotate = false;
|
|
70
|
-
this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
|
|
71
|
-
|
|
72
|
-
// Set to false to disable use of the keys
|
|
73
|
-
this.enableKeys = true;
|
|
74
|
-
|
|
75
|
-
// The four arrow keys
|
|
76
|
-
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
|
|
77
|
-
|
|
78
|
-
// Mouse buttons
|
|
79
|
-
this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
|
|
80
|
-
|
|
81
|
-
// Touch fingers
|
|
82
|
-
this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN };
|
|
83
|
-
|
|
84
|
-
// for reset
|
|
85
|
-
this.target0 = this.target.clone();
|
|
86
|
-
this.position0 = this.object.position.clone();
|
|
87
|
-
this.quaternion0 = this.object.quaternion.clone();
|
|
88
|
-
this.zoom0 = this.object.zoom;
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
// public methods
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
this.getPolarAngle = function () {
|
|
95
|
-
|
|
96
|
-
return spherical.phi;
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
this.getAzimuthalAngle = function () {
|
|
101
|
-
|
|
102
|
-
return spherical.theta;
|
|
103
|
-
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
this.saveState = function () {
|
|
107
|
-
|
|
108
|
-
scope.target0.copy( scope.target );
|
|
109
|
-
scope.position0.copy( scope.object.position );
|
|
110
|
-
scope.quaternion0.copy( scope.object.quaternion );
|
|
111
|
-
scope.zoom0 = scope.object.zoom;
|
|
112
|
-
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
this.reset = function () {
|
|
116
|
-
|
|
117
|
-
scope.target.copy( scope.target0 );
|
|
118
|
-
scope.object.position.copy( scope.position0 );
|
|
119
|
-
scope.object.quaternion.copy( scope.quaternion0 );
|
|
120
|
-
scope.object.zoom = scope.zoom0;
|
|
121
|
-
|
|
122
|
-
scope.object.updateProjectionMatrix();
|
|
123
|
-
scope.dispatchEvent( changeEvent );
|
|
124
|
-
|
|
125
|
-
scope.update();
|
|
126
|
-
|
|
127
|
-
state = STATE.NONE;
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// this method is exposed, but perhaps it would be better if we can make it private...
|
|
132
|
-
this.update = function () {
|
|
133
|
-
|
|
134
|
-
var offset = new Vector3();
|
|
135
|
-
|
|
136
|
-
// so camera.up is the orbit axis
|
|
137
|
-
var quat = new Quaternion().setFromUnitVectors( object.up, new Vector3( 0, 1, 0 ) );
|
|
138
|
-
var quatInverse = quat.clone().invert();
|
|
139
|
-
|
|
140
|
-
var lastPosition = new Vector3();
|
|
141
|
-
var lastQuaternion = new Quaternion();
|
|
142
|
-
|
|
143
|
-
var q = new Quaternion();
|
|
144
|
-
var vec = new Vector3();
|
|
145
|
-
|
|
146
|
-
return function update() {
|
|
147
|
-
|
|
148
|
-
var position = scope.object.position;
|
|
149
|
-
|
|
150
|
-
offset.copy( position ).sub( scope.target );
|
|
151
|
-
|
|
152
|
-
if ( scope.trackball ) {
|
|
153
|
-
|
|
154
|
-
// rotate around screen-space y-axis
|
|
155
|
-
|
|
156
|
-
if ( sphericalDelta.theta ) {
|
|
157
|
-
|
|
158
|
-
vec.set( 0, 1, 0 ).applyQuaternion( scope.object.quaternion );
|
|
159
|
-
|
|
160
|
-
const factor = ( scope.enableDamping ) ? scope.dampingFactor : 1;
|
|
161
|
-
|
|
162
|
-
q.setFromAxisAngle( vec, sphericalDelta.theta * factor );
|
|
163
|
-
|
|
164
|
-
scope.object.quaternion.premultiply( q );
|
|
165
|
-
offset.applyQuaternion( q );
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// rotate around screen-space x-axis
|
|
170
|
-
|
|
171
|
-
if ( sphericalDelta.phi ) {
|
|
172
|
-
|
|
173
|
-
vec.set( 1, 0, 0 ).applyQuaternion( scope.object.quaternion );
|
|
174
|
-
|
|
175
|
-
const factor = ( scope.enableDamping ) ? scope.dampingFactor : 1;
|
|
176
|
-
|
|
177
|
-
q.setFromAxisAngle( vec, sphericalDelta.phi * factor );
|
|
178
|
-
|
|
179
|
-
scope.object.quaternion.premultiply( q );
|
|
180
|
-
offset.applyQuaternion( q );
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
offset.multiplyScalar( scale );
|
|
185
|
-
offset.clampLength( scope.minDistance, scope.maxDistance );
|
|
186
|
-
|
|
187
|
-
} else {
|
|
188
|
-
|
|
189
|
-
// rotate offset to "y-axis-is-up" space
|
|
190
|
-
offset.applyQuaternion( quat );
|
|
191
|
-
|
|
192
|
-
if ( scope.autoRotate && state === STATE.NONE ) {
|
|
193
|
-
|
|
194
|
-
rotateLeft( getAutoRotationAngle() );
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
spherical.setFromVector3( offset );
|
|
199
|
-
|
|
200
|
-
if ( scope.enableDamping ) {
|
|
201
|
-
|
|
202
|
-
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
203
|
-
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
204
|
-
|
|
205
|
-
} else {
|
|
206
|
-
|
|
207
|
-
spherical.theta += sphericalDelta.theta;
|
|
208
|
-
spherical.phi += sphericalDelta.phi;
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// restrict theta to be between desired limits
|
|
213
|
-
spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) );
|
|
214
|
-
|
|
215
|
-
// restrict phi to be between desired limits
|
|
216
|
-
spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
|
|
217
|
-
|
|
218
|
-
spherical.makeSafe();
|
|
219
|
-
|
|
220
|
-
spherical.radius *= scale;
|
|
221
|
-
|
|
222
|
-
// restrict radius to be between desired limits
|
|
223
|
-
spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
|
|
224
|
-
|
|
225
|
-
offset.setFromSpherical( spherical );
|
|
226
|
-
|
|
227
|
-
// rotate offset back to "camera-up-vector-is-up" space
|
|
228
|
-
offset.applyQuaternion( quatInverse );
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// move target to panned location
|
|
233
|
-
|
|
234
|
-
if ( scope.enableDamping === true ) {
|
|
235
|
-
|
|
236
|
-
scope.target.addScaledVector( panOffset, scope.dampingFactor );
|
|
237
|
-
|
|
238
|
-
} else {
|
|
239
|
-
|
|
240
|
-
scope.target.add( panOffset );
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
position.copy( scope.target ).add( offset );
|
|
245
|
-
|
|
246
|
-
if ( scope.trackball === false ) {
|
|
247
|
-
|
|
248
|
-
scope.object.lookAt( scope.target );
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if ( scope.enableDamping === true ) {
|
|
253
|
-
|
|
254
|
-
sphericalDelta.theta *= ( 1 - scope.dampingFactor );
|
|
255
|
-
sphericalDelta.phi *= ( 1 - scope.dampingFactor );
|
|
256
|
-
|
|
257
|
-
panOffset.multiplyScalar( 1 - scope.dampingFactor );
|
|
258
|
-
|
|
259
|
-
} else {
|
|
260
|
-
|
|
261
|
-
sphericalDelta.set( 0, 0, 0 );
|
|
262
|
-
|
|
263
|
-
panOffset.set( 0, 0, 0 );
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
scale = 1;
|
|
268
|
-
|
|
269
|
-
// update condition is:
|
|
270
|
-
// min(camera displacement, camera rotation in radians)^2 > EPS
|
|
271
|
-
// using small-angle approximation cos(x/2) = 1 - x^2 / 8
|
|
272
|
-
|
|
273
|
-
if ( zoomChanged ||
|
|
274
|
-
lastPosition.distanceToSquared( scope.object.position ) > EPS ||
|
|
275
|
-
8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
|
|
276
|
-
|
|
277
|
-
scope.dispatchEvent( changeEvent );
|
|
278
|
-
|
|
279
|
-
lastPosition.copy( scope.object.position );
|
|
280
|
-
lastQuaternion.copy( scope.object.quaternion );
|
|
281
|
-
zoomChanged = false;
|
|
282
|
-
|
|
283
|
-
return true;
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return false;
|
|
288
|
-
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
}();
|
|
292
|
-
|
|
293
|
-
this.dispose = function () {
|
|
294
|
-
|
|
295
|
-
scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false );
|
|
296
|
-
scope.domElement.removeEventListener( 'mousedown', onMouseDown, false );
|
|
297
|
-
scope.domElement.removeEventListener( 'wheel', onMouseWheel, false );
|
|
298
|
-
|
|
299
|
-
scope.domElement.removeEventListener( 'touchstart', onTouchStart, false );
|
|
300
|
-
scope.domElement.removeEventListener( 'touchend', onTouchEnd, false );
|
|
301
|
-
scope.domElement.removeEventListener( 'touchmove', onTouchMove, false );
|
|
302
|
-
|
|
303
|
-
document.removeEventListener( 'mousemove', onMouseMove, false );
|
|
304
|
-
document.removeEventListener( 'mouseup', onMouseUp, false );
|
|
305
|
-
|
|
306
|
-
scope.domElement.removeEventListener( 'keydown', onKeyDown, false );
|
|
307
|
-
|
|
308
|
-
//scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
|
|
309
|
-
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
//
|
|
313
|
-
// internals
|
|
314
|
-
//
|
|
315
|
-
|
|
316
|
-
var scope = this;
|
|
317
|
-
|
|
318
|
-
var changeEvent = { type: 'change' };
|
|
319
|
-
var startEvent = { type: 'start' };
|
|
320
|
-
var endEvent = { type: 'end' };
|
|
321
|
-
|
|
322
|
-
var STATE = {
|
|
323
|
-
NONE: - 1,
|
|
324
|
-
ROTATE: 0,
|
|
325
|
-
DOLLY: 1,
|
|
326
|
-
PAN: 2,
|
|
327
|
-
TOUCH_ROTATE: 3,
|
|
328
|
-
TOUCH_PAN: 4,
|
|
329
|
-
TOUCH_DOLLY_PAN: 5,
|
|
330
|
-
TOUCH_DOLLY_ROTATE: 6
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
var state = STATE.NONE;
|
|
334
|
-
|
|
335
|
-
var EPS = 0.000001;
|
|
336
|
-
|
|
337
|
-
// current position in spherical coordinates
|
|
338
|
-
var spherical = new Spherical();
|
|
339
|
-
var sphericalDelta = new Spherical();
|
|
340
|
-
|
|
341
|
-
var scale = 1;
|
|
342
|
-
var panOffset = new Vector3();
|
|
343
|
-
var zoomChanged = false;
|
|
344
|
-
|
|
345
|
-
var rotateStart = new Vector2();
|
|
346
|
-
var rotateEnd = new Vector2();
|
|
347
|
-
var rotateDelta = new Vector2();
|
|
348
|
-
|
|
349
|
-
var panStart = new Vector2();
|
|
350
|
-
var panEnd = new Vector2();
|
|
351
|
-
var panDelta = new Vector2();
|
|
352
|
-
|
|
353
|
-
var dollyStart = new Vector2();
|
|
354
|
-
var dollyEnd = new Vector2();
|
|
355
|
-
var dollyDelta = new Vector2();
|
|
356
|
-
|
|
357
|
-
function getAutoRotationAngle() {
|
|
358
|
-
|
|
359
|
-
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function getZoomScale() {
|
|
364
|
-
|
|
365
|
-
return Math.pow( 0.95, scope.zoomSpeed );
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function rotateLeft( angle ) {
|
|
370
|
-
|
|
371
|
-
sphericalDelta.theta -= angle;
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
function rotateUp( angle ) {
|
|
376
|
-
|
|
377
|
-
sphericalDelta.phi -= angle;
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
var panLeft = function () {
|
|
382
|
-
|
|
383
|
-
var v = new Vector3();
|
|
384
|
-
|
|
385
|
-
return function panLeft( distance, objectMatrix ) {
|
|
386
|
-
|
|
387
|
-
v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix
|
|
388
|
-
v.multiplyScalar( - distance );
|
|
389
|
-
|
|
390
|
-
panOffset.add( v );
|
|
391
|
-
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
}();
|
|
395
|
-
|
|
396
|
-
var panUp = function () {
|
|
397
|
-
|
|
398
|
-
var v = new Vector3();
|
|
399
|
-
|
|
400
|
-
return function panUp( distance, objectMatrix ) {
|
|
401
|
-
|
|
402
|
-
if ( scope.screenSpacePanning === true ) {
|
|
403
|
-
|
|
404
|
-
v.setFromMatrixColumn( objectMatrix, 1 );
|
|
405
|
-
|
|
406
|
-
} else {
|
|
407
|
-
|
|
408
|
-
v.setFromMatrixColumn( objectMatrix, 0 );
|
|
409
|
-
v.crossVectors( scope.object.up, v );
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
v.multiplyScalar( distance );
|
|
414
|
-
|
|
415
|
-
panOffset.add( v );
|
|
416
|
-
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
}();
|
|
420
|
-
|
|
421
|
-
// deltaX and deltaY are in pixels; right and down are positive
|
|
422
|
-
var pan = function () {
|
|
423
|
-
|
|
424
|
-
var offset = new Vector3();
|
|
425
|
-
|
|
426
|
-
return function pan( deltaX, deltaY ) {
|
|
427
|
-
|
|
428
|
-
var element = scope.domElement;
|
|
429
|
-
|
|
430
|
-
if ( scope.object.isPerspectiveCamera ) {
|
|
431
|
-
|
|
432
|
-
// perspective
|
|
433
|
-
var position = scope.object.position;
|
|
434
|
-
offset.copy( position ).sub( scope.target );
|
|
435
|
-
var targetDistance = offset.length();
|
|
436
|
-
|
|
437
|
-
// half of the fov is center to top of screen
|
|
438
|
-
targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
|
|
439
|
-
|
|
440
|
-
// we use only clientHeight here so aspect ratio does not distort speed
|
|
441
|
-
panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
|
|
442
|
-
panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
|
|
443
|
-
|
|
444
|
-
} else if ( scope.object.isOrthographicCamera ) {
|
|
445
|
-
|
|
446
|
-
// orthographic
|
|
447
|
-
panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
|
|
448
|
-
panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
|
|
449
|
-
|
|
450
|
-
} else {
|
|
451
|
-
|
|
452
|
-
// camera neither orthographic nor perspective
|
|
453
|
-
console.warn( 'WARNING: CameraControls.js encountered an unknown camera type - pan disabled.' );
|
|
454
|
-
scope.enablePan = false;
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
}();
|
|
461
|
-
|
|
462
|
-
function dollyIn( dollyScale ) {
|
|
463
|
-
|
|
464
|
-
if ( scope.object.isPerspectiveCamera ) {
|
|
465
|
-
|
|
466
|
-
scale /= dollyScale;
|
|
467
|
-
|
|
468
|
-
} else if ( scope.object.isOrthographicCamera ) {
|
|
469
|
-
|
|
470
|
-
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
|
|
471
|
-
scope.object.updateProjectionMatrix();
|
|
472
|
-
zoomChanged = true;
|
|
473
|
-
|
|
474
|
-
} else {
|
|
475
|
-
|
|
476
|
-
console.warn( 'WARNING: CameraControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
477
|
-
scope.enableZoom = false;
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function dollyOut( dollyScale ) {
|
|
484
|
-
|
|
485
|
-
if ( scope.object.isPerspectiveCamera ) {
|
|
486
|
-
|
|
487
|
-
scale *= dollyScale;
|
|
488
|
-
|
|
489
|
-
} else if ( scope.object.isOrthographicCamera ) {
|
|
490
|
-
|
|
491
|
-
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
|
|
492
|
-
scope.object.updateProjectionMatrix();
|
|
493
|
-
zoomChanged = true;
|
|
494
|
-
|
|
495
|
-
} else {
|
|
496
|
-
|
|
497
|
-
console.warn( 'WARNING: CameraControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
498
|
-
scope.enableZoom = false;
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
//
|
|
505
|
-
// event callbacks - update the object state
|
|
506
|
-
//
|
|
507
|
-
|
|
508
|
-
function handleMouseDownRotate( event ) {
|
|
509
|
-
|
|
510
|
-
rotateStart.set( event.clientX, event.clientY );
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
function handleMouseDownDolly( event ) {
|
|
515
|
-
|
|
516
|
-
dollyStart.set( event.clientX, event.clientY );
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
function handleMouseDownPan( event ) {
|
|
521
|
-
|
|
522
|
-
panStart.set( event.clientX, event.clientY );
|
|
523
|
-
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
function handleMouseMoveRotate( event ) {
|
|
527
|
-
|
|
528
|
-
rotateEnd.set( event.clientX, event.clientY );
|
|
529
|
-
|
|
530
|
-
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
|
|
531
|
-
|
|
532
|
-
var element = scope.domElement;
|
|
533
|
-
|
|
534
|
-
rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
535
|
-
|
|
536
|
-
rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
537
|
-
|
|
538
|
-
rotateStart.copy( rotateEnd );
|
|
539
|
-
|
|
540
|
-
scope.update();
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
function handleMouseMoveDolly( event ) {
|
|
545
|
-
|
|
546
|
-
dollyEnd.set( event.clientX, event.clientY );
|
|
547
|
-
|
|
548
|
-
dollyDelta.subVectors( dollyEnd, dollyStart );
|
|
549
|
-
|
|
550
|
-
if ( dollyDelta.y > 0 ) {
|
|
551
|
-
|
|
552
|
-
dollyIn( getZoomScale() );
|
|
553
|
-
|
|
554
|
-
} else if ( dollyDelta.y < 0 ) {
|
|
555
|
-
|
|
556
|
-
dollyOut( getZoomScale() );
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
dollyStart.copy( dollyEnd );
|
|
561
|
-
|
|
562
|
-
scope.update();
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function handleMouseMovePan( event ) {
|
|
567
|
-
|
|
568
|
-
panEnd.set( event.clientX, event.clientY );
|
|
569
|
-
|
|
570
|
-
panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
|
|
571
|
-
|
|
572
|
-
pan( panDelta.x, panDelta.y );
|
|
573
|
-
|
|
574
|
-
panStart.copy( panEnd );
|
|
575
|
-
|
|
576
|
-
scope.update();
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
function handleMouseUp( /*event*/ ) {
|
|
581
|
-
|
|
582
|
-
// no-op
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
function handleMouseWheel( event ) {
|
|
587
|
-
|
|
588
|
-
if ( event.deltaY < 0 ) {
|
|
589
|
-
|
|
590
|
-
dollyOut( getZoomScale() );
|
|
591
|
-
|
|
592
|
-
} else if ( event.deltaY > 0 ) {
|
|
593
|
-
|
|
594
|
-
dollyIn( getZoomScale() );
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
scope.update();
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
function handleKeyDown( event ) {
|
|
603
|
-
|
|
604
|
-
var needsUpdate = false;
|
|
605
|
-
|
|
606
|
-
switch ( event.keyCode ) {
|
|
607
|
-
|
|
608
|
-
case scope.keys.UP:
|
|
609
|
-
pan( 0, scope.keyPanSpeed );
|
|
610
|
-
needsUpdate = true;
|
|
611
|
-
break;
|
|
612
|
-
|
|
613
|
-
case scope.keys.BOTTOM:
|
|
614
|
-
pan( 0, - scope.keyPanSpeed );
|
|
615
|
-
needsUpdate = true;
|
|
616
|
-
break;
|
|
617
|
-
|
|
618
|
-
case scope.keys.LEFT:
|
|
619
|
-
pan( scope.keyPanSpeed, 0 );
|
|
620
|
-
needsUpdate = true;
|
|
621
|
-
break;
|
|
622
|
-
|
|
623
|
-
case scope.keys.RIGHT:
|
|
624
|
-
pan( - scope.keyPanSpeed, 0 );
|
|
625
|
-
needsUpdate = true;
|
|
626
|
-
break;
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
if ( needsUpdate ) {
|
|
631
|
-
|
|
632
|
-
// prevent the browser from scrolling on cursor keys
|
|
633
|
-
event.preventDefault();
|
|
634
|
-
|
|
635
|
-
scope.update();
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
function handleTouchStartRotate( event ) {
|
|
643
|
-
|
|
644
|
-
if ( event.touches.length == 1 ) {
|
|
645
|
-
|
|
646
|
-
rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
647
|
-
|
|
648
|
-
} else {
|
|
649
|
-
|
|
650
|
-
var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
651
|
-
var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
652
|
-
|
|
653
|
-
rotateStart.set( x, y );
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
function handleTouchStartPan( event ) {
|
|
660
|
-
|
|
661
|
-
if ( event.touches.length == 1 ) {
|
|
662
|
-
|
|
663
|
-
panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
664
|
-
|
|
665
|
-
} else {
|
|
666
|
-
|
|
667
|
-
var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
668
|
-
var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
669
|
-
|
|
670
|
-
panStart.set( x, y );
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
function handleTouchStartDolly( event ) {
|
|
677
|
-
|
|
678
|
-
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
|
679
|
-
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
|
680
|
-
|
|
681
|
-
var distance = Math.sqrt( dx * dx + dy * dy );
|
|
682
|
-
|
|
683
|
-
dollyStart.set( 0, distance );
|
|
684
|
-
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
function handleTouchStartDollyPan( event ) {
|
|
688
|
-
|
|
689
|
-
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
690
|
-
|
|
691
|
-
if ( scope.enablePan ) handleTouchStartPan( event );
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function handleTouchStartDollyRotate( event ) {
|
|
696
|
-
|
|
697
|
-
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
698
|
-
|
|
699
|
-
if ( scope.enableRotate ) handleTouchStartRotate( event );
|
|
700
|
-
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
function handleTouchMoveRotate( event ) {
|
|
704
|
-
|
|
705
|
-
if ( event.touches.length == 1 ) {
|
|
706
|
-
|
|
707
|
-
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
708
|
-
|
|
709
|
-
} else {
|
|
710
|
-
|
|
711
|
-
var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
712
|
-
var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
713
|
-
|
|
714
|
-
rotateEnd.set( x, y );
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
|
|
719
|
-
|
|
720
|
-
var element = scope.domElement;
|
|
721
|
-
|
|
722
|
-
rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
723
|
-
|
|
724
|
-
rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
725
|
-
|
|
726
|
-
rotateStart.copy( rotateEnd );
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function handleTouchMovePan( event ) {
|
|
731
|
-
|
|
732
|
-
if ( event.touches.length == 1 ) {
|
|
733
|
-
|
|
734
|
-
panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
735
|
-
|
|
736
|
-
} else {
|
|
737
|
-
|
|
738
|
-
var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
739
|
-
var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
740
|
-
|
|
741
|
-
panEnd.set( x, y );
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
|
|
746
|
-
|
|
747
|
-
pan( panDelta.x, panDelta.y );
|
|
748
|
-
|
|
749
|
-
panStart.copy( panEnd );
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
function handleTouchMoveDolly( event ) {
|
|
754
|
-
|
|
755
|
-
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
|
756
|
-
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
|
757
|
-
|
|
758
|
-
var distance = Math.sqrt( dx * dx + dy * dy );
|
|
759
|
-
|
|
760
|
-
dollyEnd.set( 0, distance );
|
|
761
|
-
|
|
762
|
-
dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) );
|
|
763
|
-
|
|
764
|
-
dollyIn( dollyDelta.y );
|
|
765
|
-
|
|
766
|
-
dollyStart.copy( dollyEnd );
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
function handleTouchMoveDollyPan( event ) {
|
|
771
|
-
|
|
772
|
-
if ( scope.enableZoom ) handleTouchMoveDolly( event );
|
|
773
|
-
|
|
774
|
-
if ( scope.enablePan ) handleTouchMovePan( event );
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
function handleTouchMoveDollyRotate( event ) {
|
|
779
|
-
|
|
780
|
-
if ( scope.enableZoom ) handleTouchMoveDolly( event );
|
|
781
|
-
|
|
782
|
-
if ( scope.enableRotate ) handleTouchMoveRotate( event );
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
function handleTouchEnd( /*event*/ ) {
|
|
787
|
-
|
|
788
|
-
// no-op
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
//
|
|
793
|
-
// event handlers - FSM: listen for events and reset state
|
|
794
|
-
//
|
|
795
|
-
|
|
796
|
-
function onMouseDown( event ) {
|
|
797
|
-
|
|
798
|
-
if ( scope.enabled === false ) return;
|
|
799
|
-
|
|
800
|
-
// Prevent the browser from scrolling.
|
|
801
|
-
|
|
802
|
-
event.preventDefault();
|
|
803
|
-
|
|
804
|
-
// Manually set the focus since calling preventDefault above
|
|
805
|
-
// prevents the browser from setting it automatically.
|
|
806
|
-
|
|
807
|
-
scope.domElement.focus ? scope.domElement.focus() : window.focus();
|
|
808
|
-
|
|
809
|
-
var mouseAction;
|
|
810
|
-
|
|
811
|
-
switch ( event.button ) {
|
|
812
|
-
|
|
813
|
-
case 0:
|
|
814
|
-
|
|
815
|
-
mouseAction = scope.mouseButtons.LEFT;
|
|
816
|
-
break;
|
|
817
|
-
|
|
818
|
-
case 1:
|
|
819
|
-
|
|
820
|
-
mouseAction = scope.mouseButtons.MIDDLE;
|
|
821
|
-
break;
|
|
822
|
-
|
|
823
|
-
case 2:
|
|
824
|
-
|
|
825
|
-
mouseAction = scope.mouseButtons.RIGHT;
|
|
826
|
-
break;
|
|
827
|
-
|
|
828
|
-
default:
|
|
829
|
-
|
|
830
|
-
mouseAction = - 1;
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
switch ( mouseAction ) {
|
|
835
|
-
|
|
836
|
-
case MOUSE.DOLLY:
|
|
837
|
-
|
|
838
|
-
if ( scope.enableZoom === false ) return;
|
|
839
|
-
|
|
840
|
-
handleMouseDownDolly( event );
|
|
841
|
-
|
|
842
|
-
state = STATE.DOLLY;
|
|
843
|
-
|
|
844
|
-
break;
|
|
845
|
-
|
|
846
|
-
case MOUSE.ROTATE:
|
|
847
|
-
|
|
848
|
-
if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
|
|
849
|
-
|
|
850
|
-
if ( scope.enablePan === false ) return;
|
|
851
|
-
|
|
852
|
-
handleMouseDownPan( event );
|
|
853
|
-
|
|
854
|
-
state = STATE.PAN;
|
|
855
|
-
|
|
856
|
-
} else {
|
|
857
|
-
|
|
858
|
-
if ( scope.enableRotate === false ) return;
|
|
859
|
-
|
|
860
|
-
handleMouseDownRotate( event );
|
|
861
|
-
|
|
862
|
-
state = STATE.ROTATE;
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
break;
|
|
867
|
-
|
|
868
|
-
case MOUSE.PAN:
|
|
869
|
-
|
|
870
|
-
if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
|
|
871
|
-
|
|
872
|
-
if ( scope.enableRotate === false ) return;
|
|
873
|
-
|
|
874
|
-
handleMouseDownRotate( event );
|
|
875
|
-
|
|
876
|
-
state = STATE.ROTATE;
|
|
877
|
-
|
|
878
|
-
} else {
|
|
879
|
-
|
|
880
|
-
if ( scope.enablePan === false ) return;
|
|
881
|
-
|
|
882
|
-
handleMouseDownPan( event );
|
|
883
|
-
|
|
884
|
-
state = STATE.PAN;
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
break;
|
|
889
|
-
|
|
890
|
-
default:
|
|
891
|
-
|
|
892
|
-
state = STATE.NONE;
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
if ( state !== STATE.NONE ) {
|
|
897
|
-
|
|
898
|
-
document.addEventListener( 'mousemove', onMouseMove, false );
|
|
899
|
-
document.addEventListener( 'mouseup', onMouseUp, false );
|
|
900
|
-
|
|
901
|
-
scope.dispatchEvent( startEvent );
|
|
902
|
-
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
function onMouseMove( event ) {
|
|
908
|
-
|
|
909
|
-
if ( scope.enabled === false ) return;
|
|
910
|
-
|
|
911
|
-
event.preventDefault();
|
|
912
|
-
|
|
913
|
-
switch ( state ) {
|
|
914
|
-
|
|
915
|
-
case STATE.ROTATE:
|
|
916
|
-
|
|
917
|
-
if ( scope.enableRotate === false ) return;
|
|
918
|
-
|
|
919
|
-
handleMouseMoveRotate( event );
|
|
920
|
-
|
|
921
|
-
break;
|
|
922
|
-
|
|
923
|
-
case STATE.DOLLY:
|
|
924
|
-
|
|
925
|
-
if ( scope.enableZoom === false ) return;
|
|
926
|
-
|
|
927
|
-
handleMouseMoveDolly( event );
|
|
928
|
-
|
|
929
|
-
break;
|
|
930
|
-
|
|
931
|
-
case STATE.PAN:
|
|
932
|
-
|
|
933
|
-
if ( scope.enablePan === false ) return;
|
|
934
|
-
|
|
935
|
-
handleMouseMovePan( event );
|
|
936
|
-
|
|
937
|
-
break;
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
function onMouseUp( event ) {
|
|
944
|
-
|
|
945
|
-
if ( scope.enabled === false ) return;
|
|
946
|
-
|
|
947
|
-
handleMouseUp( event );
|
|
948
|
-
|
|
949
|
-
document.removeEventListener( 'mousemove', onMouseMove, false );
|
|
950
|
-
document.removeEventListener( 'mouseup', onMouseUp, false );
|
|
951
|
-
|
|
952
|
-
scope.dispatchEvent( endEvent );
|
|
953
|
-
|
|
954
|
-
state = STATE.NONE;
|
|
955
|
-
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
function onMouseWheel( event ) {
|
|
959
|
-
|
|
960
|
-
if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return;
|
|
961
|
-
|
|
962
|
-
event.preventDefault();
|
|
963
|
-
event.stopPropagation();
|
|
964
|
-
|
|
965
|
-
scope.dispatchEvent( startEvent );
|
|
966
|
-
|
|
967
|
-
handleMouseWheel( event );
|
|
968
|
-
|
|
969
|
-
scope.dispatchEvent( endEvent );
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
function onKeyDown( event ) {
|
|
974
|
-
|
|
975
|
-
if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;
|
|
976
|
-
|
|
977
|
-
handleKeyDown( event );
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
function onTouchStart( event ) {
|
|
982
|
-
|
|
983
|
-
if ( scope.enabled === false ) return;
|
|
984
|
-
|
|
985
|
-
event.preventDefault();
|
|
986
|
-
|
|
987
|
-
switch ( event.touches.length ) {
|
|
988
|
-
|
|
989
|
-
case 1:
|
|
990
|
-
|
|
991
|
-
switch ( scope.touches.ONE ) {
|
|
992
|
-
|
|
993
|
-
case TOUCH.ROTATE:
|
|
994
|
-
|
|
995
|
-
if ( scope.enableRotate === false ) return;
|
|
996
|
-
|
|
997
|
-
handleTouchStartRotate( event );
|
|
998
|
-
|
|
999
|
-
state = STATE.TOUCH_ROTATE;
|
|
1000
|
-
|
|
1001
|
-
break;
|
|
1002
|
-
|
|
1003
|
-
case TOUCH.PAN:
|
|
1004
|
-
|
|
1005
|
-
if ( scope.enablePan === false ) return;
|
|
1006
|
-
|
|
1007
|
-
handleTouchStartPan( event );
|
|
1008
|
-
|
|
1009
|
-
state = STATE.TOUCH_PAN;
|
|
1010
|
-
|
|
1011
|
-
break;
|
|
1012
|
-
|
|
1013
|
-
default:
|
|
1014
|
-
|
|
1015
|
-
state = STATE.NONE;
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
break;
|
|
1020
|
-
|
|
1021
|
-
case 2:
|
|
1022
|
-
|
|
1023
|
-
switch ( scope.touches.TWO ) {
|
|
1024
|
-
|
|
1025
|
-
case TOUCH.DOLLY_PAN:
|
|
1026
|
-
|
|
1027
|
-
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
1028
|
-
|
|
1029
|
-
handleTouchStartDollyPan( event );
|
|
1030
|
-
|
|
1031
|
-
state = STATE.TOUCH_DOLLY_PAN;
|
|
1032
|
-
|
|
1033
|
-
break;
|
|
1034
|
-
|
|
1035
|
-
case TOUCH.DOLLY_ROTATE:
|
|
1036
|
-
|
|
1037
|
-
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
1038
|
-
|
|
1039
|
-
handleTouchStartDollyRotate( event );
|
|
1040
|
-
|
|
1041
|
-
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
1042
|
-
|
|
1043
|
-
break;
|
|
1044
|
-
|
|
1045
|
-
default:
|
|
1046
|
-
|
|
1047
|
-
state = STATE.NONE;
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
break;
|
|
1052
|
-
|
|
1053
|
-
default:
|
|
1054
|
-
|
|
1055
|
-
state = STATE.NONE;
|
|
1056
|
-
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
if ( state !== STATE.NONE ) {
|
|
1060
|
-
|
|
1061
|
-
scope.dispatchEvent( startEvent );
|
|
1062
|
-
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
function onTouchMove( event ) {
|
|
1068
|
-
|
|
1069
|
-
if ( scope.enabled === false ) return;
|
|
1070
|
-
|
|
1071
|
-
event.preventDefault();
|
|
1072
|
-
event.stopPropagation();
|
|
1073
|
-
|
|
1074
|
-
switch ( state ) {
|
|
1075
|
-
|
|
1076
|
-
case STATE.TOUCH_ROTATE:
|
|
1077
|
-
|
|
1078
|
-
if ( scope.enableRotate === false ) return;
|
|
1079
|
-
|
|
1080
|
-
handleTouchMoveRotate( event );
|
|
1081
|
-
|
|
1082
|
-
scope.update();
|
|
1083
|
-
|
|
1084
|
-
break;
|
|
1085
|
-
|
|
1086
|
-
case STATE.TOUCH_PAN:
|
|
1087
|
-
|
|
1088
|
-
if ( scope.enablePan === false ) return;
|
|
1089
|
-
|
|
1090
|
-
handleTouchMovePan( event );
|
|
1091
|
-
|
|
1092
|
-
scope.update();
|
|
1093
|
-
|
|
1094
|
-
break;
|
|
1095
|
-
|
|
1096
|
-
case STATE.TOUCH_DOLLY_PAN:
|
|
1097
|
-
|
|
1098
|
-
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
1099
|
-
|
|
1100
|
-
handleTouchMoveDollyPan( event );
|
|
1101
|
-
|
|
1102
|
-
scope.update();
|
|
1103
|
-
|
|
1104
|
-
break;
|
|
1105
|
-
|
|
1106
|
-
case STATE.TOUCH_DOLLY_ROTATE:
|
|
1107
|
-
|
|
1108
|
-
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
1109
|
-
|
|
1110
|
-
handleTouchMoveDollyRotate( event );
|
|
1111
|
-
|
|
1112
|
-
scope.update();
|
|
1113
|
-
|
|
1114
|
-
break;
|
|
1115
|
-
|
|
1116
|
-
default:
|
|
1117
|
-
|
|
1118
|
-
state = STATE.NONE;
|
|
1119
|
-
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
function onTouchEnd( event ) {
|
|
1125
|
-
|
|
1126
|
-
if ( scope.enabled === false ) return;
|
|
1127
|
-
|
|
1128
|
-
handleTouchEnd( event );
|
|
1129
|
-
|
|
1130
|
-
scope.dispatchEvent( endEvent );
|
|
1131
|
-
|
|
1132
|
-
state = STATE.NONE;
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
function onContextMenu( event ) {
|
|
1137
|
-
|
|
1138
|
-
if ( scope.enabled === false ) return;
|
|
1139
|
-
|
|
1140
|
-
event.preventDefault();
|
|
1141
|
-
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
//
|
|
1145
|
-
|
|
1146
|
-
scope.domElement.addEventListener( 'contextmenu', onContextMenu, false );
|
|
1147
|
-
|
|
1148
|
-
scope.domElement.addEventListener( 'mousedown', onMouseDown, false );
|
|
1149
|
-
scope.domElement.addEventListener( 'wheel', onMouseWheel, false );
|
|
1150
|
-
|
|
1151
|
-
scope.domElement.addEventListener( 'touchstart', onTouchStart, false );
|
|
1152
|
-
scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
|
|
1153
|
-
scope.domElement.addEventListener( 'touchmove', onTouchMove, false );
|
|
1154
|
-
|
|
1155
|
-
scope.domElement.addEventListener( 'keydown', onKeyDown, false );
|
|
1156
|
-
|
|
1157
|
-
// make sure element can receive keys.
|
|
1158
|
-
|
|
1159
|
-
if ( scope.domElement.tabIndex === - 1 ) {
|
|
1160
|
-
|
|
1161
|
-
scope.domElement.tabIndex = 0;
|
|
1162
|
-
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
// force an update at start
|
|
1166
|
-
|
|
1167
|
-
this.object.lookAt( scope.target );
|
|
1168
|
-
this.update();
|
|
1169
|
-
this.saveState();
|
|
1170
|
-
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
CameraControls.prototype = Object.create( EventDispatcher.prototype );
|
|
1174
|
-
CameraControls.prototype.constructor = CameraControls;
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
// OrbitControls maintains the "up" direction, camera.up (+Y by default).
|
|
1178
|
-
//
|
|
1179
|
-
// Orbit - left mouse / touch: one-finger move
|
|
1180
|
-
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
1181
|
-
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
|
|
1182
|
-
|
|
1183
|
-
var OrbitControls = function ( object, domElement ) {
|
|
1184
|
-
|
|
1185
|
-
CameraControls.call( this, object, domElement );
|
|
1186
|
-
|
|
1187
|
-
this.mouseButtons.LEFT = MOUSE.ROTATE;
|
|
1188
|
-
this.mouseButtons.RIGHT = MOUSE.PAN;
|
|
1189
|
-
|
|
1190
|
-
this.touches.ONE = TOUCH.ROTATE;
|
|
1191
|
-
this.touches.TWO = TOUCH.DOLLY_PAN;
|
|
1192
|
-
|
|
1193
|
-
};
|
|
1194
|
-
|
|
1195
|
-
OrbitControls.prototype = Object.create( EventDispatcher.prototype );
|
|
1196
|
-
OrbitControls.prototype.constructor = OrbitControls;
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
// MapControls maintains the "up" direction, camera.up (+Y by default)
|
|
1200
|
-
//
|
|
1201
|
-
// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate
|
|
1202
|
-
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
1203
|
-
// Pan - left mouse, or left right + ctrl/meta/shiftKey, or arrow keys / touch: one-finger move
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
var MapControls = function ( object, domElement ) {
|
|
1207
|
-
|
|
1208
|
-
CameraControls.call( this, object, domElement );
|
|
1209
|
-
|
|
1210
|
-
this.mouseButtons.LEFT = MOUSE.PAN;
|
|
1211
|
-
this.mouseButtons.RIGHT = MOUSE.ROTATE;
|
|
1212
|
-
|
|
1213
|
-
this.touches.ONE = TOUCH.PAN;
|
|
1214
|
-
this.touches.TWO = TOUCH.DOLLY_ROTATE;
|
|
1215
|
-
|
|
1216
|
-
};
|
|
1217
|
-
|
|
1218
|
-
MapControls.prototype = Object.create( EventDispatcher.prototype );
|
|
1219
|
-
MapControls.prototype.constructor = MapControls;
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
// TrackballControls allows the camera to rotate over the polls and does not maintain camera.up
|
|
1223
|
-
//
|
|
1224
|
-
// Orbit - left mouse / touch: one-finger move
|
|
1225
|
-
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
1226
|
-
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
|
|
1227
|
-
|
|
1228
|
-
var TrackballControls = function ( object, domElement ) {
|
|
1229
|
-
|
|
1230
|
-
CameraControls.call( this, object, domElement );
|
|
1231
|
-
|
|
1232
|
-
this.trackball = true;
|
|
1233
|
-
this.screenSpacePanning = true;
|
|
1234
|
-
this.autoRotate = false;
|
|
1235
|
-
|
|
1236
|
-
this.mouseButtons.LEFT = MOUSE.ROTATE;
|
|
1237
|
-
this.mouseButtons.RIGHT = MOUSE.PAN;
|
|
1238
|
-
|
|
1239
|
-
this.touches.ONE = TOUCH.ROTATE;
|
|
1240
|
-
this.touches.TWO = TOUCH.DOLLY_PAN;
|
|
1241
|
-
|
|
1242
|
-
};
|
|
1243
|
-
|
|
1244
|
-
TrackballControls.prototype = Object.create( EventDispatcher.prototype );
|
|
1245
|
-
TrackballControls.prototype.constructor = TrackballControls;
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
export { CameraControls, OrbitControls, MapControls, TrackballControls };
|