@plastic-software/three 0.181.3 → 0.183.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 +3 -4
- package/build/three.cjs +11330 -10017
- package/build/three.core.js +10011 -9493
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1414 -631
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +21 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +8007 -5427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +8005 -5426
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +109 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +74 -14
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Parameters.js +18 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +973 -14
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -4
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +19 -3
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +4 -2
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +79 -2
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +127 -10
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +9 -5
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +193 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +5 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +7 -6
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +8 -20
- package/examples/jsm/tsl/display/SSRNode.js +8 -8
- package/examples/jsm/tsl/display/SSSNode.js +6 -4
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +273 -125
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +20 -26
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +19 -11
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +90 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +1 -25
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +21 -2
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +7 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +72 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +10 -4
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +74 -65
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +3 -5
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +6 -6
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +4 -21
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +4 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +170 -53
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +10 -8
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +3 -3
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +65 -16
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +16 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +47 -22
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +39 -4
- package/src/nodes/display/PassNode.js +98 -9
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +3 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +4 -4
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +97 -41
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +17 -14
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +3 -4
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +27 -14
- package/src/objects/InstancedMesh.js +11 -0
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +178 -92
- package/src/renderers/common/Backend.js +29 -0
- package/src/renderers/common/Background.js +24 -11
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +27 -12
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +15 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +257 -72
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +17 -1
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +61 -0
- package/src/renderers/common/XRManager.js +3 -2
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- 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/envmap_fragment.glsl.js +7 -11
- 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 +112 -51
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- 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.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- 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 +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- 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 +45 -109
- package/src/renderers/webgl/WebGLPrograms.js +45 -49
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +32 -37
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +148 -18
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +156 -35
- package/src/renderers/webgl-fallback/utils/WebGLState.js +181 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +119 -13
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +322 -68
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +61 -23
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +65 -42
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +17 -11
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +3 -3
- package/src/utils.js +258 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -66,11 +66,12 @@ 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
|
|
|
70
71
|
/**
|
|
71
72
|
* A loader for the glTF 2.0 format.
|
|
72
73
|
*
|
|
73
|
-
* [glTF](https://www.khronos.org/gltf/
|
|
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)
|
|
74
75
|
* for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb)
|
|
75
76
|
* format. External files store textures (.jpg, .png) and additional binary data (.bin). A glTF asset may deliver
|
|
76
77
|
* one or more scenes, including meshes, materials, textures, skins, skeletons, morph targets, animations, lights,
|
|
@@ -91,6 +92,7 @@ import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
|
|
|
91
92
|
* - KHR_materials_unlit
|
|
92
93
|
* - KHR_materials_volume
|
|
93
94
|
* - KHR_mesh_quantization
|
|
95
|
+
* - KHR_meshopt_compression
|
|
94
96
|
* - KHR_lights_punctual
|
|
95
97
|
* - KHR_texture_basisu
|
|
96
98
|
* - KHR_texture_transform
|
|
@@ -228,7 +230,13 @@ class GLTFLoader extends Loader {
|
|
|
228
230
|
|
|
229
231
|
this.register( function ( parser ) {
|
|
230
232
|
|
|
231
|
-
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 );
|
|
232
240
|
|
|
233
241
|
} );
|
|
234
242
|
|
|
@@ -407,7 +415,7 @@ class GLTFLoader extends Loader {
|
|
|
407
415
|
}
|
|
408
416
|
|
|
409
417
|
/**
|
|
410
|
-
* Parses the given
|
|
418
|
+
* Parses the given glTF data and returns the resulting group.
|
|
411
419
|
*
|
|
412
420
|
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
413
421
|
* @param {string} path - The URL base path.
|
|
@@ -599,6 +607,20 @@ function GLTFRegistry() {
|
|
|
599
607
|
/********** EXTENSIONS ***********/
|
|
600
608
|
/*********************************/
|
|
601
609
|
|
|
610
|
+
function getMaterialExtension( parser, materialIndex, extensionName ) {
|
|
611
|
+
|
|
612
|
+
const materialDef = parser.json.materials[ materialIndex ];
|
|
613
|
+
|
|
614
|
+
if ( materialDef.extensions && materialDef.extensions[ extensionName ] ) {
|
|
615
|
+
|
|
616
|
+
return materialDef.extensions[ extensionName ];
|
|
617
|
+
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return null;
|
|
621
|
+
|
|
622
|
+
}
|
|
623
|
+
|
|
602
624
|
const EXTENSIONS = {
|
|
603
625
|
KHR_BINARY_GLTF: 'KHR_binary_glTF',
|
|
604
626
|
KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
|
|
@@ -621,6 +643,7 @@ const EXTENSIONS = {
|
|
|
621
643
|
EXT_TEXTURE_WEBP: 'EXT_texture_webp',
|
|
622
644
|
EXT_TEXTURE_AVIF: 'EXT_texture_avif',
|
|
623
645
|
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
|
|
646
|
+
KHR_MESHOPT_COMPRESSION: 'KHR_meshopt_compression',
|
|
624
647
|
EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
|
|
625
648
|
};
|
|
626
649
|
|
|
@@ -835,20 +858,13 @@ class GLTFMaterialsEmissiveStrengthExtension {
|
|
|
835
858
|
|
|
836
859
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
837
860
|
|
|
838
|
-
const
|
|
839
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
840
|
-
|
|
841
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
861
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
842
862
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
}
|
|
863
|
+
if ( extension === null ) return Promise.resolve();
|
|
846
864
|
|
|
847
|
-
|
|
865
|
+
if ( extension.emissiveStrength !== undefined ) {
|
|
848
866
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
materialParams.emissiveIntensity = emissiveStrength;
|
|
867
|
+
materialParams.emissiveIntensity = extension.emissiveStrength;
|
|
852
868
|
|
|
853
869
|
}
|
|
854
870
|
|
|
@@ -876,30 +892,20 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
876
892
|
|
|
877
893
|
getMaterialType( materialIndex ) {
|
|
878
894
|
|
|
879
|
-
const
|
|
880
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
881
|
-
|
|
882
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
895
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
883
896
|
|
|
884
|
-
return MeshPhysicalMaterial;
|
|
897
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
885
898
|
|
|
886
899
|
}
|
|
887
900
|
|
|
888
901
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
889
902
|
|
|
890
|
-
const
|
|
891
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
892
|
-
|
|
893
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
894
|
-
|
|
895
|
-
return Promise.resolve();
|
|
903
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
896
904
|
|
|
897
|
-
|
|
905
|
+
if ( extension === null ) return Promise.resolve();
|
|
898
906
|
|
|
899
907
|
const pending = [];
|
|
900
908
|
|
|
901
|
-
const extension = materialDef.extensions[ this.name ];
|
|
902
|
-
|
|
903
909
|
if ( extension.clearcoatFactor !== undefined ) {
|
|
904
910
|
|
|
905
911
|
materialParams.clearcoat = extension.clearcoatFactor;
|
|
@@ -908,7 +914,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
908
914
|
|
|
909
915
|
if ( extension.clearcoatTexture !== undefined ) {
|
|
910
916
|
|
|
911
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
|
|
917
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
|
|
912
918
|
|
|
913
919
|
}
|
|
914
920
|
|
|
@@ -920,13 +926,13 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
920
926
|
|
|
921
927
|
if ( extension.clearcoatRoughnessTexture !== undefined ) {
|
|
922
928
|
|
|
923
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
|
|
929
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
|
|
924
930
|
|
|
925
931
|
}
|
|
926
932
|
|
|
927
933
|
if ( extension.clearcoatNormalTexture !== undefined ) {
|
|
928
934
|
|
|
929
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
|
|
935
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
|
|
930
936
|
|
|
931
937
|
if ( extension.clearcoatNormalTexture.scale !== undefined ) {
|
|
932
938
|
|
|
@@ -962,27 +968,17 @@ class GLTFMaterialsDispersionExtension {
|
|
|
962
968
|
|
|
963
969
|
getMaterialType( materialIndex ) {
|
|
964
970
|
|
|
965
|
-
const
|
|
966
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
971
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
967
972
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
return MeshPhysicalMaterial;
|
|
973
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
971
974
|
|
|
972
975
|
}
|
|
973
976
|
|
|
974
977
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
975
978
|
|
|
976
|
-
const
|
|
977
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
978
|
-
|
|
979
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
979
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
980
980
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
const extension = materialDef.extensions[ this.name ];
|
|
981
|
+
if ( extension === null ) return Promise.resolve();
|
|
986
982
|
|
|
987
983
|
materialParams.dispersion = extension.dispersion !== undefined ? extension.dispersion : 0;
|
|
988
984
|
|
|
@@ -1010,30 +1006,20 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
1010
1006
|
|
|
1011
1007
|
getMaterialType( materialIndex ) {
|
|
1012
1008
|
|
|
1013
|
-
const
|
|
1014
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1009
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1015
1010
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
return MeshPhysicalMaterial;
|
|
1011
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1019
1012
|
|
|
1020
1013
|
}
|
|
1021
1014
|
|
|
1022
1015
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1023
1016
|
|
|
1024
|
-
const
|
|
1025
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1026
|
-
|
|
1027
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1017
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1028
1018
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1019
|
+
if ( extension === null ) return Promise.resolve();
|
|
1032
1020
|
|
|
1033
1021
|
const pending = [];
|
|
1034
1022
|
|
|
1035
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1036
|
-
|
|
1037
1023
|
if ( extension.iridescenceFactor !== undefined ) {
|
|
1038
1024
|
|
|
1039
1025
|
materialParams.iridescence = extension.iridescenceFactor;
|
|
@@ -1042,7 +1028,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
1042
1028
|
|
|
1043
1029
|
if ( extension.iridescenceTexture !== undefined ) {
|
|
1044
1030
|
|
|
1045
|
-
pending.push( parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
|
|
1031
|
+
pending.push( this.parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
|
|
1046
1032
|
|
|
1047
1033
|
}
|
|
1048
1034
|
|
|
@@ -1072,7 +1058,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
1072
1058
|
|
|
1073
1059
|
if ( extension.iridescenceThicknessTexture !== undefined ) {
|
|
1074
1060
|
|
|
1075
|
-
pending.push( parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
|
|
1061
|
+
pending.push( this.parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
|
|
1076
1062
|
|
|
1077
1063
|
}
|
|
1078
1064
|
|
|
@@ -1100,25 +1086,17 @@ class GLTFMaterialsSheenExtension {
|
|
|
1100
1086
|
|
|
1101
1087
|
getMaterialType( materialIndex ) {
|
|
1102
1088
|
|
|
1103
|
-
const
|
|
1104
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1105
|
-
|
|
1106
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1089
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1107
1090
|
|
|
1108
|
-
return MeshPhysicalMaterial;
|
|
1091
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1109
1092
|
|
|
1110
1093
|
}
|
|
1111
1094
|
|
|
1112
1095
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1113
1096
|
|
|
1114
|
-
const
|
|
1115
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1116
|
-
|
|
1117
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1097
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1118
1098
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1099
|
+
if ( extension === null ) return Promise.resolve();
|
|
1122
1100
|
|
|
1123
1101
|
const pending = [];
|
|
1124
1102
|
|
|
@@ -1126,8 +1104,6 @@ class GLTFMaterialsSheenExtension {
|
|
|
1126
1104
|
materialParams.sheenRoughness = 0;
|
|
1127
1105
|
materialParams.sheen = 1;
|
|
1128
1106
|
|
|
1129
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1130
|
-
|
|
1131
1107
|
if ( extension.sheenColorFactor !== undefined ) {
|
|
1132
1108
|
|
|
1133
1109
|
const colorFactor = extension.sheenColorFactor;
|
|
@@ -1143,13 +1119,13 @@ class GLTFMaterialsSheenExtension {
|
|
|
1143
1119
|
|
|
1144
1120
|
if ( extension.sheenColorTexture !== undefined ) {
|
|
1145
1121
|
|
|
1146
|
-
pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
|
|
1122
|
+
pending.push( this.parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
|
|
1147
1123
|
|
|
1148
1124
|
}
|
|
1149
1125
|
|
|
1150
1126
|
if ( extension.sheenRoughnessTexture !== undefined ) {
|
|
1151
1127
|
|
|
1152
|
-
pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
|
|
1128
|
+
pending.push( this.parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
|
|
1153
1129
|
|
|
1154
1130
|
}
|
|
1155
1131
|
|
|
@@ -1178,30 +1154,20 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
1178
1154
|
|
|
1179
1155
|
getMaterialType( materialIndex ) {
|
|
1180
1156
|
|
|
1181
|
-
const
|
|
1182
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1183
|
-
|
|
1184
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1157
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1185
1158
|
|
|
1186
|
-
return MeshPhysicalMaterial;
|
|
1159
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1187
1160
|
|
|
1188
1161
|
}
|
|
1189
1162
|
|
|
1190
1163
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1191
1164
|
|
|
1192
|
-
const
|
|
1193
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1194
|
-
|
|
1195
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1196
|
-
|
|
1197
|
-
return Promise.resolve();
|
|
1165
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1198
1166
|
|
|
1199
|
-
|
|
1167
|
+
if ( extension === null ) return Promise.resolve();
|
|
1200
1168
|
|
|
1201
1169
|
const pending = [];
|
|
1202
1170
|
|
|
1203
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1204
|
-
|
|
1205
1171
|
if ( extension.transmissionFactor !== undefined ) {
|
|
1206
1172
|
|
|
1207
1173
|
materialParams.transmission = extension.transmissionFactor;
|
|
@@ -1210,7 +1176,7 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
1210
1176
|
|
|
1211
1177
|
if ( extension.transmissionTexture !== undefined ) {
|
|
1212
1178
|
|
|
1213
|
-
pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
|
|
1179
|
+
pending.push( this.parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
|
|
1214
1180
|
|
|
1215
1181
|
}
|
|
1216
1182
|
|
|
@@ -1238,35 +1204,25 @@ class GLTFMaterialsVolumeExtension {
|
|
|
1238
1204
|
|
|
1239
1205
|
getMaterialType( materialIndex ) {
|
|
1240
1206
|
|
|
1241
|
-
const
|
|
1242
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1243
|
-
|
|
1244
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1207
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1245
1208
|
|
|
1246
|
-
return MeshPhysicalMaterial;
|
|
1209
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1247
1210
|
|
|
1248
1211
|
}
|
|
1249
1212
|
|
|
1250
1213
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1251
1214
|
|
|
1252
|
-
const
|
|
1253
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1215
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1254
1216
|
|
|
1255
|
-
if (
|
|
1256
|
-
|
|
1257
|
-
return Promise.resolve();
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1217
|
+
if ( extension === null ) return Promise.resolve();
|
|
1260
1218
|
|
|
1261
1219
|
const pending = [];
|
|
1262
1220
|
|
|
1263
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1264
|
-
|
|
1265
1221
|
materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0;
|
|
1266
1222
|
|
|
1267
1223
|
if ( extension.thicknessTexture !== undefined ) {
|
|
1268
1224
|
|
|
1269
|
-
pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
|
|
1225
|
+
pending.push( this.parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
|
|
1270
1226
|
|
|
1271
1227
|
}
|
|
1272
1228
|
|
|
@@ -1299,27 +1255,17 @@ class GLTFMaterialsIorExtension {
|
|
|
1299
1255
|
|
|
1300
1256
|
getMaterialType( materialIndex ) {
|
|
1301
1257
|
|
|
1302
|
-
const
|
|
1303
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1304
|
-
|
|
1305
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1258
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1306
1259
|
|
|
1307
|
-
return MeshPhysicalMaterial;
|
|
1260
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1308
1261
|
|
|
1309
1262
|
}
|
|
1310
1263
|
|
|
1311
1264
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1312
1265
|
|
|
1313
|
-
const
|
|
1314
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1266
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1315
1267
|
|
|
1316
|
-
if (
|
|
1317
|
-
|
|
1318
|
-
return Promise.resolve();
|
|
1319
|
-
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1268
|
+
if ( extension === null ) return Promise.resolve();
|
|
1323
1269
|
|
|
1324
1270
|
materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5;
|
|
1325
1271
|
|
|
@@ -1347,35 +1293,25 @@ class GLTFMaterialsSpecularExtension {
|
|
|
1347
1293
|
|
|
1348
1294
|
getMaterialType( materialIndex ) {
|
|
1349
1295
|
|
|
1350
|
-
const
|
|
1351
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1352
|
-
|
|
1353
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1296
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1354
1297
|
|
|
1355
|
-
return MeshPhysicalMaterial;
|
|
1298
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1356
1299
|
|
|
1357
1300
|
}
|
|
1358
1301
|
|
|
1359
1302
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1360
1303
|
|
|
1361
|
-
const
|
|
1362
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1304
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1363
1305
|
|
|
1364
|
-
if (
|
|
1365
|
-
|
|
1366
|
-
return Promise.resolve();
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1306
|
+
if ( extension === null ) return Promise.resolve();
|
|
1369
1307
|
|
|
1370
1308
|
const pending = [];
|
|
1371
1309
|
|
|
1372
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1373
|
-
|
|
1374
1310
|
materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;
|
|
1375
1311
|
|
|
1376
1312
|
if ( extension.specularTexture !== undefined ) {
|
|
1377
1313
|
|
|
1378
|
-
pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
|
|
1314
|
+
pending.push( this.parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
|
|
1379
1315
|
|
|
1380
1316
|
}
|
|
1381
1317
|
|
|
@@ -1384,7 +1320,7 @@ class GLTFMaterialsSpecularExtension {
|
|
|
1384
1320
|
|
|
1385
1321
|
if ( extension.specularColorTexture !== undefined ) {
|
|
1386
1322
|
|
|
1387
|
-
pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
|
|
1323
|
+
pending.push( this.parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
|
|
1388
1324
|
|
|
1389
1325
|
}
|
|
1390
1326
|
|
|
@@ -1413,35 +1349,25 @@ class GLTFMaterialsBumpExtension {
|
|
|
1413
1349
|
|
|
1414
1350
|
getMaterialType( materialIndex ) {
|
|
1415
1351
|
|
|
1416
|
-
const
|
|
1417
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1418
|
-
|
|
1419
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1352
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1420
1353
|
|
|
1421
|
-
return MeshPhysicalMaterial;
|
|
1354
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1422
1355
|
|
|
1423
1356
|
}
|
|
1424
1357
|
|
|
1425
1358
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1426
1359
|
|
|
1427
|
-
const
|
|
1428
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1429
|
-
|
|
1430
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1360
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1431
1361
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
}
|
|
1362
|
+
if ( extension === null ) return Promise.resolve();
|
|
1435
1363
|
|
|
1436
1364
|
const pending = [];
|
|
1437
1365
|
|
|
1438
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1439
|
-
|
|
1440
1366
|
materialParams.bumpScale = extension.bumpFactor !== undefined ? extension.bumpFactor : 1.0;
|
|
1441
1367
|
|
|
1442
1368
|
if ( extension.bumpTexture !== undefined ) {
|
|
1443
1369
|
|
|
1444
|
-
pending.push( parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
|
|
1370
|
+
pending.push( this.parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
|
|
1445
1371
|
|
|
1446
1372
|
}
|
|
1447
1373
|
|
|
@@ -1469,30 +1395,20 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
1469
1395
|
|
|
1470
1396
|
getMaterialType( materialIndex ) {
|
|
1471
1397
|
|
|
1472
|
-
const
|
|
1473
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1474
|
-
|
|
1475
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1398
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1476
1399
|
|
|
1477
|
-
return MeshPhysicalMaterial;
|
|
1400
|
+
return extension !== null ? MeshPhysicalMaterial : null;
|
|
1478
1401
|
|
|
1479
1402
|
}
|
|
1480
1403
|
|
|
1481
1404
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
1482
1405
|
|
|
1483
|
-
const
|
|
1484
|
-
const materialDef = parser.json.materials[ materialIndex ];
|
|
1485
|
-
|
|
1486
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1406
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
1487
1407
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
}
|
|
1408
|
+
if ( extension === null ) return Promise.resolve();
|
|
1491
1409
|
|
|
1492
1410
|
const pending = [];
|
|
1493
1411
|
|
|
1494
|
-
const extension = materialDef.extensions[ this.name ];
|
|
1495
|
-
|
|
1496
1412
|
if ( extension.anisotropyStrength !== undefined ) {
|
|
1497
1413
|
|
|
1498
1414
|
materialParams.anisotropy = extension.anisotropyStrength;
|
|
@@ -1507,7 +1423,7 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
1507
1423
|
|
|
1508
1424
|
if ( extension.anisotropyTexture !== undefined ) {
|
|
1509
1425
|
|
|
1510
|
-
pending.push( parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
1426
|
+
pending.push( this.parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
1511
1427
|
|
|
1512
1428
|
}
|
|
1513
1429
|
|
|
@@ -1673,9 +1589,9 @@ class GLTFTextureAVIFExtension {
|
|
|
1673
1589
|
*/
|
|
1674
1590
|
class GLTFMeshoptCompression {
|
|
1675
1591
|
|
|
1676
|
-
constructor( parser ) {
|
|
1592
|
+
constructor( parser, name ) {
|
|
1677
1593
|
|
|
1678
|
-
this.name =
|
|
1594
|
+
this.name = name;
|
|
1679
1595
|
this.parser = parser;
|
|
1680
1596
|
|
|
1681
1597
|
}
|
|
@@ -2662,7 +2578,7 @@ class GLTFParser {
|
|
|
2662
2578
|
let isFirefox = false;
|
|
2663
2579
|
let firefoxVersion = - 1;
|
|
2664
2580
|
|
|
2665
|
-
if ( typeof navigator !== 'undefined' ) {
|
|
2581
|
+
if ( typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined' ) {
|
|
2666
2582
|
|
|
2667
2583
|
const userAgent = navigator.userAgent;
|
|
2668
2584
|
|
|
@@ -4319,6 +4235,28 @@ class GLTFParser {
|
|
|
4319
4235
|
|
|
4320
4236
|
}
|
|
4321
4237
|
|
|
4238
|
+
// Reconstruct pivot from container pattern created by GLTFExporter
|
|
4239
|
+
// The container has position+pivot, rotation, scale; child has -pivot offset and mesh
|
|
4240
|
+
if ( node.userData.pivot !== undefined && children.length > 0 ) {
|
|
4241
|
+
|
|
4242
|
+
const pivot = node.userData.pivot;
|
|
4243
|
+
const pivotChild = children[ 0 ];
|
|
4244
|
+
|
|
4245
|
+
// Set pivot on container and adjust transforms
|
|
4246
|
+
node.pivot = new Vector3().fromArray( pivot );
|
|
4247
|
+
|
|
4248
|
+
// Adjust container position: stored as position + pivot, so subtract pivot
|
|
4249
|
+
node.position.x -= pivot[ 0 ];
|
|
4250
|
+
node.position.y -= pivot[ 1 ];
|
|
4251
|
+
node.position.z -= pivot[ 2 ];
|
|
4252
|
+
|
|
4253
|
+
// Remove the child's -pivot offset since pivot now handles it
|
|
4254
|
+
pivotChild.position.set( 0, 0, 0 );
|
|
4255
|
+
|
|
4256
|
+
delete node.userData.pivot;
|
|
4257
|
+
|
|
4258
|
+
}
|
|
4259
|
+
|
|
4322
4260
|
return node;
|
|
4323
4261
|
|
|
4324
4262
|
} );
|
|
@@ -4510,7 +4448,20 @@ class GLTFParser {
|
|
|
4510
4448
|
|
|
4511
4449
|
for ( let i = 0, il = nodes.length; i < il; i ++ ) {
|
|
4512
4450
|
|
|
4513
|
-
|
|
4451
|
+
const node = nodes[ i ];
|
|
4452
|
+
|
|
4453
|
+
// If the node already has a parent, it means it's being reused across multiple scenes.
|
|
4454
|
+
// Clone it to avoid the second scene's add() removing it from the first scene.
|
|
4455
|
+
// See: https://github.com/mrdoob/three.js/issues/27993
|
|
4456
|
+
if ( node.parent !== null ) {
|
|
4457
|
+
|
|
4458
|
+
scene.add( clone( node ) );
|
|
4459
|
+
|
|
4460
|
+
} else {
|
|
4461
|
+
|
|
4462
|
+
scene.add( node );
|
|
4463
|
+
|
|
4464
|
+
}
|
|
4514
4465
|
|
|
4515
4466
|
}
|
|
4516
4467
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
LoadingManager
|
|
6
6
|
} from 'three';
|
|
7
7
|
import { ColladaLoader } from '../loaders/ColladaLoader.js';
|
|
8
|
-
import
|
|
8
|
+
import { unzipSync } from '../libs/fflate.module.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A loader for the KMZ format.
|
|
@@ -119,18 +119,18 @@ class KMZLoader extends Loader {
|
|
|
119
119
|
|
|
120
120
|
//
|
|
121
121
|
|
|
122
|
-
const zip =
|
|
122
|
+
const zip = unzipSync( new Uint8Array( data ) );
|
|
123
123
|
|
|
124
124
|
if ( zip[ 'doc.kml' ] ) {
|
|
125
125
|
|
|
126
|
-
const xml = new DOMParser().parseFromString(
|
|
126
|
+
const xml = new DOMParser().parseFromString( new TextDecoder().decode( zip[ 'doc.kml' ] ), 'application/xml' );
|
|
127
127
|
|
|
128
128
|
const model = xml.querySelector( 'Placemark Model Link href' );
|
|
129
129
|
|
|
130
130
|
if ( model ) {
|
|
131
131
|
|
|
132
132
|
const loader = new ColladaLoader( manager );
|
|
133
|
-
return loader.parse(
|
|
133
|
+
return loader.parse( new TextDecoder().decode( zip[ model.textContent ] ) );
|
|
134
134
|
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -145,7 +145,7 @@ class KMZLoader extends Loader {
|
|
|
145
145
|
if ( extension === 'dae' ) {
|
|
146
146
|
|
|
147
147
|
const loader = new ColladaLoader( manager );
|
|
148
|
-
return loader.parse(
|
|
148
|
+
return loader.parse( new TextDecoder().decode( zip[ path ] ) );
|
|
149
149
|
|
|
150
150
|
}
|
|
151
151
|
|