@needle-tools/three 0.162.12 → 0.169.2
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 +3 -3
- package/build/three.cjs +29789 -1941
- package/build/three.module.js +29095 -1933
- package/build/three.module.min.js +2 -2
- package/build/three.webgpu.js +80003 -0
- package/build/three.webgpu.min.js +6 -0
- package/build/three.webgpu.nodes.js +79951 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +2 -5
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- 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 +790 -797
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +98 -63
- package/examples/jsm/csm/CSMShader.js +4 -4
- 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 +2 -6
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +77 -8
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +55 -11
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -17
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -2
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +77 -78
- package/examples/jsm/loaders/GLTFLoader.js +76 -14
- package/examples/jsm/loaders/KTX2Loader.js +30 -22
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +45 -21
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VRMLLoader.js +11 -11
- package/examples/jsm/loaders/VTKLoader.js +80 -6
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -25
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +25 -5
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +168 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -12
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +7 -4
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +19 -5
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +47 -5
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/utils/TextureUtils.js +3 -2
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +11 -8
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +201 -0
- package/src/Three.js +23 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +6 -7
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/core/Object3D.js +34 -29
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/Controls.js +32 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/extras/TextureUtils.js +210 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +8 -1
- package/src/loaders/ObjectLoader.js +36 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +27 -5
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +22 -18
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +21 -1
- package/src/materials/Material.js +4 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +69 -68
- package/src/materials/nodes/LineBasicNodeMaterial.js +31 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +15 -12
- package/src/materials/nodes/MeshBasicNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +47 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +57 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +44 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +248 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/materials/nodes/MeshStandardNodeMaterial.js +108 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +38 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +198 -157
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +10 -7
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +123 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +108 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Spherical.js +4 -5
- package/src/math/Triangle.js +24 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +25 -0
- package/src/nodes/accessors/BatchNode.js +128 -0
- package/src/nodes/accessors/Bitangent.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +44 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +13 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +22 -15
- package/src/nodes/accessors/CubeTextureNode.js +79 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +24 -0
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +441 -0
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +10 -5
- package/src/nodes/accessors/ModelNode.js +72 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +42 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +51 -33
- package/src/nodes/accessors/Normal.js +88 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +18 -34
- package/src/nodes/accessors/PointUVNode.js +30 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +58 -9
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +35 -0
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +191 -0
- package/src/nodes/accessors/StorageBufferNode.js +147 -0
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +35 -10
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +103 -0
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +123 -39
- package/src/nodes/accessors/TextureSizeNode.js +36 -0
- package/src/nodes/accessors/UV.js +3 -0
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +33 -15
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +10 -6
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +8 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +8 -31
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +24 -7
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +11 -8
- package/{examples/jsm → src}/nodes/core/AssignNode.js +12 -9
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +29 -12
- package/{examples/jsm → src}/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +50 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +6 -3
- package/{examples/jsm → src}/nodes/core/ContextNode.js +27 -11
- package/src/nodes/core/IndexNode.js +99 -0
- package/{examples/jsm → src}/nodes/core/InputNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +85 -0
- package/{examples/jsm → src}/nodes/core/Node.js +114 -57
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +327 -90
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +52 -10
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +56 -8
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +13 -12
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +88 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +31 -11
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/TempNode.js +10 -6
- package/src/nodes/core/UniformGroupNode.js +59 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +37 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +14 -14
- package/src/nodes/core/VaryingNode.js +108 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +38 -28
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +33 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +341 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +20 -38
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +114 -0
- package/src/nodes/display/DenoiseNode.js +204 -0
- package/src/nodes/display/DepthOfFieldNode.js +124 -0
- package/src/nodes/display/DotScreenNode.js +66 -0
- package/src/nodes/display/FXAANode.js +332 -0
- package/src/nodes/display/FilmNode.js +56 -0
- package/src/nodes/display/FrontFacingNode.js +45 -0
- package/src/nodes/display/GTAONode.js +331 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +47 -24
- package/src/nodes/display/Lut3DNode.js +57 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +14 -14
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +378 -0
- package/src/nodes/display/PixelationPassNode.js +213 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +53 -0
- package/src/nodes/display/RenderOutputNode.js +60 -0
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +126 -0
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +67 -0
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +80 -0
- package/src/nodes/display/ViewportDepthNode.js +125 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +33 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +39 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +20 -14
- package/src/nodes/fog/FogExp2Node.js +35 -0
- package/src/nodes/fog/FogNode.js +50 -0
- package/src/nodes/fog/FogRangeNode.js +36 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +59 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -4
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +11 -9
- package/src/nodes/functions/PhysicalLightingModel.js +633 -0
- package/src/nodes/functions/ShadowMaskModel.js +31 -0
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +28 -11
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +27 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +522 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +30 -0
- package/src/nodes/lighting/BasicLightMapNode.js +32 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +138 -0
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +12 -11
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +27 -0
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +67 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +9 -3
- package/src/nodes/lighting/LightsNode.js +250 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +14 -16
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +127 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +48 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +407 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +319 -0
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/src/nodes/pmrem/PMREMNode.js +240 -0
- package/src/nodes/pmrem/PMREMUtils.js +288 -0
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +122 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +9 -5
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +36 -0
- package/src/nodes/utils/FlipNode.js +68 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +11 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +6 -3
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +23 -12
- package/src/nodes/utils/MatcapUVNode.js +33 -0
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +16 -7
- package/{examples/jsm → src}/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +133 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +21 -5
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +12 -8
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +8 -13
- package/{examples/jsm → src}/nodes/utils/SetNode.js +7 -4
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +7 -3
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +11 -12
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +8 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +302 -144
- package/src/objects/InstancedMesh.js +11 -1
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +67 -43
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +473 -224
- package/{examples/jsm → src}/renderers/common/Animation.js +3 -0
- package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +18 -10
- package/src/renderers/common/BindGroup.js +18 -0
- package/src/renderers/common/Bindings.js +203 -0
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +24 -12
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +35 -15
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +90 -0
- package/src/renderers/common/QuadMesh.js +55 -0
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -2
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +11 -2
- package/src/renderers/common/RenderObject.js +413 -0
- package/{examples/jsm → src}/renderers/common/RenderObjects.js +9 -2
- package/{examples/jsm → src}/renderers/common/Renderer.js +431 -83
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +15 -15
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/src/renderers/common/extras/PMREMGenerator.js +771 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +64 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +106 -68
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +38 -25
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +19 -11
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +42 -38
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +23 -22
- package/src/renderers/webgl/WebGLCapabilities.js +44 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +7 -20
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +23 -21
- package/src/renderers/webgl/WebGLLights.js +21 -44
- package/src/renderers/webgl/WebGLMaterials.js +9 -8
- package/src/renderers/webgl/WebGLMorphtargets.js +78 -217
- package/src/renderers/webgl/WebGLProgram.js +46 -78
- package/src/renderers/webgl/WebGLPrograms.js +37 -40
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLRenderStates.js +15 -9
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +35 -58
- package/src/renderers/webgl/WebGLTextures.js +313 -358
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +8 -8
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +389 -152
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +145 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +245 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +7 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +21 -3
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +271 -43
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +6 -23
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +318 -141
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +10 -7
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +424 -95
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +37 -18
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +86 -32
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +10 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +68 -27
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +235 -68
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +43 -5
- package/src/renderers/webxr/WebXRDepthSensing.js +11 -6
- package/src/renderers/webxr/WebXRManager.js +53 -38
- package/src/scenes/Scene.js +7 -1
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/textures/Texture.js +12 -2
- package/src/utils.js +62 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/nodes/Nodes.js +0 -195
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +0 -10
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -314
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -33
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -39
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -72
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/PropertyNode.js +0 -72
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/examples/jsm/nodes/display/PassNode.js +0 -183
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -184
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportNode.js +0 -134
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -38
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -393
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -241
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -181
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -188
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -155
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -90
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -130
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/math/OperatorNode.js +0 -274
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/objects/QuadMesh.js +0 -66
- package/examples/jsm/renderers/common/Bindings.js +0 -173
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -25
- package/examples/jsm/renderers/common/RenderObject.js +0 -221
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -49
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Controls,
|
|
2
3
|
GridHelper,
|
|
3
4
|
EllipseCurve,
|
|
4
5
|
BufferGeometry,
|
|
@@ -12,8 +13,7 @@ import {
|
|
|
12
13
|
Vector2,
|
|
13
14
|
Vector3,
|
|
14
15
|
Matrix4,
|
|
15
|
-
MathUtils
|
|
16
|
-
EventDispatcher
|
|
16
|
+
MathUtils
|
|
17
17
|
} from 'three';
|
|
18
18
|
|
|
19
19
|
//trackball state
|
|
@@ -76,13 +76,12 @@ const _scalePointTemp = new Vector3();
|
|
|
76
76
|
* @param {HTMLElement} domElement Renderer's dom element
|
|
77
77
|
* @param {Scene} scene The scene to be rendered
|
|
78
78
|
*/
|
|
79
|
-
class ArcballControls extends
|
|
79
|
+
class ArcballControls extends Controls {
|
|
80
80
|
|
|
81
|
-
constructor( camera, domElement, scene = null ) {
|
|
81
|
+
constructor( camera, domElement = null, scene = null ) {
|
|
82
|
+
|
|
83
|
+
super( camera, domElement );
|
|
82
84
|
|
|
83
|
-
super();
|
|
84
|
-
this.camera = null;
|
|
85
|
-
this.domElement = domElement;
|
|
86
85
|
this.scene = scene;
|
|
87
86
|
this.target = new Vector3();
|
|
88
87
|
this._currentTarget = new Vector3();
|
|
@@ -201,7 +200,6 @@ class ArcballControls extends EventDispatcher {
|
|
|
201
200
|
this.maxFov = 90;
|
|
202
201
|
this.rotateSpeed = 1;
|
|
203
202
|
|
|
204
|
-
this.enabled = true;
|
|
205
203
|
this.enablePan = true;
|
|
206
204
|
this.enableRotate = true;
|
|
207
205
|
this.enableZoom = true;
|
|
@@ -226,11 +224,10 @@ class ArcballControls extends EventDispatcher {
|
|
|
226
224
|
|
|
227
225
|
}
|
|
228
226
|
|
|
229
|
-
this.domElement.style.touchAction = 'none';
|
|
230
|
-
this._devPxRatio = window.devicePixelRatio;
|
|
231
|
-
|
|
232
227
|
this.initializeMouseActions();
|
|
233
228
|
|
|
229
|
+
// event listeners
|
|
230
|
+
|
|
234
231
|
this._onContextMenu = onContextMenu.bind( this );
|
|
235
232
|
this._onWheel = onWheel.bind( this );
|
|
236
233
|
this._onPointerUp = onPointerUp.bind( this );
|
|
@@ -239,6 +236,19 @@ class ArcballControls extends EventDispatcher {
|
|
|
239
236
|
this._onPointerCancel = onPointerCancel.bind( this );
|
|
240
237
|
this._onWindowResize = onWindowResize.bind( this );
|
|
241
238
|
|
|
239
|
+
if ( domElement !== null ) {
|
|
240
|
+
|
|
241
|
+
this.connect();
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
connect() {
|
|
248
|
+
|
|
249
|
+
this.domElement.style.touchAction = 'none';
|
|
250
|
+
this._devPxRatio = window.devicePixelRatio;
|
|
251
|
+
|
|
242
252
|
this.domElement.addEventListener( 'contextmenu', this._onContextMenu );
|
|
243
253
|
this.domElement.addEventListener( 'wheel', this._onWheel );
|
|
244
254
|
this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
|
|
@@ -248,6 +258,20 @@ class ArcballControls extends EventDispatcher {
|
|
|
248
258
|
|
|
249
259
|
}
|
|
250
260
|
|
|
261
|
+
disconnect() {
|
|
262
|
+
|
|
263
|
+
this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
|
|
264
|
+
this.domElement.removeEventListener( 'pointercancel', this._onPointerCancel );
|
|
265
|
+
this.domElement.removeEventListener( 'wheel', this._onWheel );
|
|
266
|
+
this.domElement.removeEventListener( 'contextmenu', this._onContextMenu );
|
|
267
|
+
|
|
268
|
+
window.removeEventListener( 'pointermove', this._onPointerMove );
|
|
269
|
+
window.removeEventListener( 'pointerup', this._onPointerUp );
|
|
270
|
+
|
|
271
|
+
window.removeEventListener( 'resize', this._onWindowResize );
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
251
275
|
onSinglePanStart( event, operation ) {
|
|
252
276
|
|
|
253
277
|
if ( this.enabled ) {
|
|
@@ -278,7 +302,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
278
302
|
}
|
|
279
303
|
|
|
280
304
|
this.updateTbState( STATE.PAN, true );
|
|
281
|
-
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.
|
|
305
|
+
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement ) );
|
|
282
306
|
if ( this.enableGrid ) {
|
|
283
307
|
|
|
284
308
|
this.drawGrid();
|
|
@@ -305,7 +329,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
305
329
|
}
|
|
306
330
|
|
|
307
331
|
this.updateTbState( STATE.ROTATE, true );
|
|
308
|
-
this._startCursorPosition.copy( this.unprojectOnTbSurface( this.
|
|
332
|
+
this._startCursorPosition.copy( this.unprojectOnTbSurface( this.object, _center.x, _center.y, this.domElement, this._tbRadius ) );
|
|
309
333
|
this.activateGizmos( true );
|
|
310
334
|
if ( this.enableAnimations ) {
|
|
311
335
|
|
|
@@ -323,7 +347,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
323
347
|
|
|
324
348
|
case 'FOV':
|
|
325
349
|
|
|
326
|
-
if ( ! this.
|
|
350
|
+
if ( ! this.object.isPerspectiveCamera || ! this.enableZoom ) {
|
|
327
351
|
|
|
328
352
|
return;
|
|
329
353
|
|
|
@@ -396,7 +420,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
396
420
|
this.dispatchEvent( _startEvent );
|
|
397
421
|
|
|
398
422
|
this.updateTbState( opState, true );
|
|
399
|
-
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.
|
|
423
|
+
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement ) );
|
|
400
424
|
if ( this.enableGrid ) {
|
|
401
425
|
|
|
402
426
|
this.drawGrid();
|
|
@@ -408,7 +432,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
408
432
|
} else {
|
|
409
433
|
|
|
410
434
|
//continue with pan operation
|
|
411
|
-
this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.
|
|
435
|
+
this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement ) );
|
|
412
436
|
this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition ) );
|
|
413
437
|
|
|
414
438
|
}
|
|
@@ -429,7 +453,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
429
453
|
this.dispatchEvent( _startEvent );
|
|
430
454
|
|
|
431
455
|
this.updateTbState( opState, true );
|
|
432
|
-
this._startCursorPosition.copy( this.unprojectOnTbSurface( this.
|
|
456
|
+
this._startCursorPosition.copy( this.unprojectOnTbSurface( this.object, _center.x, _center.y, this.domElement, this._tbRadius ) );
|
|
433
457
|
|
|
434
458
|
if ( this.enableGrid ) {
|
|
435
459
|
|
|
@@ -442,7 +466,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
442
466
|
} else {
|
|
443
467
|
|
|
444
468
|
//continue with rotate operation
|
|
445
|
-
this._currentCursorPosition.copy( this.unprojectOnTbSurface( this.
|
|
469
|
+
this._currentCursorPosition.copy( this.unprojectOnTbSurface( this.object, _center.x, _center.y, this.domElement, this._tbRadius ) );
|
|
446
470
|
|
|
447
471
|
const distance = this._startCursorPosition.distanceTo( this._currentCursorPosition );
|
|
448
472
|
const angle = this._startCursorPosition.angleTo( this._currentCursorPosition );
|
|
@@ -524,7 +548,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
524
548
|
|
|
525
549
|
case STATE.FOV:
|
|
526
550
|
|
|
527
|
-
if ( this.enableZoom && this.
|
|
551
|
+
if ( this.enableZoom && this.object.isPerspectiveCamera ) {
|
|
528
552
|
|
|
529
553
|
if ( restart ) {
|
|
530
554
|
|
|
@@ -588,7 +612,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
588
612
|
this.applyTransformMatrix( this.scale( size, this._v3_2, false ) );
|
|
589
613
|
|
|
590
614
|
//adjusting distance
|
|
591
|
-
_offset.copy( this._gizmos.position ).sub( this.
|
|
615
|
+
_offset.copy( this._gizmos.position ).sub( this.object.position ).normalize().multiplyScalar( newDistance / x );
|
|
592
616
|
this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
|
|
593
617
|
|
|
594
618
|
}
|
|
@@ -678,7 +702,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
678
702
|
this.dispatchEvent( _startEvent );
|
|
679
703
|
|
|
680
704
|
this.setCenter( event.clientX, event.clientY );
|
|
681
|
-
const hitP = this.unprojectOnObj( this.getCursorNDC( _center.x, _center.y, this.domElement ), this.
|
|
705
|
+
const hitP = this.unprojectOnObj( this.getCursorNDC( _center.x, _center.y, this.domElement ), this.object );
|
|
682
706
|
|
|
683
707
|
if ( hitP != null && this.enableAnimations ) {
|
|
684
708
|
|
|
@@ -721,7 +745,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
721
745
|
this.updateTbState( STATE.PAN, true );
|
|
722
746
|
|
|
723
747
|
this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
|
|
724
|
-
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.
|
|
748
|
+
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement, true ) );
|
|
725
749
|
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
726
750
|
|
|
727
751
|
this.activateGizmos( false );
|
|
@@ -743,7 +767,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
743
767
|
|
|
744
768
|
}
|
|
745
769
|
|
|
746
|
-
this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.
|
|
770
|
+
this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement, true ) );
|
|
747
771
|
this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition, true ) );
|
|
748
772
|
this.dispatchEvent( _changeEvent );
|
|
749
773
|
|
|
@@ -771,7 +795,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
771
795
|
this._startFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
|
|
772
796
|
this._currentFingerRotation = this._startFingerRotation;
|
|
773
797
|
|
|
774
|
-
this.
|
|
798
|
+
this.object.getWorldDirection( this._rotationAxis ); //rotation axis
|
|
775
799
|
|
|
776
800
|
if ( ! this.enablePan && ! this.enableZoom ) {
|
|
777
801
|
|
|
@@ -807,7 +831,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
807
831
|
} else {
|
|
808
832
|
|
|
809
833
|
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
|
|
810
|
-
rotationPoint = this.unprojectOnTbPlane( this.
|
|
834
|
+
rotationPoint = this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement ).applyQuaternion( this.object.quaternion ).multiplyScalar( 1 / this.object.zoom ).add( this._v3_2 );
|
|
811
835
|
|
|
812
836
|
}
|
|
813
837
|
|
|
@@ -869,17 +893,17 @@ class ArcballControls extends EventDispatcher {
|
|
|
869
893
|
|
|
870
894
|
} else {
|
|
871
895
|
|
|
872
|
-
if ( this.
|
|
896
|
+
if ( this.object.isOrthographicCamera ) {
|
|
873
897
|
|
|
874
|
-
scalePoint = this.unprojectOnTbPlane( this.
|
|
875
|
-
.applyQuaternion( this.
|
|
876
|
-
.multiplyScalar( 1 / this.
|
|
898
|
+
scalePoint = this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement )
|
|
899
|
+
.applyQuaternion( this.object.quaternion )
|
|
900
|
+
.multiplyScalar( 1 / this.object.zoom )
|
|
877
901
|
.add( this._gizmos.position );
|
|
878
902
|
|
|
879
|
-
} else if ( this.
|
|
903
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
880
904
|
|
|
881
|
-
scalePoint = this.unprojectOnTbPlane( this.
|
|
882
|
-
.applyQuaternion( this.
|
|
905
|
+
scalePoint = this.unprojectOnTbPlane( this.object, _center.x, _center.y, this.domElement )
|
|
906
|
+
.applyQuaternion( this.object.quaternion )
|
|
883
907
|
.add( this._gizmos.position );
|
|
884
908
|
|
|
885
909
|
}
|
|
@@ -997,7 +1021,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
997
1021
|
this.applyTransformMatrix( this.scale( size, this._v3_2, false ) );
|
|
998
1022
|
|
|
999
1023
|
//adjusting distance
|
|
1000
|
-
_offset.copy( this._gizmos.position ).sub( this.
|
|
1024
|
+
_offset.copy( this._gizmos.position ).sub( this.object.position ).normalize().multiplyScalar( newDistance / x );
|
|
1001
1025
|
this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
|
|
1002
1026
|
|
|
1003
1027
|
this.dispatchEvent( _changeEvent );
|
|
@@ -1297,13 +1321,13 @@ class ArcballControls extends EventDispatcher {
|
|
|
1297
1321
|
if ( transformation.camera != null ) {
|
|
1298
1322
|
|
|
1299
1323
|
this._m4_1.copy( this._cameraMatrixState ).premultiply( transformation.camera );
|
|
1300
|
-
this._m4_1.decompose( this.
|
|
1301
|
-
this.
|
|
1324
|
+
this._m4_1.decompose( this.object.position, this.object.quaternion, this.object.scale );
|
|
1325
|
+
this.object.updateMatrix();
|
|
1302
1326
|
|
|
1303
1327
|
//update camera up vector
|
|
1304
1328
|
if ( this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE ) {
|
|
1305
1329
|
|
|
1306
|
-
this.
|
|
1330
|
+
this.object.up.copy( this._upState ).applyQuaternion( this.object.quaternion );
|
|
1307
1331
|
|
|
1308
1332
|
}
|
|
1309
1333
|
|
|
@@ -1319,11 +1343,11 @@ class ArcballControls extends EventDispatcher {
|
|
|
1319
1343
|
|
|
1320
1344
|
if ( this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS ) {
|
|
1321
1345
|
|
|
1322
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
1346
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
1323
1347
|
|
|
1324
1348
|
if ( this.adjustNearFar ) {
|
|
1325
1349
|
|
|
1326
|
-
const cameraDistance = this.
|
|
1350
|
+
const cameraDistance = this.object.position.distanceTo( this._gizmos.position );
|
|
1327
1351
|
|
|
1328
1352
|
const bb = new Box3();
|
|
1329
1353
|
bb.setFromObject( this._gizmos );
|
|
@@ -1334,38 +1358,38 @@ class ArcballControls extends EventDispatcher {
|
|
|
1334
1358
|
const regularNearPosition = cameraDistance - this._initialNear;
|
|
1335
1359
|
|
|
1336
1360
|
const minNearPos = Math.min( adjustedNearPosition, regularNearPosition );
|
|
1337
|
-
this.
|
|
1361
|
+
this.object.near = cameraDistance - minNearPos;
|
|
1338
1362
|
|
|
1339
1363
|
|
|
1340
1364
|
const adjustedFarPosition = Math.min( this._farPos0, - sphere.radius + sphere.center.length() );
|
|
1341
1365
|
const regularFarPosition = cameraDistance - this._initialFar;
|
|
1342
1366
|
|
|
1343
1367
|
const minFarPos = Math.min( adjustedFarPosition, regularFarPosition );
|
|
1344
|
-
this.
|
|
1368
|
+
this.object.far = cameraDistance - minFarPos;
|
|
1345
1369
|
|
|
1346
|
-
this.
|
|
1370
|
+
this.object.updateProjectionMatrix();
|
|
1347
1371
|
|
|
1348
1372
|
} else {
|
|
1349
1373
|
|
|
1350
1374
|
let update = false;
|
|
1351
1375
|
|
|
1352
|
-
if ( this.
|
|
1376
|
+
if ( this.object.near != this._initialNear ) {
|
|
1353
1377
|
|
|
1354
|
-
this.
|
|
1378
|
+
this.object.near = this._initialNear;
|
|
1355
1379
|
update = true;
|
|
1356
1380
|
|
|
1357
1381
|
}
|
|
1358
1382
|
|
|
1359
|
-
if ( this.
|
|
1383
|
+
if ( this.object.far != this._initialFar ) {
|
|
1360
1384
|
|
|
1361
|
-
this.
|
|
1385
|
+
this.object.far = this._initialFar;
|
|
1362
1386
|
update = true;
|
|
1363
1387
|
|
|
1364
1388
|
}
|
|
1365
1389
|
|
|
1366
1390
|
if ( update ) {
|
|
1367
1391
|
|
|
1368
|
-
this.
|
|
1392
|
+
this.object.updateProjectionMatrix();
|
|
1369
1393
|
|
|
1370
1394
|
}
|
|
1371
1395
|
|
|
@@ -1465,7 +1489,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
1465
1489
|
|
|
1466
1490
|
_cameraMatrixStateTemp.copy( this._cameraMatrixState );
|
|
1467
1491
|
this._cameraMatrixState.premultiply( this._translationMatrix );
|
|
1468
|
-
this._cameraMatrixState.decompose( this.
|
|
1492
|
+
this._cameraMatrixState.decompose( this.object.position, this.object.quaternion, this.object.scale );
|
|
1469
1493
|
|
|
1470
1494
|
//apply zoom
|
|
1471
1495
|
if ( this.enableZoom ) {
|
|
@@ -1490,22 +1514,22 @@ class ArcballControls extends EventDispatcher {
|
|
|
1490
1514
|
const multiplier = 3;
|
|
1491
1515
|
let size, divisions, maxLength, tick;
|
|
1492
1516
|
|
|
1493
|
-
if ( this.
|
|
1517
|
+
if ( this.object.isOrthographicCamera ) {
|
|
1494
1518
|
|
|
1495
|
-
const width = this.
|
|
1496
|
-
const height = this.
|
|
1519
|
+
const width = this.object.right - this.object.left;
|
|
1520
|
+
const height = this.object.bottom - this.object.top;
|
|
1497
1521
|
|
|
1498
1522
|
maxLength = Math.max( width, height );
|
|
1499
1523
|
tick = maxLength / 20;
|
|
1500
1524
|
|
|
1501
|
-
size = maxLength / this.
|
|
1502
|
-
divisions = size / tick * this.
|
|
1525
|
+
size = maxLength / this.object.zoom * multiplier;
|
|
1526
|
+
divisions = size / tick * this.object.zoom;
|
|
1503
1527
|
|
|
1504
|
-
} else if ( this.
|
|
1528
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
1505
1529
|
|
|
1506
|
-
const distance = this.
|
|
1507
|
-
const halfFovV = MathUtils.DEG2RAD * this.
|
|
1508
|
-
const halfFovH = Math.atan( ( this.
|
|
1530
|
+
const distance = this.object.position.distanceTo( this._gizmos.position );
|
|
1531
|
+
const halfFovV = MathUtils.DEG2RAD * this.object.fov * 0.5;
|
|
1532
|
+
const halfFovH = Math.atan( ( this.object.aspect ) * Math.tan( halfFovV ) );
|
|
1509
1533
|
|
|
1510
1534
|
maxLength = Math.tan( Math.max( halfFovV, halfFovH ) ) * distance * 2;
|
|
1511
1535
|
tick = maxLength / 20;
|
|
@@ -1520,7 +1544,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
1520
1544
|
this._grid = new GridHelper( size, divisions, color, color );
|
|
1521
1545
|
this._grid.position.copy( this._gizmos.position );
|
|
1522
1546
|
this._gridPosition.copy( this._grid.position );
|
|
1523
|
-
this._grid.quaternion.copy( this.
|
|
1547
|
+
this._grid.quaternion.copy( this.object.quaternion );
|
|
1524
1548
|
this._grid.rotateX( Math.PI * 0.5 );
|
|
1525
1549
|
|
|
1526
1550
|
this.scene.add( this._grid );
|
|
@@ -1542,15 +1566,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
1542
1566
|
|
|
1543
1567
|
}
|
|
1544
1568
|
|
|
1545
|
-
this.
|
|
1546
|
-
this.domElement.removeEventListener( 'pointercancel', this._onPointerCancel );
|
|
1547
|
-
this.domElement.removeEventListener( 'wheel', this._onWheel );
|
|
1548
|
-
this.domElement.removeEventListener( 'contextmenu', this._onContextMenu );
|
|
1549
|
-
|
|
1550
|
-
window.removeEventListener( 'pointermove', this._onPointerMove );
|
|
1551
|
-
window.removeEventListener( 'pointerup', this._onPointerUp );
|
|
1552
|
-
|
|
1553
|
-
window.removeEventListener( 'resize', this._onWindowResize );
|
|
1569
|
+
this.disconnect();
|
|
1554
1570
|
|
|
1555
1571
|
if ( this.scene !== null ) this.scene.remove( this._gizmos );
|
|
1556
1572
|
this.disposeGrid();
|
|
@@ -1634,8 +1650,8 @@ class ArcballControls extends EventDispatcher {
|
|
|
1634
1650
|
getCursorPosition( cursorX, cursorY, canvas ) {
|
|
1635
1651
|
|
|
1636
1652
|
this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
|
|
1637
|
-
this._v2_1.x *= ( this.
|
|
1638
|
-
this._v2_1.y *= ( this.
|
|
1653
|
+
this._v2_1.x *= ( this.object.right - this.object.left ) * 0.5;
|
|
1654
|
+
this._v2_1.y *= ( this.object.top - this.object.bottom ) * 0.5;
|
|
1639
1655
|
return this._v2_1.clone();
|
|
1640
1656
|
|
|
1641
1657
|
}
|
|
@@ -1674,8 +1690,8 @@ class ArcballControls extends EventDispatcher {
|
|
|
1674
1690
|
this._up0.copy( camera.up );
|
|
1675
1691
|
this._upState.copy( camera.up );
|
|
1676
1692
|
|
|
1677
|
-
this.
|
|
1678
|
-
this.
|
|
1693
|
+
this.object = camera;
|
|
1694
|
+
this.object.updateProjectionMatrix();
|
|
1679
1695
|
|
|
1680
1696
|
//making gizmos
|
|
1681
1697
|
this._tbRadius = this.calculateTbRadius( camera );
|
|
@@ -1701,7 +1717,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
1701
1717
|
setTbRadius( value ) {
|
|
1702
1718
|
|
|
1703
1719
|
this.radiusFactor = value;
|
|
1704
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
1720
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
1705
1721
|
|
|
1706
1722
|
const curve = new EllipseCurve( 0, 0, this._tbRadius, this._tbRadius );
|
|
1707
1723
|
const points = curve.getPoints( this._curvePts );
|
|
@@ -1750,10 +1766,10 @@ class ArcballControls extends EventDispatcher {
|
|
|
1750
1766
|
this._gizmoMatrixState0.identity().setPosition( tbCenter );
|
|
1751
1767
|
this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
|
|
1752
1768
|
|
|
1753
|
-
if ( this.
|
|
1769
|
+
if ( this.object.zoom !== 1 ) {
|
|
1754
1770
|
|
|
1755
1771
|
//adapt gizmos size to camera zoom
|
|
1756
|
-
const size = 1 / this.
|
|
1772
|
+
const size = 1 / this.object.zoom;
|
|
1757
1773
|
this._scaleMatrix.makeScale( size, size, size );
|
|
1758
1774
|
this._translationMatrix.makeTranslation( - tbCenter.x, - tbCenter.y, - tbCenter.z );
|
|
1759
1775
|
|
|
@@ -1931,22 +1947,22 @@ class ArcballControls extends EventDispatcher {
|
|
|
1931
1947
|
|
|
1932
1948
|
const movement = p0.clone().sub( p1 );
|
|
1933
1949
|
|
|
1934
|
-
if ( this.
|
|
1950
|
+
if ( this.object.isOrthographicCamera ) {
|
|
1935
1951
|
|
|
1936
1952
|
//adjust movement amount
|
|
1937
|
-
movement.multiplyScalar( 1 / this.
|
|
1953
|
+
movement.multiplyScalar( 1 / this.object.zoom );
|
|
1938
1954
|
|
|
1939
|
-
} else if ( this.
|
|
1955
|
+
} else if ( this.object.isPerspectiveCamera && adjust ) {
|
|
1940
1956
|
|
|
1941
1957
|
//adjust movement amount
|
|
1942
1958
|
this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ); //camera's initial position
|
|
1943
1959
|
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ); //gizmo's initial position
|
|
1944
|
-
const distanceFactor = this._v3_1.distanceTo( this._v3_2 ) / this.
|
|
1960
|
+
const distanceFactor = this._v3_1.distanceTo( this._v3_2 ) / this.object.position.distanceTo( this._gizmos.position );
|
|
1945
1961
|
movement.multiplyScalar( 1 / distanceFactor );
|
|
1946
1962
|
|
|
1947
1963
|
}
|
|
1948
1964
|
|
|
1949
|
-
this._v3_1.set( movement.x, movement.y, 0 ).applyQuaternion( this.
|
|
1965
|
+
this._v3_1.set( movement.x, movement.y, 0 ).applyQuaternion( this.object.quaternion );
|
|
1950
1966
|
|
|
1951
1967
|
this._m4_1.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z );
|
|
1952
1968
|
|
|
@@ -1960,31 +1976,31 @@ class ArcballControls extends EventDispatcher {
|
|
|
1960
1976
|
*/
|
|
1961
1977
|
reset() {
|
|
1962
1978
|
|
|
1963
|
-
this.
|
|
1979
|
+
this.object.zoom = this._zoom0;
|
|
1964
1980
|
|
|
1965
|
-
if ( this.
|
|
1981
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
1966
1982
|
|
|
1967
|
-
this.
|
|
1983
|
+
this.object.fov = this._fov0;
|
|
1968
1984
|
|
|
1969
1985
|
}
|
|
1970
1986
|
|
|
1971
|
-
this.
|
|
1972
|
-
this.
|
|
1987
|
+
this.object.near = this._nearPos;
|
|
1988
|
+
this.object.far = this._farPos;
|
|
1973
1989
|
this._cameraMatrixState.copy( this._cameraMatrixState0 );
|
|
1974
|
-
this._cameraMatrixState.decompose( this.
|
|
1975
|
-
this.
|
|
1990
|
+
this._cameraMatrixState.decompose( this.object.position, this.object.quaternion, this.object.scale );
|
|
1991
|
+
this.object.up.copy( this._up0 );
|
|
1976
1992
|
|
|
1977
|
-
this.
|
|
1978
|
-
this.
|
|
1993
|
+
this.object.updateMatrix();
|
|
1994
|
+
this.object.updateProjectionMatrix();
|
|
1979
1995
|
|
|
1980
1996
|
this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
|
|
1981
1997
|
this._gizmoMatrixState0.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
1982
1998
|
this._gizmos.updateMatrix();
|
|
1983
1999
|
|
|
1984
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
2000
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
1985
2001
|
this.makeGizmos( this._gizmos.position, this._tbRadius );
|
|
1986
2002
|
|
|
1987
|
-
this.
|
|
2003
|
+
this.object.lookAt( this._gizmos.position );
|
|
1988
2004
|
|
|
1989
2005
|
this.updateTbState( STATE.IDLE, false );
|
|
1990
2006
|
|
|
@@ -2018,28 +2034,28 @@ class ArcballControls extends EventDispatcher {
|
|
|
2018
2034
|
copyState() {
|
|
2019
2035
|
|
|
2020
2036
|
let state;
|
|
2021
|
-
if ( this.
|
|
2037
|
+
if ( this.object.isOrthographicCamera ) {
|
|
2022
2038
|
|
|
2023
2039
|
state = JSON.stringify( { arcballState: {
|
|
2024
2040
|
|
|
2025
|
-
cameraFar: this.
|
|
2026
|
-
cameraMatrix: this.
|
|
2027
|
-
cameraNear: this.
|
|
2028
|
-
cameraUp: this.
|
|
2029
|
-
cameraZoom: this.
|
|
2041
|
+
cameraFar: this.object.far,
|
|
2042
|
+
cameraMatrix: this.object.matrix,
|
|
2043
|
+
cameraNear: this.object.near,
|
|
2044
|
+
cameraUp: this.object.up,
|
|
2045
|
+
cameraZoom: this.object.zoom,
|
|
2030
2046
|
gizmoMatrix: this._gizmos.matrix
|
|
2031
2047
|
|
|
2032
2048
|
} } );
|
|
2033
2049
|
|
|
2034
|
-
} else if ( this.
|
|
2050
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
2035
2051
|
|
|
2036
2052
|
state = JSON.stringify( { arcballState: {
|
|
2037
|
-
cameraFar: this.
|
|
2038
|
-
cameraFov: this.
|
|
2039
|
-
cameraMatrix: this.
|
|
2040
|
-
cameraNear: this.
|
|
2041
|
-
cameraUp: this.
|
|
2042
|
-
cameraZoom: this.
|
|
2053
|
+
cameraFar: this.object.far,
|
|
2054
|
+
cameraFov: this.object.fov,
|
|
2055
|
+
cameraMatrix: this.object.matrix,
|
|
2056
|
+
cameraNear: this.object.near,
|
|
2057
|
+
cameraUp: this.object.up,
|
|
2058
|
+
cameraZoom: this.object.zoom,
|
|
2043
2059
|
gizmoMatrix: this._gizmos.matrix
|
|
2044
2060
|
|
|
2045
2061
|
} } );
|
|
@@ -2066,16 +2082,16 @@ class ArcballControls extends EventDispatcher {
|
|
|
2066
2082
|
*/
|
|
2067
2083
|
saveState() {
|
|
2068
2084
|
|
|
2069
|
-
this._cameraMatrixState0.copy( this.
|
|
2085
|
+
this._cameraMatrixState0.copy( this.object.matrix );
|
|
2070
2086
|
this._gizmoMatrixState0.copy( this._gizmos.matrix );
|
|
2071
|
-
this._nearPos = this.
|
|
2072
|
-
this._farPos = this.
|
|
2073
|
-
this._zoom0 = this.
|
|
2074
|
-
this._up0.copy( this.
|
|
2087
|
+
this._nearPos = this.object.near;
|
|
2088
|
+
this._farPos = this.object.far;
|
|
2089
|
+
this._zoom0 = this.object.zoom;
|
|
2090
|
+
this._up0.copy( this.object.up );
|
|
2075
2091
|
|
|
2076
|
-
if ( this.
|
|
2092
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
2077
2093
|
|
|
2078
|
-
this._fov0 = this.
|
|
2094
|
+
this._fov0 = this.object.fov;
|
|
2079
2095
|
|
|
2080
2096
|
}
|
|
2081
2097
|
|
|
@@ -2093,26 +2109,26 @@ class ArcballControls extends EventDispatcher {
|
|
|
2093
2109
|
_scalePointTemp.copy( point );
|
|
2094
2110
|
let sizeInverse = 1 / size;
|
|
2095
2111
|
|
|
2096
|
-
if ( this.
|
|
2112
|
+
if ( this.object.isOrthographicCamera ) {
|
|
2097
2113
|
|
|
2098
2114
|
//camera zoom
|
|
2099
|
-
this.
|
|
2100
|
-
this.
|
|
2115
|
+
this.object.zoom = this._zoomState;
|
|
2116
|
+
this.object.zoom *= size;
|
|
2101
2117
|
|
|
2102
2118
|
//check min and max zoom
|
|
2103
|
-
if ( this.
|
|
2119
|
+
if ( this.object.zoom > this.maxZoom ) {
|
|
2104
2120
|
|
|
2105
|
-
this.
|
|
2121
|
+
this.object.zoom = this.maxZoom;
|
|
2106
2122
|
sizeInverse = this._zoomState / this.maxZoom;
|
|
2107
2123
|
|
|
2108
|
-
} else if ( this.
|
|
2124
|
+
} else if ( this.object.zoom < this.minZoom ) {
|
|
2109
2125
|
|
|
2110
|
-
this.
|
|
2126
|
+
this.object.zoom = this.minZoom;
|
|
2111
2127
|
sizeInverse = this._zoomState / this.minZoom;
|
|
2112
2128
|
|
|
2113
2129
|
}
|
|
2114
2130
|
|
|
2115
|
-
this.
|
|
2131
|
+
this.object.updateProjectionMatrix();
|
|
2116
2132
|
|
|
2117
2133
|
this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ); //gizmos position
|
|
2118
2134
|
|
|
@@ -2136,7 +2152,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
2136
2152
|
this.setTransformationMatrices( this._m4_1, this._m4_2 );
|
|
2137
2153
|
return _transformation;
|
|
2138
2154
|
|
|
2139
|
-
} else if ( this.
|
|
2155
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
2140
2156
|
|
|
2141
2157
|
this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
|
|
2142
2158
|
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
|
|
@@ -2203,10 +2219,10 @@ class ArcballControls extends EventDispatcher {
|
|
|
2203
2219
|
*/
|
|
2204
2220
|
setFov( value ) {
|
|
2205
2221
|
|
|
2206
|
-
if ( this.
|
|
2222
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
2207
2223
|
|
|
2208
|
-
this.
|
|
2209
|
-
this.
|
|
2224
|
+
this.object.fov = MathUtils.clamp( value, this.minFov, this.maxFov );
|
|
2225
|
+
this.object.updateProjectionMatrix();
|
|
2210
2226
|
|
|
2211
2227
|
}
|
|
2212
2228
|
|
|
@@ -2536,18 +2552,18 @@ class ArcballControls extends EventDispatcher {
|
|
|
2536
2552
|
updateMatrixState() {
|
|
2537
2553
|
|
|
2538
2554
|
//update camera and gizmos state
|
|
2539
|
-
this._cameraMatrixState.copy( this.
|
|
2555
|
+
this._cameraMatrixState.copy( this.object.matrix );
|
|
2540
2556
|
this._gizmoMatrixState.copy( this._gizmos.matrix );
|
|
2541
2557
|
|
|
2542
|
-
if ( this.
|
|
2558
|
+
if ( this.object.isOrthographicCamera ) {
|
|
2543
2559
|
|
|
2544
|
-
this._cameraProjectionState.copy( this.
|
|
2545
|
-
this.
|
|
2546
|
-
this._zoomState = this.
|
|
2560
|
+
this._cameraProjectionState.copy( this.object.projectionMatrix );
|
|
2561
|
+
this.object.updateProjectionMatrix();
|
|
2562
|
+
this._zoomState = this.object.zoom;
|
|
2547
2563
|
|
|
2548
|
-
} else if ( this.
|
|
2564
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
2549
2565
|
|
|
2550
|
-
this._fovState = this.
|
|
2566
|
+
this._fovState = this.object.fov;
|
|
2551
2567
|
|
|
2552
2568
|
}
|
|
2553
2569
|
|
|
@@ -2576,27 +2592,27 @@ class ArcballControls extends EventDispatcher {
|
|
|
2576
2592
|
if ( this.target.equals( this._currentTarget ) === false ) {
|
|
2577
2593
|
|
|
2578
2594
|
this._gizmos.position.copy( this.target ); //for correct radius calculation
|
|
2579
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
2595
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
2580
2596
|
this.makeGizmos( this.target, this._tbRadius );
|
|
2581
2597
|
this._currentTarget.copy( this.target );
|
|
2582
2598
|
|
|
2583
2599
|
}
|
|
2584
2600
|
|
|
2585
2601
|
//check min/max parameters
|
|
2586
|
-
if ( this.
|
|
2602
|
+
if ( this.object.isOrthographicCamera ) {
|
|
2587
2603
|
|
|
2588
2604
|
//check zoom
|
|
2589
|
-
if ( this.
|
|
2605
|
+
if ( this.object.zoom > this.maxZoom || this.object.zoom < this.minZoom ) {
|
|
2590
2606
|
|
|
2591
|
-
const newZoom = MathUtils.clamp( this.
|
|
2592
|
-
this.applyTransformMatrix( this.scale( newZoom / this.
|
|
2607
|
+
const newZoom = MathUtils.clamp( this.object.zoom, this.minZoom, this.maxZoom );
|
|
2608
|
+
this.applyTransformMatrix( this.scale( newZoom / this.object.zoom, this._gizmos.position, true ) );
|
|
2593
2609
|
|
|
2594
2610
|
}
|
|
2595
2611
|
|
|
2596
|
-
} else if ( this.
|
|
2612
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
2597
2613
|
|
|
2598
2614
|
//check distance
|
|
2599
|
-
const distance = this.
|
|
2615
|
+
const distance = this.object.position.distanceTo( this._gizmos.position );
|
|
2600
2616
|
|
|
2601
2617
|
if ( distance > this.maxDistance + EPS || distance < this.minDistance - EPS ) {
|
|
2602
2618
|
|
|
@@ -2607,15 +2623,15 @@ class ArcballControls extends EventDispatcher {
|
|
|
2607
2623
|
}
|
|
2608
2624
|
|
|
2609
2625
|
//check fov
|
|
2610
|
-
if ( this.
|
|
2626
|
+
if ( this.object.fov < this.minFov || this.object.fov > this.maxFov ) {
|
|
2611
2627
|
|
|
2612
|
-
this.
|
|
2613
|
-
this.
|
|
2628
|
+
this.object.fov = MathUtils.clamp( this.object.fov, this.minFov, this.maxFov );
|
|
2629
|
+
this.object.updateProjectionMatrix();
|
|
2614
2630
|
|
|
2615
2631
|
}
|
|
2616
2632
|
|
|
2617
2633
|
const oldRadius = this._tbRadius;
|
|
2618
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
2634
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
2619
2635
|
|
|
2620
2636
|
if ( oldRadius < this._tbRadius - EPS || oldRadius > this._tbRadius + EPS ) {
|
|
2621
2637
|
|
|
@@ -2635,7 +2651,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
2635
2651
|
|
|
2636
2652
|
}
|
|
2637
2653
|
|
|
2638
|
-
this.
|
|
2654
|
+
this.object.lookAt( this._gizmos.position );
|
|
2639
2655
|
|
|
2640
2656
|
}
|
|
2641
2657
|
|
|
@@ -2646,34 +2662,34 @@ class ArcballControls extends EventDispatcher {
|
|
|
2646
2662
|
if ( state.arcballState != undefined ) {
|
|
2647
2663
|
|
|
2648
2664
|
this._cameraMatrixState.fromArray( state.arcballState.cameraMatrix.elements );
|
|
2649
|
-
this._cameraMatrixState.decompose( this.
|
|
2665
|
+
this._cameraMatrixState.decompose( this.object.position, this.object.quaternion, this.object.scale );
|
|
2650
2666
|
|
|
2651
|
-
this.
|
|
2652
|
-
this.
|
|
2653
|
-
this.
|
|
2667
|
+
this.object.up.copy( state.arcballState.cameraUp );
|
|
2668
|
+
this.object.near = state.arcballState.cameraNear;
|
|
2669
|
+
this.object.far = state.arcballState.cameraFar;
|
|
2654
2670
|
|
|
2655
|
-
this.
|
|
2671
|
+
this.object.zoom = state.arcballState.cameraZoom;
|
|
2656
2672
|
|
|
2657
|
-
if ( this.
|
|
2673
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
2658
2674
|
|
|
2659
|
-
this.
|
|
2675
|
+
this.object.fov = state.arcballState.cameraFov;
|
|
2660
2676
|
|
|
2661
2677
|
}
|
|
2662
2678
|
|
|
2663
2679
|
this._gizmoMatrixState.fromArray( state.arcballState.gizmoMatrix.elements );
|
|
2664
2680
|
this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
2665
2681
|
|
|
2666
|
-
this.
|
|
2667
|
-
this.
|
|
2682
|
+
this.object.updateMatrix();
|
|
2683
|
+
this.object.updateProjectionMatrix();
|
|
2668
2684
|
|
|
2669
2685
|
this._gizmos.updateMatrix();
|
|
2670
2686
|
|
|
2671
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
2687
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
2672
2688
|
const gizmoTmp = new Matrix4().copy( this._gizmoMatrixState0 );
|
|
2673
2689
|
this.makeGizmos( this._gizmos.position, this._tbRadius );
|
|
2674
2690
|
this._gizmoMatrixState0.copy( gizmoTmp );
|
|
2675
2691
|
|
|
2676
|
-
this.
|
|
2692
|
+
this.object.lookAt( this._gizmos.position );
|
|
2677
2693
|
this.updateTbState( STATE.IDLE, false );
|
|
2678
2694
|
|
|
2679
2695
|
this.dispatchEvent( _changeEvent );
|
|
@@ -2689,7 +2705,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
2689
2705
|
function onWindowResize() {
|
|
2690
2706
|
|
|
2691
2707
|
const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
|
|
2692
|
-
this._tbRadius = this.calculateTbRadius( this.
|
|
2708
|
+
this._tbRadius = this.calculateTbRadius( this.object );
|
|
2693
2709
|
|
|
2694
2710
|
const newRadius = this._tbRadius / scale;
|
|
2695
2711
|
const curve = new EllipseCurve( 0, 0, newRadius, newRadius );
|
|
@@ -3098,13 +3114,13 @@ function onWheel( event ) {
|
|
|
3098
3114
|
|
|
3099
3115
|
let scalePoint;
|
|
3100
3116
|
|
|
3101
|
-
if ( this.
|
|
3117
|
+
if ( this.object.isOrthographicCamera ) {
|
|
3102
3118
|
|
|
3103
|
-
scalePoint = this.unprojectOnTbPlane( this.
|
|
3119
|
+
scalePoint = this.unprojectOnTbPlane( this.object, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.object.quaternion ).multiplyScalar( 1 / this.object.zoom ).add( this._gizmos.position );
|
|
3104
3120
|
|
|
3105
|
-
} else if ( this.
|
|
3121
|
+
} else if ( this.object.isPerspectiveCamera ) {
|
|
3106
3122
|
|
|
3107
|
-
scalePoint = this.unprojectOnTbPlane( this.
|
|
3123
|
+
scalePoint = this.unprojectOnTbPlane( this.object, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.object.quaternion ).add( this._gizmos.position );
|
|
3108
3124
|
|
|
3109
3125
|
}
|
|
3110
3126
|
|
|
@@ -3132,7 +3148,7 @@ function onWheel( event ) {
|
|
|
3132
3148
|
|
|
3133
3149
|
case 'FOV':
|
|
3134
3150
|
|
|
3135
|
-
if ( this.
|
|
3151
|
+
if ( this.object.isPerspectiveCamera ) {
|
|
3136
3152
|
|
|
3137
3153
|
this.updateTbState( STATE.FOV, true );
|
|
3138
3154
|
|
|
@@ -3175,7 +3191,7 @@ function onWheel( event ) {
|
|
|
3175
3191
|
//check min and max distance
|
|
3176
3192
|
xNew = MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
|
|
3177
3193
|
|
|
3178
|
-
const y = x * Math.tan( MathUtils.DEG2RAD * this.
|
|
3194
|
+
const y = x * Math.tan( MathUtils.DEG2RAD * this.object.fov * 0.5 );
|
|
3179
3195
|
|
|
3180
3196
|
//calculate new fov
|
|
3181
3197
|
let newFov = MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
|