@needle-tools/three 0.169.20 → 0.183.2-canary.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/LICENSE +1 -1
- package/README.md +5 -6
- package/build/three.cjs +54178 -56709
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73012
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53905 -51657
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53884 -51814
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -34
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +99 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +144 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
package/src/math/Vector3.js
CHANGED
|
@@ -1,18 +1,82 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clamp } from './MathUtils.js';
|
|
2
2
|
import { Quaternion } from './Quaternion.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Class representing a 3D vector. A 3D vector is an ordered triplet of numbers
|
|
6
|
+
* (labeled x, y and z), which can be used to represent a number of things, such as:
|
|
7
|
+
*
|
|
8
|
+
* - A point in 3D space.
|
|
9
|
+
* - A direction and length in 3D space. In three.js the length will
|
|
10
|
+
* always be the Euclidean distance(straight-line distance) from `(0, 0, 0)` to `(x, y, z)`
|
|
11
|
+
* and the direction is also measured from `(0, 0, 0)` towards `(x, y, z)`.
|
|
12
|
+
* - Any arbitrary ordered triplet of numbers.
|
|
13
|
+
*
|
|
14
|
+
* There are other things a 3D vector can be used to represent, such as
|
|
15
|
+
* momentum vectors and so on, however these are the most
|
|
16
|
+
* common uses in three.js.
|
|
17
|
+
*
|
|
18
|
+
* Iterating through a vector instance will yield its components `(x, y, z)` in
|
|
19
|
+
* the corresponding order.
|
|
20
|
+
* ```js
|
|
21
|
+
* const a = new THREE.Vector3( 0, 1, 0 );
|
|
22
|
+
*
|
|
23
|
+
* //no arguments; will be initialised to (0, 0, 0)
|
|
24
|
+
* const b = new THREE.Vector3( );
|
|
25
|
+
*
|
|
26
|
+
* const d = a.distanceTo( b );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
4
29
|
class Vector3 {
|
|
5
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new 3D vector.
|
|
33
|
+
*
|
|
34
|
+
* @param {number} [x=0] - The x value of this vector.
|
|
35
|
+
* @param {number} [y=0] - The y value of this vector.
|
|
36
|
+
* @param {number} [z=0] - The z value of this vector.
|
|
37
|
+
*/
|
|
6
38
|
constructor( x = 0, y = 0, z = 0 ) {
|
|
7
39
|
|
|
40
|
+
/**
|
|
41
|
+
* This flag can be used for type testing.
|
|
42
|
+
*
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
* @readonly
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
8
47
|
Vector3.prototype.isVector3 = true;
|
|
9
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The x value of this vector.
|
|
51
|
+
*
|
|
52
|
+
* @type {number}
|
|
53
|
+
*/
|
|
10
54
|
this.x = x;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The y value of this vector.
|
|
58
|
+
*
|
|
59
|
+
* @type {number}
|
|
60
|
+
*/
|
|
11
61
|
this.y = y;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The z value of this vector.
|
|
65
|
+
*
|
|
66
|
+
* @type {number}
|
|
67
|
+
*/
|
|
12
68
|
this.z = z;
|
|
13
69
|
|
|
14
70
|
}
|
|
15
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Sets the vector components.
|
|
74
|
+
*
|
|
75
|
+
* @param {number} x - The value of the x component.
|
|
76
|
+
* @param {number} y - The value of the y component.
|
|
77
|
+
* @param {number} z - The value of the z component.
|
|
78
|
+
* @return {Vector3} A reference to this vector.
|
|
79
|
+
*/
|
|
16
80
|
set( x, y, z ) {
|
|
17
81
|
|
|
18
82
|
if ( z === undefined ) z = this.z; // sprite.scale.set(x,y)
|
|
@@ -25,6 +89,12 @@ class Vector3 {
|
|
|
25
89
|
|
|
26
90
|
}
|
|
27
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Sets the vector components to the same value.
|
|
94
|
+
*
|
|
95
|
+
* @param {number} scalar - The value to set for all vector components.
|
|
96
|
+
* @return {Vector3} A reference to this vector.
|
|
97
|
+
*/
|
|
28
98
|
setScalar( scalar ) {
|
|
29
99
|
|
|
30
100
|
this.x = scalar;
|
|
@@ -35,6 +105,12 @@ class Vector3 {
|
|
|
35
105
|
|
|
36
106
|
}
|
|
37
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Sets the vector's x component to the given value.
|
|
110
|
+
*
|
|
111
|
+
* @param {number} x - The value to set.
|
|
112
|
+
* @return {Vector3} A reference to this vector.
|
|
113
|
+
*/
|
|
38
114
|
setX( x ) {
|
|
39
115
|
|
|
40
116
|
this.x = x;
|
|
@@ -43,6 +119,12 @@ class Vector3 {
|
|
|
43
119
|
|
|
44
120
|
}
|
|
45
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Sets the vector's y component to the given value.
|
|
124
|
+
*
|
|
125
|
+
* @param {number} y - The value to set.
|
|
126
|
+
* @return {Vector3} A reference to this vector.
|
|
127
|
+
*/
|
|
46
128
|
setY( y ) {
|
|
47
129
|
|
|
48
130
|
this.y = y;
|
|
@@ -51,6 +133,12 @@ class Vector3 {
|
|
|
51
133
|
|
|
52
134
|
}
|
|
53
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Sets the vector's z component to the given value.
|
|
138
|
+
*
|
|
139
|
+
* @param {number} z - The value to set.
|
|
140
|
+
* @return {Vector3} A reference to this vector.
|
|
141
|
+
*/
|
|
54
142
|
setZ( z ) {
|
|
55
143
|
|
|
56
144
|
this.z = z;
|
|
@@ -59,6 +147,13 @@ class Vector3 {
|
|
|
59
147
|
|
|
60
148
|
}
|
|
61
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Allows to set a vector component with an index.
|
|
152
|
+
*
|
|
153
|
+
* @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
|
|
154
|
+
* @param {number} value - The value to set.
|
|
155
|
+
* @return {Vector3} A reference to this vector.
|
|
156
|
+
*/
|
|
62
157
|
setComponent( index, value ) {
|
|
63
158
|
|
|
64
159
|
switch ( index ) {
|
|
@@ -74,6 +169,12 @@ class Vector3 {
|
|
|
74
169
|
|
|
75
170
|
}
|
|
76
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Returns the value of the vector component which matches the given index.
|
|
174
|
+
*
|
|
175
|
+
* @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
|
|
176
|
+
* @return {number} A vector component value.
|
|
177
|
+
*/
|
|
77
178
|
getComponent( index ) {
|
|
78
179
|
|
|
79
180
|
switch ( index ) {
|
|
@@ -87,12 +188,23 @@ class Vector3 {
|
|
|
87
188
|
|
|
88
189
|
}
|
|
89
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Returns a new vector with copied values from this instance.
|
|
193
|
+
*
|
|
194
|
+
* @return {Vector3} A clone of this instance.
|
|
195
|
+
*/
|
|
90
196
|
clone() {
|
|
91
197
|
|
|
92
198
|
return new this.constructor( this.x, this.y, this.z );
|
|
93
199
|
|
|
94
200
|
}
|
|
95
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Copies the values of the given vector to this instance.
|
|
204
|
+
*
|
|
205
|
+
* @param {Vector3} v - The vector to copy.
|
|
206
|
+
* @return {Vector3} A reference to this vector.
|
|
207
|
+
*/
|
|
96
208
|
copy( v ) {
|
|
97
209
|
|
|
98
210
|
this.x = v.x;
|
|
@@ -103,6 +215,12 @@ class Vector3 {
|
|
|
103
215
|
|
|
104
216
|
}
|
|
105
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Adds the given vector to this instance.
|
|
220
|
+
*
|
|
221
|
+
* @param {Vector3} v - The vector to add.
|
|
222
|
+
* @return {Vector3} A reference to this vector.
|
|
223
|
+
*/
|
|
106
224
|
add( v ) {
|
|
107
225
|
|
|
108
226
|
this.x += v.x;
|
|
@@ -113,6 +231,12 @@ class Vector3 {
|
|
|
113
231
|
|
|
114
232
|
}
|
|
115
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Adds the given scalar value to all components of this instance.
|
|
236
|
+
*
|
|
237
|
+
* @param {number} s - The scalar to add.
|
|
238
|
+
* @return {Vector3} A reference to this vector.
|
|
239
|
+
*/
|
|
116
240
|
addScalar( s ) {
|
|
117
241
|
|
|
118
242
|
this.x += s;
|
|
@@ -123,6 +247,13 @@ class Vector3 {
|
|
|
123
247
|
|
|
124
248
|
}
|
|
125
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Adds the given vectors and stores the result in this instance.
|
|
252
|
+
*
|
|
253
|
+
* @param {Vector3} a - The first vector.
|
|
254
|
+
* @param {Vector3} b - The second vector.
|
|
255
|
+
* @return {Vector3} A reference to this vector.
|
|
256
|
+
*/
|
|
126
257
|
addVectors( a, b ) {
|
|
127
258
|
|
|
128
259
|
this.x = a.x + b.x;
|
|
@@ -133,6 +264,13 @@ class Vector3 {
|
|
|
133
264
|
|
|
134
265
|
}
|
|
135
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Adds the given vector scaled by the given factor to this instance.
|
|
269
|
+
*
|
|
270
|
+
* @param {Vector3|Vector4} v - The vector.
|
|
271
|
+
* @param {number} s - The factor that scales `v`.
|
|
272
|
+
* @return {Vector3} A reference to this vector.
|
|
273
|
+
*/
|
|
136
274
|
addScaledVector( v, s ) {
|
|
137
275
|
|
|
138
276
|
this.x += v.x * s;
|
|
@@ -143,6 +281,12 @@ class Vector3 {
|
|
|
143
281
|
|
|
144
282
|
}
|
|
145
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Subtracts the given vector from this instance.
|
|
286
|
+
*
|
|
287
|
+
* @param {Vector3} v - The vector to subtract.
|
|
288
|
+
* @return {Vector3} A reference to this vector.
|
|
289
|
+
*/
|
|
146
290
|
sub( v ) {
|
|
147
291
|
|
|
148
292
|
this.x -= v.x;
|
|
@@ -153,6 +297,12 @@ class Vector3 {
|
|
|
153
297
|
|
|
154
298
|
}
|
|
155
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Subtracts the given scalar value from all components of this instance.
|
|
302
|
+
*
|
|
303
|
+
* @param {number} s - The scalar to subtract.
|
|
304
|
+
* @return {Vector3} A reference to this vector.
|
|
305
|
+
*/
|
|
156
306
|
subScalar( s ) {
|
|
157
307
|
|
|
158
308
|
this.x -= s;
|
|
@@ -163,6 +313,13 @@ class Vector3 {
|
|
|
163
313
|
|
|
164
314
|
}
|
|
165
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Subtracts the given vectors and stores the result in this instance.
|
|
318
|
+
*
|
|
319
|
+
* @param {Vector3} a - The first vector.
|
|
320
|
+
* @param {Vector3} b - The second vector.
|
|
321
|
+
* @return {Vector3} A reference to this vector.
|
|
322
|
+
*/
|
|
166
323
|
subVectors( a, b ) {
|
|
167
324
|
|
|
168
325
|
this.x = a.x - b.x;
|
|
@@ -173,6 +330,12 @@ class Vector3 {
|
|
|
173
330
|
|
|
174
331
|
}
|
|
175
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Multiplies the given vector with this instance.
|
|
335
|
+
*
|
|
336
|
+
* @param {Vector3} v - The vector to multiply.
|
|
337
|
+
* @return {Vector3} A reference to this vector.
|
|
338
|
+
*/
|
|
176
339
|
multiply( v ) {
|
|
177
340
|
|
|
178
341
|
this.x *= v.x;
|
|
@@ -183,6 +346,12 @@ class Vector3 {
|
|
|
183
346
|
|
|
184
347
|
}
|
|
185
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Multiplies the given scalar value with all components of this instance.
|
|
351
|
+
*
|
|
352
|
+
* @param {number} scalar - The scalar to multiply.
|
|
353
|
+
* @return {Vector3} A reference to this vector.
|
|
354
|
+
*/
|
|
186
355
|
multiplyScalar( scalar ) {
|
|
187
356
|
|
|
188
357
|
this.x *= scalar;
|
|
@@ -193,6 +362,13 @@ class Vector3 {
|
|
|
193
362
|
|
|
194
363
|
}
|
|
195
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Multiplies the given vectors and stores the result in this instance.
|
|
367
|
+
*
|
|
368
|
+
* @param {Vector3} a - The first vector.
|
|
369
|
+
* @param {Vector3} b - The second vector.
|
|
370
|
+
* @return {Vector3} A reference to this vector.
|
|
371
|
+
*/
|
|
196
372
|
multiplyVectors( a, b ) {
|
|
197
373
|
|
|
198
374
|
this.x = a.x * b.x;
|
|
@@ -203,18 +379,37 @@ class Vector3 {
|
|
|
203
379
|
|
|
204
380
|
}
|
|
205
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Applies the given Euler rotation to this vector.
|
|
384
|
+
*
|
|
385
|
+
* @param {Euler} euler - The Euler angles.
|
|
386
|
+
* @return {Vector3} A reference to this vector.
|
|
387
|
+
*/
|
|
206
388
|
applyEuler( euler ) {
|
|
207
389
|
|
|
208
390
|
return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
|
|
209
391
|
|
|
210
392
|
}
|
|
211
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Applies a rotation specified by an axis and an angle to this vector.
|
|
396
|
+
*
|
|
397
|
+
* @param {Vector3} axis - A normalized vector representing the rotation axis.
|
|
398
|
+
* @param {number} angle - The angle in radians.
|
|
399
|
+
* @return {Vector3} A reference to this vector.
|
|
400
|
+
*/
|
|
212
401
|
applyAxisAngle( axis, angle ) {
|
|
213
402
|
|
|
214
403
|
return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
|
|
215
404
|
|
|
216
405
|
}
|
|
217
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Multiplies this vector with the given 3x3 matrix.
|
|
409
|
+
*
|
|
410
|
+
* @param {Matrix3} m - The 3x3 matrix.
|
|
411
|
+
* @return {Vector3} A reference to this vector.
|
|
412
|
+
*/
|
|
218
413
|
applyMatrix3( m ) {
|
|
219
414
|
|
|
220
415
|
const x = this.x, y = this.y, z = this.z;
|
|
@@ -228,12 +423,26 @@ class Vector3 {
|
|
|
228
423
|
|
|
229
424
|
}
|
|
230
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Multiplies this vector by the given normal matrix and normalizes
|
|
428
|
+
* the result.
|
|
429
|
+
*
|
|
430
|
+
* @param {Matrix3} m - The normal matrix.
|
|
431
|
+
* @return {Vector3} A reference to this vector.
|
|
432
|
+
*/
|
|
231
433
|
applyNormalMatrix( m ) {
|
|
232
434
|
|
|
233
435
|
return this.applyMatrix3( m ).normalize();
|
|
234
436
|
|
|
235
437
|
}
|
|
236
438
|
|
|
439
|
+
/**
|
|
440
|
+
* Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
|
|
441
|
+
* divides by perspective.
|
|
442
|
+
*
|
|
443
|
+
* @param {Matrix4} m - The matrix to apply.
|
|
444
|
+
* @return {Vector3} A reference to this vector.
|
|
445
|
+
*/
|
|
237
446
|
applyMatrix4( m ) {
|
|
238
447
|
|
|
239
448
|
const x = this.x, y = this.y, z = this.z;
|
|
@@ -249,6 +458,12 @@ class Vector3 {
|
|
|
249
458
|
|
|
250
459
|
}
|
|
251
460
|
|
|
461
|
+
/**
|
|
462
|
+
* Applies the given Quaternion to this vector.
|
|
463
|
+
*
|
|
464
|
+
* @param {Quaternion} q - The Quaternion.
|
|
465
|
+
* @return {Vector3} A reference to this vector.
|
|
466
|
+
*/
|
|
252
467
|
applyQuaternion( q ) {
|
|
253
468
|
|
|
254
469
|
// quaternion q is assumed to have unit length
|
|
@@ -270,18 +485,39 @@ class Vector3 {
|
|
|
270
485
|
|
|
271
486
|
}
|
|
272
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Projects this vector from world space into the camera's normalized
|
|
490
|
+
* device coordinate (NDC) space.
|
|
491
|
+
*
|
|
492
|
+
* @param {Camera} camera - The camera.
|
|
493
|
+
* @return {Vector3} A reference to this vector.
|
|
494
|
+
*/
|
|
273
495
|
project( camera ) {
|
|
274
496
|
|
|
275
497
|
return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
|
|
276
498
|
|
|
277
499
|
}
|
|
278
500
|
|
|
501
|
+
/**
|
|
502
|
+
* Unprojects this vector from the camera's normalized device coordinate (NDC)
|
|
503
|
+
* space into world space.
|
|
504
|
+
*
|
|
505
|
+
* @param {Camera} camera - The camera.
|
|
506
|
+
* @return {Vector3} A reference to this vector.
|
|
507
|
+
*/
|
|
279
508
|
unproject( camera ) {
|
|
280
509
|
|
|
281
510
|
return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
|
|
282
511
|
|
|
283
512
|
}
|
|
284
513
|
|
|
514
|
+
/**
|
|
515
|
+
* Transforms the direction of this vector by a matrix (the upper left 3 x 3
|
|
516
|
+
* subset of the given 4x4 matrix and then normalizes the result.
|
|
517
|
+
*
|
|
518
|
+
* @param {Matrix4} m - The matrix.
|
|
519
|
+
* @return {Vector3} A reference to this vector.
|
|
520
|
+
*/
|
|
285
521
|
transformDirection( m ) {
|
|
286
522
|
|
|
287
523
|
// input: THREE.Matrix4 affine matrix
|
|
@@ -298,6 +534,12 @@ class Vector3 {
|
|
|
298
534
|
|
|
299
535
|
}
|
|
300
536
|
|
|
537
|
+
/**
|
|
538
|
+
* Divides this instance by the given vector.
|
|
539
|
+
*
|
|
540
|
+
* @param {Vector3} v - The vector to divide.
|
|
541
|
+
* @return {Vector3} A reference to this vector.
|
|
542
|
+
*/
|
|
301
543
|
divide( v ) {
|
|
302
544
|
|
|
303
545
|
this.x /= v.x;
|
|
@@ -308,12 +550,25 @@ class Vector3 {
|
|
|
308
550
|
|
|
309
551
|
}
|
|
310
552
|
|
|
553
|
+
/**
|
|
554
|
+
* Divides this vector by the given scalar.
|
|
555
|
+
*
|
|
556
|
+
* @param {number} scalar - The scalar to divide.
|
|
557
|
+
* @return {Vector3} A reference to this vector.
|
|
558
|
+
*/
|
|
311
559
|
divideScalar( scalar ) {
|
|
312
560
|
|
|
313
561
|
return this.multiplyScalar( 1 / scalar );
|
|
314
562
|
|
|
315
563
|
}
|
|
316
564
|
|
|
565
|
+
/**
|
|
566
|
+
* If this vector's x, y or z value is greater than the given vector's x, y or z
|
|
567
|
+
* value, replace that value with the corresponding min value.
|
|
568
|
+
*
|
|
569
|
+
* @param {Vector3} v - The vector.
|
|
570
|
+
* @return {Vector3} A reference to this vector.
|
|
571
|
+
*/
|
|
317
572
|
min( v ) {
|
|
318
573
|
|
|
319
574
|
this.x = Math.min( this.x, v.x );
|
|
@@ -324,6 +579,13 @@ class Vector3 {
|
|
|
324
579
|
|
|
325
580
|
}
|
|
326
581
|
|
|
582
|
+
/**
|
|
583
|
+
* If this vector's x, y or z value is less than the given vector's x, y or z
|
|
584
|
+
* value, replace that value with the corresponding max value.
|
|
585
|
+
*
|
|
586
|
+
* @param {Vector3} v - The vector.
|
|
587
|
+
* @return {Vector3} A reference to this vector.
|
|
588
|
+
*/
|
|
327
589
|
max( v ) {
|
|
328
590
|
|
|
329
591
|
this.x = Math.max( this.x, v.x );
|
|
@@ -334,36 +596,71 @@ class Vector3 {
|
|
|
334
596
|
|
|
335
597
|
}
|
|
336
598
|
|
|
599
|
+
/**
|
|
600
|
+
* If this vector's x, y or z value is greater than the max vector's x, y or z
|
|
601
|
+
* value, it is replaced by the corresponding value.
|
|
602
|
+
* If this vector's x, y or z value is less than the min vector's x, y or z value,
|
|
603
|
+
* it is replaced by the corresponding value.
|
|
604
|
+
*
|
|
605
|
+
* @param {Vector3} min - The minimum x, y and z values.
|
|
606
|
+
* @param {Vector3} max - The maximum x, y and z values in the desired range.
|
|
607
|
+
* @return {Vector3} A reference to this vector.
|
|
608
|
+
*/
|
|
337
609
|
clamp( min, max ) {
|
|
338
610
|
|
|
339
611
|
// assumes min < max, componentwise
|
|
340
612
|
|
|
341
|
-
this.x =
|
|
342
|
-
this.y =
|
|
343
|
-
this.z =
|
|
613
|
+
this.x = clamp( this.x, min.x, max.x );
|
|
614
|
+
this.y = clamp( this.y, min.y, max.y );
|
|
615
|
+
this.z = clamp( this.z, min.z, max.z );
|
|
344
616
|
|
|
345
617
|
return this;
|
|
346
618
|
|
|
347
619
|
}
|
|
348
620
|
|
|
621
|
+
/**
|
|
622
|
+
* If this vector's x, y or z values are greater than the max value, they are
|
|
623
|
+
* replaced by the max value.
|
|
624
|
+
* If this vector's x, y or z values are less than the min value, they are
|
|
625
|
+
* replaced by the min value.
|
|
626
|
+
*
|
|
627
|
+
* @param {number} minVal - The minimum value the components will be clamped to.
|
|
628
|
+
* @param {number} maxVal - The maximum value the components will be clamped to.
|
|
629
|
+
* @return {Vector3} A reference to this vector.
|
|
630
|
+
*/
|
|
349
631
|
clampScalar( minVal, maxVal ) {
|
|
350
632
|
|
|
351
|
-
this.x =
|
|
352
|
-
this.y =
|
|
353
|
-
this.z =
|
|
633
|
+
this.x = clamp( this.x, minVal, maxVal );
|
|
634
|
+
this.y = clamp( this.y, minVal, maxVal );
|
|
635
|
+
this.z = clamp( this.z, minVal, maxVal );
|
|
354
636
|
|
|
355
637
|
return this;
|
|
356
638
|
|
|
357
639
|
}
|
|
358
640
|
|
|
641
|
+
/**
|
|
642
|
+
* If this vector's length is greater than the max value, it is replaced by
|
|
643
|
+
* the max value.
|
|
644
|
+
* If this vector's length is less than the min value, it is replaced by the
|
|
645
|
+
* min value.
|
|
646
|
+
*
|
|
647
|
+
* @param {number} min - The minimum value the vector length will be clamped to.
|
|
648
|
+
* @param {number} max - The maximum value the vector length will be clamped to.
|
|
649
|
+
* @return {Vector3} A reference to this vector.
|
|
650
|
+
*/
|
|
359
651
|
clampLength( min, max ) {
|
|
360
652
|
|
|
361
653
|
const length = this.length();
|
|
362
654
|
|
|
363
|
-
return this.divideScalar( length || 1 ).multiplyScalar(
|
|
655
|
+
return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
|
|
364
656
|
|
|
365
657
|
}
|
|
366
658
|
|
|
659
|
+
/**
|
|
660
|
+
* The components of this vector are rounded down to the nearest integer value.
|
|
661
|
+
*
|
|
662
|
+
* @return {Vector3} A reference to this vector.
|
|
663
|
+
*/
|
|
367
664
|
floor() {
|
|
368
665
|
|
|
369
666
|
this.x = Math.floor( this.x );
|
|
@@ -374,6 +671,11 @@ class Vector3 {
|
|
|
374
671
|
|
|
375
672
|
}
|
|
376
673
|
|
|
674
|
+
/**
|
|
675
|
+
* The components of this vector are rounded up to the nearest integer value.
|
|
676
|
+
*
|
|
677
|
+
* @return {Vector3} A reference to this vector.
|
|
678
|
+
*/
|
|
377
679
|
ceil() {
|
|
378
680
|
|
|
379
681
|
this.x = Math.ceil( this.x );
|
|
@@ -384,6 +686,11 @@ class Vector3 {
|
|
|
384
686
|
|
|
385
687
|
}
|
|
386
688
|
|
|
689
|
+
/**
|
|
690
|
+
* The components of this vector are rounded to the nearest integer value
|
|
691
|
+
*
|
|
692
|
+
* @return {Vector3} A reference to this vector.
|
|
693
|
+
*/
|
|
387
694
|
round() {
|
|
388
695
|
|
|
389
696
|
this.x = Math.round( this.x );
|
|
@@ -394,6 +701,12 @@ class Vector3 {
|
|
|
394
701
|
|
|
395
702
|
}
|
|
396
703
|
|
|
704
|
+
/**
|
|
705
|
+
* The components of this vector are rounded towards zero (up if negative,
|
|
706
|
+
* down if positive) to an integer value.
|
|
707
|
+
*
|
|
708
|
+
* @return {Vector3} A reference to this vector.
|
|
709
|
+
*/
|
|
397
710
|
roundToZero() {
|
|
398
711
|
|
|
399
712
|
this.x = Math.trunc( this.x );
|
|
@@ -404,6 +717,11 @@ class Vector3 {
|
|
|
404
717
|
|
|
405
718
|
}
|
|
406
719
|
|
|
720
|
+
/**
|
|
721
|
+
* Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
|
|
722
|
+
*
|
|
723
|
+
* @return {Vector3} A reference to this vector.
|
|
724
|
+
*/
|
|
407
725
|
negate() {
|
|
408
726
|
|
|
409
727
|
this.x = - this.x;
|
|
@@ -414,44 +732,87 @@ class Vector3 {
|
|
|
414
732
|
|
|
415
733
|
}
|
|
416
734
|
|
|
735
|
+
/**
|
|
736
|
+
* Calculates the dot product of the given vector with this instance.
|
|
737
|
+
*
|
|
738
|
+
* @param {Vector3} v - The vector to compute the dot product with.
|
|
739
|
+
* @return {number} The result of the dot product.
|
|
740
|
+
*/
|
|
417
741
|
dot( v ) {
|
|
418
742
|
|
|
419
743
|
return this.x * v.x + this.y * v.y + this.z * v.z;
|
|
420
744
|
|
|
421
745
|
}
|
|
422
746
|
|
|
423
|
-
|
|
424
|
-
|
|
747
|
+
/**
|
|
748
|
+
* Computes the square of the Euclidean length (straight-line length) from
|
|
749
|
+
* (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
|
|
750
|
+
* compare the length squared instead as it is slightly more efficient to calculate.
|
|
751
|
+
*
|
|
752
|
+
* @return {number} The square length of this vector.
|
|
753
|
+
*/
|
|
425
754
|
lengthSq() {
|
|
426
755
|
|
|
427
756
|
return this.x * this.x + this.y * this.y + this.z * this.z;
|
|
428
757
|
|
|
429
758
|
}
|
|
430
759
|
|
|
760
|
+
/**
|
|
761
|
+
* Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
|
|
762
|
+
*
|
|
763
|
+
* @return {number} The length of this vector.
|
|
764
|
+
*/
|
|
431
765
|
length() {
|
|
432
766
|
|
|
433
767
|
return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
|
|
434
768
|
|
|
435
769
|
}
|
|
436
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Computes the Manhattan length of this vector.
|
|
773
|
+
*
|
|
774
|
+
* @return {number} The length of this vector.
|
|
775
|
+
*/
|
|
437
776
|
manhattanLength() {
|
|
438
777
|
|
|
439
778
|
return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
|
|
440
779
|
|
|
441
780
|
}
|
|
442
781
|
|
|
782
|
+
/**
|
|
783
|
+
* Converts this vector to a unit vector - that is, sets it equal to a vector
|
|
784
|
+
* with the same direction as this one, but with a vector length of `1`.
|
|
785
|
+
*
|
|
786
|
+
* @return {Vector3} A reference to this vector.
|
|
787
|
+
*/
|
|
443
788
|
normalize() {
|
|
444
789
|
|
|
445
790
|
return this.divideScalar( this.length() || 1 );
|
|
446
791
|
|
|
447
792
|
}
|
|
448
793
|
|
|
794
|
+
/**
|
|
795
|
+
* Sets this vector to a vector with the same direction as this one, but
|
|
796
|
+
* with the specified length.
|
|
797
|
+
*
|
|
798
|
+
* @param {number} length - The new length of this vector.
|
|
799
|
+
* @return {Vector3} A reference to this vector.
|
|
800
|
+
*/
|
|
449
801
|
setLength( length ) {
|
|
450
802
|
|
|
451
803
|
return this.normalize().multiplyScalar( length );
|
|
452
804
|
|
|
453
805
|
}
|
|
454
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Linearly interpolates between the given vector and this instance, where
|
|
809
|
+
* alpha is the percent distance along the line - alpha = 0 will be this
|
|
810
|
+
* vector, and alpha = 1 will be the given one.
|
|
811
|
+
*
|
|
812
|
+
* @param {Vector3} v - The vector to interpolate towards.
|
|
813
|
+
* @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
|
|
814
|
+
* @return {Vector3} A reference to this vector.
|
|
815
|
+
*/
|
|
455
816
|
lerp( v, alpha ) {
|
|
456
817
|
|
|
457
818
|
this.x += ( v.x - this.x ) * alpha;
|
|
@@ -462,6 +823,16 @@ class Vector3 {
|
|
|
462
823
|
|
|
463
824
|
}
|
|
464
825
|
|
|
826
|
+
/**
|
|
827
|
+
* Linearly interpolates between the given vectors, where alpha is the percent
|
|
828
|
+
* distance along the line - alpha = 0 will be first vector, and alpha = 1 will
|
|
829
|
+
* be the second one. The result is stored in this instance.
|
|
830
|
+
*
|
|
831
|
+
* @param {Vector3} v1 - The first vector.
|
|
832
|
+
* @param {Vector3} v2 - The second vector.
|
|
833
|
+
* @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
|
|
834
|
+
* @return {Vector3} A reference to this vector.
|
|
835
|
+
*/
|
|
465
836
|
lerpVectors( v1, v2, alpha ) {
|
|
466
837
|
|
|
467
838
|
this.x = v1.x + ( v2.x - v1.x ) * alpha;
|
|
@@ -472,12 +843,26 @@ class Vector3 {
|
|
|
472
843
|
|
|
473
844
|
}
|
|
474
845
|
|
|
846
|
+
/**
|
|
847
|
+
* Calculates the cross product of the given vector with this instance.
|
|
848
|
+
*
|
|
849
|
+
* @param {Vector3} v - The vector to compute the cross product with.
|
|
850
|
+
* @return {Vector3} The result of the cross product.
|
|
851
|
+
*/
|
|
475
852
|
cross( v ) {
|
|
476
853
|
|
|
477
854
|
return this.crossVectors( this, v );
|
|
478
855
|
|
|
479
856
|
}
|
|
480
857
|
|
|
858
|
+
/**
|
|
859
|
+
* Calculates the cross product of the given vectors and stores the result
|
|
860
|
+
* in this instance.
|
|
861
|
+
*
|
|
862
|
+
* @param {Vector3} a - The first vector.
|
|
863
|
+
* @param {Vector3} b - The second vector.
|
|
864
|
+
* @return {Vector3} A reference to this vector.
|
|
865
|
+
*/
|
|
481
866
|
crossVectors( a, b ) {
|
|
482
867
|
|
|
483
868
|
const ax = a.x, ay = a.y, az = a.z;
|
|
@@ -491,6 +876,12 @@ class Vector3 {
|
|
|
491
876
|
|
|
492
877
|
}
|
|
493
878
|
|
|
879
|
+
/**
|
|
880
|
+
* Projects this vector onto the given one.
|
|
881
|
+
*
|
|
882
|
+
* @param {Vector3} v - The vector to project to.
|
|
883
|
+
* @return {Vector3} A reference to this vector.
|
|
884
|
+
*/
|
|
494
885
|
projectOnVector( v ) {
|
|
495
886
|
|
|
496
887
|
const denominator = v.lengthSq();
|
|
@@ -503,6 +894,13 @@ class Vector3 {
|
|
|
503
894
|
|
|
504
895
|
}
|
|
505
896
|
|
|
897
|
+
/**
|
|
898
|
+
* Projects this vector onto a plane by subtracting this
|
|
899
|
+
* vector projected onto the plane's normal from this vector.
|
|
900
|
+
*
|
|
901
|
+
* @param {Vector3} planeNormal - The plane normal.
|
|
902
|
+
* @return {Vector3} A reference to this vector.
|
|
903
|
+
*/
|
|
506
904
|
projectOnPlane( planeNormal ) {
|
|
507
905
|
|
|
508
906
|
_vector.copy( this ).projectOnVector( planeNormal );
|
|
@@ -511,15 +909,23 @@ class Vector3 {
|
|
|
511
909
|
|
|
512
910
|
}
|
|
513
911
|
|
|
912
|
+
/**
|
|
913
|
+
* Reflects this vector off a plane orthogonal to the given normal vector.
|
|
914
|
+
*
|
|
915
|
+
* @param {Vector3} normal - The (normalized) normal vector.
|
|
916
|
+
* @return {Vector3} A reference to this vector.
|
|
917
|
+
*/
|
|
514
918
|
reflect( normal ) {
|
|
515
919
|
|
|
516
|
-
// reflect incident vector off plane orthogonal to normal
|
|
517
|
-
// normal is assumed to have unit length
|
|
518
|
-
|
|
519
920
|
return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
|
|
520
921
|
|
|
521
922
|
}
|
|
522
|
-
|
|
923
|
+
/**
|
|
924
|
+
* Returns the angle between the given vector and this instance in radians.
|
|
925
|
+
*
|
|
926
|
+
* @param {Vector3} v - The vector to compute the angle with.
|
|
927
|
+
* @return {number} The angle in radians.
|
|
928
|
+
*/
|
|
523
929
|
angleTo( v ) {
|
|
524
930
|
|
|
525
931
|
const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
|
|
@@ -530,16 +936,30 @@ class Vector3 {
|
|
|
530
936
|
|
|
531
937
|
// clamp, to handle numerical problems
|
|
532
938
|
|
|
533
|
-
return Math.acos(
|
|
939
|
+
return Math.acos( clamp( theta, - 1, 1 ) );
|
|
534
940
|
|
|
535
941
|
}
|
|
536
942
|
|
|
943
|
+
/**
|
|
944
|
+
* Computes the distance from the given vector to this instance.
|
|
945
|
+
*
|
|
946
|
+
* @param {Vector3} v - The vector to compute the distance to.
|
|
947
|
+
* @return {number} The distance.
|
|
948
|
+
*/
|
|
537
949
|
distanceTo( v ) {
|
|
538
950
|
|
|
539
951
|
return Math.sqrt( this.distanceToSquared( v ) );
|
|
540
952
|
|
|
541
953
|
}
|
|
542
954
|
|
|
955
|
+
/**
|
|
956
|
+
* Computes the squared distance from the given vector to this instance.
|
|
957
|
+
* If you are just comparing the distance with another distance, you should compare
|
|
958
|
+
* the distance squared instead as it is slightly more efficient to calculate.
|
|
959
|
+
*
|
|
960
|
+
* @param {Vector3} v - The vector to compute the squared distance to.
|
|
961
|
+
* @return {number} The squared distance.
|
|
962
|
+
*/
|
|
543
963
|
distanceToSquared( v ) {
|
|
544
964
|
|
|
545
965
|
const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
|
|
@@ -548,18 +968,38 @@ class Vector3 {
|
|
|
548
968
|
|
|
549
969
|
}
|
|
550
970
|
|
|
971
|
+
/**
|
|
972
|
+
* Computes the Manhattan distance from the given vector to this instance.
|
|
973
|
+
*
|
|
974
|
+
* @param {Vector3} v - The vector to compute the Manhattan distance to.
|
|
975
|
+
* @return {number} The Manhattan distance.
|
|
976
|
+
*/
|
|
551
977
|
manhattanDistanceTo( v ) {
|
|
552
978
|
|
|
553
979
|
return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
|
|
554
980
|
|
|
555
981
|
}
|
|
556
982
|
|
|
983
|
+
/**
|
|
984
|
+
* Sets the vector components from the given spherical coordinates.
|
|
985
|
+
*
|
|
986
|
+
* @param {Spherical} s - The spherical coordinates.
|
|
987
|
+
* @return {Vector3} A reference to this vector.
|
|
988
|
+
*/
|
|
557
989
|
setFromSpherical( s ) {
|
|
558
990
|
|
|
559
991
|
return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
|
|
560
992
|
|
|
561
993
|
}
|
|
562
994
|
|
|
995
|
+
/**
|
|
996
|
+
* Sets the vector components from the given spherical coordinates.
|
|
997
|
+
*
|
|
998
|
+
* @param {number} radius - The radius.
|
|
999
|
+
* @param {number} phi - The phi angle in radians.
|
|
1000
|
+
* @param {number} theta - The theta angle in radians.
|
|
1001
|
+
* @return {Vector3} A reference to this vector.
|
|
1002
|
+
*/
|
|
563
1003
|
setFromSphericalCoords( radius, phi, theta ) {
|
|
564
1004
|
|
|
565
1005
|
const sinPhiRadius = Math.sin( phi ) * radius;
|
|
@@ -572,12 +1012,26 @@ class Vector3 {
|
|
|
572
1012
|
|
|
573
1013
|
}
|
|
574
1014
|
|
|
1015
|
+
/**
|
|
1016
|
+
* Sets the vector components from the given cylindrical coordinates.
|
|
1017
|
+
*
|
|
1018
|
+
* @param {Cylindrical} c - The cylindrical coordinates.
|
|
1019
|
+
* @return {Vector3} A reference to this vector.
|
|
1020
|
+
*/
|
|
575
1021
|
setFromCylindrical( c ) {
|
|
576
1022
|
|
|
577
1023
|
return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
|
|
578
1024
|
|
|
579
1025
|
}
|
|
580
1026
|
|
|
1027
|
+
/**
|
|
1028
|
+
* Sets the vector components from the given cylindrical coordinates.
|
|
1029
|
+
*
|
|
1030
|
+
* @param {number} radius - The radius.
|
|
1031
|
+
* @param {number} theta - The theta angle in radians.
|
|
1032
|
+
* @param {number} y - The y value.
|
|
1033
|
+
* @return {Vector3} A reference to this vector.
|
|
1034
|
+
*/
|
|
581
1035
|
setFromCylindricalCoords( radius, theta, y ) {
|
|
582
1036
|
|
|
583
1037
|
this.x = radius * Math.sin( theta );
|
|
@@ -588,6 +1042,13 @@ class Vector3 {
|
|
|
588
1042
|
|
|
589
1043
|
}
|
|
590
1044
|
|
|
1045
|
+
/**
|
|
1046
|
+
* Sets the vector components to the position elements of the
|
|
1047
|
+
* given transformation matrix.
|
|
1048
|
+
*
|
|
1049
|
+
* @param {Matrix4} m - The 4x4 matrix.
|
|
1050
|
+
* @return {Vector3} A reference to this vector.
|
|
1051
|
+
*/
|
|
591
1052
|
setFromMatrixPosition( m ) {
|
|
592
1053
|
|
|
593
1054
|
const e = m.elements;
|
|
@@ -600,6 +1061,13 @@ class Vector3 {
|
|
|
600
1061
|
|
|
601
1062
|
}
|
|
602
1063
|
|
|
1064
|
+
/**
|
|
1065
|
+
* Sets the vector components to the scale elements of the
|
|
1066
|
+
* given transformation matrix.
|
|
1067
|
+
*
|
|
1068
|
+
* @param {Matrix4} m - The 4x4 matrix.
|
|
1069
|
+
* @return {Vector3} A reference to this vector.
|
|
1070
|
+
*/
|
|
603
1071
|
setFromMatrixScale( m ) {
|
|
604
1072
|
|
|
605
1073
|
const sx = this.setFromMatrixColumn( m, 0 ).length();
|
|
@@ -614,18 +1082,38 @@ class Vector3 {
|
|
|
614
1082
|
|
|
615
1083
|
}
|
|
616
1084
|
|
|
1085
|
+
/**
|
|
1086
|
+
* Sets the vector components from the specified matrix column.
|
|
1087
|
+
*
|
|
1088
|
+
* @param {Matrix4} m - The 4x4 matrix.
|
|
1089
|
+
* @param {number} index - The column index.
|
|
1090
|
+
* @return {Vector3} A reference to this vector.
|
|
1091
|
+
*/
|
|
617
1092
|
setFromMatrixColumn( m, index ) {
|
|
618
1093
|
|
|
619
1094
|
return this.fromArray( m.elements, index * 4 );
|
|
620
1095
|
|
|
621
1096
|
}
|
|
622
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* Sets the vector components from the specified matrix column.
|
|
1100
|
+
*
|
|
1101
|
+
* @param {Matrix3} m - The 3x3 matrix.
|
|
1102
|
+
* @param {number} index - The column index.
|
|
1103
|
+
* @return {Vector3} A reference to this vector.
|
|
1104
|
+
*/
|
|
623
1105
|
setFromMatrix3Column( m, index ) {
|
|
624
1106
|
|
|
625
1107
|
return this.fromArray( m.elements, index * 3 );
|
|
626
1108
|
|
|
627
1109
|
}
|
|
628
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* Sets the vector components from the given Euler angles.
|
|
1113
|
+
*
|
|
1114
|
+
* @param {Euler} e - The Euler angles to set.
|
|
1115
|
+
* @return {Vector3} A reference to this vector.
|
|
1116
|
+
*/
|
|
629
1117
|
setFromEuler( e ) {
|
|
630
1118
|
|
|
631
1119
|
this.x = e._x;
|
|
@@ -636,6 +1124,13 @@ class Vector3 {
|
|
|
636
1124
|
|
|
637
1125
|
}
|
|
638
1126
|
|
|
1127
|
+
/**
|
|
1128
|
+
* Sets the vector components from the RGB components of the
|
|
1129
|
+
* given color.
|
|
1130
|
+
*
|
|
1131
|
+
* @param {Color} c - The color to set.
|
|
1132
|
+
* @return {Vector3} A reference to this vector.
|
|
1133
|
+
*/
|
|
639
1134
|
setFromColor( c ) {
|
|
640
1135
|
|
|
641
1136
|
this.x = c.r;
|
|
@@ -646,12 +1141,26 @@ class Vector3 {
|
|
|
646
1141
|
|
|
647
1142
|
}
|
|
648
1143
|
|
|
1144
|
+
/**
|
|
1145
|
+
* Returns `true` if this vector is equal with the given one.
|
|
1146
|
+
*
|
|
1147
|
+
* @param {Vector3} v - The vector to test for equality.
|
|
1148
|
+
* @return {boolean} Whether this vector is equal with the given one.
|
|
1149
|
+
*/
|
|
649
1150
|
equals( v ) {
|
|
650
1151
|
|
|
651
1152
|
return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
|
|
652
1153
|
|
|
653
1154
|
}
|
|
654
1155
|
|
|
1156
|
+
/**
|
|
1157
|
+
* Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`
|
|
1158
|
+
* and z value to be `array[ offset + 2 ]`.
|
|
1159
|
+
*
|
|
1160
|
+
* @param {Array<number>} array - An array holding the vector component values.
|
|
1161
|
+
* @param {number} [offset=0] - The offset into the array.
|
|
1162
|
+
* @return {Vector3} A reference to this vector.
|
|
1163
|
+
*/
|
|
655
1164
|
fromArray( array, offset = 0 ) {
|
|
656
1165
|
|
|
657
1166
|
this.x = array[ offset ];
|
|
@@ -662,6 +1171,14 @@ class Vector3 {
|
|
|
662
1171
|
|
|
663
1172
|
}
|
|
664
1173
|
|
|
1174
|
+
/**
|
|
1175
|
+
* Writes the components of this vector to the given array. If no array is provided,
|
|
1176
|
+
* the method returns a new instance.
|
|
1177
|
+
*
|
|
1178
|
+
* @param {Array<number>} [array=[]] - The target array holding the vector components.
|
|
1179
|
+
* @param {number} [offset=0] - Index of the first element in the array.
|
|
1180
|
+
* @return {Array<number>} The vector components.
|
|
1181
|
+
*/
|
|
665
1182
|
toArray( array = [], offset = 0 ) {
|
|
666
1183
|
|
|
667
1184
|
array[ offset ] = this.x;
|
|
@@ -672,6 +1189,13 @@ class Vector3 {
|
|
|
672
1189
|
|
|
673
1190
|
}
|
|
674
1191
|
|
|
1192
|
+
/**
|
|
1193
|
+
* Sets the components of this vector from the given buffer attribute.
|
|
1194
|
+
*
|
|
1195
|
+
* @param {BufferAttribute} attribute - The buffer attribute holding vector data.
|
|
1196
|
+
* @param {number} index - The index into the attribute.
|
|
1197
|
+
* @return {Vector3} A reference to this vector.
|
|
1198
|
+
*/
|
|
675
1199
|
fromBufferAttribute( attribute, index ) {
|
|
676
1200
|
|
|
677
1201
|
this.x = attribute.getX( index );
|
|
@@ -682,6 +1206,12 @@ class Vector3 {
|
|
|
682
1206
|
|
|
683
1207
|
}
|
|
684
1208
|
|
|
1209
|
+
/**
|
|
1210
|
+
* Sets each component of this vector to a pseudo-random value between `0` and
|
|
1211
|
+
* `1`, excluding `1`.
|
|
1212
|
+
*
|
|
1213
|
+
* @return {Vector3} A reference to this vector.
|
|
1214
|
+
*/
|
|
685
1215
|
random() {
|
|
686
1216
|
|
|
687
1217
|
this.x = Math.random();
|
|
@@ -692,6 +1222,11 @@ class Vector3 {
|
|
|
692
1222
|
|
|
693
1223
|
}
|
|
694
1224
|
|
|
1225
|
+
/**
|
|
1226
|
+
* Sets this vector to a uniformly random point on a unit sphere.
|
|
1227
|
+
*
|
|
1228
|
+
* @return {Vector3} A reference to this vector.
|
|
1229
|
+
*/
|
|
695
1230
|
randomDirection() {
|
|
696
1231
|
|
|
697
1232
|
// https://mathworld.wolfram.com/SpherePointPicking.html
|