@plastic-software/three 0.174.0 → 0.175.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +10655 -1446
- package/build/three.core.js +9626 -1094
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +834 -157
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +4 -2
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2658 -1697
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2654 -1709
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/animation/AnimationClipCreator.js +57 -6
- package/examples/jsm/animation/CCDIKSolver.js +93 -39
- package/examples/jsm/capabilities/WebGL.js +28 -3
- package/examples/jsm/capabilities/WebGPU.js +16 -6
- package/examples/jsm/controls/ArcballControls.js +424 -154
- package/examples/jsm/controls/DragControls.js +93 -2
- package/examples/jsm/controls/FirstPersonControls.js +113 -4
- package/examples/jsm/controls/FlyControls.js +49 -2
- package/examples/jsm/controls/MapControls.js +42 -9
- package/examples/jsm/controls/OrbitControls.js +345 -42
- package/examples/jsm/controls/PointerLockControls.js +111 -9
- package/examples/jsm/controls/TrackballControls.js +159 -8
- package/examples/jsm/controls/TransformControls.js +252 -6
- package/examples/jsm/csm/CSM.js +226 -15
- package/examples/jsm/csm/CSMFrustum.js +52 -0
- package/examples/jsm/csm/CSMHelper.js +47 -0
- package/examples/jsm/csm/CSMShader.js +10 -1
- package/examples/jsm/csm/CSMShadowNode.js +156 -13
- package/examples/jsm/curves/CurveExtras.js +289 -31
- package/examples/jsm/curves/NURBSCurve.js +57 -14
- package/examples/jsm/curves/NURBSSurface.js +50 -6
- package/examples/jsm/curves/NURBSUtils.js +96 -112
- package/examples/jsm/curves/NURBSVolume.js +22 -4
- package/examples/jsm/effects/AnaglyphEffect.js +30 -0
- package/examples/jsm/effects/AsciiEffect.js +60 -15
- package/examples/jsm/effects/OutlineEffect.js +59 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +28 -0
- package/examples/jsm/effects/PeppersGhostEffect.js +21 -2
- package/examples/jsm/effects/StereoEffect.js +29 -0
- package/examples/jsm/environments/DebugEnvironment.js +49 -0
- package/examples/jsm/environments/RoomEnvironment.js +23 -4
- package/examples/jsm/exporters/DRACOExporter.js +53 -13
- package/examples/jsm/exporters/EXRExporter.js +37 -8
- package/examples/jsm/exporters/GLTFExporter.js +171 -48
- package/examples/jsm/exporters/KTX2Exporter.js +20 -0
- package/examples/jsm/exporters/OBJExporter.js +18 -0
- package/examples/jsm/exporters/PLYExporter.js +39 -9
- package/examples/jsm/exporters/STLExporter.js +25 -5
- package/examples/jsm/exporters/USDZExporter.js +70 -3
- package/examples/jsm/geometries/BoxLineGeometry.js +22 -0
- package/examples/jsm/geometries/ConvexGeometry.js +18 -0
- package/examples/jsm/geometries/DecalGeometry.js +20 -9
- package/examples/jsm/geometries/ParametricFunctions.js +97 -0
- package/examples/jsm/geometries/ParametricGeometry.js +37 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +21 -0
- package/examples/jsm/geometries/TeapotGeometry.js +22 -38
- package/examples/jsm/geometries/TextGeometry.js +44 -16
- package/examples/jsm/helpers/LightProbeHelper.js +35 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +36 -0
- package/examples/jsm/helpers/OctreeHelper.js +35 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +35 -3
- package/examples/jsm/helpers/TextureHelper.js +27 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +28 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +58 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +46 -2
- package/examples/jsm/helpers/ViewHelper.js +75 -1
- package/examples/jsm/interactive/HTMLMesh.js +25 -0
- package/examples/jsm/interactive/InteractiveGroup.js +65 -5
- package/examples/jsm/interactive/SelectionBox.js +74 -9
- package/examples/jsm/interactive/SelectionHelper.js +71 -29
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +23 -0
- package/examples/jsm/lights/LightProbeGenerator.js +26 -1
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +48 -13
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +15 -0
- package/examples/jsm/lines/Line2.js +36 -0
- package/examples/jsm/lines/LineGeometry.js +52 -0
- package/examples/jsm/lines/LineMaterial.js +95 -0
- package/examples/jsm/lines/LineSegments2.js +51 -2
- package/examples/jsm/lines/LineSegmentsGeometry.js +62 -8
- package/examples/jsm/lines/Wireframe.js +38 -2
- package/examples/jsm/lines/WireframeGeometry2.js +24 -0
- package/examples/jsm/lines/webgpu/Line2.js +25 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +44 -6
- package/examples/jsm/lines/webgpu/Wireframe.js +30 -2
- package/examples/jsm/loaders/3DMLoader.js +71 -2
- package/examples/jsm/loaders/3MFLoader.js +41 -3
- package/examples/jsm/loaders/AMFLoader.js +31 -12
- package/examples/jsm/loaders/BVHLoader.js +57 -11
- package/examples/jsm/loaders/ColladaLoader.js +35 -0
- package/examples/jsm/loaders/DDSLoader.js +24 -0
- package/examples/jsm/loaders/DRACOLoader.js +73 -1
- package/examples/jsm/loaders/EXRLoader.js +40 -8
- package/examples/jsm/loaders/FBXLoader.js +42 -14
- package/examples/jsm/loaders/FontLoader.js +60 -2
- package/examples/jsm/loaders/GCodeLoader.js +33 -5
- package/examples/jsm/loaders/GLTFLoader.js +218 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +48 -0
- package/examples/jsm/loaders/IESLoader.js +41 -0
- package/examples/jsm/loaders/KMZLoader.js +32 -0
- package/examples/jsm/loaders/KTX2Loader.js +86 -18
- package/examples/jsm/loaders/KTXLoader.js +26 -6
- package/examples/jsm/loaders/LDrawLoader.js +115 -5
- package/examples/jsm/loaders/LUT3dlLoader.js +46 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +45 -9
- package/examples/jsm/loaders/LUTImageLoader.js +78 -38
- package/examples/jsm/loaders/LWOLoader.js +46 -7
- package/examples/jsm/loaders/LottieLoader.js +37 -0
- package/examples/jsm/loaders/MD2Loader.js +36 -1
- package/examples/jsm/loaders/MDDLoader.js +56 -12
- package/examples/jsm/loaders/MTLLoader.js +38 -33
- package/examples/jsm/loaders/MaterialXLoader.js +33 -0
- package/examples/jsm/loaders/NRRDLoader.js +36 -5
- package/examples/jsm/loaders/OBJLoader.js +48 -1
- package/examples/jsm/loaders/PCDLoader.js +47 -0
- package/examples/jsm/loaders/PDBLoader.js +40 -2
- package/examples/jsm/loaders/PLYLoader.js +62 -32
- package/examples/jsm/loaders/PVRLoader.js +23 -5
- package/examples/jsm/loaders/RGBELoader.js +38 -5
- package/examples/jsm/loaders/RGBMLoader.js +67 -1
- package/examples/jsm/loaders/STLLoader.js +47 -38
- package/examples/jsm/loaders/SVGLoader.js +113 -20
- package/examples/jsm/loaders/TDSLoader.js +81 -61
- package/examples/jsm/loaders/TGALoader.js +22 -0
- package/examples/jsm/loaders/TIFFLoader.js +22 -0
- package/examples/jsm/loaders/TTFLoader.js +36 -2
- package/examples/jsm/loaders/USDZLoader.js +34 -1
- package/examples/jsm/loaders/UltraHDRLoader.js +58 -12
- package/examples/jsm/loaders/VOXLoader.js +57 -0
- package/examples/jsm/loaders/VRMLLoader.js +32 -1
- package/examples/jsm/loaders/VTKLoader.js +38 -0
- package/examples/jsm/loaders/XYZLoader.js +35 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +39 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +39 -0
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +24 -2
- package/examples/jsm/math/Capsule.js +89 -14
- package/examples/jsm/math/ColorConverter.js +21 -0
- package/examples/jsm/math/ColorSpaces.js +53 -0
- package/examples/jsm/math/ConvexHull.js +514 -92
- package/examples/jsm/math/ImprovedNoise.js +14 -2
- package/examples/jsm/math/Lut.js +111 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +76 -13
- package/examples/jsm/math/OBB.js +139 -46
- package/examples/jsm/math/Octree.js +132 -5
- package/examples/jsm/math/SimplexNoise.js +66 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +43 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +92 -17
- package/examples/jsm/misc/Gyroscope.js +11 -0
- package/examples/jsm/misc/MD2Character.js +115 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +170 -8
- package/examples/jsm/misc/MorphAnimMesh.js +43 -0
- package/examples/jsm/misc/MorphBlendMesh.js +102 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +40 -15
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +33 -13
- package/examples/jsm/misc/RollerCoaster.js +52 -0
- package/examples/jsm/misc/Timer.js +79 -2
- package/examples/jsm/misc/TubePainter.js +53 -0
- package/examples/jsm/misc/Volume.js +108 -72
- package/examples/jsm/misc/VolumeSlice.js +88 -45
- package/examples/jsm/modifiers/CurveModifier.js +57 -34
- package/examples/jsm/modifiers/CurveModifierGPU.js +36 -17
- package/examples/jsm/modifiers/EdgeSplitModifier.js +18 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +20 -8
- package/examples/jsm/modifiers/TessellateModifier.js +33 -2
- package/examples/jsm/objects/GroundedSkybox.js +23 -5
- package/examples/jsm/objects/Lensflare.js +91 -2
- package/examples/jsm/objects/LensflareMesh.js +53 -2
- package/examples/jsm/objects/MarchingCubes.js +88 -5
- package/examples/jsm/objects/Reflector.js +70 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +39 -0
- package/examples/jsm/objects/Refractor.js +61 -0
- package/examples/jsm/objects/ShadowMesh.js +53 -4
- package/examples/jsm/objects/Sky.js +26 -9
- package/examples/jsm/objects/SkyMesh.js +60 -9
- package/examples/jsm/objects/Water.js +44 -5
- package/examples/jsm/objects/Water2.js +42 -3
- package/examples/jsm/objects/Water2Mesh.js +38 -3
- package/examples/jsm/objects/WaterMesh.js +94 -7
- package/examples/jsm/physics/AmmoPhysics.js +47 -0
- package/examples/jsm/physics/JoltPhysics.js +48 -0
- package/examples/jsm/physics/RapierPhysics.js +56 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +90 -38
- package/examples/jsm/postprocessing/BloomPass.js +125 -24
- package/examples/jsm/postprocessing/BokehPass.js +98 -22
- package/examples/jsm/postprocessing/ClearPass.js +53 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +81 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +58 -10
- package/examples/jsm/postprocessing/EffectComposer.js +131 -0
- package/examples/jsm/postprocessing/FilmPass.js +53 -5
- package/examples/jsm/postprocessing/GTAOPass.js +191 -48
- package/examples/jsm/postprocessing/GlitchPass.js +84 -33
- package/examples/jsm/postprocessing/HalftonePass.js +64 -10
- package/examples/jsm/postprocessing/LUTPass.js +37 -8
- package/examples/jsm/postprocessing/MaskPass.js +90 -0
- package/examples/jsm/postprocessing/OutlinePass.js +266 -133
- package/examples/jsm/postprocessing/OutputPass.js +53 -14
- package/examples/jsm/postprocessing/Pass.js +98 -4
- package/examples/jsm/postprocessing/RenderPass.js +83 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +123 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +119 -21
- package/examples/jsm/postprocessing/SAOPass.js +126 -53
- package/examples/jsm/postprocessing/SMAAPass.js +103 -71
- package/examples/jsm/postprocessing/SSAARenderPass.js +117 -35
- package/examples/jsm/postprocessing/SSAOPass.js +160 -47
- package/examples/jsm/postprocessing/SSRPass.js +230 -49
- package/examples/jsm/postprocessing/SavePass.js +68 -16
- package/examples/jsm/postprocessing/ShaderPass.js +64 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +78 -24
- package/examples/jsm/postprocessing/TexturePass.js +71 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +113 -37
- package/examples/jsm/renderers/CSS2DRenderer.js +77 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +99 -3
- package/examples/jsm/renderers/Projector.js +18 -2
- package/examples/jsm/renderers/SVGRenderer.js +124 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +9 -5
- package/examples/jsm/shaders/AfterimageShader.js +6 -4
- package/examples/jsm/shaders/BasicShader.js +6 -2
- package/examples/jsm/shaders/BleachBypassShader.js +8 -4
- package/examples/jsm/shaders/BlendShader.js +6 -2
- package/examples/jsm/shaders/BokehShader.js +7 -4
- package/examples/jsm/shaders/BokehShader2.js +7 -3
- package/examples/jsm/shaders/BrightnessContrastShader.js +8 -5
- package/examples/jsm/shaders/ColorCorrectionShader.js +6 -2
- package/examples/jsm/shaders/ColorifyShader.js +6 -2
- package/examples/jsm/shaders/ConvolutionShader.js +7 -39
- package/examples/jsm/shaders/CopyShader.js +6 -2
- package/examples/jsm/shaders/DOFMipMapShader.js +8 -4
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +7 -1
- package/examples/jsm/shaders/DigitalGlitch.js +7 -7
- package/examples/jsm/shaders/DotScreenShader.js +6 -4
- package/examples/jsm/shaders/ExposureShader.js +6 -2
- package/examples/jsm/shaders/FXAAShader.js +15 -7
- package/examples/jsm/shaders/FilmShader.js +10 -0
- package/examples/jsm/shaders/FocusShader.js +6 -4
- package/examples/jsm/shaders/FreiChenShader.js +7 -3
- package/examples/jsm/shaders/GTAOShader.js +33 -39
- package/examples/jsm/shaders/GammaCorrectionShader.js +8 -2
- package/examples/jsm/shaders/GodRaysShader.js +14 -5
- package/examples/jsm/shaders/HalftoneShader.js +11 -5
- package/examples/jsm/shaders/HorizontalBlurShader.js +9 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +6 -2
- package/examples/jsm/shaders/HueSaturationShader.js +7 -3
- package/examples/jsm/shaders/KaleidoShader.js +8 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +6 -5
- package/examples/jsm/shaders/LuminosityShader.js +6 -3
- package/examples/jsm/shaders/MirrorShader.js +7 -4
- package/examples/jsm/shaders/NormalMapShader.js +5 -3
- package/examples/jsm/shaders/OutputShader.js +11 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +21 -15
- package/examples/jsm/shaders/RGBShiftShader.js +5 -1
- package/examples/jsm/shaders/SAOShader.js +8 -2
- package/examples/jsm/shaders/SMAAShader.js +23 -1
- package/examples/jsm/shaders/SSAOShader.js +23 -5
- package/examples/jsm/shaders/SSRShader.js +25 -1
- package/examples/jsm/shaders/SepiaShader.js +6 -4
- package/examples/jsm/shaders/SobelOperatorShader.js +5 -2
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +10 -8
- package/examples/jsm/shaders/TechnicolorShader.js +7 -4
- package/examples/jsm/shaders/ToonShader.js +29 -7
- package/examples/jsm/shaders/TriangleBlurShader.js +6 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +6 -3
- package/examples/jsm/shaders/VelocityShader.js +6 -2
- package/examples/jsm/shaders/VerticalBlurShader.js +6 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +5 -1
- package/examples/jsm/shaders/VignetteShader.js +6 -4
- package/examples/jsm/shaders/VolumeShader.js +7 -1
- package/examples/jsm/shaders/WaterRefractionShader.js +8 -0
- package/examples/jsm/textures/FlakesTexture.js +12 -0
- package/examples/jsm/transpiler/Transpiler.js +31 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +1 -1
- package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +29 -3
- package/examples/jsm/tsl/math/Bayer.js +14 -1
- package/examples/jsm/tsl/utils/Raymarching.js +4 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +88 -29
- package/examples/jsm/utils/CameraUtils.js +10 -7
- package/examples/jsm/utils/GeometryCompressionUtils.js +20 -30
- package/examples/jsm/utils/GeometryUtils.js +12 -13
- package/examples/jsm/utils/LDrawUtils.js +11 -4
- package/examples/jsm/utils/SceneOptimizer.js +66 -20
- package/examples/jsm/utils/SceneUtils.js +50 -3
- package/examples/jsm/utils/ShadowMapViewer.js +47 -24
- package/examples/jsm/utils/ShadowMapViewerGPU.js +47 -24
- package/examples/jsm/utils/SkeletonUtils.js +45 -0
- package/examples/jsm/utils/SortUtils.js +14 -5
- package/examples/jsm/utils/UVsDebug.js +9 -4
- package/examples/jsm/utils/WebGLTextureUtils.js +13 -0
- package/examples/jsm/utils/WebGPUTextureUtils.js +14 -0
- package/examples/jsm/utils/WorkerPool.js +65 -2
- package/examples/jsm/webxr/ARButton.js +18 -0
- package/examples/jsm/webxr/OculusHandModel.js +83 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +125 -0
- package/examples/jsm/webxr/Text2D.js +11 -0
- package/examples/jsm/webxr/VRButton.js +30 -0
- package/examples/jsm/webxr/XRButton.js +22 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +87 -3
- package/examples/jsm/webxr/XREstimatedLight.js +33 -3
- package/examples/jsm/webxr/XRHandMeshModel.js +35 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +92 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +42 -0
- package/examples/jsm/webxr/XRPlanes.js +17 -0
- package/package.json +1 -1
- package/src/Three.TSL.js +3 -1
- package/src/animation/AnimationAction.js +262 -30
- package/src/animation/AnimationClip.js +141 -2
- package/src/animation/AnimationMixer.js +99 -15
- package/src/animation/AnimationObjectGroup.js +41 -18
- package/src/animation/AnimationUtils.js +168 -18
- package/src/animation/KeyframeTrack.js +144 -10
- package/src/animation/PropertyBinding.js +77 -3
- 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/AudioAnalyser.js +1 -1
- package/src/audio/AudioListener.js +2 -2
- package/src/audio/PositionalAudio.js +5 -5
- package/src/constants.js +1429 -5
- package/src/core/BufferAttribute.js +413 -3
- package/src/core/BufferGeometry.js +337 -1
- package/src/core/Clock.js +60 -0
- package/src/core/GLBufferAttribute.js +99 -0
- 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 +137 -3
- package/src/core/InterleavedBufferAttribute.js +197 -0
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +23 -0
- package/src/core/Raycaster.js +134 -1
- package/src/core/RenderTarget.js +166 -7
- package/src/core/RenderTarget3D.js +25 -0
- package/src/core/RenderTargetArray.js +18 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +16 -1
- package/src/extras/Earcut.js +3 -781
- package/src/extras/ImageUtils.js +3 -2
- package/src/extras/PMREMGenerator.js +22 -17
- package/src/extras/core/Curve.js +1 -1
- package/src/extras/core/Path.js +1 -1
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/ConeGeometry.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/ExtrudeGeometry.js +71 -39
- package/src/geometries/LatheGeometry.js +1 -1
- package/src/lights/LightShadow.js +1 -1
- package/src/lights/webgpu/IESSpotLight.js +1 -1
- package/src/loaders/AnimationLoader.js +31 -0
- package/src/loaders/AudioLoader.js +31 -0
- package/src/loaders/BufferGeometryLoader.js +34 -0
- package/src/loaders/Cache.js +45 -0
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +44 -3
- package/src/loaders/FileLoader.js +57 -1
- package/src/loaders/ImageBitmapLoader.js +57 -0
- package/src/loaders/ImageLoader.js +30 -0
- package/src/loaders/Loader.js +4 -6
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +142 -0
- package/src/loaders/MaterialLoader.js +57 -0
- package/src/loaders/ObjectLoader.js +53 -0
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +6 -2
- package/src/loaders/nodes/NodeMaterialLoader.js +1 -1
- package/src/loaders/nodes/NodeObjectLoader.js +3 -3
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -0
- package/src/materials/Material.js +18 -3
- package/src/materials/MeshBasicMaterial.js +165 -0
- package/src/materials/MeshDepthMaterial.js +93 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +273 -0
- package/src/materials/MeshMatcapMaterial.js +142 -0
- package/src/materials/MeshNormalMaterial.js +113 -0
- package/src/materials/MeshPhongMaterial.js +288 -0
- package/src/materials/MeshPhysicalMaterial.js +292 -1
- package/src/materials/MeshStandardMaterial.js +297 -0
- package/src/materials/MeshToonMaterial.js +218 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +215 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +1 -1
- package/src/materials/nodes/LineBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshStandardNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshToonNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +7 -3
- package/src/materials/nodes/PointsNodeMaterial.js +1 -1
- package/src/materials/nodes/ShadowNodeMaterial.js +11 -2
- package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
- package/src/materials/nodes/VolumeNodeMaterial.js +10 -1
- package/src/math/Color.js +1 -1
- package/src/math/MathUtils.js +223 -0
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/accessors/BatchNode.js +8 -8
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/CubeTextureNode.js +1 -1
- package/src/nodes/accessors/InstanceNode.js +5 -5
- package/src/nodes/accessors/InstancedMeshNode.js +1 -1
- package/src/nodes/accessors/MorphNode.js +27 -23
- package/src/nodes/accessors/Normal.js +1 -1
- package/src/nodes/accessors/Object3DNode.js +12 -12
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +1 -1
- package/src/nodes/accessors/SkinningNode.js +46 -37
- package/src/nodes/accessors/StorageBufferNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +25 -5
- package/src/nodes/accessors/TextureSizeNode.js +1 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/CodeNode.js +4 -4
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +23 -3
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/code/ScriptableValueNode.js +2 -2
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/CacheNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/Node.js +14 -2
- package/src/nodes/core/NodeBuilder.js +86 -14
- package/src/nodes/core/StackNode.js +5 -5
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/VarNode.js +2 -8
- package/src/nodes/core/VaryingNode.js +3 -3
- package/src/nodes/display/BlendModes.js +4 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +1 -1
- package/src/nodes/display/PosterizeNode.js +1 -1
- package/src/nodes/display/ScreenNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +2 -2
- package/src/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/src/nodes/display/ViewportSharedTextureNode.js +2 -2
- package/src/nodes/display/ViewportTextureNode.js +4 -4
- package/src/nodes/functions/ShadowMaskModel.js +4 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +6 -6
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +16 -40
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +30 -2
- package/src/nodes/lighting/AnalyticLightNode.js +9 -1
- package/src/nodes/lighting/LightsNode.js +3 -3
- package/src/nodes/lighting/ShadowNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +20 -3
- package/src/nodes/math/MathNode.js +83 -78
- package/src/nodes/math/OperatorNode.js +171 -82
- package/src/nodes/pmrem/PMREMNode.js +4 -4
- package/src/nodes/pmrem/PMREMUtils.js +2 -2
- package/src/nodes/tsl/TSLBase.js +2 -1
- package/src/nodes/tsl/TSLCore.js +115 -12
- package/src/nodes/utils/ArrayElementNode.js +3 -1
- package/src/nodes/utils/CubeMapNode.js +3 -3
- package/src/nodes/utils/DebugNode.js +70 -0
- package/src/nodes/utils/EquirectUVNode.js +2 -2
- package/src/nodes/utils/JoinNode.js +27 -2
- package/src/nodes/utils/LoopNode.js +58 -28
- package/src/nodes/utils/MaxMipLevelNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -2
- package/src/nodes/utils/RemapNode.js +6 -6
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUVNode.js +3 -3
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/src/objects/BatchedMesh.js +4 -4
- package/src/objects/InstancedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Skeleton.js +1 -1
- package/src/renderers/WebGL3DRenderTarget.js +25 -0
- package/src/renderers/WebGLArrayRenderTarget.js +25 -0
- package/src/renderers/WebGLCubeRenderTarget.js +39 -1
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +617 -79
- package/src/renderers/common/Animation.js +2 -2
- package/src/renderers/common/Attributes.js +2 -2
- package/src/renderers/common/Backend.js +12 -3
- package/src/renderers/common/Background.js +1 -0
- package/src/renderers/common/Color4.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/PostProcessing.js +2 -0
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderList.js +2 -2
- package/src/renderers/common/RenderObject.js +1 -1
- package/src/renderers/common/RenderObjects.js +2 -2
- package/src/renderers/common/Renderer.js +52 -31
- package/src/renderers/common/XRManager.js +333 -10
- package/src/renderers/common/extras/PMREMGenerator.js +6 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/shaders/UniformsLib.js +1 -4
- package/src/renderers/shaders/UniformsUtils.js +1 -3
- package/src/renderers/webgl/WebGLBackground.js +4 -2
- package/src/renderers/webgl/WebGLState.js +9 -9
- package/src/renderers/webgl-fallback/WebGLBackend.js +25 -26
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -12
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +67 -19
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +128 -87
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -11
- package/src/renderers/webgpu/WebGPURenderer.js +17 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +4 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +49 -0
- package/src/renderers/webxr/WebXRManager.js +173 -1
- package/src/scenes/Scene.js +2 -1
- 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/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +77 -0
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -9
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +69 -0
- package/src/textures/Texture.js +5 -5
- package/src/textures/VideoFrameTexture.js +43 -6
- package/src/textures/VideoTexture.js +49 -4
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
|
@@ -14,14 +14,58 @@ class HttpError extends Error {
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* A low level class for loading resources with the Fetch API, used internally by
|
|
19
|
+
* most loaders. It can also be used directly to load any file type that does
|
|
20
|
+
* not have a loader.
|
|
21
|
+
*
|
|
22
|
+
* This loader supports caching. If you want to use it, add `THREE.Cache.enabled = true;`
|
|
23
|
+
* once to your application.
|
|
24
|
+
*
|
|
25
|
+
* ```js
|
|
26
|
+
* const loader = new THREE.FileLoader();
|
|
27
|
+
* const data = await loader.loadAsync( 'example.txt' );
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @augments Loader
|
|
31
|
+
*/
|
|
17
32
|
class FileLoader extends Loader {
|
|
18
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Constructs a new file loader.
|
|
36
|
+
*
|
|
37
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
38
|
+
*/
|
|
19
39
|
constructor( manager ) {
|
|
20
40
|
|
|
21
41
|
super( manager );
|
|
22
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The expected mime type.
|
|
45
|
+
*
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
this.mimeType = '';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The expected response type.
|
|
52
|
+
*
|
|
53
|
+
* @type {('arraybuffer'|'blob'|'document'|'json'|'')}
|
|
54
|
+
* @default ''
|
|
55
|
+
*/
|
|
56
|
+
this.responseType = '';
|
|
57
|
+
|
|
23
58
|
}
|
|
24
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Starts loading from the given URL and pass the loaded response to the `onLoad()` callback.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
64
|
+
* @param {function(any)} onLoad - Executed when the loading process has been finished.
|
|
65
|
+
* @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
|
|
66
|
+
* @param {onErrorCallback} [onError] - Executed when errors occur.
|
|
67
|
+
* @return {any|undefined} The cached resource if available.
|
|
68
|
+
*/
|
|
25
69
|
load( url, onLoad, onProgress, onError ) {
|
|
26
70
|
|
|
27
71
|
if ( url === undefined ) url = '';
|
|
@@ -197,7 +241,7 @@ class FileLoader extends Loader {
|
|
|
197
241
|
|
|
198
242
|
default:
|
|
199
243
|
|
|
200
|
-
if ( mimeType ===
|
|
244
|
+
if ( mimeType === '' ) {
|
|
201
245
|
|
|
202
246
|
return response.text();
|
|
203
247
|
|
|
@@ -268,6 +312,12 @@ class FileLoader extends Loader {
|
|
|
268
312
|
|
|
269
313
|
}
|
|
270
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Sets the expected response type.
|
|
317
|
+
*
|
|
318
|
+
* @param {('arraybuffer'|'blob'|'document'|'json'|'')} value - The response type.
|
|
319
|
+
* @return {FileLoader} A reference to this file loader.
|
|
320
|
+
*/
|
|
271
321
|
setResponseType( value ) {
|
|
272
322
|
|
|
273
323
|
this.responseType = value;
|
|
@@ -275,6 +325,12 @@ class FileLoader extends Loader {
|
|
|
275
325
|
|
|
276
326
|
}
|
|
277
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Sets the expected mime type of the loaded file.
|
|
330
|
+
*
|
|
331
|
+
* @param {string} value - The mime type.
|
|
332
|
+
* @return {FileLoader} A reference to this file loader.
|
|
333
|
+
*/
|
|
278
334
|
setMimeType( value ) {
|
|
279
335
|
|
|
280
336
|
this.mimeType = value;
|
|
@@ -1,12 +1,47 @@
|
|
|
1
1
|
import { Cache } from './Cache.js';
|
|
2
2
|
import { Loader } from './Loader.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A loader for loading images as an [ImageBitmap]{@link https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap}.
|
|
6
|
+
* An `ImageBitmap` provides an asynchronous and resource efficient pathway to prepare
|
|
7
|
+
* textures for rendering.
|
|
8
|
+
*
|
|
9
|
+
* Note that {@link Texture#flipY} and {@link Texture#premultiplyAlpha} are ignored with image bitmaps.
|
|
10
|
+
* They needs these configuration on bitmap creation unlike regular images need them on uploading to GPU.
|
|
11
|
+
*
|
|
12
|
+
* You need to set the equivalent options via {@link ImageBitmapLoader#setOptions} instead.
|
|
13
|
+
*
|
|
14
|
+
* Also note that unlike {@link FileLoader}, this loader does not avoid multiple concurrent requests to the same URL.
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* const loader = new THREE.ImageBitmapLoader();
|
|
18
|
+
* loader.setOptions( { imageOrientation: 'flipY' } ); // set options if needed
|
|
19
|
+
* const imageBitmap = await loader.loadAsync( 'image.png' );
|
|
20
|
+
*
|
|
21
|
+
* const texture = new THREE.Texture( imageBitmap );
|
|
22
|
+
* texture.needsUpdate = true;
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @augments Loader
|
|
26
|
+
*/
|
|
4
27
|
class ImageBitmapLoader extends Loader {
|
|
5
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Constructs a new image bitmap loader.
|
|
31
|
+
*
|
|
32
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
33
|
+
*/
|
|
6
34
|
constructor( manager ) {
|
|
7
35
|
|
|
8
36
|
super( manager );
|
|
9
37
|
|
|
38
|
+
/**
|
|
39
|
+
* This flag can be used for type testing.
|
|
40
|
+
*
|
|
41
|
+
* @type {boolean}
|
|
42
|
+
* @readonly
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
10
45
|
this.isImageBitmapLoader = true;
|
|
11
46
|
|
|
12
47
|
if ( typeof createImageBitmap === 'undefined' ) {
|
|
@@ -21,10 +56,23 @@ class ImageBitmapLoader extends Loader {
|
|
|
21
56
|
|
|
22
57
|
}
|
|
23
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Represents the loader options.
|
|
61
|
+
*
|
|
62
|
+
* @type {Object}
|
|
63
|
+
* @default {premultiplyAlpha:'none'}
|
|
64
|
+
*/
|
|
24
65
|
this.options = { premultiplyAlpha: 'none' };
|
|
25
66
|
|
|
26
67
|
}
|
|
27
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Sets the given loader options. The structure of the object must match the `options` parameter of
|
|
71
|
+
* [createImageBitmap]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap}.
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} options - The loader options to set.
|
|
74
|
+
* @return {ImageBitmapLoader} A reference to this image bitmap loader.
|
|
75
|
+
*/
|
|
28
76
|
setOptions( options ) {
|
|
29
77
|
|
|
30
78
|
this.options = options;
|
|
@@ -33,6 +81,15 @@ class ImageBitmapLoader extends Loader {
|
|
|
33
81
|
|
|
34
82
|
}
|
|
35
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Starts loading from the given URL and pass the loaded image bitmap to the `onLoad()` callback.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
88
|
+
* @param {function(ImageBitmap)} onLoad - Executed when the loading process has been finished.
|
|
89
|
+
* @param {onProgressCallback} onProgress - Unsupported in this loader.
|
|
90
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
91
|
+
* @return {ImageBitmap|undefined} The image bitmap.
|
|
92
|
+
*/
|
|
36
93
|
load( url, onLoad, onProgress, onError ) {
|
|
37
94
|
|
|
38
95
|
if ( url === undefined ) url = '';
|
|
@@ -2,14 +2,44 @@ import { Cache } from './Cache.js';
|
|
|
2
2
|
import { Loader } from './Loader.js';
|
|
3
3
|
import { createElementNS } from '../utils.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A loader for loading images. The class loads images with the HTML `Image` API.
|
|
7
|
+
*
|
|
8
|
+
* ```js
|
|
9
|
+
* const loader = new THREE.ImageLoader();
|
|
10
|
+
* const image = await loader.loadAsync( 'image.png' );
|
|
11
|
+
* ```
|
|
12
|
+
* Please note that `ImageLoader` has dropped support for progress
|
|
13
|
+
* events in `r84`. For an `ImageLoader` that supports progress events, see
|
|
14
|
+
* [this thread]{@link https://github.com/mrdoob/three.js/issues/10439#issuecomment-275785639}.
|
|
15
|
+
*
|
|
16
|
+
* @augments Loader
|
|
17
|
+
*/
|
|
5
18
|
class ImageLoader extends Loader {
|
|
6
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new image loader.
|
|
22
|
+
*
|
|
23
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
24
|
+
*/
|
|
7
25
|
constructor( manager ) {
|
|
8
26
|
|
|
9
27
|
super( manager );
|
|
10
28
|
|
|
11
29
|
}
|
|
12
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Starts loading from the given URL and passes the loaded image
|
|
33
|
+
* to the `onLoad()` callback. The method also returns a new `Image` object which can
|
|
34
|
+
* directly be used for texture creation. If you do it this way, the texture
|
|
35
|
+
* may pop up in your scene once the respective loading process is finished.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
38
|
+
* @param {function(Image)} onLoad - Executed when the loading process has been finished.
|
|
39
|
+
* @param {onProgressCallback} onProgress - Unsupported in this loader.
|
|
40
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
41
|
+
* @return {Image} The image.
|
|
42
|
+
*/
|
|
13
43
|
load( url, onLoad, onProgress, onError ) {
|
|
14
44
|
|
|
15
45
|
if ( this.path !== undefined ) url = this.path + url;
|
package/src/loaders/Loader.js
CHANGED
|
@@ -57,7 +57,7 @@ class Loader {
|
|
|
57
57
|
* The [request header]{@link https://developer.mozilla.org/en-US/docs/Glossary/Request_header}
|
|
58
58
|
* used in HTTP request.
|
|
59
59
|
*
|
|
60
|
-
* @type {Object}
|
|
60
|
+
* @type {Object<string, any>}
|
|
61
61
|
*/
|
|
62
62
|
this.requestHeader = {};
|
|
63
63
|
|
|
@@ -69,8 +69,8 @@ class Loader {
|
|
|
69
69
|
*
|
|
70
70
|
* @param {string} url - The path/URL of the file to be loaded.
|
|
71
71
|
* @param {Function} onLoad - Executed when the loading process has been finished.
|
|
72
|
-
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
73
|
-
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
72
|
+
* @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
|
|
73
|
+
* @param {onErrorCallback} [onError] - Executed when errors occur.
|
|
74
74
|
*/
|
|
75
75
|
load( /* url, onLoad, onProgress, onError */ ) {}
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ class Loader {
|
|
|
78
78
|
* A async version of {@link Loader#load}.
|
|
79
79
|
*
|
|
80
80
|
* @param {string} url - The path/URL of the file to be loaded.
|
|
81
|
-
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
81
|
+
* @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
|
|
82
82
|
* @return {Promise} A Promise that resolves when the asset has been loaded.
|
|
83
83
|
*/
|
|
84
84
|
loadAsync( url, onProgress ) {
|
|
@@ -176,7 +176,6 @@ class Loader {
|
|
|
176
176
|
/**
|
|
177
177
|
* Callback for onProgress in loaders.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
180
179
|
* @callback onProgressCallback
|
|
181
180
|
* @param {ProgressEvent} event - An instance of `ProgressEvent` that represents the current loading status.
|
|
182
181
|
*/
|
|
@@ -184,7 +183,6 @@ class Loader {
|
|
|
184
183
|
/**
|
|
185
184
|
* Callback for onError in loaders.
|
|
186
185
|
*
|
|
187
|
-
*
|
|
188
186
|
* @callback onErrorCallback
|
|
189
187
|
* @param {Error} error - The error which occurred during the loading process.
|
|
190
188
|
*/
|
|
@@ -1,41 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class with loader utility functions.
|
|
3
|
+
*/
|
|
1
4
|
class LoaderUtils {
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return new TextDecoder().decode( array );
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Avoid the String.fromCharCode.apply(null, array) shortcut, which
|
|
14
|
-
// throws a "maximum call stack size exceeded" error for large arrays.
|
|
15
|
-
|
|
16
|
-
let s = '';
|
|
17
|
-
|
|
18
|
-
for ( let i = 0, il = array.length; i < il; i ++ ) {
|
|
19
|
-
|
|
20
|
-
// Implicitly assumes little-endian.
|
|
21
|
-
s += String.fromCharCode( array[ i ] );
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
|
|
27
|
-
// merges multi-byte utf-8 characters.
|
|
28
|
-
|
|
29
|
-
return decodeURIComponent( escape( s ) );
|
|
30
|
-
|
|
31
|
-
} catch ( e ) { // see #16358
|
|
32
|
-
|
|
33
|
-
return s;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Extracts the base URL from the given URL.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} url -The URL to extract the base URL from.
|
|
10
|
+
* @return {string} The extracted base URL.
|
|
11
|
+
*/
|
|
39
12
|
static extractUrlBase( url ) {
|
|
40
13
|
|
|
41
14
|
const index = url.lastIndexOf( '/' );
|
|
@@ -46,6 +19,15 @@ class LoaderUtils {
|
|
|
46
19
|
|
|
47
20
|
}
|
|
48
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Resolves relative URLs against the given path. Absolute paths, data urls,
|
|
24
|
+
* and blob URLs will be returned as is. Invalid URLs will return an empty
|
|
25
|
+
* string.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} url -The URL to resolve.
|
|
28
|
+
* @param {string} path - The base path for relative URLs to be resolved against.
|
|
29
|
+
* @return {string} The resolved URL.
|
|
30
|
+
*/
|
|
49
31
|
static resolveURL( url, path ) {
|
|
50
32
|
|
|
51
33
|
// Invalid URL
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles and keeps track of loaded and pending data. A default global
|
|
3
|
+
* instance of this class is created and used by loaders if not supplied
|
|
4
|
+
* manually.
|
|
5
|
+
*
|
|
6
|
+
* In general that should be sufficient, however there are times when it can
|
|
7
|
+
* be useful to have separate loaders - for example if you want to show
|
|
8
|
+
* separate loading bars for objects and textures.
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* const manager = new THREE.LoadingManager();
|
|
12
|
+
* manager.onLoad = () => console.log( 'Loading complete!' );
|
|
13
|
+
*
|
|
14
|
+
* const loader1 = new OBJLoader( manager );
|
|
15
|
+
* const loader2 = new ColladaLoader( manager );
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
class LoadingManager {
|
|
2
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new loading manager.
|
|
22
|
+
*
|
|
23
|
+
* @param {Function} [onLoad] - Executes when all items have been loaded.
|
|
24
|
+
* @param {Function} [onProgress] - Executes when single items have been loaded.
|
|
25
|
+
* @param {Function} [onError] - Executes when an error occurs.
|
|
26
|
+
*/
|
|
3
27
|
constructor( onLoad, onProgress, onError ) {
|
|
4
28
|
|
|
5
29
|
const scope = this;
|
|
@@ -13,11 +37,44 @@ class LoadingManager {
|
|
|
13
37
|
// Refer to #5689 for the reason why we don't set .onStart
|
|
14
38
|
// in the constructor
|
|
15
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Executes when an item starts loading.
|
|
42
|
+
*
|
|
43
|
+
* @type {Function|undefined}
|
|
44
|
+
* @default undefined
|
|
45
|
+
*/
|
|
16
46
|
this.onStart = undefined;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Executes when all items have been loaded.
|
|
50
|
+
*
|
|
51
|
+
* @type {Function|undefined}
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
17
54
|
this.onLoad = onLoad;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Executes when single items have been loaded.
|
|
58
|
+
*
|
|
59
|
+
* @type {Function|undefined}
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
18
62
|
this.onProgress = onProgress;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Executes when an error occurs.
|
|
66
|
+
*
|
|
67
|
+
* @type {Function|undefined}
|
|
68
|
+
* @default undefined
|
|
69
|
+
*/
|
|
19
70
|
this.onError = onError;
|
|
20
71
|
|
|
72
|
+
/**
|
|
73
|
+
* This should be called by any loader using the manager when the loader
|
|
74
|
+
* starts loading an item.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} url - The URL to load.
|
|
77
|
+
*/
|
|
21
78
|
this.itemStart = function ( url ) {
|
|
22
79
|
|
|
23
80
|
itemsTotal ++;
|
|
@@ -36,6 +93,12 @@ class LoadingManager {
|
|
|
36
93
|
|
|
37
94
|
};
|
|
38
95
|
|
|
96
|
+
/**
|
|
97
|
+
* This should be called by any loader using the manager when the loader
|
|
98
|
+
* ended loading an item.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} url - The URL of the loaded item.
|
|
101
|
+
*/
|
|
39
102
|
this.itemEnd = function ( url ) {
|
|
40
103
|
|
|
41
104
|
itemsLoaded ++;
|
|
@@ -60,6 +123,12 @@ class LoadingManager {
|
|
|
60
123
|
|
|
61
124
|
};
|
|
62
125
|
|
|
126
|
+
/**
|
|
127
|
+
* This should be called by any loader using the manager when the loader
|
|
128
|
+
* encounters an error when loading an item.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} url - The URL of the item that produces an error.
|
|
131
|
+
*/
|
|
63
132
|
this.itemError = function ( url ) {
|
|
64
133
|
|
|
65
134
|
if ( scope.onError !== undefined ) {
|
|
@@ -70,6 +139,13 @@ class LoadingManager {
|
|
|
70
139
|
|
|
71
140
|
};
|
|
72
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Given a URL, uses the URL modifier callback (if any) and returns a
|
|
144
|
+
* resolved URL. If no URL modifier is set, returns the original URL.
|
|
145
|
+
*
|
|
146
|
+
* @param {string} url - The URL to load.
|
|
147
|
+
* @return {string} The resolved URL.
|
|
148
|
+
*/
|
|
73
149
|
this.resolveURL = function ( url ) {
|
|
74
150
|
|
|
75
151
|
if ( urlModifier ) {
|
|
@@ -82,6 +158,40 @@ class LoadingManager {
|
|
|
82
158
|
|
|
83
159
|
};
|
|
84
160
|
|
|
161
|
+
/**
|
|
162
|
+
* If provided, the callback will be passed each resource URL before a
|
|
163
|
+
* request is sent. The callback may return the original URL, or a new URL to
|
|
164
|
+
* override loading behavior. This behavior can be used to load assets from
|
|
165
|
+
* .ZIP files, drag-and-drop APIs, and Data URIs.
|
|
166
|
+
*
|
|
167
|
+
* ```js
|
|
168
|
+
* const blobs = {'fish.gltf': blob1, 'diffuse.png': blob2, 'normal.png': blob3};
|
|
169
|
+
*
|
|
170
|
+
* const manager = new THREE.LoadingManager();
|
|
171
|
+
*
|
|
172
|
+
* // Initialize loading manager with URL callback.
|
|
173
|
+
* const objectURLs = [];
|
|
174
|
+
* manager.setURLModifier( ( url ) => {
|
|
175
|
+
*
|
|
176
|
+
* url = URL.createObjectURL( blobs[ url ] );
|
|
177
|
+
* objectURLs.push( url );
|
|
178
|
+
* return url;
|
|
179
|
+
*
|
|
180
|
+
* } );
|
|
181
|
+
*
|
|
182
|
+
* // Load as usual, then revoke the blob URLs.
|
|
183
|
+
* const loader = new GLTFLoader( manager );
|
|
184
|
+
* loader.load( 'fish.gltf', (gltf) => {
|
|
185
|
+
*
|
|
186
|
+
* scene.add( gltf.scene );
|
|
187
|
+
* objectURLs.forEach( ( url ) => URL.revokeObjectURL( url ) );
|
|
188
|
+
*
|
|
189
|
+
* } );
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @param {function(string):string} transform - URL modifier callback. Called with an URL and must return a resolved URL.
|
|
193
|
+
* @return {LoadingManager} A reference to this loading manager.
|
|
194
|
+
*/
|
|
85
195
|
this.setURLModifier = function ( transform ) {
|
|
86
196
|
|
|
87
197
|
urlModifier = transform;
|
|
@@ -90,6 +200,20 @@ class LoadingManager {
|
|
|
90
200
|
|
|
91
201
|
};
|
|
92
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Registers a loader with the given regular expression. Can be used to
|
|
205
|
+
* define what loader should be used in order to load specific files. A
|
|
206
|
+
* typical use case is to overwrite the default loader for textures.
|
|
207
|
+
*
|
|
208
|
+
* ```js
|
|
209
|
+
* // add handler for TGA textures
|
|
210
|
+
* manager.addHandler( /\.tga$/i, new TGALoader() );
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @param {string} regex - A regular expression.
|
|
214
|
+
* @param {Loader} loader - A loader that should handle matched cases.
|
|
215
|
+
* @return {LoadingManager} A reference to this loading manager.
|
|
216
|
+
*/
|
|
93
217
|
this.addHandler = function ( regex, loader ) {
|
|
94
218
|
|
|
95
219
|
handlers.push( regex, loader );
|
|
@@ -98,6 +222,12 @@ class LoadingManager {
|
|
|
98
222
|
|
|
99
223
|
};
|
|
100
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Removes the loader for the given regular expression.
|
|
227
|
+
*
|
|
228
|
+
* @param {string} regex - A regular expression.
|
|
229
|
+
* @return {LoadingManager} A reference to this loading manager.
|
|
230
|
+
*/
|
|
101
231
|
this.removeHandler = function ( regex ) {
|
|
102
232
|
|
|
103
233
|
const index = handlers.indexOf( regex );
|
|
@@ -112,6 +242,12 @@ class LoadingManager {
|
|
|
112
242
|
|
|
113
243
|
};
|
|
114
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Can be used to retrieve the registered loader for the given file path.
|
|
247
|
+
*
|
|
248
|
+
* @param {string} file - The file path.
|
|
249
|
+
* @return {?Loader} The registered loader. Returns `null` if no loader was found.
|
|
250
|
+
*/
|
|
115
251
|
this.getHandler = function ( file ) {
|
|
116
252
|
|
|
117
253
|
for ( let i = 0, l = handlers.length; i < l; i += 2 ) {
|
|
@@ -137,6 +273,12 @@ class LoadingManager {
|
|
|
137
273
|
|
|
138
274
|
}
|
|
139
275
|
|
|
276
|
+
/**
|
|
277
|
+
* The global default loading manager.
|
|
278
|
+
*
|
|
279
|
+
* @constant
|
|
280
|
+
* @type {LoadingManager}
|
|
281
|
+
*/
|
|
140
282
|
const DefaultLoadingManager = /*@__PURE__*/ new LoadingManager();
|
|
141
283
|
|
|
142
284
|
export { DefaultLoadingManager, LoadingManager };
|
|
@@ -27,15 +27,46 @@ import {
|
|
|
27
27
|
Material,
|
|
28
28
|
} from '../materials/Materials.js';
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Class for loading geometries. The files are internally
|
|
32
|
+
* loaded via {@link FileLoader}.
|
|
33
|
+
*
|
|
34
|
+
* ```js
|
|
35
|
+
* const loader = new THREE.MaterialLoader();
|
|
36
|
+
* const material = await loader.loadAsync( 'material.json' );
|
|
37
|
+
* ```
|
|
38
|
+
* This loader does not support node materials. Use {@link NodeMaterialLoader} instead.
|
|
39
|
+
*
|
|
40
|
+
* @augments Loader
|
|
41
|
+
*/
|
|
30
42
|
class MaterialLoader extends Loader {
|
|
31
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Constructs a new material loader.
|
|
46
|
+
*
|
|
47
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
48
|
+
*/
|
|
32
49
|
constructor( manager ) {
|
|
33
50
|
|
|
34
51
|
super( manager );
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A dictionary holding textures used by the material.
|
|
55
|
+
*
|
|
56
|
+
* @type {Object<string,Texture>}
|
|
57
|
+
*/
|
|
35
58
|
this.textures = {};
|
|
36
59
|
|
|
37
60
|
}
|
|
38
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Starts loading from the given URL and pass the loaded material to the `onLoad()` callback.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
66
|
+
* @param {function(Material)} onLoad - Executed when the loading process has been finished.
|
|
67
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
68
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
69
|
+
*/
|
|
39
70
|
load( url, onLoad, onProgress, onError ) {
|
|
40
71
|
|
|
41
72
|
const scope = this;
|
|
@@ -70,6 +101,12 @@ class MaterialLoader extends Loader {
|
|
|
70
101
|
|
|
71
102
|
}
|
|
72
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Parses the given JSON object and returns a material.
|
|
106
|
+
*
|
|
107
|
+
* @param {Object} json - The serialized material.
|
|
108
|
+
* @return {Material} The parsed material.
|
|
109
|
+
*/
|
|
73
110
|
parse( json ) {
|
|
74
111
|
|
|
75
112
|
const textures = this.textures;
|
|
@@ -335,6 +372,13 @@ class MaterialLoader extends Loader {
|
|
|
335
372
|
|
|
336
373
|
}
|
|
337
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Textures are not embedded in the material JSON so they have
|
|
377
|
+
* to be injected before the loading process starts.
|
|
378
|
+
*
|
|
379
|
+
* @param {Object} value - A dictionary holding textures for material properties.
|
|
380
|
+
* @return {MaterialLoader} A reference to this material loader.
|
|
381
|
+
*/
|
|
338
382
|
setTextures( value ) {
|
|
339
383
|
|
|
340
384
|
this.textures = value;
|
|
@@ -342,12 +386,25 @@ class MaterialLoader extends Loader {
|
|
|
342
386
|
|
|
343
387
|
}
|
|
344
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Creates a material for the given type.
|
|
391
|
+
*
|
|
392
|
+
* @param {string} type - The material type.
|
|
393
|
+
* @return {Material} The new material.
|
|
394
|
+
*/
|
|
345
395
|
createMaterialFromType( type ) {
|
|
346
396
|
|
|
347
397
|
return MaterialLoader.createMaterialFromType( type );
|
|
348
398
|
|
|
349
399
|
}
|
|
350
400
|
|
|
401
|
+
/**
|
|
402
|
+
* Creates a material for the given type.
|
|
403
|
+
*
|
|
404
|
+
* @static
|
|
405
|
+
* @param {string} type - The material type.
|
|
406
|
+
* @return {Material} The new material.
|
|
407
|
+
*/
|
|
351
408
|
static createMaterialFromType( type ) {
|
|
352
409
|
|
|
353
410
|
const materialLib = {
|