@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
|
@@ -31,14 +31,14 @@ import { WebGLBindingStates } from './webgl/WebGLBindingStates.js';
|
|
|
31
31
|
import { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';
|
|
32
32
|
import { WebGLCapabilities } from './webgl/WebGLCapabilities.js';
|
|
33
33
|
import { WebGLClipping } from './webgl/WebGLClipping.js';
|
|
34
|
-
import {
|
|
35
|
-
import { WebGLCubeUVMaps } from './webgl/WebGLCubeUVMaps.js';
|
|
34
|
+
import { WebGLEnvironments } from './webgl/WebGLEnvironments.js';
|
|
36
35
|
import { WebGLExtensions } from './webgl/WebGLExtensions.js';
|
|
37
36
|
import { WebGLGeometries } from './webgl/WebGLGeometries.js';
|
|
38
37
|
import { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';
|
|
39
38
|
import { WebGLInfo } from './webgl/WebGLInfo.js';
|
|
40
39
|
import { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';
|
|
41
40
|
import { WebGLObjects } from './webgl/WebGLObjects.js';
|
|
41
|
+
import { WebGLOutput } from './webgl/WebGLOutput.js';
|
|
42
42
|
import { WebGLPrograms } from './webgl/WebGLPrograms.js';
|
|
43
43
|
import { WebGLProperties } from './webgl/WebGLProperties.js';
|
|
44
44
|
import { WebGLRenderLists } from './webgl/WebGLRenderLists.js';
|
|
@@ -82,6 +82,7 @@ class WebGLRenderer {
|
|
|
82
82
|
powerPreference = 'default',
|
|
83
83
|
failIfMajorPerformanceCaveat = false,
|
|
84
84
|
reversedDepthBuffer = false,
|
|
85
|
+
outputBufferType = UnsignedByteType,
|
|
85
86
|
} = parameters;
|
|
86
87
|
|
|
87
88
|
/**
|
|
@@ -111,6 +112,8 @@ class WebGLRenderer {
|
|
|
111
112
|
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
const _outputBufferType = outputBufferType;
|
|
116
|
+
|
|
114
117
|
const INTEGER_FORMATS = new Set( [
|
|
115
118
|
RGBAIntegerFormat,
|
|
116
119
|
RGIntegerFormat,
|
|
@@ -138,10 +141,14 @@ class WebGLRenderer {
|
|
|
138
141
|
const renderListStack = [];
|
|
139
142
|
const renderStateStack = [];
|
|
140
143
|
|
|
144
|
+
// internal render target for non-UnsignedByteType color buffer
|
|
145
|
+
|
|
146
|
+
let output = null;
|
|
147
|
+
|
|
141
148
|
// public properties
|
|
142
149
|
|
|
143
150
|
/**
|
|
144
|
-
* A canvas where the renderer draws its output.This is automatically created by the renderer
|
|
151
|
+
* A canvas where the renderer draws its output. This is automatically created by the renderer
|
|
145
152
|
* in the constructor (if not provided already); you just need to add it to your page like so:
|
|
146
153
|
* ```js
|
|
147
154
|
* document.body.appendChild( renderer.domElement );
|
|
@@ -157,7 +164,7 @@ class WebGLRenderer {
|
|
|
157
164
|
* - `checkShaderErrors`: If it is `true`, defines whether material shader programs are
|
|
158
165
|
* checked for errors during compilation and linkage process. It may be useful to disable
|
|
159
166
|
* this check in production for performance gain. It is strongly recommended to keep these
|
|
160
|
-
* checks enabled during development. If the shader does not compile and link
|
|
167
|
+
* checks enabled during development. If the shader does not compile and link, it will not
|
|
161
168
|
* work and associated material will not render.
|
|
162
169
|
* - `onShaderError(gl, program, glVertexShader,glFragmentShader)`: A callback function that
|
|
163
170
|
* can be used for custom error reporting. The callback receives the WebGL context, an instance
|
|
@@ -398,15 +405,15 @@ class WebGLRenderer {
|
|
|
398
405
|
|
|
399
406
|
}
|
|
400
407
|
|
|
401
|
-
} catch (
|
|
408
|
+
} catch ( e ) {
|
|
402
409
|
|
|
403
|
-
error( 'WebGLRenderer: ' +
|
|
404
|
-
throw
|
|
410
|
+
error( 'WebGLRenderer: ' + e.message );
|
|
411
|
+
throw e;
|
|
405
412
|
|
|
406
413
|
}
|
|
407
414
|
|
|
408
415
|
let extensions, capabilities, state, info;
|
|
409
|
-
let properties, textures,
|
|
416
|
+
let properties, textures, environments, attributes, geometries, objects;
|
|
410
417
|
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
|
|
411
418
|
|
|
412
419
|
let background, morphtargets, bufferRenderer, indexedBufferRenderer;
|
|
@@ -433,19 +440,18 @@ class WebGLRenderer {
|
|
|
433
440
|
info = new WebGLInfo( _gl );
|
|
434
441
|
properties = new WebGLProperties();
|
|
435
442
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
436
|
-
|
|
437
|
-
cubeuvmaps = new WebGLCubeUVMaps( _this );
|
|
443
|
+
environments = new WebGLEnvironments( _this );
|
|
438
444
|
attributes = new WebGLAttributes( _gl );
|
|
439
445
|
bindingStates = new WebGLBindingStates( _gl, attributes );
|
|
440
446
|
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
441
|
-
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
447
|
+
objects = new WebGLObjects( _gl, geometries, attributes, bindingStates, info );
|
|
442
448
|
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
443
449
|
clipping = new WebGLClipping( properties );
|
|
444
|
-
programCache = new WebGLPrograms( _this,
|
|
450
|
+
programCache = new WebGLPrograms( _this, environments, extensions, capabilities, bindingStates, clipping );
|
|
445
451
|
materials = new WebGLMaterials( _this, properties );
|
|
446
452
|
renderLists = new WebGLRenderLists();
|
|
447
453
|
renderStates = new WebGLRenderStates( extensions );
|
|
448
|
-
background = new WebGLBackground( _this,
|
|
454
|
+
background = new WebGLBackground( _this, environments, state, objects, _alpha, premultipliedAlpha );
|
|
449
455
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
450
456
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
451
457
|
|
|
@@ -533,6 +539,14 @@ class WebGLRenderer {
|
|
|
533
539
|
|
|
534
540
|
initGLContext();
|
|
535
541
|
|
|
542
|
+
// initialize internal render target for non-UnsignedByteType color buffer
|
|
543
|
+
|
|
544
|
+
if ( _outputBufferType !== UnsignedByteType ) {
|
|
545
|
+
|
|
546
|
+
output = new WebGLOutput( _outputBufferType, canvas.width, canvas.height, depth, stencil );
|
|
547
|
+
|
|
548
|
+
}
|
|
549
|
+
|
|
536
550
|
// xr
|
|
537
551
|
|
|
538
552
|
const xr = new WebXRManager( _this, _gl );
|
|
@@ -655,6 +669,12 @@ class WebGLRenderer {
|
|
|
655
669
|
|
|
656
670
|
}
|
|
657
671
|
|
|
672
|
+
if ( output !== null ) {
|
|
673
|
+
|
|
674
|
+
output.setSize( canvas.width, canvas.height );
|
|
675
|
+
|
|
676
|
+
}
|
|
677
|
+
|
|
658
678
|
this.setViewport( 0, 0, width, height );
|
|
659
679
|
|
|
660
680
|
};
|
|
@@ -698,6 +718,39 @@ class WebGLRenderer {
|
|
|
698
718
|
|
|
699
719
|
};
|
|
700
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Sets the post-processing effects to be applied after rendering.
|
|
723
|
+
*
|
|
724
|
+
* @param {Array} effects - An array of post-processing effects.
|
|
725
|
+
*/
|
|
726
|
+
this.setEffects = function ( effects ) {
|
|
727
|
+
|
|
728
|
+
if ( _outputBufferType === UnsignedByteType ) {
|
|
729
|
+
|
|
730
|
+
console.error( 'THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.' );
|
|
731
|
+
return;
|
|
732
|
+
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if ( effects ) {
|
|
736
|
+
|
|
737
|
+
for ( let i = 0; i < effects.length; i ++ ) {
|
|
738
|
+
|
|
739
|
+
if ( effects[ i ].isOutputPass === true ) {
|
|
740
|
+
|
|
741
|
+
console.warn( 'THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.' );
|
|
742
|
+
break;
|
|
743
|
+
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
output.setEffects( effects || [] );
|
|
751
|
+
|
|
752
|
+
};
|
|
753
|
+
|
|
701
754
|
/**
|
|
702
755
|
* Returns the current viewport definition.
|
|
703
756
|
*
|
|
@@ -955,7 +1008,11 @@ class WebGLRenderer {
|
|
|
955
1008
|
|
|
956
1009
|
}
|
|
957
1010
|
|
|
958
|
-
|
|
1011
|
+
if ( bits !== 0 ) {
|
|
1012
|
+
|
|
1013
|
+
_gl.clear( bits );
|
|
1014
|
+
|
|
1015
|
+
}
|
|
959
1016
|
|
|
960
1017
|
};
|
|
961
1018
|
|
|
@@ -1000,8 +1057,7 @@ class WebGLRenderer {
|
|
|
1000
1057
|
renderLists.dispose();
|
|
1001
1058
|
renderStates.dispose();
|
|
1002
1059
|
properties.dispose();
|
|
1003
|
-
|
|
1004
|
-
cubeuvmaps.dispose();
|
|
1060
|
+
environments.dispose();
|
|
1005
1061
|
objects.dispose();
|
|
1006
1062
|
bindingStates.dispose();
|
|
1007
1063
|
uniformsGroups.dispose();
|
|
@@ -1547,6 +1603,12 @@ class WebGLRenderer {
|
|
|
1547
1603
|
|
|
1548
1604
|
if ( _isContextLost === true ) return;
|
|
1549
1605
|
|
|
1606
|
+
// use internal render target for HalfFloatType color buffer (only when tone mapping is enabled)
|
|
1607
|
+
|
|
1608
|
+
const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
|
|
1609
|
+
|
|
1610
|
+
const useOutput = output !== null && ( _currentRenderTarget === null || isXRPresenting ) && output.begin( _this, _currentRenderTarget );
|
|
1611
|
+
|
|
1550
1612
|
// update scene graph
|
|
1551
1613
|
|
|
1552
1614
|
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
@@ -1555,7 +1617,7 @@ class WebGLRenderer {
|
|
|
1555
1617
|
|
|
1556
1618
|
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
1557
1619
|
|
|
1558
|
-
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
1620
|
+
if ( xr.enabled === true && xr.isPresenting === true && ( output === null || output.isCompositing() === false ) ) {
|
|
1559
1621
|
|
|
1560
1622
|
if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
|
|
1561
1623
|
|
|
@@ -1627,46 +1689,52 @@ class WebGLRenderer {
|
|
|
1627
1689
|
|
|
1628
1690
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
1629
1691
|
|
|
1630
|
-
// render scene
|
|
1692
|
+
// render scene (skip if first effect is a render pass - it will render the scene itself)
|
|
1631
1693
|
|
|
1632
|
-
const
|
|
1633
|
-
const transmissiveObjects = currentRenderList.transmissive;
|
|
1694
|
+
const skipSceneRender = useOutput && output.hasRenderPass();
|
|
1634
1695
|
|
|
1635
|
-
|
|
1696
|
+
if ( skipSceneRender === false ) {
|
|
1636
1697
|
|
|
1637
|
-
|
|
1698
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
1699
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
1638
1700
|
|
|
1639
|
-
|
|
1701
|
+
currentRenderState.setupLights();
|
|
1640
1702
|
|
|
1641
|
-
if (
|
|
1703
|
+
if ( camera.isArrayCamera ) {
|
|
1642
1704
|
|
|
1643
|
-
|
|
1705
|
+
const cameras = camera.cameras;
|
|
1644
1706
|
|
|
1645
|
-
|
|
1707
|
+
if ( transmissiveObjects.length > 0 ) {
|
|
1646
1708
|
|
|
1647
|
-
|
|
1709
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1710
|
+
|
|
1711
|
+
const camera2 = cameras[ i ];
|
|
1712
|
+
|
|
1713
|
+
renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
|
|
1714
|
+
|
|
1715
|
+
}
|
|
1648
1716
|
|
|
1649
1717
|
}
|
|
1650
1718
|
|
|
1651
|
-
|
|
1719
|
+
if ( _renderBackground ) background.render( scene );
|
|
1652
1720
|
|
|
1653
|
-
|
|
1721
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1654
1722
|
|
|
1655
|
-
|
|
1723
|
+
const camera2 = cameras[ i ];
|
|
1656
1724
|
|
|
1657
|
-
|
|
1725
|
+
renderScene( currentRenderList, scene, camera2, camera2.viewport );
|
|
1658
1726
|
|
|
1659
|
-
|
|
1727
|
+
}
|
|
1660
1728
|
|
|
1661
|
-
}
|
|
1729
|
+
} else {
|
|
1662
1730
|
|
|
1663
|
-
|
|
1731
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
1664
1732
|
|
|
1665
|
-
|
|
1733
|
+
if ( _renderBackground ) background.render( scene );
|
|
1666
1734
|
|
|
1667
|
-
|
|
1735
|
+
renderScene( currentRenderList, scene, camera );
|
|
1668
1736
|
|
|
1669
|
-
|
|
1737
|
+
}
|
|
1670
1738
|
|
|
1671
1739
|
}
|
|
1672
1740
|
|
|
@@ -1684,6 +1752,14 @@ class WebGLRenderer {
|
|
|
1684
1752
|
|
|
1685
1753
|
}
|
|
1686
1754
|
|
|
1755
|
+
// copy from internal render target to canvas using fullscreen quad
|
|
1756
|
+
|
|
1757
|
+
if ( useOutput ) {
|
|
1758
|
+
|
|
1759
|
+
output.end( _this );
|
|
1760
|
+
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1687
1763
|
//
|
|
1688
1764
|
|
|
1689
1765
|
if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
|
|
@@ -1872,11 +1948,13 @@ class WebGLRenderer {
|
|
|
1872
1948
|
|
|
1873
1949
|
if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
|
|
1874
1950
|
|
|
1951
|
+
const hasHalfFloatSupport = extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' );
|
|
1952
|
+
|
|
1875
1953
|
currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
|
|
1876
1954
|
generateMipmaps: true,
|
|
1877
|
-
type:
|
|
1955
|
+
type: hasHalfFloatSupport ? HalfFloatType : UnsignedByteType,
|
|
1878
1956
|
minFilter: LinearMipmapLinearFilter,
|
|
1879
|
-
samples: 4,
|
|
1957
|
+
samples: Math.max( 4, capabilities.samples ), // to avoid feedback loops, the transmission render target requires a resolve, see #26177
|
|
1880
1958
|
stencilBuffer: stencil,
|
|
1881
1959
|
resolveDepthBuffer: false,
|
|
1882
1960
|
resolveStencilBuffer: false,
|
|
@@ -2058,9 +2136,11 @@ class WebGLRenderer {
|
|
|
2058
2136
|
|
|
2059
2137
|
// always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change
|
|
2060
2138
|
|
|
2061
|
-
materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
2139
|
+
materialProperties.environment = ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) ? scene.environment : null;
|
|
2062
2140
|
materialProperties.fog = scene.fog;
|
|
2063
|
-
|
|
2141
|
+
|
|
2142
|
+
const usePMREM = material.isMeshStandardMaterial || ( material.isMeshLambertMaterial && ! material.envMap ) || ( material.isMeshPhongMaterial && ! material.envMap );
|
|
2143
|
+
materialProperties.envMap = environments.get( material.envMap || materialProperties.environment, usePMREM );
|
|
2064
2144
|
materialProperties.envMapRotation = ( materialProperties.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
|
|
2065
2145
|
|
|
2066
2146
|
if ( programs === undefined ) {
|
|
@@ -2133,12 +2213,9 @@ class WebGLRenderer {
|
|
|
2133
2213
|
uniforms.pointLightShadows.value = lights.state.pointShadow;
|
|
2134
2214
|
uniforms.hemisphereLights.value = lights.state.hemi;
|
|
2135
2215
|
|
|
2136
|
-
uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
|
|
2137
2216
|
uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
|
|
2138
|
-
uniforms.spotShadowMap.value = lights.state.spotShadowMap;
|
|
2139
2217
|
uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
|
|
2140
2218
|
uniforms.spotLightMap.value = lights.state.spotLightMap;
|
|
2141
|
-
uniforms.pointShadowMap.value = lights.state.pointShadowMap;
|
|
2142
2219
|
uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
|
|
2143
2220
|
// TODO (abelnation): add area lights shadow info to uniforms
|
|
2144
2221
|
|
|
@@ -2194,9 +2271,10 @@ class WebGLRenderer {
|
|
|
2194
2271
|
textures.resetTextureUnits();
|
|
2195
2272
|
|
|
2196
2273
|
const fog = scene.fog;
|
|
2197
|
-
const environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
2274
|
+
const environment = ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) ? scene.environment : null;
|
|
2198
2275
|
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
|
|
2199
|
-
const
|
|
2276
|
+
const usePMREM = material.isMeshStandardMaterial || ( material.isMeshLambertMaterial && ! material.envMap ) || ( material.isMeshPhongMaterial && ! material.envMap );
|
|
2277
|
+
const envMap = environments.get( material.envMap || environment, usePMREM );
|
|
2200
2278
|
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
2201
2279
|
const vertexTangents = !! geometry.attributes.tangent && ( !! material.normalMap || material.anisotropy > 0 );
|
|
2202
2280
|
const morphTargets = !! geometry.morphAttributes.position;
|
|
@@ -2452,6 +2530,30 @@ class WebGLRenderer {
|
|
|
2452
2530
|
|
|
2453
2531
|
}
|
|
2454
2532
|
|
|
2533
|
+
// Pre-allocate texture units for shadow samplers before setting data textures
|
|
2534
|
+
if ( materialProperties.needsLights ) {
|
|
2535
|
+
|
|
2536
|
+
// Set shadow map uniforms first to ensure they get the first texture units
|
|
2537
|
+
if ( lights.state.directionalShadowMap.length > 0 ) {
|
|
2538
|
+
|
|
2539
|
+
p_uniforms.setValue( _gl, 'directionalShadowMap', lights.state.directionalShadowMap, textures );
|
|
2540
|
+
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
if ( lights.state.spotShadowMap.length > 0 ) {
|
|
2544
|
+
|
|
2545
|
+
p_uniforms.setValue( _gl, 'spotShadowMap', lights.state.spotShadowMap, textures );
|
|
2546
|
+
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
if ( lights.state.pointShadowMap.length > 0 ) {
|
|
2550
|
+
|
|
2551
|
+
p_uniforms.setValue( _gl, 'pointShadowMap', lights.state.pointShadowMap, textures );
|
|
2552
|
+
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2455
2557
|
// skinning and morph target uniforms must be set even if material didn't change
|
|
2456
2558
|
// auto-setting of texture unit for bone and morph texture must go before other textures
|
|
2457
2559
|
// otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
|
|
@@ -2513,17 +2615,7 @@ class WebGLRenderer {
|
|
|
2513
2615
|
|
|
2514
2616
|
}
|
|
2515
2617
|
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
if ( material.isMeshGouraudMaterial && material.envMap !== null ) {
|
|
2519
|
-
|
|
2520
|
-
m_uniforms.envMap.value = envMap;
|
|
2521
|
-
|
|
2522
|
-
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
2523
|
-
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
|
|
2618
|
+
if ( ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) && material.envMap === null && scene.environment !== null ) {
|
|
2527
2619
|
|
|
2528
2620
|
m_uniforms.envMapIntensity.value = scene.environmentIntensity;
|
|
2529
2621
|
|
|
@@ -2714,7 +2806,6 @@ class WebGLRenderer {
|
|
|
2714
2806
|
_currentActiveCubeFace = activeCubeFace;
|
|
2715
2807
|
_currentActiveMipmapLevel = activeMipmapLevel;
|
|
2716
2808
|
|
|
2717
|
-
let useDefaultFramebuffer = true;
|
|
2718
2809
|
let framebuffer = null;
|
|
2719
2810
|
let isCube = false;
|
|
2720
2811
|
let isRenderTarget3D = false;
|
|
@@ -2725,9 +2816,21 @@ class WebGLRenderer {
|
|
|
2725
2816
|
|
|
2726
2817
|
if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
|
|
2727
2818
|
|
|
2728
|
-
//
|
|
2729
|
-
|
|
2730
|
-
|
|
2819
|
+
// Externally-managed framebuffer (e.g. XR)
|
|
2820
|
+
// Bind to the stored framebuffer (may be null for default, or a WebGLFramebuffer)
|
|
2821
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2822
|
+
|
|
2823
|
+
_currentViewport.copy( renderTarget.viewport );
|
|
2824
|
+
_currentScissor.copy( renderTarget.scissor );
|
|
2825
|
+
_currentScissorTest = renderTarget.scissorTest;
|
|
2826
|
+
|
|
2827
|
+
state.viewport( _currentViewport );
|
|
2828
|
+
state.scissor( _currentScissor );
|
|
2829
|
+
state.setScissorTest( _currentScissorTest );
|
|
2830
|
+
|
|
2831
|
+
_currentMaterialId = - 1;
|
|
2832
|
+
|
|
2833
|
+
return;
|
|
2731
2834
|
|
|
2732
2835
|
} else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
|
|
2733
2836
|
|
|
@@ -2826,7 +2929,7 @@ class WebGLRenderer {
|
|
|
2826
2929
|
|
|
2827
2930
|
const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2828
2931
|
|
|
2829
|
-
if ( framebufferBound
|
|
2932
|
+
if ( framebufferBound ) {
|
|
2830
2933
|
|
|
2831
2934
|
state.drawBuffers( renderTarget, framebuffer );
|
|
2832
2935
|
|
|
@@ -2905,6 +3008,10 @@ class WebGLRenderer {
|
|
|
2905
3008
|
const textureFormat = texture.format;
|
|
2906
3009
|
const textureType = texture.type;
|
|
2907
3010
|
|
|
3011
|
+
// when using MRT, select the correct color buffer for the subsequent read command
|
|
3012
|
+
|
|
3013
|
+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
3014
|
+
|
|
2908
3015
|
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2909
3016
|
|
|
2910
3017
|
error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
@@ -2923,10 +3030,6 @@ class WebGLRenderer {
|
|
|
2923
3030
|
|
|
2924
3031
|
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2925
3032
|
|
|
2926
|
-
// when using MRT, select the correct color buffer for the subsequent read command
|
|
2927
|
-
|
|
2928
|
-
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
2929
|
-
|
|
2930
3033
|
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
|
|
2931
3034
|
|
|
2932
3035
|
}
|
|
@@ -2987,6 +3090,11 @@ class WebGLRenderer {
|
|
|
2987
3090
|
const textureFormat = texture.format;
|
|
2988
3091
|
const textureType = texture.type;
|
|
2989
3092
|
|
|
3093
|
+
// when using MRT, select the correct color buffer for the subsequent read command
|
|
3094
|
+
|
|
3095
|
+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
3096
|
+
|
|
3097
|
+
|
|
2990
3098
|
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2991
3099
|
|
|
2992
3100
|
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
@@ -3003,10 +3111,6 @@ class WebGLRenderer {
|
|
|
3003
3111
|
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
3004
3112
|
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
3005
3113
|
|
|
3006
|
-
// when using MRT, select the correct color buffer for the subsequent read command
|
|
3007
|
-
|
|
3008
|
-
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
3009
|
-
|
|
3010
3114
|
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
3011
3115
|
|
|
3012
3116
|
// reset the frame buffer to the currently set buffer before waiting
|
|
@@ -3076,27 +3180,9 @@ class WebGLRenderer {
|
|
|
3076
3180
|
* @param {?(Box2|Box3)} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
|
|
3077
3181
|
* @param {?(Vector2|Vector3)} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
|
|
3078
3182
|
* @param {number} [srcLevel=0] - The source mipmap level to copy.
|
|
3079
|
-
* @param {?number} [dstLevel=
|
|
3183
|
+
* @param {?number} [dstLevel=0] - The destination mipmap level.
|
|
3080
3184
|
*/
|
|
3081
|
-
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel =
|
|
3082
|
-
|
|
3083
|
-
// support the previous signature with just a single dst mipmap level
|
|
3084
|
-
if ( dstLevel === null ) {
|
|
3085
|
-
|
|
3086
|
-
if ( srcLevel !== 0 ) {
|
|
3087
|
-
|
|
3088
|
-
// @deprecated, r171
|
|
3089
|
-
warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.' );
|
|
3090
|
-
dstLevel = srcLevel;
|
|
3091
|
-
srcLevel = 0;
|
|
3092
|
-
|
|
3093
|
-
} else {
|
|
3094
|
-
|
|
3095
|
-
dstLevel = 0;
|
|
3096
|
-
|
|
3097
|
-
}
|
|
3098
|
-
|
|
3099
|
-
}
|
|
3185
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = 0 ) {
|
|
3100
3186
|
|
|
3101
3187
|
// gather the necessary dimensions to copy
|
|
3102
3188
|
let width, height, depth, minX, minY, minZ;
|
|
@@ -3461,6 +3547,7 @@ class WebGLRenderer {
|
|
|
3461
3547
|
* Note that this setting uses `gl_FragDepth` if available which disables the Early Fragment Test optimization and can cause a decrease in performance.
|
|
3462
3548
|
* @property {boolean} [reversedDepthBuffer=false] Whether to use a reverse depth buffer. Requires the `EXT_clip_control` extension.
|
|
3463
3549
|
* This is a more faster and accurate version than logarithmic depth buffer.
|
|
3550
|
+
* @property {number} [outputBufferType=UnsignedByteType] Defines the type of the output buffer. Use `HalfFloatType` for HDR rendering with tone mapping and post-processing support.
|
|
3464
3551
|
**/
|
|
3465
3552
|
|
|
3466
3553
|
/**
|
|
@@ -3482,7 +3569,6 @@ class WebGLRenderer {
|
|
|
3482
3569
|
* @property {string} precision - The shader precision currently being used by the renderer.
|
|
3483
3570
|
* @property {boolean} reversedDepthBuffer - `true` if `reversedDepthBuffer` was set to `true` in the constructor
|
|
3484
3571
|
* and the rendering context supports `EXT_clip_control`.
|
|
3485
|
-
* @property {boolean} vertexTextures - `true` if vertex textures can be used.
|
|
3486
3572
|
**/
|
|
3487
3573
|
|
|
3488
3574
|
/**
|
|
@@ -3524,7 +3610,7 @@ class WebGLRenderer {
|
|
|
3524
3610
|
* If you do not require dynamic lighting / shadows, you may set this to `false`.
|
|
3525
3611
|
* @property {boolean} [needsUpdate=false] - When set to `true`, shadow maps in the scene
|
|
3526
3612
|
* will be updated in the next `render` call.
|
|
3527
|
-
* @property {(BasicShadowMap|PCFShadowMap|
|
|
3613
|
+
* @property {(BasicShadowMap|PCFShadowMap|VSMShadowMap)} [type=PCFShadowMap] - Defines the shadow map type.
|
|
3528
3614
|
**/
|
|
3529
3615
|
|
|
3530
3616
|
export { WebGLRenderer };
|
|
@@ -678,6 +678,27 @@ class Backend {
|
|
|
678
678
|
|
|
679
679
|
}
|
|
680
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Checks if the backend has the given compatibility.
|
|
683
|
+
*
|
|
684
|
+
* @abstract
|
|
685
|
+
* @param {string} name - The compatibility.
|
|
686
|
+
* @return {boolean} Whether the backend has the given compatibility or not.
|
|
687
|
+
*/
|
|
688
|
+
hasCompatibility( /*name*/ ) {
|
|
689
|
+
|
|
690
|
+
return false;
|
|
691
|
+
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Initializes the render target defined in the given render context.
|
|
696
|
+
*
|
|
697
|
+
* @abstract
|
|
698
|
+
* @param {RenderContext} renderContext - The render context.
|
|
699
|
+
*/
|
|
700
|
+
initRenderTarget( /*renderContext*/ ) {}
|
|
701
|
+
|
|
681
702
|
/**
|
|
682
703
|
* Sets a dictionary for the given object into the
|
|
683
704
|
* internal data structure.
|
|
@@ -736,6 +757,14 @@ class Backend {
|
|
|
736
757
|
|
|
737
758
|
}
|
|
738
759
|
|
|
760
|
+
/**
|
|
761
|
+
* Delete GPU data associated with a bind group.
|
|
762
|
+
*
|
|
763
|
+
* @abstract
|
|
764
|
+
* @param {BindGroup} bindGroup - The bind group.
|
|
765
|
+
*/
|
|
766
|
+
deleteBindGroupData( /*bindGroup*/ ) { }
|
|
767
|
+
|
|
739
768
|
/**
|
|
740
769
|
* Frees internal resources.
|
|
741
770
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DataMap from './DataMap.js';
|
|
2
2
|
import Color4 from './Color4.js';
|
|
3
|
-
import { vec4,
|
|
3
|
+
import { vec4, normalWorldGeometry, backgroundBlurriness, backgroundIntensity, backgroundRotation, positionLocal, cameraProjectionMatrix, modelViewMatrix, div } from '../../nodes/TSL.js';
|
|
4
4
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
5
5
|
|
|
6
6
|
import { Mesh } from '../../objects/Mesh.js';
|
|
@@ -88,13 +88,32 @@ class Background extends DataMap {
|
|
|
88
88
|
|
|
89
89
|
if ( backgroundMesh === undefined ) {
|
|
90
90
|
|
|
91
|
-
const backgroundMeshNode =
|
|
91
|
+
const backgroundMeshNode = vec4( backgroundNode ).mul( backgroundIntensity ).context( {
|
|
92
92
|
// @TODO: Add Texture2D support using node context
|
|
93
93
|
getUV: () => backgroundRotation.mul( normalWorldGeometry ),
|
|
94
94
|
getTextureLevel: () => backgroundBlurriness
|
|
95
95
|
} );
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
// when using orthographic cameras, we must scale the skybox sphere
|
|
98
|
+
// up to exceed the dimensions of the camera's viewing box.
|
|
99
|
+
const isOrtho = cameraProjectionMatrix.element( 3 ).element( 3 ).equal( 1.0 );
|
|
100
|
+
|
|
101
|
+
// calculate the orthographic scale
|
|
102
|
+
// projectionMatrix[1][1] is (1 / top). Invert it to get the height and multiply by 3.0
|
|
103
|
+
// (an arbitrary safety factor) to ensure the skybox is large enough to cover the corners
|
|
104
|
+
// of the rectangular screen
|
|
105
|
+
const orthoScale = div( 1.0, cameraProjectionMatrix.element( 1 ).element( 1 ) ).mul( 3.0 );
|
|
106
|
+
|
|
107
|
+
// compute vertex position
|
|
108
|
+
const modifiedPosition = isOrtho.select( positionLocal.mul( orthoScale ), positionLocal );
|
|
109
|
+
|
|
110
|
+
// by using a w component of 0, the skybox will not translate when the camera moves through the scene
|
|
111
|
+
const viewPosition = modelViewMatrix.mul( vec4( modifiedPosition, 0.0 ) );
|
|
112
|
+
|
|
113
|
+
// we force w=1.0 here to prevent the w_clip=0 divide-by-zero error for ortho cameras.
|
|
114
|
+
let viewProj = cameraProjectionMatrix.mul( vec4( viewPosition.xyz, 1.0 ) );
|
|
115
|
+
|
|
116
|
+
// force background to far plane so it does not occlude objects
|
|
98
117
|
viewProj = viewProj.setZ( viewProj.w );
|
|
99
118
|
|
|
100
119
|
const nodeMaterial = new NodeMaterial();
|
|
@@ -113,12 +132,6 @@ class Background extends DataMap {
|
|
|
113
132
|
backgroundMesh.frustumCulled = false;
|
|
114
133
|
backgroundMesh.name = 'Background.mesh';
|
|
115
134
|
|
|
116
|
-
backgroundMesh.onBeforeRender = function ( renderer, scene, camera ) {
|
|
117
|
-
|
|
118
|
-
this.matrixWorld.copyPosition( camera.matrixWorld );
|
|
119
|
-
|
|
120
|
-
};
|
|
121
|
-
|
|
122
135
|
function onBackgroundDispose() {
|
|
123
136
|
|
|
124
137
|
background.removeEventListener( 'dispose', onBackgroundDispose );
|
|
@@ -190,8 +203,8 @@ class Background extends DataMap {
|
|
|
190
203
|
|
|
191
204
|
//
|
|
192
205
|
|
|
193
|
-
renderContext.depthClearValue = renderer.
|
|
194
|
-
renderContext.stencilClearValue = renderer.
|
|
206
|
+
renderContext.depthClearValue = renderer.getClearDepth();
|
|
207
|
+
renderContext.stencilClearValue = renderer.getClearStencil();
|
|
195
208
|
|
|
196
209
|
renderContext.clearColor = renderer.autoClearColor === true;
|
|
197
210
|
renderContext.clearDepth = renderer.autoClearDepth === true;
|
|
@@ -15,9 +15,8 @@ class BindGroup {
|
|
|
15
15
|
* @param {string} name - The bind group's name.
|
|
16
16
|
* @param {Array<Binding>} bindings - An array of bindings.
|
|
17
17
|
* @param {number} index - The group index.
|
|
18
|
-
* @param {Array<Binding>} bindingsReference - An array of reference bindings.
|
|
19
18
|
*/
|
|
20
|
-
constructor( name = '', bindings = [], index = 0
|
|
19
|
+
constructor( name = '', bindings = [], index = 0 ) {
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* The bind group's name.
|
|
@@ -40,13 +39,6 @@ class BindGroup {
|
|
|
40
39
|
*/
|
|
41
40
|
this.index = index;
|
|
42
41
|
|
|
43
|
-
/**
|
|
44
|
-
* An array of reference bindings.
|
|
45
|
-
*
|
|
46
|
-
* @type {Array<Binding>}
|
|
47
|
-
*/
|
|
48
|
-
this.bindingsReference = bindingsReference;
|
|
49
|
-
|
|
50
42
|
/**
|
|
51
43
|
* The group's ID.
|
|
52
44
|
*
|