super-three 0.181.0 → 0.184.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 +13152 -11354
- package/build/three.core.js +12319 -11539
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1808 -781
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +27 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +10523 -6263
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +10484 -6262
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +11 -3
- package/examples/jsm/animation/CCDIKSolver.js +7 -3
- package/examples/jsm/controls/ArcballControls.js +7 -4
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +111 -8
- package/examples/jsm/controls/TrackballControls.js +8 -8
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- 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 +152 -9
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -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/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +203 -88
- package/examples/jsm/inspector/RendererInspector.js +14 -4
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +51 -3
- package/examples/jsm/inspector/tabs/Performance.js +4 -4
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +107 -5
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +1936 -34
- package/examples/jsm/inspector/ui/Style.js +1044 -31
- package/examples/jsm/inspector/ui/Tab.js +222 -3
- package/examples/jsm/inspector/ui/Values.js +55 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +9 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +7 -1
- 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 +687 -48
- package/examples/jsm/loaders/FBXLoader.js +235 -37
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +146 -178
- package/examples/jsm/loaders/HDRLoader.js +1 -2
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +27 -5
- package/examples/jsm/loaders/LDrawLoader.js +41 -50
- 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 +2 -2
- 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 +42 -25
- package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
- package/examples/jsm/loaders/usd/USDAParser.js +450 -363
- package/examples/jsm/loaders/usd/USDCParser.js +1867 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4594 -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/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +90 -6
- package/examples/jsm/objects/SkyMesh.js +150 -16
- 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 +246 -28
- package/examples/jsm/renderers/SVGRenderer.js +174 -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 +63 -6
- 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/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +11 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +12 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- 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/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +6 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +21 -2
- package/examples/jsm/tsl/display/GodraysNode.js +615 -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 +69 -19
- 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 -24
- 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/SharpenNode.js +283 -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/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +315 -126
- 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/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +53 -3
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- 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/SkeletonUtils.js +14 -8
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +24 -30
- package/src/Three.Core.js +3 -1
- package/src/Three.TSL.js +25 -11
- package/src/Three.WebGPU.Nodes.js +5 -0
- package/src/Three.WebGPU.js +9 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +12 -2
- 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/AudioContext.js +2 -2
- 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/BufferAttribute.js +13 -1
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +52 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +4 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- 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/AudioLoader.js +11 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +2 -3
- package/src/loaders/ImageBitmapLoader.js +12 -9
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +46 -6
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +34 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +45 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +191 -86
- package/src/math/Line3.js +6 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +87 -74
- package/src/math/Plane.js +4 -3
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +15 -13
- package/src/math/Vector4.js +13 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +86 -68
- package/src/nodes/TSL.js +7 -7
- 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 +107 -15
- 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 +27 -2
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- 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/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +6 -6
- package/src/nodes/accessors/ReferenceNode.js +8 -8
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +47 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +14 -25
- package/src/nodes/accessors/StorageTextureNode.js +40 -9
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +67 -23
- package/src/nodes/accessors/UniformArrayNode.js +6 -4
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +2 -3
- package/src/nodes/core/ArrayNode.js +21 -2
- package/src/nodes/core/AssignNode.js +3 -3
- package/src/nodes/core/AttributeNode.js +3 -3
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +104 -5
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +112 -15
- package/src/nodes/core/NodeBuilder.js +284 -66
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +11 -9
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +66 -17
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +17 -3
- package/src/nodes/core/StructTypeNode.js +12 -18
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +48 -23
- package/src/nodes/core/VaryingNode.js +2 -19
- 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 +125 -16
- package/src/nodes/display/RenderOutputNode.js +7 -7
- package/src/nodes/display/ScreenNode.js +4 -2
- 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/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +39 -11
- 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 +2 -2
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +5 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -3
- package/src/nodes/gpgpu/ComputeNode.js +74 -48
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +2 -2
- 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 +7 -28
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +120 -42
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +76 -41
- package/src/nodes/math/OperatorNode.js +3 -2
- 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/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +38 -17
- package/src/nodes/utils/ArrayElementNode.js +14 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +12 -12
- package/src/nodes/utils/EventNode.js +31 -2
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +3 -3
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +2 -2
- 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/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +44 -16
- package/src/objects/InstancedMesh.js +30 -3
- 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/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +329 -145
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +29 -8
- package/src/renderers/common/Background.js +26 -13
- package/src/renderers/common/BindGroup.js +1 -16
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +29 -14
- 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/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +51 -7
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +40 -7
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +7 -3
- 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 +17 -5
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +21 -5
- package/src/renderers/common/RenderPipeline.js +232 -17
- package/src/renderers/common/Renderer.js +481 -117
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +89 -4
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +62 -1
- package/src/renderers/common/XRManager.js +37 -29
- package/src/renderers/common/extras/PMREMGenerator.js +25 -23
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +242 -99
- 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_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +8 -12
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +13 -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_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -53
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- 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 +5 -3
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- 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 -6
- package/src/renderers/shaders/UniformsLib.js +7 -5
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +15 -15
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +9 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +24 -13
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +270 -0
- package/src/renderers/webgl/WebGLProgram.js +49 -109
- package/src/renderers/webgl/WebGLPrograms.js +63 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +75 -37
- package/src/renderers/webgl/WebGLTextures.js +215 -54
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +253 -82
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +173 -74
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +223 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +68 -53
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +10 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +260 -140
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +366 -90
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +107 -34
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +10 -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 +156 -59
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +33 -11
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +4 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +16 -5
- package/src/utils.js +280 -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/RemapNode.js +0 -125
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
NoToneMapping,
|
|
9
9
|
LinearMipmapLinearFilter,
|
|
10
10
|
SRGBColorSpace,
|
|
11
|
-
LinearSRGBColorSpace,
|
|
12
11
|
RGBAIntegerFormat,
|
|
13
12
|
RGIntegerFormat,
|
|
14
13
|
RedIntegerFormat,
|
|
@@ -31,8 +30,7 @@ import { WebGLBindingStates } from './webgl/WebGLBindingStates.js';
|
|
|
31
30
|
import { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';
|
|
32
31
|
import { WebGLCapabilities } from './webgl/WebGLCapabilities.js';
|
|
33
32
|
import { WebGLClipping } from './webgl/WebGLClipping.js';
|
|
34
|
-
import {
|
|
35
|
-
import { WebGLCubeUVMaps } from './webgl/WebGLCubeUVMaps.js';
|
|
33
|
+
import { WebGLEnvironments } from './webgl/WebGLEnvironments.js';
|
|
36
34
|
import { WebGLExtensions } from './webgl/WebGLExtensions.js';
|
|
37
35
|
import { WebGLGeometries } from './webgl/WebGLGeometries.js';
|
|
38
36
|
import { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';
|
|
@@ -40,6 +38,7 @@ import { WebGLInfo } from './webgl/WebGLInfo.js';
|
|
|
40
38
|
import { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';
|
|
41
39
|
import { WebGLMultiview } from './webgl/WebGLMultiview.js';
|
|
42
40
|
import { WebGLObjects } from './webgl/WebGLObjects.js';
|
|
41
|
+
import { WebGLOutput } from './webgl/WebGLOutput.js';
|
|
43
42
|
import { WebGLPrograms } from './webgl/WebGLPrograms.js';
|
|
44
43
|
import { WebGLProperties } from './webgl/WebGLProperties.js';
|
|
45
44
|
import { WebGLRenderLists } from './webgl/WebGLRenderLists.js';
|
|
@@ -53,7 +52,7 @@ import { WebGLUtils } from './webgl/WebGLUtils.js';
|
|
|
53
52
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
54
53
|
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
|
|
55
54
|
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
|
|
56
|
-
import { createCanvasElement, probeAsync,
|
|
55
|
+
import { createCanvasElement, probeAsync, error, warn, log } from '../utils.js';
|
|
57
56
|
import { ColorManagement } from '../math/ColorManagement.js';
|
|
58
57
|
import { getDFGLUT } from './shaders/DFGLUTData.js';
|
|
59
58
|
|
|
@@ -83,6 +82,7 @@ class WebGLRenderer {
|
|
|
83
82
|
powerPreference = 'default',
|
|
84
83
|
failIfMajorPerformanceCaveat = false,
|
|
85
84
|
reversedDepthBuffer = false,
|
|
85
|
+
outputBufferType = UnsignedByteType,
|
|
86
86
|
multiviewStereo = false,
|
|
87
87
|
} = parameters;
|
|
88
88
|
|
|
@@ -113,6 +113,8 @@ class WebGLRenderer {
|
|
|
113
113
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
const _outputBufferType = outputBufferType;
|
|
117
|
+
|
|
116
118
|
const INTEGER_FORMATS = new Set( [
|
|
117
119
|
RGBAIntegerFormat,
|
|
118
120
|
RGIntegerFormat,
|
|
@@ -130,6 +132,7 @@ class WebGLRenderer {
|
|
|
130
132
|
|
|
131
133
|
const uintClearColor = new Uint32Array( 4 );
|
|
132
134
|
const intClearColor = new Int32Array( 4 );
|
|
135
|
+
const objectPosition = new Vector3();
|
|
133
136
|
|
|
134
137
|
let currentRenderList = null;
|
|
135
138
|
let currentRenderState = null;
|
|
@@ -140,10 +143,14 @@ class WebGLRenderer {
|
|
|
140
143
|
const renderListStack = [];
|
|
141
144
|
const renderStateStack = [];
|
|
142
145
|
|
|
146
|
+
// internal render target for non-UnsignedByteType color buffer
|
|
147
|
+
|
|
148
|
+
let output = null;
|
|
149
|
+
|
|
143
150
|
// public properties
|
|
144
151
|
|
|
145
152
|
/**
|
|
146
|
-
* A canvas where the renderer draws its output.This is automatically created by the renderer
|
|
153
|
+
* A canvas where the renderer draws its output. This is automatically created by the renderer
|
|
147
154
|
* in the constructor (if not provided already); you just need to add it to your page like so:
|
|
148
155
|
* ```js
|
|
149
156
|
* document.body.appendChild( renderer.domElement );
|
|
@@ -159,7 +166,7 @@ class WebGLRenderer {
|
|
|
159
166
|
* - `checkShaderErrors`: If it is `true`, defines whether material shader programs are
|
|
160
167
|
* checked for errors during compilation and linkage process. It may be useful to disable
|
|
161
168
|
* this check in production for performance gain. It is strongly recommended to keep these
|
|
162
|
-
* checks enabled during development. If the shader does not compile and link
|
|
169
|
+
* checks enabled during development. If the shader does not compile and link, it will not
|
|
163
170
|
* work and associated material will not render.
|
|
164
171
|
* - `onShaderError(gl, program, glVertexShader,glFragmentShader)`: A callback function that
|
|
165
172
|
* can be used for custom error reporting. The callback receives the WebGL context, an instance
|
|
@@ -288,6 +295,7 @@ class WebGLRenderer {
|
|
|
288
295
|
const _this = this;
|
|
289
296
|
|
|
290
297
|
let _isContextLost = false;
|
|
298
|
+
let _nodesHandler = null;
|
|
291
299
|
|
|
292
300
|
// internal state cache
|
|
293
301
|
|
|
@@ -400,15 +408,15 @@ class WebGLRenderer {
|
|
|
400
408
|
|
|
401
409
|
}
|
|
402
410
|
|
|
403
|
-
} catch (
|
|
411
|
+
} catch ( e ) {
|
|
404
412
|
|
|
405
|
-
error( 'WebGLRenderer: ' +
|
|
406
|
-
throw
|
|
413
|
+
error( 'WebGLRenderer: ' + e.message );
|
|
414
|
+
throw e;
|
|
407
415
|
|
|
408
416
|
}
|
|
409
417
|
|
|
410
418
|
let extensions, capabilities, state, info;
|
|
411
|
-
let properties, textures,
|
|
419
|
+
let properties, textures, environments, attributes, geometries, objects;
|
|
412
420
|
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
|
|
413
421
|
let multiview;
|
|
414
422
|
|
|
@@ -436,19 +444,18 @@ class WebGLRenderer {
|
|
|
436
444
|
info = new WebGLInfo( _gl );
|
|
437
445
|
properties = new WebGLProperties();
|
|
438
446
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
439
|
-
|
|
440
|
-
cubeuvmaps = new WebGLCubeUVMaps( _this );
|
|
447
|
+
environments = new WebGLEnvironments( _this );
|
|
441
448
|
attributes = new WebGLAttributes( _gl );
|
|
442
449
|
bindingStates = new WebGLBindingStates( _gl, attributes );
|
|
443
450
|
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
444
|
-
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
451
|
+
objects = new WebGLObjects( _gl, geometries, attributes, bindingStates, info );
|
|
445
452
|
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
446
453
|
clipping = new WebGLClipping( properties );
|
|
447
|
-
programCache = new WebGLPrograms( _this,
|
|
454
|
+
programCache = new WebGLPrograms( _this, environments, extensions, capabilities, bindingStates, clipping );
|
|
448
455
|
materials = new WebGLMaterials( _this, properties );
|
|
449
456
|
renderLists = new WebGLRenderLists();
|
|
450
457
|
renderStates = new WebGLRenderStates( extensions );
|
|
451
|
-
background = new WebGLBackground( _this,
|
|
458
|
+
background = new WebGLBackground( _this, environments, state, objects, _alpha, premultipliedAlpha );
|
|
452
459
|
multiview = new WebGLMultiview( _this, extensions, _gl );
|
|
453
460
|
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
454
461
|
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
@@ -537,6 +544,14 @@ class WebGLRenderer {
|
|
|
537
544
|
|
|
538
545
|
initGLContext();
|
|
539
546
|
|
|
547
|
+
// initialize internal render target for non-UnsignedByteType color buffer
|
|
548
|
+
|
|
549
|
+
if ( _outputBufferType !== UnsignedByteType ) {
|
|
550
|
+
|
|
551
|
+
output = new WebGLOutput( _outputBufferType, canvas.width, canvas.height, depth, stencil );
|
|
552
|
+
|
|
553
|
+
}
|
|
554
|
+
|
|
540
555
|
// xr
|
|
541
556
|
|
|
542
557
|
const xr = new WebXRManager( _this, _gl, extensions, multiviewStereo );
|
|
@@ -659,6 +674,12 @@ class WebGLRenderer {
|
|
|
659
674
|
|
|
660
675
|
}
|
|
661
676
|
|
|
677
|
+
if ( output !== null ) {
|
|
678
|
+
|
|
679
|
+
output.setSize( canvas.width, canvas.height );
|
|
680
|
+
|
|
681
|
+
}
|
|
682
|
+
|
|
662
683
|
this.setViewport( 0, 0, width, height );
|
|
663
684
|
|
|
664
685
|
};
|
|
@@ -702,6 +723,39 @@ class WebGLRenderer {
|
|
|
702
723
|
|
|
703
724
|
};
|
|
704
725
|
|
|
726
|
+
/**
|
|
727
|
+
* Sets the post-processing effects to be applied after rendering.
|
|
728
|
+
*
|
|
729
|
+
* @param {Array} effects - An array of post-processing effects.
|
|
730
|
+
*/
|
|
731
|
+
this.setEffects = function ( effects ) {
|
|
732
|
+
|
|
733
|
+
if ( _outputBufferType === UnsignedByteType ) {
|
|
734
|
+
|
|
735
|
+
error( 'THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.' );
|
|
736
|
+
return;
|
|
737
|
+
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if ( effects ) {
|
|
741
|
+
|
|
742
|
+
for ( let i = 0; i < effects.length; i ++ ) {
|
|
743
|
+
|
|
744
|
+
if ( effects[ i ].isOutputPass === true ) {
|
|
745
|
+
|
|
746
|
+
warn( 'THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.' );
|
|
747
|
+
break;
|
|
748
|
+
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
output.setEffects( effects || [] );
|
|
756
|
+
|
|
757
|
+
};
|
|
758
|
+
|
|
705
759
|
/**
|
|
706
760
|
* Returns the current viewport definition.
|
|
707
761
|
*
|
|
@@ -949,6 +1003,7 @@ class WebGLRenderer {
|
|
|
949
1003
|
if ( depth ) {
|
|
950
1004
|
|
|
951
1005
|
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
1006
|
+
this.state.buffers.depth.setMask( true );
|
|
952
1007
|
|
|
953
1008
|
}
|
|
954
1009
|
|
|
@@ -959,7 +1014,11 @@ class WebGLRenderer {
|
|
|
959
1014
|
|
|
960
1015
|
}
|
|
961
1016
|
|
|
962
|
-
|
|
1017
|
+
if ( bits !== 0 ) {
|
|
1018
|
+
|
|
1019
|
+
_gl.clear( bits );
|
|
1020
|
+
|
|
1021
|
+
}
|
|
963
1022
|
|
|
964
1023
|
};
|
|
965
1024
|
|
|
@@ -990,6 +1049,20 @@ class WebGLRenderer {
|
|
|
990
1049
|
|
|
991
1050
|
};
|
|
992
1051
|
|
|
1052
|
+
/**
|
|
1053
|
+
* Sets a compatibility node builder for rendering node materials with WebGLRenderer.
|
|
1054
|
+
* This enables using TSL (Three.js Shading Language) node materials to prepare
|
|
1055
|
+
* for migration to WebGPURenderer.
|
|
1056
|
+
*
|
|
1057
|
+
* @param {WebGLNodesHandler} nodesHandler - The node builder instance.
|
|
1058
|
+
*/
|
|
1059
|
+
this.setNodesHandler = function ( nodesHandler ) {
|
|
1060
|
+
|
|
1061
|
+
nodesHandler.setRenderer( this );
|
|
1062
|
+
_nodesHandler = nodesHandler;
|
|
1063
|
+
|
|
1064
|
+
};
|
|
1065
|
+
|
|
993
1066
|
/**
|
|
994
1067
|
* Frees the GPU-related resources allocated by this instance. Call this
|
|
995
1068
|
* method whenever this instance is no longer used in your app.
|
|
@@ -1004,8 +1077,7 @@ class WebGLRenderer {
|
|
|
1004
1077
|
renderLists.dispose();
|
|
1005
1078
|
renderStates.dispose();
|
|
1006
1079
|
properties.dispose();
|
|
1007
|
-
|
|
1008
|
-
cubeuvmaps.dispose();
|
|
1080
|
+
environments.dispose();
|
|
1009
1081
|
objects.dispose();
|
|
1010
1082
|
bindingStates.dispose();
|
|
1011
1083
|
uniformsGroups.dispose();
|
|
@@ -1226,33 +1298,23 @@ class WebGLRenderer {
|
|
|
1226
1298
|
|
|
1227
1299
|
if ( object.isBatchedMesh ) {
|
|
1228
1300
|
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1231
|
-
// @deprecated, r174
|
|
1232
|
-
warnOnce( 'WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
|
|
1233
|
-
renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
1234
|
-
|
|
1235
|
-
} else {
|
|
1301
|
+
if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
|
|
1236
1302
|
|
|
1237
|
-
|
|
1303
|
+
const starts = object._multiDrawStarts;
|
|
1304
|
+
const counts = object._multiDrawCounts;
|
|
1305
|
+
const drawCount = object._multiDrawCount;
|
|
1306
|
+
const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
|
|
1307
|
+
const uniforms = properties.get( material ).currentProgram.getUniforms();
|
|
1308
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
1238
1309
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
const drawCount = object._multiDrawCount;
|
|
1242
|
-
const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
|
|
1243
|
-
const uniforms = properties.get( material ).currentProgram.getUniforms();
|
|
1244
|
-
for ( let i = 0; i < drawCount; i ++ ) {
|
|
1310
|
+
uniforms.setValue( _gl, '_gl_DrawID', i );
|
|
1311
|
+
renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
|
|
1245
1312
|
|
|
1246
|
-
|
|
1247
|
-
renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
|
|
1248
|
-
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
} else {
|
|
1313
|
+
}
|
|
1252
1314
|
|
|
1253
|
-
|
|
1315
|
+
} else {
|
|
1254
1316
|
|
|
1255
|
-
|
|
1317
|
+
renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
1256
1318
|
|
|
1257
1319
|
}
|
|
1258
1320
|
|
|
@@ -1551,6 +1613,19 @@ class WebGLRenderer {
|
|
|
1551
1613
|
|
|
1552
1614
|
if ( _isContextLost === true ) return;
|
|
1553
1615
|
|
|
1616
|
+
// update node builder if available
|
|
1617
|
+
if ( _nodesHandler !== null ) {
|
|
1618
|
+
|
|
1619
|
+
_nodesHandler.renderStart( scene, camera );
|
|
1620
|
+
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// use internal render target for HalfFloatType color buffer (only when tone mapping is enabled)
|
|
1624
|
+
|
|
1625
|
+
const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
|
|
1626
|
+
|
|
1627
|
+
const useOutput = output !== null && ( _currentRenderTarget === null || isXRPresenting ) && output.begin( _this, _currentRenderTarget );
|
|
1628
|
+
|
|
1554
1629
|
// update scene graph
|
|
1555
1630
|
|
|
1556
1631
|
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
@@ -1559,7 +1634,7 @@ class WebGLRenderer {
|
|
|
1559
1634
|
|
|
1560
1635
|
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
1561
1636
|
|
|
1562
|
-
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
1637
|
+
if ( xr.enabled === true && xr.isPresenting === true && ( output === null || output.isCompositing() === false ) ) {
|
|
1563
1638
|
|
|
1564
1639
|
if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
|
|
1565
1640
|
|
|
@@ -1573,6 +1648,7 @@ class WebGLRenderer {
|
|
|
1573
1648
|
currentRenderState = renderStates.get( scene, renderStateStack.length );
|
|
1574
1649
|
currentRenderState.init( camera );
|
|
1575
1650
|
|
|
1651
|
+
currentRenderState.state.textureUnits = textures.getTextureUnits();
|
|
1576
1652
|
renderStateStack.push( currentRenderState );
|
|
1577
1653
|
|
|
1578
1654
|
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
@@ -1631,56 +1707,62 @@ class WebGLRenderer {
|
|
|
1631
1707
|
|
|
1632
1708
|
if ( this.info.autoReset === true ) this.info.reset();
|
|
1633
1709
|
|
|
1634
|
-
// render scene
|
|
1710
|
+
// render scene (skip if first effect is a render pass - it will render the scene itself)
|
|
1635
1711
|
|
|
1636
|
-
const
|
|
1637
|
-
const transmissiveObjects = currentRenderList.transmissive;
|
|
1712
|
+
const skipSceneRender = useOutput && output.hasRenderPass();
|
|
1638
1713
|
|
|
1639
|
-
|
|
1714
|
+
if ( skipSceneRender === false ) {
|
|
1715
|
+
|
|
1716
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
1717
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
1718
|
+
|
|
1719
|
+
currentRenderState.setupLights();
|
|
1640
1720
|
|
|
1641
|
-
|
|
1721
|
+
if ( camera.isArrayCamera ) {
|
|
1642
1722
|
|
|
1643
|
-
|
|
1723
|
+
const cameras = camera.cameras;
|
|
1644
1724
|
|
|
1645
|
-
|
|
1725
|
+
if ( transmissiveObjects.length > 0 ) {
|
|
1646
1726
|
|
|
1647
|
-
|
|
1727
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1648
1728
|
|
|
1649
|
-
|
|
1729
|
+
const camera2 = cameras[ i ];
|
|
1650
1730
|
|
|
1651
|
-
|
|
1731
|
+
renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
|
|
1732
|
+
|
|
1733
|
+
}
|
|
1652
1734
|
|
|
1653
1735
|
}
|
|
1654
1736
|
|
|
1655
|
-
|
|
1737
|
+
if ( _renderBackground ) background.render( scene );
|
|
1656
1738
|
|
|
1657
|
-
|
|
1739
|
+
if ( xr.enabled && xr.isMultiview ) {
|
|
1658
1740
|
|
|
1659
|
-
|
|
1741
|
+
textures.setDeferTextureUploads( true );
|
|
1660
1742
|
|
|
1661
|
-
|
|
1743
|
+
renderScene( currentRenderList, scene, camera, camera.cameras[ 0 ].viewport );
|
|
1662
1744
|
|
|
1663
|
-
|
|
1745
|
+
} else {
|
|
1664
1746
|
|
|
1665
|
-
|
|
1747
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1666
1748
|
|
|
1667
|
-
|
|
1749
|
+
const camera2 = cameras[ i ];
|
|
1668
1750
|
|
|
1669
|
-
|
|
1751
|
+
renderScene( currentRenderList, scene, camera2, camera2.viewport );
|
|
1670
1752
|
|
|
1671
|
-
|
|
1753
|
+
}
|
|
1672
1754
|
|
|
1673
1755
|
}
|
|
1674
1756
|
|
|
1675
|
-
}
|
|
1757
|
+
} else {
|
|
1676
1758
|
|
|
1677
|
-
|
|
1759
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
1678
1760
|
|
|
1679
|
-
|
|
1761
|
+
if ( _renderBackground ) background.render( scene );
|
|
1680
1762
|
|
|
1681
|
-
|
|
1763
|
+
renderScene( currentRenderList, scene, camera );
|
|
1682
1764
|
|
|
1683
|
-
|
|
1765
|
+
}
|
|
1684
1766
|
|
|
1685
1767
|
}
|
|
1686
1768
|
|
|
@@ -1698,12 +1780,18 @@ class WebGLRenderer {
|
|
|
1698
1780
|
|
|
1699
1781
|
}
|
|
1700
1782
|
|
|
1783
|
+
// copy from internal render target to canvas using fullscreen quad
|
|
1784
|
+
|
|
1785
|
+
if ( useOutput ) {
|
|
1786
|
+
|
|
1787
|
+
output.end( _this );
|
|
1788
|
+
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1701
1791
|
//
|
|
1702
1792
|
|
|
1703
1793
|
if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
|
|
1704
1794
|
|
|
1705
|
-
textures.runDeferredUploads();
|
|
1706
|
-
|
|
1707
1795
|
// _gl.finish();
|
|
1708
1796
|
|
|
1709
1797
|
bindingStates.resetDefaultState();
|
|
@@ -1716,6 +1804,8 @@ class WebGLRenderer {
|
|
|
1716
1804
|
|
|
1717
1805
|
currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
|
|
1718
1806
|
|
|
1807
|
+
textures.setTextureUnits( currentRenderState.state.textureUnits );
|
|
1808
|
+
|
|
1719
1809
|
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
|
|
1720
1810
|
|
|
1721
1811
|
} else {
|
|
@@ -1736,6 +1826,12 @@ class WebGLRenderer {
|
|
|
1736
1826
|
|
|
1737
1827
|
}
|
|
1738
1828
|
|
|
1829
|
+
if ( _nodesHandler !== null ) {
|
|
1830
|
+
|
|
1831
|
+
_nodesHandler.renderEnd();
|
|
1832
|
+
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1739
1835
|
};
|
|
1740
1836
|
|
|
1741
1837
|
function projectObject( object, camera, groupOrder, sortObjects ) {
|
|
@@ -1754,6 +1850,10 @@ class WebGLRenderer {
|
|
|
1754
1850
|
|
|
1755
1851
|
if ( object.autoUpdate === true ) object.update( camera );
|
|
1756
1852
|
|
|
1853
|
+
} else if ( object.isLightProbeGrid ) {
|
|
1854
|
+
|
|
1855
|
+
currentRenderState.pushLightProbeGrid( object );
|
|
1856
|
+
|
|
1757
1857
|
} else if ( object.isLight ) {
|
|
1758
1858
|
|
|
1759
1859
|
currentRenderState.pushLight( object );
|
|
@@ -1888,11 +1988,13 @@ class WebGLRenderer {
|
|
|
1888
1988
|
|
|
1889
1989
|
if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
|
|
1890
1990
|
|
|
1991
|
+
const hasHalfFloatSupport = extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' );
|
|
1992
|
+
|
|
1891
1993
|
currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
|
|
1892
1994
|
generateMipmaps: true,
|
|
1893
|
-
type:
|
|
1995
|
+
type: hasHalfFloatSupport ? HalfFloatType : UnsignedByteType,
|
|
1894
1996
|
minFilter: LinearMipmapLinearFilter,
|
|
1895
|
-
samples: 4,
|
|
1997
|
+
samples: Math.max( 4, capabilities.samples ), // to avoid feedback loops, the transmission render target requires a resolve, see #26177
|
|
1896
1998
|
stencilBuffer: stencil,
|
|
1897
1999
|
resolveDepthBuffer: false,
|
|
1898
2000
|
resolveStencilBuffer: false,
|
|
@@ -2067,16 +2169,18 @@ class WebGLRenderer {
|
|
|
2067
2169
|
|
|
2068
2170
|
const lightsStateVersion = lights.state.version;
|
|
2069
2171
|
|
|
2070
|
-
const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object );
|
|
2172
|
+
const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object, currentRenderState.state.lightProbeGridArray );
|
|
2071
2173
|
const programCacheKey = programCache.getProgramCacheKey( parameters );
|
|
2072
2174
|
|
|
2073
2175
|
let programs = materialProperties.programs;
|
|
2074
2176
|
|
|
2075
2177
|
// always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change
|
|
2076
2178
|
|
|
2077
|
-
materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
2179
|
+
materialProperties.environment = ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) ? scene.environment : null;
|
|
2078
2180
|
materialProperties.fog = scene.fog;
|
|
2079
|
-
|
|
2181
|
+
|
|
2182
|
+
const usePMREM = material.isMeshStandardMaterial || ( material.isMeshLambertMaterial && ! material.envMap ) || ( material.isMeshPhongMaterial && ! material.envMap );
|
|
2183
|
+
materialProperties.envMap = environments.get( material.envMap || materialProperties.environment, usePMREM );
|
|
2080
2184
|
materialProperties.envMapRotation = ( materialProperties.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
|
|
2081
2185
|
|
|
2082
2186
|
if ( programs === undefined ) {
|
|
@@ -2108,6 +2212,13 @@ class WebGLRenderer {
|
|
|
2108
2212
|
|
|
2109
2213
|
parameters.uniforms = programCache.getUniforms( material );
|
|
2110
2214
|
|
|
2215
|
+
// Use node builder for node materials if available
|
|
2216
|
+
if ( _nodesHandler !== null && material.isNodeMaterial ) {
|
|
2217
|
+
|
|
2218
|
+
_nodesHandler.build( material, object, parameters );
|
|
2219
|
+
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2111
2222
|
material.onBeforeCompile( parameters, _this );
|
|
2112
2223
|
|
|
2113
2224
|
program = programCache.acquireProgram( parameters, programCacheKey );
|
|
@@ -2149,17 +2260,16 @@ class WebGLRenderer {
|
|
|
2149
2260
|
uniforms.pointLightShadows.value = lights.state.pointShadow;
|
|
2150
2261
|
uniforms.hemisphereLights.value = lights.state.hemi;
|
|
2151
2262
|
|
|
2152
|
-
uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
|
|
2153
2263
|
uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
|
|
2154
|
-
uniforms.spotShadowMap.value = lights.state.spotShadowMap;
|
|
2155
2264
|
uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
|
|
2156
2265
|
uniforms.spotLightMap.value = lights.state.spotLightMap;
|
|
2157
|
-
uniforms.pointShadowMap.value = lights.state.pointShadowMap;
|
|
2158
2266
|
uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
|
|
2159
2267
|
// TODO (abelnation): add area lights shadow info to uniforms
|
|
2160
2268
|
|
|
2161
2269
|
}
|
|
2162
2270
|
|
|
2271
|
+
materialProperties.lightProbeGrid = currentRenderState.state.lightProbeGridArray.length > 0;
|
|
2272
|
+
|
|
2163
2273
|
materialProperties.currentProgram = program;
|
|
2164
2274
|
materialProperties.uniformsList = null;
|
|
2165
2275
|
|
|
@@ -2204,6 +2314,30 @@ class WebGLRenderer {
|
|
|
2204
2314
|
|
|
2205
2315
|
}
|
|
2206
2316
|
|
|
2317
|
+
function findLightProbeGrid( volumes, object ) {
|
|
2318
|
+
|
|
2319
|
+
if ( volumes.length === 0 ) return null;
|
|
2320
|
+
|
|
2321
|
+
if ( volumes.length === 1 ) {
|
|
2322
|
+
|
|
2323
|
+
return volumes[ 0 ].texture !== null ? volumes[ 0 ] : null;
|
|
2324
|
+
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
objectPosition.setFromMatrixPosition( object.matrixWorld );
|
|
2328
|
+
|
|
2329
|
+
for ( let i = 0, l = volumes.length; i < l; i ++ ) {
|
|
2330
|
+
|
|
2331
|
+
const v = volumes[ i ];
|
|
2332
|
+
|
|
2333
|
+
if ( v.texture !== null && v.boundingBox.containsPoint( objectPosition ) ) return v;
|
|
2334
|
+
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
return null;
|
|
2338
|
+
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2207
2341
|
function setProgram( camera, scene, geometry, material, object ) {
|
|
2208
2342
|
|
|
2209
2343
|
if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
|
|
@@ -2211,9 +2345,10 @@ class WebGLRenderer {
|
|
|
2211
2345
|
textures.resetTextureUnits();
|
|
2212
2346
|
|
|
2213
2347
|
const fog = scene.fog;
|
|
2214
|
-
const environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
2215
|
-
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace :
|
|
2216
|
-
const
|
|
2348
|
+
const environment = ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) ? scene.environment : null;
|
|
2349
|
+
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace );
|
|
2350
|
+
const usePMREM = material.isMeshStandardMaterial || ( material.isMeshLambertMaterial && ! material.envMap ) || ( material.isMeshPhongMaterial && ! material.envMap );
|
|
2351
|
+
const envMap = environments.get( material.envMap || environment, usePMREM );
|
|
2217
2352
|
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
2218
2353
|
const vertexTangents = !! geometry.attributes.tangent && ( !! material.normalMap || material.anisotropy > 0 );
|
|
2219
2354
|
const morphTargets = !! geometry.morphAttributes.position;
|
|
@@ -2361,6 +2496,10 @@ class WebGLRenderer {
|
|
|
2361
2496
|
|
|
2362
2497
|
needsProgramChange = true;
|
|
2363
2498
|
|
|
2499
|
+
} else if ( !! materialProperties.lightProbeGrid !== ( currentRenderState.state.lightProbeGridArray.length > 0 ) ) {
|
|
2500
|
+
|
|
2501
|
+
needsProgramChange = true;
|
|
2502
|
+
|
|
2364
2503
|
} else if ( materialProperties.numMultiviewViews !== numMultiviewViews ) {
|
|
2365
2504
|
|
|
2366
2505
|
needsProgramChange = true;
|
|
@@ -2382,6 +2521,14 @@ class WebGLRenderer {
|
|
|
2382
2521
|
|
|
2383
2522
|
program = getProgram( material, scene, object );
|
|
2384
2523
|
|
|
2524
|
+
// notify the node builder that the program has changed so uniforms and update nodes can
|
|
2525
|
+
// be cached and triggered.
|
|
2526
|
+
if ( _nodesHandler && material.isNodeMaterial ) {
|
|
2527
|
+
|
|
2528
|
+
_nodesHandler.onUpdateProgram( material, program, materialProperties );
|
|
2529
|
+
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2385
2532
|
}
|
|
2386
2533
|
|
|
2387
2534
|
let refreshProgram = false;
|
|
@@ -2407,6 +2554,19 @@ class WebGLRenderer {
|
|
|
2407
2554
|
|
|
2408
2555
|
}
|
|
2409
2556
|
|
|
2557
|
+
if ( materialProperties.needsLights ) {
|
|
2558
|
+
|
|
2559
|
+
const objectVolume = findLightProbeGrid( currentRenderState.state.lightProbeGridArray, object );
|
|
2560
|
+
|
|
2561
|
+
if ( materialProperties.lightProbeGrid !== objectVolume ) {
|
|
2562
|
+
|
|
2563
|
+
materialProperties.lightProbeGrid = objectVolume;
|
|
2564
|
+
refreshMaterial = true;
|
|
2565
|
+
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2410
2570
|
if ( refreshProgram || _currentCamera !== camera ) {
|
|
2411
2571
|
|
|
2412
2572
|
// common camera uniforms
|
|
@@ -2433,6 +2593,7 @@ class WebGLRenderer {
|
|
|
2433
2593
|
|
|
2434
2594
|
}
|
|
2435
2595
|
|
|
2596
|
+
|
|
2436
2597
|
const uCamPos = p_uniforms.map.cameraPosition;
|
|
2437
2598
|
|
|
2438
2599
|
if ( uCamPos !== undefined ) {
|
|
@@ -2476,6 +2637,30 @@ class WebGLRenderer {
|
|
|
2476
2637
|
|
|
2477
2638
|
}
|
|
2478
2639
|
|
|
2640
|
+
// Pre-allocate texture units for shadow samplers before setting data textures
|
|
2641
|
+
if ( materialProperties.needsLights ) {
|
|
2642
|
+
|
|
2643
|
+
// Set shadow map uniforms first to ensure they get the first texture units
|
|
2644
|
+
if ( lights.state.directionalShadowMap.length > 0 ) {
|
|
2645
|
+
|
|
2646
|
+
p_uniforms.setValue( _gl, 'directionalShadowMap', lights.state.directionalShadowMap, textures );
|
|
2647
|
+
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
if ( lights.state.spotShadowMap.length > 0 ) {
|
|
2651
|
+
|
|
2652
|
+
p_uniforms.setValue( _gl, 'spotShadowMap', lights.state.spotShadowMap, textures );
|
|
2653
|
+
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
if ( lights.state.pointShadowMap.length > 0 ) {
|
|
2657
|
+
|
|
2658
|
+
p_uniforms.setValue( _gl, 'pointShadowMap', lights.state.pointShadowMap, textures );
|
|
2659
|
+
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2479
2664
|
// skinning and morph target uniforms must be set even if material didn't change
|
|
2480
2665
|
// auto-setting of texture unit for bone and morph texture must go before other textures
|
|
2481
2666
|
// otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
|
|
@@ -2529,17 +2714,7 @@ class WebGLRenderer {
|
|
|
2529
2714
|
|
|
2530
2715
|
}
|
|
2531
2716
|
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
if ( material.isMeshGouraudMaterial && material.envMap !== null ) {
|
|
2535
|
-
|
|
2536
|
-
m_uniforms.envMap.value = envMap;
|
|
2537
|
-
|
|
2538
|
-
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
2539
|
-
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
|
|
2717
|
+
if ( ( material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ) && material.envMap === null && scene.environment !== null ) {
|
|
2543
2718
|
|
|
2544
2719
|
m_uniforms.envMapIntensity.value = scene.environmentIntensity;
|
|
2545
2720
|
|
|
@@ -2581,6 +2756,19 @@ class WebGLRenderer {
|
|
|
2581
2756
|
|
|
2582
2757
|
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
|
|
2583
2758
|
|
|
2759
|
+
// light probe volume
|
|
2760
|
+
|
|
2761
|
+
if ( materialProperties.needsLights && materialProperties.lightProbeGrid ) {
|
|
2762
|
+
|
|
2763
|
+
const volume = materialProperties.lightProbeGrid;
|
|
2764
|
+
|
|
2765
|
+
m_uniforms.probesSH.value = volume.texture;
|
|
2766
|
+
m_uniforms.probesMin.value.copy( volume.boundingBox.min );
|
|
2767
|
+
m_uniforms.probesMax.value.copy( volume.boundingBox.max );
|
|
2768
|
+
m_uniforms.probesResolution.value.copy( volume.resolution );
|
|
2769
|
+
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2584
2772
|
WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
|
|
2585
2773
|
|
|
2586
2774
|
}
|
|
@@ -2615,7 +2803,7 @@ class WebGLRenderer {
|
|
|
2615
2803
|
|
|
2616
2804
|
// UBOs
|
|
2617
2805
|
|
|
2618
|
-
if ( material.
|
|
2806
|
+
if ( material.uniformsGroups !== undefined ) {
|
|
2619
2807
|
|
|
2620
2808
|
const groups = material.uniformsGroups;
|
|
2621
2809
|
|
|
@@ -2725,7 +2913,7 @@ class WebGLRenderer {
|
|
|
2725
2913
|
const renderTargetProperties = properties.get( renderTarget );
|
|
2726
2914
|
|
|
2727
2915
|
renderTargetProperties.__autoAllocateDepthBuffer = renderTarget.resolveDepthBuffer === false;
|
|
2728
|
-
if (
|
|
2916
|
+
if ( renderTargetProperties.__autoAllocateDepthBuffer === false && ( ! _currentRenderTarget || ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) ) {
|
|
2729
2917
|
|
|
2730
2918
|
// The multisample_render_to_texture extension doesn't work properly if there
|
|
2731
2919
|
// are midframe flushes and an external depth buffer. Disable use of the extension.
|
|
@@ -2772,7 +2960,6 @@ class WebGLRenderer {
|
|
|
2772
2960
|
_currentActiveCubeFace = activeCubeFace;
|
|
2773
2961
|
_currentActiveMipmapLevel = activeMipmapLevel;
|
|
2774
2962
|
|
|
2775
|
-
let useDefaultFramebuffer = true;
|
|
2776
2963
|
let framebuffer = null;
|
|
2777
2964
|
let isCube = false;
|
|
2778
2965
|
let isRenderTarget3D = false;
|
|
@@ -2783,9 +2970,21 @@ class WebGLRenderer {
|
|
|
2783
2970
|
|
|
2784
2971
|
if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
|
|
2785
2972
|
|
|
2786
|
-
//
|
|
2787
|
-
|
|
2788
|
-
|
|
2973
|
+
// Externally-managed framebuffer (e.g. XR)
|
|
2974
|
+
// Bind to the stored framebuffer (may be null for default, or a WebGLFramebuffer)
|
|
2975
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
2976
|
+
|
|
2977
|
+
_currentViewport.copy( renderTarget.viewport );
|
|
2978
|
+
_currentScissor.copy( renderTarget.scissor );
|
|
2979
|
+
_currentScissorTest = renderTarget.scissorTest;
|
|
2980
|
+
|
|
2981
|
+
state.viewport( _currentViewport );
|
|
2982
|
+
state.scissor( _currentScissor );
|
|
2983
|
+
state.setScissorTest( _currentScissorTest );
|
|
2984
|
+
|
|
2985
|
+
_currentMaterialId = - 1;
|
|
2986
|
+
|
|
2987
|
+
return;
|
|
2789
2988
|
|
|
2790
2989
|
} else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
|
|
2791
2990
|
|
|
@@ -2884,7 +3083,7 @@ class WebGLRenderer {
|
|
|
2884
3083
|
|
|
2885
3084
|
const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2886
3085
|
|
|
2887
|
-
if ( framebufferBound
|
|
3086
|
+
if ( framebufferBound ) {
|
|
2888
3087
|
|
|
2889
3088
|
state.drawBuffers( renderTarget, framebuffer );
|
|
2890
3089
|
|
|
@@ -2963,6 +3162,10 @@ class WebGLRenderer {
|
|
|
2963
3162
|
const textureFormat = texture.format;
|
|
2964
3163
|
const textureType = texture.type;
|
|
2965
3164
|
|
|
3165
|
+
// when using MRT, select the correct color buffer for the subsequent read command
|
|
3166
|
+
|
|
3167
|
+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
3168
|
+
|
|
2966
3169
|
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2967
3170
|
|
|
2968
3171
|
error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
@@ -2981,10 +3184,6 @@ class WebGLRenderer {
|
|
|
2981
3184
|
|
|
2982
3185
|
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2983
3186
|
|
|
2984
|
-
// when using MRT, select the correct color buffer for the subsequent read command
|
|
2985
|
-
|
|
2986
|
-
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
2987
|
-
|
|
2988
3187
|
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
|
|
2989
3188
|
|
|
2990
3189
|
}
|
|
@@ -3045,6 +3244,11 @@ class WebGLRenderer {
|
|
|
3045
3244
|
const textureFormat = texture.format;
|
|
3046
3245
|
const textureType = texture.type;
|
|
3047
3246
|
|
|
3247
|
+
// when using MRT, select the correct color buffer for the subsequent read command
|
|
3248
|
+
|
|
3249
|
+
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
3250
|
+
|
|
3251
|
+
|
|
3048
3252
|
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
3049
3253
|
|
|
3050
3254
|
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
@@ -3061,10 +3265,6 @@ class WebGLRenderer {
|
|
|
3061
3265
|
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
3062
3266
|
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
3063
3267
|
|
|
3064
|
-
// when using MRT, select the correct color buffer for the subsequent read command
|
|
3065
|
-
|
|
3066
|
-
if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
|
|
3067
|
-
|
|
3068
3268
|
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
3069
3269
|
|
|
3070
3270
|
// reset the frame buffer to the currently set buffer before waiting
|
|
@@ -3134,27 +3334,9 @@ class WebGLRenderer {
|
|
|
3134
3334
|
* @param {?(Box2|Box3)} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
|
|
3135
3335
|
* @param {?(Vector2|Vector3)} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
|
|
3136
3336
|
* @param {number} [srcLevel=0] - The source mipmap level to copy.
|
|
3137
|
-
* @param {?number} [dstLevel=
|
|
3337
|
+
* @param {?number} [dstLevel=0] - The destination mipmap level.
|
|
3138
3338
|
*/
|
|
3139
|
-
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel =
|
|
3140
|
-
|
|
3141
|
-
// support the previous signature with just a single dst mipmap level
|
|
3142
|
-
if ( dstLevel === null ) {
|
|
3143
|
-
|
|
3144
|
-
if ( srcLevel !== 0 ) {
|
|
3145
|
-
|
|
3146
|
-
// @deprecated, r171
|
|
3147
|
-
warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.' );
|
|
3148
|
-
dstLevel = srcLevel;
|
|
3149
|
-
srcLevel = 0;
|
|
3150
|
-
|
|
3151
|
-
} else {
|
|
3152
|
-
|
|
3153
|
-
dstLevel = 0;
|
|
3154
|
-
|
|
3155
|
-
}
|
|
3156
|
-
|
|
3157
|
-
}
|
|
3339
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = 0 ) {
|
|
3158
3340
|
|
|
3159
3341
|
// gather the necessary dimensions to copy
|
|
3160
3342
|
let width, height, depth, minX, minY, minZ;
|
|
@@ -3230,22 +3412,24 @@ class WebGLRenderer {
|
|
|
3230
3412
|
|
|
3231
3413
|
}
|
|
3232
3414
|
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3415
|
+
state.activeTexture( _gl.TEXTURE0 ); // see #33153
|
|
3416
|
+
|
|
3417
|
+
state.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
3418
|
+
state.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
3419
|
+
state.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
3236
3420
|
|
|
3237
3421
|
// used for copying data from cpu
|
|
3238
|
-
const currentUnpackRowLen =
|
|
3239
|
-
const currentUnpackImageHeight =
|
|
3240
|
-
const currentUnpackSkipPixels =
|
|
3241
|
-
const currentUnpackSkipRows =
|
|
3242
|
-
const currentUnpackSkipImages =
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3422
|
+
const currentUnpackRowLen = state.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
3423
|
+
const currentUnpackImageHeight = state.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
3424
|
+
const currentUnpackSkipPixels = state.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
3425
|
+
const currentUnpackSkipRows = state.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
3426
|
+
const currentUnpackSkipImages = state.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
3427
|
+
|
|
3428
|
+
state.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
3429
|
+
state.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
3430
|
+
state.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
|
|
3431
|
+
state.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
|
|
3432
|
+
state.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
|
|
3249
3433
|
|
|
3250
3434
|
// set up the src texture
|
|
3251
3435
|
const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
|
|
@@ -3371,11 +3555,11 @@ class WebGLRenderer {
|
|
|
3371
3555
|
}
|
|
3372
3556
|
|
|
3373
3557
|
// reset values
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3558
|
+
state.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
|
|
3559
|
+
state.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
|
|
3560
|
+
state.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
|
|
3561
|
+
state.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
|
|
3562
|
+
state.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
|
|
3379
3563
|
|
|
3380
3564
|
// Generate mipmaps only when copying level 0
|
|
3381
3565
|
if ( dstLevel === 0 && dstTexture.generateMipmaps ) {
|
|
@@ -3519,6 +3703,7 @@ class WebGLRenderer {
|
|
|
3519
3703
|
* Note that this setting uses `gl_FragDepth` if available which disables the Early Fragment Test optimization and can cause a decrease in performance.
|
|
3520
3704
|
* @property {boolean} [reversedDepthBuffer=false] Whether to use a reverse depth buffer. Requires the `EXT_clip_control` extension.
|
|
3521
3705
|
* This is a more faster and accurate version than logarithmic depth buffer.
|
|
3706
|
+
* @property {number} [outputBufferType=UnsignedByteType] Defines the type of the output buffer. Use `HalfFloatType` for HDR rendering with tone mapping and post-processing support.
|
|
3522
3707
|
**/
|
|
3523
3708
|
|
|
3524
3709
|
/**
|
|
@@ -3540,7 +3725,6 @@ class WebGLRenderer {
|
|
|
3540
3725
|
* @property {string} precision - The shader precision currently being used by the renderer.
|
|
3541
3726
|
* @property {boolean} reversedDepthBuffer - `true` if `reversedDepthBuffer` was set to `true` in the constructor
|
|
3542
3727
|
* and the rendering context supports `EXT_clip_control`.
|
|
3543
|
-
* @property {boolean} vertexTextures - `true` if vertex textures can be used.
|
|
3544
3728
|
**/
|
|
3545
3729
|
|
|
3546
3730
|
/**
|
|
@@ -3582,7 +3766,7 @@ class WebGLRenderer {
|
|
|
3582
3766
|
* If you do not require dynamic lighting / shadows, you may set this to `false`.
|
|
3583
3767
|
* @property {boolean} [needsUpdate=false] - When set to `true`, shadow maps in the scene
|
|
3584
3768
|
* will be updated in the next `render` call.
|
|
3585
|
-
* @property {(BasicShadowMap|PCFShadowMap|
|
|
3769
|
+
* @property {(BasicShadowMap|PCFShadowMap|VSMShadowMap)} [type=PCFShadowMap] - Defines the shadow map type.
|
|
3586
3770
|
**/
|
|
3587
3771
|
|
|
3588
3772
|
export { WebGLRenderer };
|