@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
|
@@ -66,9 +66,68 @@ import {
|
|
|
66
66
|
InstancedBufferAttribute
|
|
67
67
|
} from 'three';
|
|
68
68
|
import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
|
|
69
|
+
import { clone } from '../utils/SkeletonUtils.js';
|
|
69
70
|
|
|
71
|
+
/**
|
|
72
|
+
* A loader for the glTF 2.0 format.
|
|
73
|
+
*
|
|
74
|
+
* [glTF](https://www.khronos.org/gltf/) (GL Transmission Format) is an [open format specification]{@link https://github.com/KhronosGroup/glTF/tree/main/specification/2.0)
|
|
75
|
+
* for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb)
|
|
76
|
+
* format. External files store textures (.jpg, .png) and additional binary data (.bin). A glTF asset may deliver
|
|
77
|
+
* one or more scenes, including meshes, materials, textures, skins, skeletons, morph targets, animations, lights,
|
|
78
|
+
* and/or cameras.
|
|
79
|
+
*
|
|
80
|
+
* `GLTFLoader` uses {@link ImageBitmapLoader} whenever possible. Be advised that image bitmaps are not
|
|
81
|
+
* automatically GC-collected when they are no longer referenced, and they require special handling during
|
|
82
|
+
* the disposal process.
|
|
83
|
+
*
|
|
84
|
+
* `GLTFLoader` supports the following glTF 2.0 extensions:
|
|
85
|
+
* - KHR_draco_mesh_compression
|
|
86
|
+
* - KHR_materials_clearcoat
|
|
87
|
+
* - KHR_materials_dispersion
|
|
88
|
+
* - KHR_materials_ior
|
|
89
|
+
* - KHR_materials_specular
|
|
90
|
+
* - KHR_materials_transmission
|
|
91
|
+
* - KHR_materials_iridescence
|
|
92
|
+
* - KHR_materials_unlit
|
|
93
|
+
* - KHR_materials_volume
|
|
94
|
+
* - KHR_mesh_quantization
|
|
95
|
+
* - KHR_meshopt_compression
|
|
96
|
+
* - KHR_lights_punctual
|
|
97
|
+
* - KHR_texture_basisu
|
|
98
|
+
* - KHR_texture_transform
|
|
99
|
+
* - EXT_texture_webp
|
|
100
|
+
* - EXT_meshopt_compression
|
|
101
|
+
* - EXT_mesh_gpu_instancing
|
|
102
|
+
*
|
|
103
|
+
* The following glTF 2.0 extension is supported by an external user plugin:
|
|
104
|
+
* - [KHR_materials_variants](https://github.com/takahirox/three-gltf-extensions)
|
|
105
|
+
* - [MSFT_texture_dds](https://github.com/takahirox/three-gltf-extensions)
|
|
106
|
+
* - [KHR_animation_pointer](https://github.com/needle-tools/three-animation-pointer)
|
|
107
|
+
* - [NEEDLE_progressive](https://github.com/needle-tools/gltf-progressive)
|
|
108
|
+
*
|
|
109
|
+
* ```js
|
|
110
|
+
* const loader = new GLTFLoader();
|
|
111
|
+
*
|
|
112
|
+
* // Optional: Provide a DRACOLoader instance to decode compressed mesh data
|
|
113
|
+
* const dracoLoader = new DRACOLoader();
|
|
114
|
+
* dracoLoader.setDecoderPath( '/examples/jsm/libs/draco/' );
|
|
115
|
+
* loader.setDRACOLoader( dracoLoader );
|
|
116
|
+
*
|
|
117
|
+
* const gltf = await loader.loadAsync( 'models/gltf/duck/duck.gltf' );
|
|
118
|
+
* scene.add( gltf.scene );
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @augments Loader
|
|
122
|
+
* @three_import import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
123
|
+
*/
|
|
70
124
|
class GLTFLoader extends Loader {
|
|
71
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Constructs a new glTF loader.
|
|
128
|
+
*
|
|
129
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
130
|
+
*/
|
|
72
131
|
constructor( manager ) {
|
|
73
132
|
|
|
74
133
|
super( manager );
|
|
@@ -171,7 +230,13 @@ class GLTFLoader extends Loader {
|
|
|
171
230
|
|
|
172
231
|
this.register( function ( parser ) {
|
|
173
232
|
|
|
174
|
-
return new GLTFMeshoptCompression( parser );
|
|
233
|
+
return new GLTFMeshoptCompression( parser, EXTENSIONS.EXT_MESHOPT_COMPRESSION );
|
|
234
|
+
|
|
235
|
+
} );
|
|
236
|
+
|
|
237
|
+
this.register( function ( parser ) {
|
|
238
|
+
|
|
239
|
+
return new GLTFMeshoptCompression( parser, EXTENSIONS.KHR_MESHOPT_COMPRESSION );
|
|
175
240
|
|
|
176
241
|
} );
|
|
177
242
|
|
|
@@ -183,6 +248,15 @@ class GLTFLoader extends Loader {
|
|
|
183
248
|
|
|
184
249
|
}
|
|
185
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
253
|
+
* to the `onLoad()` callback.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
256
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
257
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
258
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
259
|
+
*/
|
|
186
260
|
load( url, onLoad, onProgress, onError ) {
|
|
187
261
|
|
|
188
262
|
const scope = this;
|
|
@@ -260,6 +334,13 @@ class GLTFLoader extends Loader {
|
|
|
260
334
|
|
|
261
335
|
}
|
|
262
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
339
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
340
|
+
*
|
|
341
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
342
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
343
|
+
*/
|
|
263
344
|
setDRACOLoader( dracoLoader ) {
|
|
264
345
|
|
|
265
346
|
this.dracoLoader = dracoLoader;
|
|
@@ -267,6 +348,13 @@ class GLTFLoader extends Loader {
|
|
|
267
348
|
|
|
268
349
|
}
|
|
269
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
353
|
+
* compressed textures.
|
|
354
|
+
*
|
|
355
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
356
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
357
|
+
*/
|
|
270
358
|
setKTX2Loader( ktx2Loader ) {
|
|
271
359
|
|
|
272
360
|
this.ktx2Loader = ktx2Loader;
|
|
@@ -274,6 +362,13 @@ class GLTFLoader extends Loader {
|
|
|
274
362
|
|
|
275
363
|
}
|
|
276
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
367
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
368
|
+
*
|
|
369
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
370
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
371
|
+
*/
|
|
277
372
|
setMeshoptDecoder( meshoptDecoder ) {
|
|
278
373
|
|
|
279
374
|
this.meshoptDecoder = meshoptDecoder;
|
|
@@ -281,6 +376,14 @@ class GLTFLoader extends Loader {
|
|
|
281
376
|
|
|
282
377
|
}
|
|
283
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
381
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
382
|
+
* to the loader.
|
|
383
|
+
*
|
|
384
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
385
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
386
|
+
*/
|
|
284
387
|
register( callback ) {
|
|
285
388
|
|
|
286
389
|
if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
|
|
@@ -293,6 +396,12 @@ class GLTFLoader extends Loader {
|
|
|
293
396
|
|
|
294
397
|
}
|
|
295
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Unregisters a plugin callback.
|
|
401
|
+
*
|
|
402
|
+
* @param {Function} callback - The callback function to unregister.
|
|
403
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
404
|
+
*/
|
|
296
405
|
unregister( callback ) {
|
|
297
406
|
|
|
298
407
|
if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
|
|
@@ -305,6 +414,14 @@ class GLTFLoader extends Loader {
|
|
|
305
414
|
|
|
306
415
|
}
|
|
307
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Parses the given glTF data and returns the resulting group.
|
|
419
|
+
*
|
|
420
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
421
|
+
* @param {string} path - The URL base path.
|
|
422
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
423
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
424
|
+
*/
|
|
308
425
|
parse( data, path, onLoad, onError ) {
|
|
309
426
|
|
|
310
427
|
let json;
|
|
@@ -463,6 +580,14 @@ class GLTFLoader extends Loader {
|
|
|
463
580
|
|
|
464
581
|
}
|
|
465
582
|
|
|
583
|
+
/**
|
|
584
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
585
|
+
*
|
|
586
|
+
* @async
|
|
587
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
588
|
+
* @param {string} path - The URL base path.
|
|
589
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
590
|
+
*/
|
|
466
591
|
parseAsync( data, path ) {
|
|
467
592
|
|
|
468
593
|
const scope = this;
|
|
@@ -517,6 +642,20 @@ function GLTFRegistry() {
|
|
|
517
642
|
/********** EXTENSIONS ***********/
|
|
518
643
|
/*********************************/
|
|
519
644
|
|
|
645
|
+
function getMaterialExtension( parser, materialIndex, extensionName ) {
|
|
646
|
+
|
|
647
|
+
const materialDef = parser.json.materials[ materialIndex ];
|
|
648
|
+
|
|
649
|
+
if ( materialDef.extensions && materialDef.extensions[ extensionName ] ) {
|
|
650
|
+
|
|
651
|
+
return materialDef.extensions[ extensionName ];
|
|
652
|
+
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
return null;
|
|
656
|
+
|
|
657
|
+
}
|
|
658
|
+
|
|
520
659
|
const EXTENSIONS = {
|
|
521
660
|
KHR_BINARY_GLTF: 'KHR_binary_glTF',
|
|
522
661
|
KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
|
|
@@ -539,6 +678,7 @@ const EXTENSIONS = {
|
|
|
539
678
|
EXT_TEXTURE_WEBP: 'EXT_texture_webp',
|
|
540
679
|
EXT_TEXTURE_AVIF: 'EXT_texture_avif',
|
|
541
680
|
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
|
|
681
|
+
KHR_MESHOPT_COMPRESSION: 'KHR_meshopt_compression',
|
|
542
682
|
EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
|
|
543
683
|
};
|
|
544
684
|
|
|
@@ -546,6 +686,8 @@ const EXTENSIONS = {
|
|
|
546
686
|
* Punctual Lights Extension
|
|
547
687
|
*
|
|
548
688
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
|
689
|
+
*
|
|
690
|
+
* @private
|
|
549
691
|
*/
|
|
550
692
|
class GLTFLightsExtension {
|
|
551
693
|
|
|
@@ -635,8 +777,6 @@ class GLTFLightsExtension {
|
|
|
635
777
|
// here, because node-level parsing will only override position if explicitly specified.
|
|
636
778
|
lightNode.position.set( 0, 0, 0 );
|
|
637
779
|
|
|
638
|
-
lightNode.decay = 2;
|
|
639
|
-
|
|
640
780
|
assignExtrasToUserData( lightNode, lightDef );
|
|
641
781
|
|
|
642
782
|
if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
|
|
@@ -684,6 +824,8 @@ class GLTFLightsExtension {
|
|
|
684
824
|
* Unlit Materials Extension
|
|
685
825
|
*
|
|
686
826
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
|
|
827
|
+
*
|
|
828
|
+
* @private
|
|
687
829
|
*/
|
|
688
830
|
class GLTFMaterialsUnlitExtension {
|
|
689
831
|
|
|
@@ -737,6 +879,8 @@ class GLTFMaterialsUnlitExtension {
|
|
|
737
879
|
* Materials Emissive Strength Extension
|
|
738
880
|
*
|
|
739
881
|
* Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
|
|
882
|
+
*
|
|
883
|
+
* @private
|
|
740
884
|
*/
|
|
741
885
|
class GLTFMaterialsEmissiveStrengthExtension {
|
|
742
886
|
|
|
@@ -749,20 +893,13 @@ class GLTFMaterialsEmissiveStrengthExtension {
|
|
|
749
893
|
|
|
750
894
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
751
895
|
|
|
752
|
-
const
|
|
753
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
754
|
-
|
|
755
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
896
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
756
897
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
898
|
+
if ( extension === null ) return Promise.resolve();
|
|
760
899
|
|
|
761
|
-
|
|
900
|
+
if ( extension.emissiveStrength !== undefined ) {
|
|
762
901
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
materialParams.emissiveIntensity = emissiveStrength;
|
|
902
|
+
materialParams.emissiveIntensity = extension.emissiveStrength;
|
|
766
903
|
|
|
767
904
|
}
|
|
768
905
|
|
|
@@ -776,6 +913,8 @@ class GLTFMaterialsEmissiveStrengthExtension {
|
|
|
776
913
|
* Clearcoat Materials Extension
|
|
777
914
|
*
|
|
778
915
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
916
|
+
*
|
|
917
|
+
* @private
|
|
779
918
|
*/
|
|
780
919
|
class GLTFMaterialsClearcoatExtension {
|
|
781
920
|
|
|
@@ -788,30 +927,20 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
788
927
|
|
|
789
928
|
getMaterialType( materialIndex ) {
|
|
790
929
|
|
|
791
|
-
const
|
|
792
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
793
|
-
|
|
794
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
930
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
795
931
|
|
|
796
|
-
return MeshPhysicalMaterial;
|
|
932
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
797
933
|
|
|
798
934
|
}
|
|
799
935
|
|
|
800
936
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
801
937
|
|
|
802
|
-
const
|
|
803
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
804
|
-
|
|
805
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
806
|
-
|
|
807
|
-
return Promise.resolve();
|
|
938
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
808
939
|
|
|
809
|
-
|
|
940
|
+
if ( extension === null ) return Promise.resolve();
|
|
810
941
|
|
|
811
942
|
const pending = [];
|
|
812
943
|
|
|
813
|
-
const extension = materialDef.extensions[ this.name ];
|
|
814
|
-
|
|
815
944
|
if ( extension.clearcoatFactor !== undefined ) {
|
|
816
945
|
|
|
817
946
|
materialParams.clearcoat = extension.clearcoatFactor;
|
|
@@ -820,7 +949,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
820
949
|
|
|
821
950
|
if ( extension.clearcoatTexture !== undefined ) {
|
|
822
951
|
|
|
823
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
|
|
952
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
|
|
824
953
|
|
|
825
954
|
}
|
|
826
955
|
|
|
@@ -832,13 +961,13 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
832
961
|
|
|
833
962
|
if ( extension.clearcoatRoughnessTexture !== undefined ) {
|
|
834
963
|
|
|
835
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
|
|
964
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
|
|
836
965
|
|
|
837
966
|
}
|
|
838
967
|
|
|
839
968
|
if ( extension.clearcoatNormalTexture !== undefined ) {
|
|
840
969
|
|
|
841
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
|
|
970
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
|
|
842
971
|
|
|
843
972
|
if ( extension.clearcoatNormalTexture.scale !== undefined ) {
|
|
844
973
|
|
|
@@ -860,6 +989,8 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
860
989
|
* Materials dispersion Extension
|
|
861
990
|
*
|
|
862
991
|
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
|
|
992
|
+
*
|
|
993
|
+
* @private
|
|
863
994
|
*/
|
|
864
995
|
class GLTFMaterialsDispersionExtension {
|
|
865
996
|
|
|
@@ -872,27 +1003,17 @@ class GLTFMaterialsDispersionExtension {
|
|
|
872
1003
|
|
|
873
1004
|
getMaterialType( materialIndex ) {
|
|
874
1005
|
|
|
875
|
-
const
|
|
876
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
877
|
-
|
|
878
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1006
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
879
1007
|
|
|
880
|
-
return MeshPhysicalMaterial;
|
|
1008
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
881
1009
|
|
|
882
1010
|
}
|
|
883
1011
|
|
|
884
1012
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
885
1013
|
|
|
886
|
-
const
|
|
887
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
888
|
-
|
|
889
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
890
|
-
|
|
891
|
-
return Promise.resolve();
|
|
1014
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
892
1015
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1016
|
+
if ( extension === null ) return Promise.resolve();
|
|
896
1017
|
|
|
897
1018
|
materialParams.dispersion = extension.dispersion !== undefined ? extension.dispersion : 0;
|
|
898
1019
|
|
|
@@ -906,6 +1027,8 @@ class GLTFMaterialsDispersionExtension {
|
|
|
906
1027
|
* Iridescence Materials Extension
|
|
907
1028
|
*
|
|
908
1029
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
|
|
1030
|
+
*
|
|
1031
|
+
* @private
|
|
909
1032
|
*/
|
|
910
1033
|
class GLTFMaterialsIridescenceExtension {
|
|
911
1034
|
|
|
@@ -918,30 +1041,20 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
918
1041
|
|
|
919
1042
|
getMaterialType( materialIndex ) {
|
|
920
1043
|
|
|
921
|
-
const
|
|
922
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1044
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
923
1045
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
return MeshPhysicalMaterial;
|
|
1046
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
927
1047
|
|
|
928
1048
|
}
|
|
929
1049
|
|
|
930
1050
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
931
1051
|
|
|
932
|
-
const
|
|
933
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
934
|
-
|
|
935
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
936
|
-
|
|
937
|
-
return Promise.resolve();
|
|
1052
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
938
1053
|
|
|
939
|
-
|
|
1054
|
+
if ( extension === null ) return Promise.resolve();
|
|
940
1055
|
|
|
941
1056
|
const pending = [];
|
|
942
1057
|
|
|
943
|
-
const extension = materialDef.extensions[ this.name ];
|
|
944
|
-
|
|
945
1058
|
if ( extension.iridescenceFactor !== undefined ) {
|
|
946
1059
|
|
|
947
1060
|
materialParams.iridescence = extension.iridescenceFactor;
|
|
@@ -950,7 +1063,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
950
1063
|
|
|
951
1064
|
if ( extension.iridescenceTexture !== undefined ) {
|
|
952
1065
|
|
|
953
|
-
pending.push( parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
|
|
1066
|
+
pending.push( this.parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
|
|
954
1067
|
|
|
955
1068
|
}
|
|
956
1069
|
|
|
@@ -980,7 +1093,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
980
1093
|
|
|
981
1094
|
if ( extension.iridescenceThicknessTexture !== undefined ) {
|
|
982
1095
|
|
|
983
|
-
pending.push( parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
|
|
1096
|
+
pending.push( this.parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
|
|
984
1097
|
|
|
985
1098
|
}
|
|
986
1099
|
|
|
@@ -994,6 +1107,8 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
994
1107
|
* Sheen Materials Extension
|
|
995
1108
|
*
|
|
996
1109
|
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
|
|
1110
|
+
*
|
|
1111
|
+
* @private
|
|
997
1112
|
*/
|
|
998
1113
|
class GLTFMaterialsSheenExtension {
|
|
999
1114
|
|
|
@@ -1006,25 +1121,17 @@ class GLTFMaterialsSheenExtension {
|
|
|
1006
1121
|
|
|
1007
1122
|
getMaterialType( materialIndex ) {
|
|
1008
1123
|
|
|
1009
|
-
const
|
|
1010
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1124
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1011
1125
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
return MeshPhysicalMaterial;
|
|
1126
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1015
1127
|
|
|
1016
1128
|
}
|
|
1017
1129
|
|
|
1018
1130
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1019
1131
|
|
|
1020
|
-
const
|
|
1021
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1022
|
-
|
|
1023
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1132
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1024
1133
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1134
|
+
if ( extension === null ) return Promise.resolve();
|
|
1028
1135
|
|
|
1029
1136
|
const pending = [];
|
|
1030
1137
|
|
|
@@ -1032,8 +1139,6 @@ class GLTFMaterialsSheenExtension {
|
|
|
1032
1139
|
materialParams.sheenRoughness = 0;
|
|
1033
1140
|
materialParams.sheen = 1;
|
|
1034
1141
|
|
|
1035
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1036
|
-
|
|
1037
1142
|
if ( extension.sheenColorFactor !== undefined ) {
|
|
1038
1143
|
|
|
1039
1144
|
const colorFactor = extension.sheenColorFactor;
|
|
@@ -1049,13 +1154,13 @@ class GLTFMaterialsSheenExtension {
|
|
|
1049
1154
|
|
|
1050
1155
|
if ( extension.sheenColorTexture !== undefined ) {
|
|
1051
1156
|
|
|
1052
|
-
pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
|
|
1157
|
+
pending.push( this.parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
|
|
1053
1158
|
|
|
1054
1159
|
}
|
|
1055
1160
|
|
|
1056
1161
|
if ( extension.sheenRoughnessTexture !== undefined ) {
|
|
1057
1162
|
|
|
1058
|
-
pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
|
|
1163
|
+
pending.push( this.parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
|
|
1059
1164
|
|
|
1060
1165
|
}
|
|
1061
1166
|
|
|
@@ -1070,6 +1175,8 @@ class GLTFMaterialsSheenExtension {
|
|
|
1070
1175
|
*
|
|
1071
1176
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
|
|
1072
1177
|
* Draft: https://github.com/KhronosGroup/glTF/pull/1698
|
|
1178
|
+
*
|
|
1179
|
+
* @private
|
|
1073
1180
|
*/
|
|
1074
1181
|
class GLTFMaterialsTransmissionExtension {
|
|
1075
1182
|
|
|
@@ -1082,30 +1189,20 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
1082
1189
|
|
|
1083
1190
|
getMaterialType( materialIndex ) {
|
|
1084
1191
|
|
|
1085
|
-
const
|
|
1086
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1087
|
-
|
|
1088
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1192
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1089
1193
|
|
|
1090
|
-
return MeshPhysicalMaterial;
|
|
1194
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1091
1195
|
|
|
1092
1196
|
}
|
|
1093
1197
|
|
|
1094
1198
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1095
1199
|
|
|
1096
|
-
const
|
|
1097
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1098
|
-
|
|
1099
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1200
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1100
1201
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
}
|
|
1202
|
+
if ( extension === null ) return Promise.resolve();
|
|
1104
1203
|
|
|
1105
1204
|
const pending = [];
|
|
1106
1205
|
|
|
1107
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1108
|
-
|
|
1109
1206
|
if ( extension.transmissionFactor !== undefined ) {
|
|
1110
1207
|
|
|
1111
1208
|
materialParams.transmission = extension.transmissionFactor;
|
|
@@ -1114,7 +1211,7 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
1114
1211
|
|
|
1115
1212
|
if ( extension.transmissionTexture !== undefined ) {
|
|
1116
1213
|
|
|
1117
|
-
pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
|
|
1214
|
+
pending.push( this.parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
|
|
1118
1215
|
|
|
1119
1216
|
}
|
|
1120
1217
|
|
|
@@ -1128,6 +1225,8 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
1128
1225
|
* Materials Volume Extension
|
|
1129
1226
|
*
|
|
1130
1227
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
|
|
1228
|
+
*
|
|
1229
|
+
* @private
|
|
1131
1230
|
*/
|
|
1132
1231
|
class GLTFMaterialsVolumeExtension {
|
|
1133
1232
|
|
|
@@ -1140,35 +1239,25 @@ class GLTFMaterialsVolumeExtension {
|
|
|
1140
1239
|
|
|
1141
1240
|
getMaterialType( materialIndex ) {
|
|
1142
1241
|
|
|
1143
|
-
const
|
|
1144
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1145
|
-
|
|
1146
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1242
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1147
1243
|
|
|
1148
|
-
return MeshPhysicalMaterial;
|
|
1244
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1149
1245
|
|
|
1150
1246
|
}
|
|
1151
1247
|
|
|
1152
1248
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1153
1249
|
|
|
1154
|
-
const
|
|
1155
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1156
|
-
|
|
1157
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1250
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1158
1251
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
}
|
|
1252
|
+
if ( extension === null ) return Promise.resolve();
|
|
1162
1253
|
|
|
1163
1254
|
const pending = [];
|
|
1164
1255
|
|
|
1165
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1166
|
-
|
|
1167
1256
|
materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0;
|
|
1168
1257
|
|
|
1169
1258
|
if ( extension.thicknessTexture !== undefined ) {
|
|
1170
1259
|
|
|
1171
|
-
pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
|
|
1260
|
+
pending.push( this.parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
|
|
1172
1261
|
|
|
1173
1262
|
}
|
|
1174
1263
|
|
|
@@ -1187,6 +1276,8 @@ class GLTFMaterialsVolumeExtension {
|
|
|
1187
1276
|
* Materials ior Extension
|
|
1188
1277
|
*
|
|
1189
1278
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
|
|
1279
|
+
*
|
|
1280
|
+
* @private
|
|
1190
1281
|
*/
|
|
1191
1282
|
class GLTFMaterialsIorExtension {
|
|
1192
1283
|
|
|
@@ -1199,27 +1290,17 @@ class GLTFMaterialsIorExtension {
|
|
|
1199
1290
|
|
|
1200
1291
|
getMaterialType( materialIndex ) {
|
|
1201
1292
|
|
|
1202
|
-
const
|
|
1203
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1204
|
-
|
|
1205
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1293
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1206
1294
|
|
|
1207
|
-
return MeshPhysicalMaterial;
|
|
1295
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1208
1296
|
|
|
1209
1297
|
}
|
|
1210
1298
|
|
|
1211
1299
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1212
1300
|
|
|
1213
|
-
const
|
|
1214
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1215
|
-
|
|
1216
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1301
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1217
1302
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1303
|
+
if ( extension === null ) return Promise.resolve();
|
|
1223
1304
|
|
|
1224
1305
|
materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5;
|
|
1225
1306
|
|
|
@@ -1233,6 +1314,8 @@ class GLTFMaterialsIorExtension {
|
|
|
1233
1314
|
* Materials specular Extension
|
|
1234
1315
|
*
|
|
1235
1316
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
|
|
1317
|
+
*
|
|
1318
|
+
* @private
|
|
1236
1319
|
*/
|
|
1237
1320
|
class GLTFMaterialsSpecularExtension {
|
|
1238
1321
|
|
|
@@ -1245,35 +1328,25 @@ class GLTFMaterialsSpecularExtension {
|
|
|
1245
1328
|
|
|
1246
1329
|
getMaterialType( materialIndex ) {
|
|
1247
1330
|
|
|
1248
|
-
const
|
|
1249
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1250
|
-
|
|
1251
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1331
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1252
1332
|
|
|
1253
|
-
return MeshPhysicalMaterial;
|
|
1333
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1254
1334
|
|
|
1255
1335
|
}
|
|
1256
1336
|
|
|
1257
1337
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1258
1338
|
|
|
1259
|
-
const
|
|
1260
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1261
|
-
|
|
1262
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1339
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1263
1340
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
}
|
|
1341
|
+
if ( extension === null ) return Promise.resolve();
|
|
1267
1342
|
|
|
1268
1343
|
const pending = [];
|
|
1269
1344
|
|
|
1270
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1271
|
-
|
|
1272
1345
|
materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;
|
|
1273
1346
|
|
|
1274
1347
|
if ( extension.specularTexture !== undefined ) {
|
|
1275
1348
|
|
|
1276
|
-
pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
|
|
1349
|
+
pending.push( this.parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
|
|
1277
1350
|
|
|
1278
1351
|
}
|
|
1279
1352
|
|
|
@@ -1282,7 +1355,7 @@ class GLTFMaterialsSpecularExtension {
|
|
|
1282
1355
|
|
|
1283
1356
|
if ( extension.specularColorTexture !== undefined ) {
|
|
1284
1357
|
|
|
1285
|
-
pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
|
|
1358
|
+
pending.push( this.parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
|
|
1286
1359
|
|
|
1287
1360
|
}
|
|
1288
1361
|
|
|
@@ -1297,6 +1370,8 @@ class GLTFMaterialsSpecularExtension {
|
|
|
1297
1370
|
* Materials bump Extension
|
|
1298
1371
|
*
|
|
1299
1372
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
|
|
1373
|
+
*
|
|
1374
|
+
* @private
|
|
1300
1375
|
*/
|
|
1301
1376
|
class GLTFMaterialsBumpExtension {
|
|
1302
1377
|
|
|
@@ -1309,35 +1384,25 @@ class GLTFMaterialsBumpExtension {
|
|
|
1309
1384
|
|
|
1310
1385
|
getMaterialType( materialIndex ) {
|
|
1311
1386
|
|
|
1312
|
-
const
|
|
1313
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1314
|
-
|
|
1315
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1387
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1316
1388
|
|
|
1317
|
-
return MeshPhysicalMaterial;
|
|
1389
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1318
1390
|
|
|
1319
1391
|
}
|
|
1320
1392
|
|
|
1321
1393
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1322
1394
|
|
|
1323
|
-
const
|
|
1324
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1325
|
-
|
|
1326
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1327
|
-
|
|
1328
|
-
return Promise.resolve();
|
|
1395
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1329
1396
|
|
|
1330
|
-
|
|
1397
|
+
if ( extension === null ) return Promise.resolve();
|
|
1331
1398
|
|
|
1332
1399
|
const pending = [];
|
|
1333
1400
|
|
|
1334
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1335
|
-
|
|
1336
1401
|
materialParams.bumpScale = extension.bumpFactor !== undefined ? extension.bumpFactor : 1.0;
|
|
1337
1402
|
|
|
1338
1403
|
if ( extension.bumpTexture !== undefined ) {
|
|
1339
1404
|
|
|
1340
|
-
pending.push( parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
|
|
1405
|
+
pending.push( this.parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
|
|
1341
1406
|
|
|
1342
1407
|
}
|
|
1343
1408
|
|
|
@@ -1351,6 +1416,8 @@ class GLTFMaterialsBumpExtension {
|
|
|
1351
1416
|
* Materials anisotropy Extension
|
|
1352
1417
|
*
|
|
1353
1418
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
|
|
1419
|
+
*
|
|
1420
|
+
* @private
|
|
1354
1421
|
*/
|
|
1355
1422
|
class GLTFMaterialsAnisotropyExtension {
|
|
1356
1423
|
|
|
@@ -1363,30 +1430,20 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
1363
1430
|
|
|
1364
1431
|
getMaterialType( materialIndex ) {
|
|
1365
1432
|
|
|
1366
|
-
const
|
|
1367
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1368
|
-
|
|
1369
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1433
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1370
1434
|
|
|
1371
|
-
return MeshPhysicalMaterial;
|
|
1435
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1372
1436
|
|
|
1373
1437
|
}
|
|
1374
1438
|
|
|
1375
1439
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1376
1440
|
|
|
1377
|
-
const
|
|
1378
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1379
|
-
|
|
1380
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1381
|
-
|
|
1382
|
-
return Promise.resolve();
|
|
1441
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1383
1442
|
|
|
1384
|
-
|
|
1443
|
+
if ( extension === null ) return Promise.resolve();
|
|
1385
1444
|
|
|
1386
1445
|
const pending = [];
|
|
1387
1446
|
|
|
1388
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1389
|
-
|
|
1390
1447
|
if ( extension.anisotropyStrength !== undefined ) {
|
|
1391
1448
|
|
|
1392
1449
|
materialParams.anisotropy = extension.anisotropyStrength;
|
|
@@ -1401,7 +1458,7 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
1401
1458
|
|
|
1402
1459
|
if ( extension.anisotropyTexture !== undefined ) {
|
|
1403
1460
|
|
|
1404
|
-
pending.push( parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
1461
|
+
pending.push( this.parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
1405
1462
|
|
|
1406
1463
|
}
|
|
1407
1464
|
|
|
@@ -1415,6 +1472,8 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
1415
1472
|
* BasisU Texture Extension
|
|
1416
1473
|
*
|
|
1417
1474
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
|
|
1475
|
+
*
|
|
1476
|
+
* @private
|
|
1418
1477
|
*/
|
|
1419
1478
|
class GLTFTextureBasisUExtension {
|
|
1420
1479
|
|
|
@@ -1466,6 +1525,8 @@ class GLTFTextureBasisUExtension {
|
|
|
1466
1525
|
* WebP Texture Extension
|
|
1467
1526
|
*
|
|
1468
1527
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
|
|
1528
|
+
*
|
|
1529
|
+
* @private
|
|
1469
1530
|
*/
|
|
1470
1531
|
class GLTFTextureWebPExtension {
|
|
1471
1532
|
|
|
@@ -1473,7 +1534,6 @@ class GLTFTextureWebPExtension {
|
|
|
1473
1534
|
|
|
1474
1535
|
this.parser = parser;
|
|
1475
1536
|
this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
|
|
1476
|
-
this.isSupported = null;
|
|
1477
1537
|
|
|
1478
1538
|
}
|
|
1479
1539
|
|
|
@@ -1502,46 +1562,7 @@ class GLTFTextureWebPExtension {
|
|
|
1502
1562
|
|
|
1503
1563
|
}
|
|
1504
1564
|
|
|
1505
|
-
return
|
|
1506
|
-
|
|
1507
|
-
if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );
|
|
1508
|
-
|
|
1509
|
-
if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
|
|
1510
|
-
|
|
1511
|
-
throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' );
|
|
1512
|
-
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
// Fall back to PNG or JPEG.
|
|
1516
|
-
return parser.loadTexture( textureIndex );
|
|
1517
|
-
|
|
1518
|
-
} );
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
detectSupport() {
|
|
1523
|
-
|
|
1524
|
-
if ( ! this.isSupported ) {
|
|
1525
|
-
|
|
1526
|
-
this.isSupported = new Promise( function ( resolve ) {
|
|
1527
|
-
|
|
1528
|
-
const image = new Image();
|
|
1529
|
-
|
|
1530
|
-
// Lossy test image. Support for lossy images doesn't guarantee support for all
|
|
1531
|
-
// WebP images, unfortunately.
|
|
1532
|
-
image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
|
|
1533
|
-
|
|
1534
|
-
image.onload = image.onerror = function () {
|
|
1535
|
-
|
|
1536
|
-
resolve( image.height === 1 );
|
|
1537
|
-
|
|
1538
|
-
};
|
|
1539
|
-
|
|
1540
|
-
} );
|
|
1541
|
-
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
return this.isSupported;
|
|
1565
|
+
return parser.loadTextureImage( textureIndex, extension.source, loader );
|
|
1545
1566
|
|
|
1546
1567
|
}
|
|
1547
1568
|
|
|
@@ -1551,6 +1572,8 @@ class GLTFTextureWebPExtension {
|
|
|
1551
1572
|
* AVIF Texture Extension
|
|
1552
1573
|
*
|
|
1553
1574
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
|
|
1575
|
+
*
|
|
1576
|
+
* @private
|
|
1554
1577
|
*/
|
|
1555
1578
|
class GLTFTextureAVIFExtension {
|
|
1556
1579
|
|
|
@@ -1558,7 +1581,6 @@ class GLTFTextureAVIFExtension {
|
|
|
1558
1581
|
|
|
1559
1582
|
this.parser = parser;
|
|
1560
1583
|
this.name = EXTENSIONS.EXT_TEXTURE_AVIF;
|
|
1561
|
-
this.isSupported = null;
|
|
1562
1584
|
|
|
1563
1585
|
}
|
|
1564
1586
|
|
|
@@ -1587,44 +1609,7 @@ class GLTFTextureAVIFExtension {
|
|
|
1587
1609
|
|
|
1588
1610
|
}
|
|
1589
1611
|
|
|
1590
|
-
return
|
|
1591
|
-
|
|
1592
|
-
if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );
|
|
1593
|
-
|
|
1594
|
-
if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
|
|
1595
|
-
|
|
1596
|
-
throw new Error( 'THREE.GLTFLoader: AVIF required by asset but unsupported.' );
|
|
1597
|
-
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
// Fall back to PNG or JPEG.
|
|
1601
|
-
return parser.loadTexture( textureIndex );
|
|
1602
|
-
|
|
1603
|
-
} );
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
detectSupport() {
|
|
1608
|
-
|
|
1609
|
-
if ( ! this.isSupported ) {
|
|
1610
|
-
|
|
1611
|
-
this.isSupported = new Promise( function ( resolve ) {
|
|
1612
|
-
|
|
1613
|
-
const image = new Image();
|
|
1614
|
-
|
|
1615
|
-
// Lossy test image.
|
|
1616
|
-
image.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=';
|
|
1617
|
-
image.onload = image.onerror = function () {
|
|
1618
|
-
|
|
1619
|
-
resolve( image.height === 1 );
|
|
1620
|
-
|
|
1621
|
-
};
|
|
1622
|
-
|
|
1623
|
-
} );
|
|
1624
|
-
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
return this.isSupported;
|
|
1612
|
+
return parser.loadTextureImage( textureIndex, extension.source, loader );
|
|
1628
1613
|
|
|
1629
1614
|
}
|
|
1630
1615
|
|
|
@@ -1634,12 +1619,14 @@ class GLTFTextureAVIFExtension {
|
|
|
1634
1619
|
* meshopt BufferView Compression Extension
|
|
1635
1620
|
*
|
|
1636
1621
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
|
|
1622
|
+
*
|
|
1623
|
+
* @private
|
|
1637
1624
|
*/
|
|
1638
1625
|
class GLTFMeshoptCompression {
|
|
1639
1626
|
|
|
1640
|
-
constructor( parser ) {
|
|
1627
|
+
constructor( parser, name ) {
|
|
1641
1628
|
|
|
1642
|
-
this.name =
|
|
1629
|
+
this.name = name;
|
|
1643
1630
|
this.parser = parser;
|
|
1644
1631
|
|
|
1645
1632
|
}
|
|
@@ -1719,6 +1706,7 @@ class GLTFMeshoptCompression {
|
|
|
1719
1706
|
*
|
|
1720
1707
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
|
|
1721
1708
|
*
|
|
1709
|
+
* @private
|
|
1722
1710
|
*/
|
|
1723
1711
|
class GLTFMeshGpuInstancing {
|
|
1724
1712
|
|
|
@@ -1947,6 +1935,8 @@ class GLTFBinaryExtension {
|
|
|
1947
1935
|
* DRACO Mesh Compression Extension
|
|
1948
1936
|
*
|
|
1949
1937
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
1938
|
+
*
|
|
1939
|
+
* @private
|
|
1950
1940
|
*/
|
|
1951
1941
|
class GLTFDracoMeshCompressionExtension {
|
|
1952
1942
|
|
|
@@ -2030,6 +2020,8 @@ class GLTFDracoMeshCompressionExtension {
|
|
|
2030
2020
|
* Texture Transform Extension
|
|
2031
2021
|
*
|
|
2032
2022
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
|
|
2023
|
+
*
|
|
2024
|
+
* @private
|
|
2033
2025
|
*/
|
|
2034
2026
|
class GLTFTextureTransformExtension {
|
|
2035
2027
|
|
|
@@ -2089,6 +2081,8 @@ class GLTFTextureTransformExtension {
|
|
|
2089
2081
|
* Mesh Quantization Extension
|
|
2090
2082
|
*
|
|
2091
2083
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
|
|
2084
|
+
*
|
|
2085
|
+
* @private
|
|
2092
2086
|
*/
|
|
2093
2087
|
class GLTFMeshQuantizationExtension {
|
|
2094
2088
|
|
|
@@ -2176,7 +2170,7 @@ class GLTFCubicSplineInterpolant extends Interpolant {
|
|
|
2176
2170
|
|
|
2177
2171
|
}
|
|
2178
2172
|
|
|
2179
|
-
const
|
|
2173
|
+
const _quaternion = new Quaternion();
|
|
2180
2174
|
|
|
2181
2175
|
class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
|
2182
2176
|
|
|
@@ -2184,7 +2178,7 @@ class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
|
|
2184
2178
|
|
|
2185
2179
|
const result = super.interpolate_( i1, t0, t, t1 );
|
|
2186
2180
|
|
|
2187
|
-
|
|
2181
|
+
_quaternion.fromArray( result ).normalize().toArray( result );
|
|
2188
2182
|
|
|
2189
2183
|
return result;
|
|
2190
2184
|
|
|
@@ -2290,6 +2284,10 @@ const ALPHA_MODES = {
|
|
|
2290
2284
|
|
|
2291
2285
|
/**
|
|
2292
2286
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
|
2287
|
+
*
|
|
2288
|
+
* @private
|
|
2289
|
+
* @param {Object<string, Material>} cache
|
|
2290
|
+
* @return {Material}
|
|
2293
2291
|
*/
|
|
2294
2292
|
function createDefaultMaterial( cache ) {
|
|
2295
2293
|
|
|
@@ -2329,7 +2327,9 @@ function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
|
|
|
2329
2327
|
}
|
|
2330
2328
|
|
|
2331
2329
|
/**
|
|
2332
|
-
*
|
|
2330
|
+
*
|
|
2331
|
+
* @private
|
|
2332
|
+
* @param {Object3D|Material|BufferGeometry|Object|AnimationClip} object
|
|
2333
2333
|
* @param {GLTF.definition} gltfDef
|
|
2334
2334
|
*/
|
|
2335
2335
|
function assignExtrasToUserData( object, gltfDef ) {
|
|
@@ -2353,6 +2353,7 @@ function assignExtrasToUserData( object, gltfDef ) {
|
|
|
2353
2353
|
/**
|
|
2354
2354
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
|
|
2355
2355
|
*
|
|
2356
|
+
* @private
|
|
2356
2357
|
* @param {BufferGeometry} geometry
|
|
2357
2358
|
* @param {Array<GLTF.Target>} targets
|
|
2358
2359
|
* @param {GLTFParser} parser
|
|
@@ -2440,6 +2441,8 @@ function addMorphTargets( geometry, targets, parser ) {
|
|
|
2440
2441
|
}
|
|
2441
2442
|
|
|
2442
2443
|
/**
|
|
2444
|
+
*
|
|
2445
|
+
* @private
|
|
2443
2446
|
* @param {Mesh} mesh
|
|
2444
2447
|
* @param {GLTF.Mesh} meshDef
|
|
2445
2448
|
*/
|
|
@@ -2560,6 +2563,7 @@ function getImageURIMimeType( uri ) {
|
|
|
2560
2563
|
|
|
2561
2564
|
if ( uri.search( /\.jpe?g($|\?)/i ) > 0 || uri.search( /^data\:image\/jpeg/ ) === 0 ) return 'image/jpeg';
|
|
2562
2565
|
if ( uri.search( /\.webp($|\?)/i ) > 0 || uri.search( /^data\:image\/webp/ ) === 0 ) return 'image/webp';
|
|
2566
|
+
if ( uri.search( /\.ktx2($|\?)/i ) > 0 || uri.search( /^data\:image\/ktx2/ ) === 0 ) return 'image/ktx2';
|
|
2563
2567
|
|
|
2564
2568
|
return 'image/png';
|
|
2565
2569
|
|
|
@@ -2609,7 +2613,7 @@ class GLTFParser {
|
|
|
2609
2613
|
let isFirefox = false;
|
|
2610
2614
|
let firefoxVersion = - 1;
|
|
2611
2615
|
|
|
2612
|
-
if ( typeof navigator !== 'undefined' ) {
|
|
2616
|
+
if ( typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined' ) {
|
|
2613
2617
|
|
|
2614
2618
|
const userAgent = navigator.userAgent;
|
|
2615
2619
|
|
|
@@ -2727,6 +2731,8 @@ class GLTFParser {
|
|
|
2727
2731
|
|
|
2728
2732
|
/**
|
|
2729
2733
|
* Marks the special nodes/meshes in json for efficient parse.
|
|
2734
|
+
*
|
|
2735
|
+
* @private
|
|
2730
2736
|
*/
|
|
2731
2737
|
_markDefs() {
|
|
2732
2738
|
|
|
@@ -2787,6 +2793,10 @@ class GLTFParser {
|
|
|
2787
2793
|
* Textures) can be reused directly and are not marked here.
|
|
2788
2794
|
*
|
|
2789
2795
|
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
2796
|
+
*
|
|
2797
|
+
* @private
|
|
2798
|
+
* @param {Object} cache
|
|
2799
|
+
* @param {Object3D} index
|
|
2790
2800
|
*/
|
|
2791
2801
|
_addNodeRef( cache, index ) {
|
|
2792
2802
|
|
|
@@ -2802,7 +2812,15 @@ class GLTFParser {
|
|
|
2802
2812
|
|
|
2803
2813
|
}
|
|
2804
2814
|
|
|
2805
|
-
/**
|
|
2815
|
+
/**
|
|
2816
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
2817
|
+
*
|
|
2818
|
+
* @private
|
|
2819
|
+
* @param {Object} cache
|
|
2820
|
+
* @param {number} index
|
|
2821
|
+
* @param {Object} object
|
|
2822
|
+
* @return {Object}
|
|
2823
|
+
*/
|
|
2806
2824
|
_getNodeRef( cache, index, object ) {
|
|
2807
2825
|
|
|
2808
2826
|
if ( cache.refs[ index ] <= 1 ) return object;
|
|
@@ -2874,9 +2892,11 @@ class GLTFParser {
|
|
|
2874
2892
|
|
|
2875
2893
|
/**
|
|
2876
2894
|
* Requests the specified dependency asynchronously, with caching.
|
|
2895
|
+
*
|
|
2896
|
+
* @private
|
|
2877
2897
|
* @param {string} type
|
|
2878
2898
|
* @param {number} index
|
|
2879
|
-
* @return {Promise<Object3D|Material|
|
|
2899
|
+
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
|
|
2880
2900
|
*/
|
|
2881
2901
|
getDependency( type, index ) {
|
|
2882
2902
|
|
|
@@ -2982,6 +3002,8 @@ class GLTFParser {
|
|
|
2982
3002
|
|
|
2983
3003
|
/**
|
|
2984
3004
|
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
3005
|
+
*
|
|
3006
|
+
* @private
|
|
2985
3007
|
* @param {string} type
|
|
2986
3008
|
* @return {Promise<Array<Object>>}
|
|
2987
3009
|
*/
|
|
@@ -3010,6 +3032,8 @@ class GLTFParser {
|
|
|
3010
3032
|
|
|
3011
3033
|
/**
|
|
3012
3034
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
3035
|
+
*
|
|
3036
|
+
* @private
|
|
3013
3037
|
* @param {number} bufferIndex
|
|
3014
3038
|
* @return {Promise<ArrayBuffer>}
|
|
3015
3039
|
*/
|
|
@@ -3047,6 +3071,8 @@ class GLTFParser {
|
|
|
3047
3071
|
|
|
3048
3072
|
/**
|
|
3049
3073
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
3074
|
+
*
|
|
3075
|
+
* @private
|
|
3050
3076
|
* @param {number} bufferViewIndex
|
|
3051
3077
|
* @return {Promise<ArrayBuffer>}
|
|
3052
3078
|
*/
|
|
@@ -3066,6 +3092,8 @@ class GLTFParser {
|
|
|
3066
3092
|
|
|
3067
3093
|
/**
|
|
3068
3094
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
3095
|
+
*
|
|
3096
|
+
* @private
|
|
3069
3097
|
* @param {number} accessorIndex
|
|
3070
3098
|
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
3071
3099
|
*/
|
|
@@ -3205,8 +3233,10 @@ class GLTFParser {
|
|
|
3205
3233
|
|
|
3206
3234
|
/**
|
|
3207
3235
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
3236
|
+
*
|
|
3237
|
+
* @private
|
|
3208
3238
|
* @param {number} textureIndex
|
|
3209
|
-
* @return {Promise
|
|
3239
|
+
* @return {Promise<?Texture>}
|
|
3210
3240
|
*/
|
|
3211
3241
|
loadTexture( textureIndex ) {
|
|
3212
3242
|
|
|
@@ -3265,6 +3295,7 @@ class GLTFParser {
|
|
|
3265
3295
|
texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || LinearMipmapLinearFilter;
|
|
3266
3296
|
texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || RepeatWrapping;
|
|
3267
3297
|
texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || RepeatWrapping;
|
|
3298
|
+
texture.generateMipmaps = ! texture.isCompressedTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
3268
3299
|
texture.anisotropy = 4;
|
|
3269
3300
|
|
|
3270
3301
|
parser.associations.set( texture, { textures: textureIndex } );
|
|
@@ -3374,9 +3405,12 @@ class GLTFParser {
|
|
|
3374
3405
|
|
|
3375
3406
|
/**
|
|
3376
3407
|
* Asynchronously assigns a texture to the given material parameters.
|
|
3408
|
+
*
|
|
3409
|
+
* @private
|
|
3377
3410
|
* @param {Object} materialParams
|
|
3378
3411
|
* @param {string} mapName
|
|
3379
3412
|
* @param {Object} mapDef
|
|
3413
|
+
* @param {string} [colorSpace]
|
|
3380
3414
|
* @return {Promise<Texture>}
|
|
3381
3415
|
*/
|
|
3382
3416
|
assignTexture( materialParams, mapName, mapDef, colorSpace ) {
|
|
@@ -3428,7 +3462,9 @@ class GLTFParser {
|
|
|
3428
3462
|
* but reuse of the same glTF material may require multiple threejs materials
|
|
3429
3463
|
* to accommodate different primitive types, defines, etc. New materials will
|
|
3430
3464
|
* be created if necessary, and reused from a cache.
|
|
3431
|
-
*
|
|
3465
|
+
*
|
|
3466
|
+
* @private
|
|
3467
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
3432
3468
|
*/
|
|
3433
3469
|
assignFinalMaterial( mesh ) {
|
|
3434
3470
|
|
|
@@ -3528,6 +3564,8 @@ class GLTFParser {
|
|
|
3528
3564
|
|
|
3529
3565
|
/**
|
|
3530
3566
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
3567
|
+
*
|
|
3568
|
+
* @private
|
|
3531
3569
|
* @param {number} materialIndex
|
|
3532
3570
|
* @return {Promise<Material>}
|
|
3533
3571
|
*/
|
|
@@ -3685,7 +3723,13 @@ class GLTFParser {
|
|
|
3685
3723
|
|
|
3686
3724
|
}
|
|
3687
3725
|
|
|
3688
|
-
/**
|
|
3726
|
+
/**
|
|
3727
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
3728
|
+
*
|
|
3729
|
+
* @private
|
|
3730
|
+
* @param {string} originalName
|
|
3731
|
+
* @return {string}
|
|
3732
|
+
*/
|
|
3689
3733
|
createUniqueName( originalName ) {
|
|
3690
3734
|
|
|
3691
3735
|
const sanitizedName = PropertyBinding.sanitizeNodeName( originalName || '' );
|
|
@@ -3709,6 +3753,7 @@ class GLTFParser {
|
|
|
3709
3753
|
*
|
|
3710
3754
|
* Creates BufferGeometries from primitives.
|
|
3711
3755
|
*
|
|
3756
|
+
* @private
|
|
3712
3757
|
* @param {Array<GLTF.Primitive>} primitives
|
|
3713
3758
|
* @return {Promise<Array<BufferGeometry>>}
|
|
3714
3759
|
*/
|
|
@@ -3776,8 +3821,10 @@ class GLTFParser {
|
|
|
3776
3821
|
|
|
3777
3822
|
/**
|
|
3778
3823
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
3824
|
+
*
|
|
3825
|
+
* @private
|
|
3779
3826
|
* @param {number} meshIndex
|
|
3780
|
-
* @return {Promise<Group|Mesh|SkinnedMesh>}
|
|
3827
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
3781
3828
|
*/
|
|
3782
3829
|
loadMesh( meshIndex ) {
|
|
3783
3830
|
|
|
@@ -3924,8 +3971,10 @@ class GLTFParser {
|
|
|
3924
3971
|
|
|
3925
3972
|
/**
|
|
3926
3973
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
3974
|
+
*
|
|
3975
|
+
* @private
|
|
3927
3976
|
* @param {number} cameraIndex
|
|
3928
|
-
* @return {Promise<
|
|
3977
|
+
* @return {Promise<Camera>|undefined}
|
|
3929
3978
|
*/
|
|
3930
3979
|
loadCamera( cameraIndex ) {
|
|
3931
3980
|
|
|
@@ -3960,6 +4009,8 @@ class GLTFParser {
|
|
|
3960
4009
|
|
|
3961
4010
|
/**
|
|
3962
4011
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
4012
|
+
*
|
|
4013
|
+
* @private
|
|
3963
4014
|
* @param {number} skinIndex
|
|
3964
4015
|
* @return {Promise<Skeleton>}
|
|
3965
4016
|
*/
|
|
@@ -4030,6 +4081,8 @@ class GLTFParser {
|
|
|
4030
4081
|
|
|
4031
4082
|
/**
|
|
4032
4083
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
4084
|
+
*
|
|
4085
|
+
* @private
|
|
4033
4086
|
* @param {number} animationIndex
|
|
4034
4087
|
* @return {Promise<AnimationClip>}
|
|
4035
4088
|
*/
|
|
@@ -4116,7 +4169,11 @@ class GLTFParser {
|
|
|
4116
4169
|
|
|
4117
4170
|
}
|
|
4118
4171
|
|
|
4119
|
-
|
|
4172
|
+
const animation = new AnimationClip( animationName, undefined, tracks );
|
|
4173
|
+
|
|
4174
|
+
assignExtrasToUserData( animation, animationDef );
|
|
4175
|
+
|
|
4176
|
+
return animation;
|
|
4120
4177
|
|
|
4121
4178
|
} );
|
|
4122
4179
|
|
|
@@ -4159,6 +4216,8 @@ class GLTFParser {
|
|
|
4159
4216
|
|
|
4160
4217
|
/**
|
|
4161
4218
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
4219
|
+
*
|
|
4220
|
+
* @private
|
|
4162
4221
|
* @param {number} nodeIndex
|
|
4163
4222
|
* @return {Promise<Object3D>}
|
|
4164
4223
|
*/
|
|
@@ -4214,6 +4273,28 @@ class GLTFParser {
|
|
|
4214
4273
|
|
|
4215
4274
|
}
|
|
4216
4275
|
|
|
4276
|
+
// Reconstruct pivot from container pattern created by GLTFExporter
|
|
4277
|
+
// The container has position+pivot, rotation, scale; child has -pivot offset and mesh
|
|
4278
|
+
if ( node.userData.pivot !== undefined && children.length > 0 ) {
|
|
4279
|
+
|
|
4280
|
+
const pivot = node.userData.pivot;
|
|
4281
|
+
const pivotChild = children[ 0 ];
|
|
4282
|
+
|
|
4283
|
+
// Set pivot on container and adjust transforms
|
|
4284
|
+
node.pivot = new Vector3().fromArray( pivot );
|
|
4285
|
+
|
|
4286
|
+
// Adjust container position: stored as position + pivot, so subtract pivot
|
|
4287
|
+
node.position.x -= pivot[ 0 ];
|
|
4288
|
+
node.position.y -= pivot[ 1 ];
|
|
4289
|
+
node.position.z -= pivot[ 2 ];
|
|
4290
|
+
|
|
4291
|
+
// Remove the child's -pivot offset since pivot now handles it
|
|
4292
|
+
pivotChild.position.set( 0, 0, 0 );
|
|
4293
|
+
|
|
4294
|
+
delete node.userData.pivot;
|
|
4295
|
+
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4217
4298
|
return node;
|
|
4218
4299
|
|
|
4219
4300
|
} );
|
|
@@ -4352,6 +4433,11 @@ class GLTFParser {
|
|
|
4352
4433
|
|
|
4353
4434
|
parser.associations.set( node, {} );
|
|
4354
4435
|
|
|
4436
|
+
} else if ( nodeDef.mesh !== undefined && parser.meshCache.refs[ nodeDef.mesh ] > 1 ) {
|
|
4437
|
+
|
|
4438
|
+
const mapping = parser.associations.get( node );
|
|
4439
|
+
parser.associations.set( node, { ...mapping } );
|
|
4440
|
+
|
|
4355
4441
|
}
|
|
4356
4442
|
|
|
4357
4443
|
parser.associations.get( node ).nodes = nodeIndex;
|
|
@@ -4366,6 +4452,8 @@ class GLTFParser {
|
|
|
4366
4452
|
|
|
4367
4453
|
/**
|
|
4368
4454
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
4455
|
+
*
|
|
4456
|
+
* @private
|
|
4369
4457
|
* @param {number} sceneIndex
|
|
4370
4458
|
* @return {Promise<Group>}
|
|
4371
4459
|
*/
|
|
@@ -4398,7 +4486,20 @@ class GLTFParser {
|
|
|
4398
4486
|
|
|
4399
4487
|
for ( let i = 0, il = nodes.length; i < il; i ++ ) {
|
|
4400
4488
|
|
|
4401
|
-
|
|
4489
|
+
const node = nodes[ i ];
|
|
4490
|
+
|
|
4491
|
+
// If the node already has a parent, it means it's being reused across multiple scenes.
|
|
4492
|
+
// Clone it to avoid the second scene's add() removing it from the first scene.
|
|
4493
|
+
// See: https://github.com/mrdoob/three.js/issues/27993
|
|
4494
|
+
if ( node.parent !== null ) {
|
|
4495
|
+
|
|
4496
|
+
scene.add( clone( node ) );
|
|
4497
|
+
|
|
4498
|
+
} else {
|
|
4499
|
+
|
|
4500
|
+
scene.add( node );
|
|
4501
|
+
|
|
4502
|
+
}
|
|
4402
4503
|
|
|
4403
4504
|
}
|
|
4404
4505
|
|
|
@@ -4481,7 +4582,7 @@ class GLTFParser {
|
|
|
4481
4582
|
TypedKeyframeTrack = QuaternionKeyframeTrack;
|
|
4482
4583
|
break;
|
|
4483
4584
|
|
|
4484
|
-
case PATH_PROPERTIES.
|
|
4585
|
+
case PATH_PROPERTIES.translation:
|
|
4485
4586
|
case PATH_PROPERTIES.scale:
|
|
4486
4587
|
|
|
4487
4588
|
TypedKeyframeTrack = VectorKeyframeTrack;
|
|
@@ -4580,6 +4681,8 @@ class GLTFParser {
|
|
|
4580
4681
|
}
|
|
4581
4682
|
|
|
4582
4683
|
/**
|
|
4684
|
+
*
|
|
4685
|
+
* @private
|
|
4583
4686
|
* @param {BufferGeometry} geometry
|
|
4584
4687
|
* @param {GLTF.Primitive} primitiveDef
|
|
4585
4688
|
* @param {GLTFParser} parser
|
|
@@ -4695,6 +4798,8 @@ function computeBounds( geometry, primitiveDef, parser ) {
|
|
|
4695
4798
|
}
|
|
4696
4799
|
|
|
4697
4800
|
/**
|
|
4801
|
+
*
|
|
4802
|
+
* @private
|
|
4698
4803
|
* @param {BufferGeometry} geometry
|
|
4699
4804
|
* @param {GLTF.Primitive} primitiveDef
|
|
4700
4805
|
* @param {GLTFParser} parser
|
|
@@ -4760,4 +4865,17 @@ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
|
|
|
4760
4865
|
|
|
4761
4866
|
}
|
|
4762
4867
|
|
|
4868
|
+
/**
|
|
4869
|
+
* Loader result of `GLTFLoader`.
|
|
4870
|
+
*
|
|
4871
|
+
* @typedef {Object} GLTFLoader~LoadObject
|
|
4872
|
+
* @property {Array<AnimationClip>} animations - An array of animation clips.
|
|
4873
|
+
* @property {Object} asset - Meta data about the loaded asset.
|
|
4874
|
+
* @property {Array<Camera>} cameras - An array of cameras.
|
|
4875
|
+
* @property {GLTFParser} parser - A reference to the internal parser.
|
|
4876
|
+
* @property {Group} scene - The default scene.
|
|
4877
|
+
* @property {Array<Group>} scenes - glTF assets might define multiple scenes.
|
|
4878
|
+
* @property {Object} userData - Additional data.
|
|
4879
|
+
**/
|
|
4880
|
+
|
|
4763
4881
|
export { GLTFLoader };
|