super-three 0.177.0 → 0.181.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/README.md +1 -1
- package/build/three.cjs +1994 -749
- package/build/three.core.js +1358 -506
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +631 -247
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +113 -33
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +9571 -3424
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +9397 -3426
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +9 -9
- package/examples/jsm/controls/DragControls.js +7 -57
- package/examples/jsm/controls/FirstPersonControls.js +3 -3
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -10
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +62 -15
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +33 -25
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +683 -299
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +11 -13
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -4
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +4 -4
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +14 -8
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +136 -49
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +233 -34
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +247 -104
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +196 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +812 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
- package/examples/jsm/tsl/display/BloomNode.js +11 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
- package/examples/jsm/tsl/display/GTAONode.js +53 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +55 -43
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +182 -65
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +578 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +18 -20
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +22 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +5 -2
- package/src/Three.TSL.js +112 -32
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationClip.js +20 -4
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +8 -7
- package/src/animation/PropertyBinding.js +12 -11
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +2 -2
- package/src/cameras/PerspectiveCamera.js +2 -2
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +13 -5
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/Clock.js +2 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +4 -3
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +279 -55
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/Path.js +22 -22
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +8 -8
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +42 -12
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +29 -5
- package/src/loaders/ImageBitmapLoader.js +32 -8
- package/src/loaders/ImageLoader.js +56 -9
- package/src/loaders/Loader.js +17 -3
- package/src/loaders/LoadingManager.js +45 -0
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +16 -3
- package/src/materials/MeshBasicMaterial.js +2 -1
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -10
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +3 -3
- package/src/materials/nodes/NodeMaterial.js +90 -27
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +89 -3
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +9 -3
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +55 -34
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +69 -67
- package/src/math/Spherical.js +3 -3
- package/src/nodes/Nodes.js +6 -4
- package/src/nodes/TSL.js +9 -4
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +97 -30
- package/src/nodes/accessors/Object3DNode.js +2 -2
- package/src/nodes/accessors/Position.js +25 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +20 -4
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +3 -2
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +23 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +142 -44
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +13 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +48 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +36 -17
- package/src/nodes/core/Node.js +167 -34
- package/src/nodes/core/NodeBuilder.js +404 -120
- package/src/nodes/core/NodeFrame.js +21 -21
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +17 -88
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +77 -30
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +80 -14
- package/src/nodes/core/VarNode.js +142 -16
- package/src/nodes/core/VaryingNode.js +9 -6
- package/src/nodes/display/BlendModes.js +7 -6
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +35 -7
- package/src/nodes/display/NormalMapNode.js +20 -50
- package/src/nodes/display/PassNode.js +206 -17
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -40
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +94 -4
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +19 -18
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +81 -25
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +29 -3
- package/src/nodes/lighting/EnvironmentNode.js +11 -11
- package/src/nodes/lighting/LightsNode.js +7 -8
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +3 -1
- package/src/nodes/lighting/ShadowNode.js +77 -10
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +25 -27
- package/src/nodes/math/MathNode.js +106 -65
- package/src/nodes/math/OperatorNode.js +28 -43
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +6 -2
- package/src/nodes/tsl/TSLCore.js +546 -186
- package/src/nodes/utils/DebugNode.js +3 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +119 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -41
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +33 -6
- package/src/nodes/utils/ReflectorNode.js +68 -10
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +4 -3
- package/src/renderers/WebGLRenderer.js +77 -66
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +108 -27
- package/src/renderers/common/Background.js +4 -3
- package/src/renderers/common/Bindings.js +76 -19
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +61 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +84 -5
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +486 -255
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -68
- package/src/renderers/common/Sampler.js +117 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +27 -0
- package/src/renderers/common/Textures.js +138 -46
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +63 -24
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +161 -66
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +4 -3
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +25 -18
- package/src/renderers/webgl/WebGLPrograms.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +13 -2
- package/src/renderers/webgl/WebGLState.js +17 -16
- package/src/renderers/webgl/WebGLTextures.js +38 -21
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +245 -182
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +184 -30
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +9 -8
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +171 -19
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +205 -128
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +198 -121
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +8 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +49 -33
- package/src/renderers/webgpu/utils/WebGPUConstants.js +14 -3
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -37
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +266 -158
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +24 -19
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +89 -13
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +14 -3
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +29 -2
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
- package/examples/jsm/tsl/display/TRAAPassNode.js +0 -452
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -17,19 +17,25 @@ import RenderBundles from './RenderBundles.js';
|
|
|
17
17
|
import NodeLibrary from './nodes/NodeLibrary.js';
|
|
18
18
|
import Lighting from './Lighting.js';
|
|
19
19
|
import XRManager from './XRManager.js';
|
|
20
|
+
import InspectorBase from './InspectorBase.js';
|
|
21
|
+
import CanvasTarget from './CanvasTarget.js';
|
|
20
22
|
|
|
21
23
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
22
24
|
|
|
23
25
|
import { Scene } from '../../scenes/Scene.js';
|
|
26
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
24
27
|
import { Frustum } from '../../math/Frustum.js';
|
|
25
28
|
import { FrustumArray } from '../../math/FrustumArray.js';
|
|
26
29
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
27
30
|
import { Vector2 } from '../../math/Vector2.js';
|
|
28
31
|
import { Vector4 } from '../../math/Vector4.js';
|
|
29
32
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
30
|
-
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter,
|
|
33
|
+
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
|
|
31
34
|
|
|
35
|
+
import { float, vec3, vec4 } from '../../nodes/tsl/TSLCore.js';
|
|
36
|
+
import { reference } from '../../nodes/accessors/ReferenceNode.js';
|
|
32
37
|
import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
38
|
+
import { error, warn, warnOnce } from '../../utils.js';
|
|
33
39
|
|
|
34
40
|
const _scene = /*@__PURE__*/ new Scene();
|
|
35
41
|
const _drawingBufferSize = /*@__PURE__*/ new Vector2();
|
|
@@ -94,15 +100,6 @@ class Renderer {
|
|
|
94
100
|
multiview = false
|
|
95
101
|
} = parameters;
|
|
96
102
|
|
|
97
|
-
/**
|
|
98
|
-
* A reference to the canvas element the renderer is drawing to.
|
|
99
|
-
* This value of this property will automatically be created by
|
|
100
|
-
* the renderer.
|
|
101
|
-
*
|
|
102
|
-
* @type {HTMLCanvasElement|OffscreenCanvas}
|
|
103
|
-
*/
|
|
104
|
-
this.domElement = backend.getDomElement();
|
|
105
|
-
|
|
106
103
|
/**
|
|
107
104
|
* A reference to the current backend.
|
|
108
105
|
*
|
|
@@ -110,14 +107,6 @@ class Renderer {
|
|
|
110
107
|
*/
|
|
111
108
|
this.backend = backend;
|
|
112
109
|
|
|
113
|
-
/**
|
|
114
|
-
* The number of MSAA samples.
|
|
115
|
-
*
|
|
116
|
-
* @type {number}
|
|
117
|
-
* @default 0
|
|
118
|
-
*/
|
|
119
|
-
this.samples = samples || ( antialias === true ) ? 4 : 0;
|
|
120
|
-
|
|
121
110
|
/**
|
|
122
111
|
* Whether the renderer should automatically clear the current rendering target
|
|
123
112
|
* before execute a `render()` call. The target can be the canvas (default framebuffer)
|
|
@@ -266,61 +255,48 @@ class Renderer {
|
|
|
266
255
|
// internals
|
|
267
256
|
|
|
268
257
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
* @private
|
|
272
|
-
* @type {?Function}
|
|
273
|
-
*/
|
|
274
|
-
this._getFallback = getFallback;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* The renderer's pixel ratio.
|
|
278
|
-
*
|
|
279
|
-
* @private
|
|
280
|
-
* @type {number}
|
|
281
|
-
* @default 1
|
|
282
|
-
*/
|
|
283
|
-
this._pixelRatio = 1;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* The width of the renderer's default framebuffer in logical pixel unit.
|
|
258
|
+
* The number of MSAA samples.
|
|
287
259
|
*
|
|
288
260
|
* @private
|
|
289
261
|
* @type {number}
|
|
262
|
+
* @default 0
|
|
290
263
|
*/
|
|
291
|
-
this.
|
|
264
|
+
this._samples = samples || ( antialias === true ) ? 4 : 0;
|
|
292
265
|
|
|
293
266
|
/**
|
|
294
|
-
*
|
|
267
|
+
* OnCanvasTargetResize callback function.
|
|
295
268
|
*
|
|
296
269
|
* @private
|
|
297
|
-
* @type {
|
|
270
|
+
* @type {Function}
|
|
298
271
|
*/
|
|
299
|
-
this.
|
|
272
|
+
this._onCanvasTargetResize = this._onCanvasTargetResize.bind( this );
|
|
300
273
|
|
|
301
274
|
/**
|
|
302
|
-
* The
|
|
275
|
+
* The canvas target for rendering.
|
|
303
276
|
*
|
|
304
277
|
* @private
|
|
305
|
-
* @type {
|
|
278
|
+
* @type {CanvasTarget}
|
|
306
279
|
*/
|
|
307
|
-
this.
|
|
280
|
+
this._canvasTarget = new CanvasTarget( backend.getDomElement() );
|
|
281
|
+
this._canvasTarget.addEventListener( 'resize', this._onCanvasTargetResize );
|
|
282
|
+
this._canvasTarget.isDefaultCanvasTarget = true;
|
|
308
283
|
|
|
309
284
|
/**
|
|
310
|
-
* The
|
|
285
|
+
* The inspector provides information about the internal renderer state.
|
|
311
286
|
*
|
|
312
287
|
* @private
|
|
313
|
-
* @type {
|
|
288
|
+
* @type {InspectorBase}
|
|
314
289
|
*/
|
|
315
|
-
this.
|
|
290
|
+
this._inspector = new InspectorBase();
|
|
291
|
+
this._inspector.setRenderer( this );
|
|
316
292
|
|
|
317
293
|
/**
|
|
318
|
-
*
|
|
294
|
+
* This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
|
|
319
295
|
*
|
|
320
296
|
* @private
|
|
321
|
-
* @type {
|
|
297
|
+
* @type {?Function}
|
|
322
298
|
*/
|
|
323
|
-
this.
|
|
299
|
+
this._getFallback = getFallback;
|
|
324
300
|
|
|
325
301
|
/**
|
|
326
302
|
* A reference to a renderer module for managing shader attributes.
|
|
@@ -438,7 +414,8 @@ class Renderer {
|
|
|
438
414
|
* @type {QuadMesh}
|
|
439
415
|
*/
|
|
440
416
|
this._quad = new QuadMesh( new NodeMaterial() );
|
|
441
|
-
this._quad.
|
|
417
|
+
this._quad.name = 'Output Color Transform';
|
|
418
|
+
this._quad.material.name = 'outputColorTransform';
|
|
442
419
|
|
|
443
420
|
/**
|
|
444
421
|
* A reference to the current render context.
|
|
@@ -620,6 +597,14 @@ class Renderer {
|
|
|
620
597
|
*/
|
|
621
598
|
this._colorBufferType = colorBufferType;
|
|
622
599
|
|
|
600
|
+
/**
|
|
601
|
+
* A cache for shadow nodes per material
|
|
602
|
+
*
|
|
603
|
+
* @private
|
|
604
|
+
* @type {WeakMap<Material, Object>}
|
|
605
|
+
*/
|
|
606
|
+
this._cacheShadowNodes = new WeakMap();
|
|
607
|
+
|
|
623
608
|
/**
|
|
624
609
|
* Whether the renderer has been initialized or not.
|
|
625
610
|
*
|
|
@@ -737,12 +722,6 @@ class Renderer {
|
|
|
737
722
|
*/
|
|
738
723
|
async init() {
|
|
739
724
|
|
|
740
|
-
if ( this._initialized ) {
|
|
741
|
-
|
|
742
|
-
throw new Error( 'Renderer: Backend has already been initialized.' );
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
725
|
if ( this._initPromise !== null ) {
|
|
747
726
|
|
|
748
727
|
return this._initPromise;
|
|
@@ -785,7 +764,7 @@ class Renderer {
|
|
|
785
764
|
}
|
|
786
765
|
|
|
787
766
|
this._nodes = new Nodes( this, backend );
|
|
788
|
-
this._animation = new Animation( this._nodes, this.info );
|
|
767
|
+
this._animation = new Animation( this, this._nodes, this.info );
|
|
789
768
|
this._attributes = new Attributes( backend );
|
|
790
769
|
this._background = new Background( this, this._nodes );
|
|
791
770
|
this._geometries = new Geometries( this._attributes, this.info );
|
|
@@ -802,6 +781,12 @@ class Renderer {
|
|
|
802
781
|
this._animation.start();
|
|
803
782
|
this._initialized = true;
|
|
804
783
|
|
|
784
|
+
//
|
|
785
|
+
|
|
786
|
+
this._inspector.init();
|
|
787
|
+
|
|
788
|
+
//
|
|
789
|
+
|
|
805
790
|
resolve( this );
|
|
806
791
|
|
|
807
792
|
} );
|
|
@@ -810,6 +795,19 @@ class Renderer {
|
|
|
810
795
|
|
|
811
796
|
}
|
|
812
797
|
|
|
798
|
+
/**
|
|
799
|
+
* A reference to the canvas element the renderer is drawing to.
|
|
800
|
+
* This value of this property will automatically be created by
|
|
801
|
+
* the renderer.
|
|
802
|
+
*
|
|
803
|
+
* @type {HTMLCanvasElement|OffscreenCanvas}
|
|
804
|
+
*/
|
|
805
|
+
get domElement() {
|
|
806
|
+
|
|
807
|
+
return this._canvasTarget.domElement;
|
|
808
|
+
|
|
809
|
+
}
|
|
810
|
+
|
|
813
811
|
/**
|
|
814
812
|
* The coordinate system of the renderer. The value of this property
|
|
815
813
|
* depends on the selected backend. Either `THREE.WebGLCoordinateSystem` or
|
|
@@ -967,15 +965,18 @@ class Renderer {
|
|
|
967
965
|
* Renders the scene in an async fashion.
|
|
968
966
|
*
|
|
969
967
|
* @async
|
|
968
|
+
* @deprecated
|
|
970
969
|
* @param {Object3D} scene - The scene or 3D object to render.
|
|
971
970
|
* @param {Camera} camera - The camera.
|
|
972
971
|
* @return {Promise} A Promise that resolves when the render has been finished.
|
|
973
972
|
*/
|
|
974
973
|
async renderAsync( scene, camera ) {
|
|
975
974
|
|
|
976
|
-
|
|
975
|
+
warnOnce( 'Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
977
976
|
|
|
978
|
-
this.
|
|
977
|
+
await this.init();
|
|
978
|
+
|
|
979
|
+
this.render( scene, camera );
|
|
979
980
|
|
|
980
981
|
}
|
|
981
982
|
|
|
@@ -984,11 +985,38 @@ class Renderer {
|
|
|
984
985
|
* the CPU waits for the GPU to complete its operation (e.g. a compute task).
|
|
985
986
|
*
|
|
986
987
|
* @async
|
|
988
|
+
* @deprecated
|
|
987
989
|
* @return {Promise} A Promise that resolves when synchronization has been finished.
|
|
988
990
|
*/
|
|
989
991
|
async waitForGPU() {
|
|
990
992
|
|
|
991
|
-
|
|
993
|
+
error( 'Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.' );
|
|
994
|
+
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
//
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Sets the inspector instance. The inspector can be any class that extends from `InspectorBase`.
|
|
1001
|
+
*
|
|
1002
|
+
* @param {InspectorBase} value - The new inspector.
|
|
1003
|
+
*/
|
|
1004
|
+
set inspector( value ) {
|
|
1005
|
+
|
|
1006
|
+
if ( this._inspector !== null ) {
|
|
1007
|
+
|
|
1008
|
+
this._inspector.setRenderer( null );
|
|
1009
|
+
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
this._inspector = value;
|
|
1013
|
+
this._inspector.setRenderer( this );
|
|
1014
|
+
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
get inspector() {
|
|
1018
|
+
|
|
1019
|
+
return this._inspector;
|
|
992
1020
|
|
|
993
1021
|
}
|
|
994
1022
|
|
|
@@ -1081,7 +1109,7 @@ class Renderer {
|
|
|
1081
1109
|
|
|
1082
1110
|
}
|
|
1083
1111
|
|
|
1084
|
-
|
|
1112
|
+
error( errorMessage );
|
|
1085
1113
|
|
|
1086
1114
|
this._isDeviceLost = true;
|
|
1087
1115
|
|
|
@@ -1173,23 +1201,24 @@ class Renderer {
|
|
|
1173
1201
|
|
|
1174
1202
|
/**
|
|
1175
1203
|
* Renders the scene or 3D object with the given camera. This method can only be called
|
|
1176
|
-
* if the renderer has been initialized.
|
|
1204
|
+
* if the renderer has been initialized. When using `render()` inside an animation loop,
|
|
1205
|
+
* it's guaranteed the renderer will be initialized. The animation loop must be defined
|
|
1206
|
+
* with {@link Renderer#setAnimationLoop} though.
|
|
1207
|
+
*
|
|
1208
|
+
* For all other use cases (like when using on-demand rendering), you must call
|
|
1209
|
+
* {@link Renderer#init} before rendering.
|
|
1177
1210
|
*
|
|
1178
1211
|
* The target of the method is the default framebuffer (meaning the canvas)
|
|
1179
1212
|
* or alternatively a render target when specified via `setRenderTarget()`.
|
|
1180
1213
|
*
|
|
1181
1214
|
* @param {Object3D} scene - The scene or 3D object to render.
|
|
1182
1215
|
* @param {Camera} camera - The camera to render the scene with.
|
|
1183
|
-
* @return {?Promise} A Promise that resolve when the scene has been rendered.
|
|
1184
|
-
* Only returned when the renderer has not been initialized.
|
|
1185
1216
|
*/
|
|
1186
1217
|
render( scene, camera ) {
|
|
1187
1218
|
|
|
1188
1219
|
if ( this._initialized === false ) {
|
|
1189
1220
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
return this.renderAsync( scene, camera );
|
|
1221
|
+
throw new Error( 'Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.' );
|
|
1193
1222
|
|
|
1194
1223
|
}
|
|
1195
1224
|
|
|
@@ -1197,6 +1226,18 @@ class Renderer {
|
|
|
1197
1226
|
|
|
1198
1227
|
}
|
|
1199
1228
|
|
|
1229
|
+
/**
|
|
1230
|
+
* Returns whether the renderer has been initialized or not.
|
|
1231
|
+
*
|
|
1232
|
+
* @readonly
|
|
1233
|
+
* @return {boolean} Whether the renderer has been initialized or not.
|
|
1234
|
+
*/
|
|
1235
|
+
get initialized() {
|
|
1236
|
+
|
|
1237
|
+
return this._initialized;
|
|
1238
|
+
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1200
1241
|
/**
|
|
1201
1242
|
* Returns an internal render target which is used when computing the output tone mapping
|
|
1202
1243
|
* and color space conversion. Unlike in `WebGLRenderer`, this is done in a separate render
|
|
@@ -1210,7 +1251,7 @@ class Renderer {
|
|
|
1210
1251
|
const { currentToneMapping, currentColorSpace } = this;
|
|
1211
1252
|
|
|
1212
1253
|
const useToneMapping = currentToneMapping !== NoToneMapping;
|
|
1213
|
-
const useColorSpace = currentColorSpace !==
|
|
1254
|
+
const useColorSpace = currentColorSpace !== ColorManagement.workingColorSpace;
|
|
1214
1255
|
|
|
1215
1256
|
if ( useToneMapping === false && useColorSpace === false ) return null;
|
|
1216
1257
|
|
|
@@ -1226,7 +1267,7 @@ class Renderer {
|
|
|
1226
1267
|
stencilBuffer: stencil,
|
|
1227
1268
|
type: this._colorBufferType,
|
|
1228
1269
|
format: RGBAFormat,
|
|
1229
|
-
colorSpace:
|
|
1270
|
+
colorSpace: ColorManagement.workingColorSpace,
|
|
1230
1271
|
generateMipmaps: false,
|
|
1231
1272
|
minFilter: LinearFilter,
|
|
1232
1273
|
magFilter: LinearFilter,
|
|
@@ -1253,14 +1294,16 @@ class Renderer {
|
|
|
1253
1294
|
|
|
1254
1295
|
}
|
|
1255
1296
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
frameBufferTarget.viewport.
|
|
1259
|
-
frameBufferTarget.scissor.
|
|
1260
|
-
frameBufferTarget.
|
|
1297
|
+
const canvasTarget = this._canvasTarget;
|
|
1298
|
+
|
|
1299
|
+
frameBufferTarget.viewport.copy( canvasTarget._viewport );
|
|
1300
|
+
frameBufferTarget.scissor.copy( canvasTarget._scissor );
|
|
1301
|
+
frameBufferTarget.viewport.multiplyScalar( canvasTarget._pixelRatio );
|
|
1302
|
+
frameBufferTarget.scissor.multiplyScalar( canvasTarget._pixelRatio );
|
|
1303
|
+
frameBufferTarget.scissorTest = canvasTarget._scissorTest;
|
|
1261
1304
|
frameBufferTarget.multiview = outputRenderTarget !== null ? outputRenderTarget.multiview : false;
|
|
1262
1305
|
frameBufferTarget.resolveDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.resolveDepthBuffer : true;
|
|
1263
|
-
frameBufferTarget.
|
|
1306
|
+
frameBufferTarget._autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget._autoAllocateDepthBuffer : false;
|
|
1264
1307
|
|
|
1265
1308
|
return frameBufferTarget;
|
|
1266
1309
|
|
|
@@ -1279,6 +1322,8 @@ class Renderer {
|
|
|
1279
1322
|
|
|
1280
1323
|
if ( this._isDeviceLost === true ) return;
|
|
1281
1324
|
|
|
1325
|
+
//
|
|
1326
|
+
|
|
1282
1327
|
const frameBufferTarget = useFrameBufferTarget ? this._getFrameBufferTarget() : null;
|
|
1283
1328
|
|
|
1284
1329
|
// preserve render tree
|
|
@@ -1331,6 +1376,12 @@ class Renderer {
|
|
|
1331
1376
|
|
|
1332
1377
|
//
|
|
1333
1378
|
|
|
1379
|
+
this.backend.updateTimeStampUID( renderContext );
|
|
1380
|
+
|
|
1381
|
+
this.inspector.beginRender( this.backend.getTimestampUID( renderContext ), scene, camera, renderTarget );
|
|
1382
|
+
|
|
1383
|
+
//
|
|
1384
|
+
|
|
1334
1385
|
const coordinateSystem = this.coordinateSystem;
|
|
1335
1386
|
const xr = this.xr;
|
|
1336
1387
|
|
|
@@ -1367,9 +1418,11 @@ class Renderer {
|
|
|
1367
1418
|
|
|
1368
1419
|
//
|
|
1369
1420
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
let
|
|
1421
|
+
const canvasTarget = this._canvasTarget;
|
|
1422
|
+
|
|
1423
|
+
let viewport = canvasTarget._viewport;
|
|
1424
|
+
let scissor = canvasTarget._scissor;
|
|
1425
|
+
let pixelRatio = canvasTarget._pixelRatio;
|
|
1373
1426
|
|
|
1374
1427
|
if ( renderTarget !== null ) {
|
|
1375
1428
|
|
|
@@ -1394,7 +1447,7 @@ class Renderer {
|
|
|
1394
1447
|
renderContext.viewport = renderContext.viewportValue.equals( _screen ) === false;
|
|
1395
1448
|
|
|
1396
1449
|
renderContext.scissorValue.copy( scissor ).multiplyScalar( pixelRatio ).floor();
|
|
1397
|
-
renderContext.scissor =
|
|
1450
|
+
renderContext.scissor = canvasTarget._scissorTest && renderContext.scissorValue.equals( _screen ) === false;
|
|
1398
1451
|
renderContext.scissorValue.width >>= activeMipmapLevel;
|
|
1399
1452
|
renderContext.scissorValue.height >>= activeMipmapLevel;
|
|
1400
1453
|
|
|
@@ -1412,7 +1465,7 @@ class Renderer {
|
|
|
1412
1465
|
if ( ! camera.isArrayCamera ) {
|
|
1413
1466
|
|
|
1414
1467
|
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
1415
|
-
frustum.setFromProjectionMatrix( _projScreenMatrix, coordinateSystem );
|
|
1468
|
+
frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
|
|
1416
1469
|
|
|
1417
1470
|
}
|
|
1418
1471
|
|
|
@@ -1449,8 +1502,8 @@ class Renderer {
|
|
|
1449
1502
|
|
|
1450
1503
|
renderContext.textures = null;
|
|
1451
1504
|
renderContext.depthTexture = null;
|
|
1452
|
-
renderContext.width =
|
|
1453
|
-
renderContext.height =
|
|
1505
|
+
renderContext.width = _drawingBufferSize.width;
|
|
1506
|
+
renderContext.height = _drawingBufferSize.height;
|
|
1454
1507
|
renderContext.depth = this.depth;
|
|
1455
1508
|
renderContext.stencil = this.stencil;
|
|
1456
1509
|
|
|
@@ -1464,6 +1517,22 @@ class Renderer {
|
|
|
1464
1517
|
|
|
1465
1518
|
//
|
|
1466
1519
|
|
|
1520
|
+
renderContext.scissorValue.max( _vector4.set( 0, 0, 0, 0 ) );
|
|
1521
|
+
|
|
1522
|
+
if ( renderContext.scissorValue.x + renderContext.scissorValue.width > renderContext.width ) {
|
|
1523
|
+
|
|
1524
|
+
renderContext.scissorValue.width = Math.max( renderContext.width - renderContext.scissorValue.x, 0 );
|
|
1525
|
+
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
if ( renderContext.scissorValue.y + renderContext.scissorValue.height > renderContext.height ) {
|
|
1529
|
+
|
|
1530
|
+
renderContext.scissorValue.height = Math.max( renderContext.height - renderContext.scissorValue.y, 0 );
|
|
1531
|
+
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
//
|
|
1535
|
+
|
|
1467
1536
|
this._background.update( sceneRef, renderList, renderContext );
|
|
1468
1537
|
|
|
1469
1538
|
//
|
|
@@ -1512,14 +1581,20 @@ class Renderer {
|
|
|
1512
1581
|
|
|
1513
1582
|
//
|
|
1514
1583
|
|
|
1584
|
+
this.inspector.finishRender( this.backend.getTimestampUID( renderContext ) );
|
|
1585
|
+
|
|
1586
|
+
//
|
|
1587
|
+
|
|
1515
1588
|
return renderContext;
|
|
1516
1589
|
|
|
1517
1590
|
}
|
|
1518
1591
|
|
|
1519
1592
|
_setXRLayerSize( width, height ) {
|
|
1520
1593
|
|
|
1521
|
-
|
|
1522
|
-
|
|
1594
|
+
// TODO: Find a better solution to resize the canvas when in XR.
|
|
1595
|
+
|
|
1596
|
+
this._canvasTarget._width = width;
|
|
1597
|
+
this._canvasTarget._height = height;
|
|
1523
1598
|
|
|
1524
1599
|
this.setViewport( 0, 0, width, height );
|
|
1525
1600
|
|
|
@@ -1597,7 +1672,7 @@ class Renderer {
|
|
|
1597
1672
|
* for best compatibility.
|
|
1598
1673
|
*
|
|
1599
1674
|
* @async
|
|
1600
|
-
* @param {?
|
|
1675
|
+
* @param {?onAnimationCallback} callback - The application's animation loop.
|
|
1601
1676
|
* @return {Promise} A Promise that resolves when the set has been executed.
|
|
1602
1677
|
*/
|
|
1603
1678
|
async setAnimationLoop( callback ) {
|
|
@@ -1608,6 +1683,17 @@ class Renderer {
|
|
|
1608
1683
|
|
|
1609
1684
|
}
|
|
1610
1685
|
|
|
1686
|
+
/**
|
|
1687
|
+
* Returns the current animation loop callback.
|
|
1688
|
+
*
|
|
1689
|
+
* @return {?Function} The current animation loop callback.
|
|
1690
|
+
*/
|
|
1691
|
+
getAnimationLoop() {
|
|
1692
|
+
|
|
1693
|
+
return this._animation.getAnimationLoop();
|
|
1694
|
+
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1611
1697
|
/**
|
|
1612
1698
|
* Can be used to transfer buffer data from a storage buffer attribute
|
|
1613
1699
|
* from the GPU to the CPU in context of compute shaders.
|
|
@@ -1640,7 +1726,7 @@ class Renderer {
|
|
|
1640
1726
|
*/
|
|
1641
1727
|
getPixelRatio() {
|
|
1642
1728
|
|
|
1643
|
-
return this.
|
|
1729
|
+
return this._canvasTarget.getPixelRatio();
|
|
1644
1730
|
|
|
1645
1731
|
}
|
|
1646
1732
|
|
|
@@ -1652,7 +1738,7 @@ class Renderer {
|
|
|
1652
1738
|
*/
|
|
1653
1739
|
getDrawingBufferSize( target ) {
|
|
1654
1740
|
|
|
1655
|
-
return
|
|
1741
|
+
return this._canvasTarget.getDrawingBufferSize( target );
|
|
1656
1742
|
|
|
1657
1743
|
}
|
|
1658
1744
|
|
|
@@ -1664,7 +1750,7 @@ class Renderer {
|
|
|
1664
1750
|
*/
|
|
1665
1751
|
getSize( target ) {
|
|
1666
1752
|
|
|
1667
|
-
return
|
|
1753
|
+
return this._canvasTarget.getSize( target );
|
|
1668
1754
|
|
|
1669
1755
|
}
|
|
1670
1756
|
|
|
@@ -1675,11 +1761,7 @@ class Renderer {
|
|
|
1675
1761
|
*/
|
|
1676
1762
|
setPixelRatio( value = 1 ) {
|
|
1677
1763
|
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
this._pixelRatio = value;
|
|
1681
|
-
|
|
1682
|
-
this.setSize( this._width, this._height, false );
|
|
1764
|
+
this._canvasTarget.setPixelRatio( value );
|
|
1683
1765
|
|
|
1684
1766
|
}
|
|
1685
1767
|
|
|
@@ -1701,17 +1783,7 @@ class Renderer {
|
|
|
1701
1783
|
// Renderer can't be resized while presenting in XR.
|
|
1702
1784
|
if ( this.xr && this.xr.isPresenting ) return;
|
|
1703
1785
|
|
|
1704
|
-
this.
|
|
1705
|
-
this._height = height;
|
|
1706
|
-
|
|
1707
|
-
this._pixelRatio = pixelRatio;
|
|
1708
|
-
|
|
1709
|
-
this.domElement.width = Math.floor( width * pixelRatio );
|
|
1710
|
-
this.domElement.height = Math.floor( height * pixelRatio );
|
|
1711
|
-
|
|
1712
|
-
this.setViewport( 0, 0, width, height );
|
|
1713
|
-
|
|
1714
|
-
if ( this._initialized ) this.backend.updateSize();
|
|
1786
|
+
this._canvasTarget.setDrawingBufferSize( width, height, pixelRatio );
|
|
1715
1787
|
|
|
1716
1788
|
}
|
|
1717
1789
|
|
|
@@ -1727,22 +1799,7 @@ class Renderer {
|
|
|
1727
1799
|
// Renderer can't be resized while presenting in XR.
|
|
1728
1800
|
if ( this.xr && this.xr.isPresenting ) return;
|
|
1729
1801
|
|
|
1730
|
-
this.
|
|
1731
|
-
this._height = height;
|
|
1732
|
-
|
|
1733
|
-
this.domElement.width = Math.floor( width * this._pixelRatio );
|
|
1734
|
-
this.domElement.height = Math.floor( height * this._pixelRatio );
|
|
1735
|
-
|
|
1736
|
-
if ( updateStyle === true ) {
|
|
1737
|
-
|
|
1738
|
-
this.domElement.style.width = width + 'px';
|
|
1739
|
-
this.domElement.style.height = height + 'px';
|
|
1740
|
-
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
this.setViewport( 0, 0, width, height );
|
|
1744
|
-
|
|
1745
|
-
if ( this._initialized ) this.backend.updateSize();
|
|
1802
|
+
this._canvasTarget.setSize( width, height, updateStyle );
|
|
1746
1803
|
|
|
1747
1804
|
}
|
|
1748
1805
|
|
|
@@ -1778,14 +1835,7 @@ class Renderer {
|
|
|
1778
1835
|
*/
|
|
1779
1836
|
getScissor( target ) {
|
|
1780
1837
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
target.x = scissor.x;
|
|
1784
|
-
target.y = scissor.y;
|
|
1785
|
-
target.width = scissor.width;
|
|
1786
|
-
target.height = scissor.height;
|
|
1787
|
-
|
|
1788
|
-
return target;
|
|
1838
|
+
return this._canvasTarget.getScissor( target );
|
|
1789
1839
|
|
|
1790
1840
|
}
|
|
1791
1841
|
|
|
@@ -1800,17 +1850,7 @@ class Renderer {
|
|
|
1800
1850
|
*/
|
|
1801
1851
|
setScissor( x, y, width, height ) {
|
|
1802
1852
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
if ( x.isVector4 ) {
|
|
1806
|
-
|
|
1807
|
-
scissor.copy( x );
|
|
1808
|
-
|
|
1809
|
-
} else {
|
|
1810
|
-
|
|
1811
|
-
scissor.set( x, y, width, height );
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1853
|
+
this._canvasTarget.setScissor( x, y, width, height );
|
|
1814
1854
|
|
|
1815
1855
|
}
|
|
1816
1856
|
|
|
@@ -1821,7 +1861,7 @@ class Renderer {
|
|
|
1821
1861
|
*/
|
|
1822
1862
|
getScissorTest() {
|
|
1823
1863
|
|
|
1824
|
-
return this.
|
|
1864
|
+
return this._canvasTarget.getScissorTest();
|
|
1825
1865
|
|
|
1826
1866
|
}
|
|
1827
1867
|
|
|
@@ -1832,7 +1872,9 @@ class Renderer {
|
|
|
1832
1872
|
*/
|
|
1833
1873
|
setScissorTest( boolean ) {
|
|
1834
1874
|
|
|
1835
|
-
this.
|
|
1875
|
+
this._canvasTarget.setScissorTest( boolean );
|
|
1876
|
+
|
|
1877
|
+
// TODO: Move it to CanvasTarget event listener.
|
|
1836
1878
|
|
|
1837
1879
|
this.backend.setScissorTest( boolean );
|
|
1838
1880
|
|
|
@@ -1846,7 +1888,7 @@ class Renderer {
|
|
|
1846
1888
|
*/
|
|
1847
1889
|
getViewport( target ) {
|
|
1848
1890
|
|
|
1849
|
-
return
|
|
1891
|
+
return this._canvasTarget.getViewport( target );
|
|
1850
1892
|
|
|
1851
1893
|
}
|
|
1852
1894
|
|
|
@@ -1862,20 +1904,7 @@ class Renderer {
|
|
|
1862
1904
|
*/
|
|
1863
1905
|
setViewport( x, y, width, height, minDepth = 0, maxDepth = 1 ) {
|
|
1864
1906
|
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
if ( x.isVector4 ) {
|
|
1868
|
-
|
|
1869
|
-
viewport.copy( x );
|
|
1870
|
-
|
|
1871
|
-
} else {
|
|
1872
|
-
|
|
1873
|
-
viewport.set( x, y, width, height );
|
|
1874
|
-
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
viewport.minDepth = minDepth;
|
|
1878
|
-
viewport.maxDepth = maxDepth;
|
|
1907
|
+
this._canvasTarget.setViewport( x, y, width, height, minDepth, maxDepth );
|
|
1879
1908
|
|
|
1880
1909
|
}
|
|
1881
1910
|
|
|
@@ -1992,16 +2021,12 @@ class Renderer {
|
|
|
1992
2021
|
* @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
|
|
1993
2022
|
* @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
|
|
1994
2023
|
* @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
|
|
1995
|
-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1996
|
-
* Only returned when the renderer has not been initialized.
|
|
1997
2024
|
*/
|
|
1998
2025
|
clear( color = true, depth = true, stencil = true ) {
|
|
1999
2026
|
|
|
2000
2027
|
if ( this._initialized === false ) {
|
|
2001
2028
|
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
return this.clearAsync( color, depth, stencil );
|
|
2029
|
+
throw new Error( 'Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
|
|
2005
2030
|
|
|
2006
2031
|
}
|
|
2007
2032
|
|
|
@@ -2042,37 +2067,28 @@ class Renderer {
|
|
|
2042
2067
|
|
|
2043
2068
|
/**
|
|
2044
2069
|
* Performs a manual clear operation of the color buffer. This method ignores `autoClear` properties.
|
|
2045
|
-
*
|
|
2046
|
-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2047
|
-
* Only returned when the renderer has not been initialized.
|
|
2048
2070
|
*/
|
|
2049
2071
|
clearColor() {
|
|
2050
2072
|
|
|
2051
|
-
|
|
2073
|
+
this.clear( true, false, false );
|
|
2052
2074
|
|
|
2053
2075
|
}
|
|
2054
2076
|
|
|
2055
2077
|
/**
|
|
2056
2078
|
* Performs a manual clear operation of the depth buffer. This method ignores `autoClear` properties.
|
|
2057
|
-
*
|
|
2058
|
-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2059
|
-
* Only returned when the renderer has not been initialized.
|
|
2060
2079
|
*/
|
|
2061
2080
|
clearDepth() {
|
|
2062
2081
|
|
|
2063
|
-
|
|
2082
|
+
this.clear( false, true, false );
|
|
2064
2083
|
|
|
2065
2084
|
}
|
|
2066
2085
|
|
|
2067
2086
|
/**
|
|
2068
2087
|
* Performs a manual clear operation of the stencil buffer. This method ignores `autoClear` properties.
|
|
2069
|
-
*
|
|
2070
|
-
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2071
|
-
* Only returned when the renderer has not been initialized.
|
|
2072
2088
|
*/
|
|
2073
2089
|
clearStencil() {
|
|
2074
2090
|
|
|
2075
|
-
|
|
2091
|
+
this.clear( false, false, true );
|
|
2076
2092
|
|
|
2077
2093
|
}
|
|
2078
2094
|
|
|
@@ -2080,6 +2096,7 @@ class Renderer {
|
|
|
2080
2096
|
* Async version of {@link Renderer#clear}.
|
|
2081
2097
|
*
|
|
2082
2098
|
* @async
|
|
2099
|
+
* @deprecated
|
|
2083
2100
|
* @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
|
|
2084
2101
|
* @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
|
|
2085
2102
|
* @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
|
|
@@ -2087,7 +2104,9 @@ class Renderer {
|
|
|
2087
2104
|
*/
|
|
2088
2105
|
async clearAsync( color = true, depth = true, stencil = true ) {
|
|
2089
2106
|
|
|
2090
|
-
|
|
2107
|
+
warnOnce( 'Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
2108
|
+
|
|
2109
|
+
await this.init();
|
|
2091
2110
|
|
|
2092
2111
|
this.clear( color, depth, stencil );
|
|
2093
2112
|
|
|
@@ -2097,11 +2116,14 @@ class Renderer {
|
|
|
2097
2116
|
* Async version of {@link Renderer#clearColor}.
|
|
2098
2117
|
*
|
|
2099
2118
|
* @async
|
|
2119
|
+
* @deprecated
|
|
2100
2120
|
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2101
2121
|
*/
|
|
2102
2122
|
async clearColorAsync() {
|
|
2103
2123
|
|
|
2104
|
-
|
|
2124
|
+
warnOnce( 'Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
2125
|
+
|
|
2126
|
+
this.clear( true, false, false );
|
|
2105
2127
|
|
|
2106
2128
|
}
|
|
2107
2129
|
|
|
@@ -2109,11 +2131,14 @@ class Renderer {
|
|
|
2109
2131
|
* Async version of {@link Renderer#clearDepth}.
|
|
2110
2132
|
*
|
|
2111
2133
|
* @async
|
|
2134
|
+
* @deprecated
|
|
2112
2135
|
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2113
2136
|
*/
|
|
2114
2137
|
async clearDepthAsync() {
|
|
2115
2138
|
|
|
2116
|
-
|
|
2139
|
+
warnOnce( 'Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
2140
|
+
|
|
2141
|
+
this.clear( false, true, false );
|
|
2117
2142
|
|
|
2118
2143
|
}
|
|
2119
2144
|
|
|
@@ -2121,17 +2146,73 @@ class Renderer {
|
|
|
2121
2146
|
* Async version of {@link Renderer#clearStencil}.
|
|
2122
2147
|
*
|
|
2123
2148
|
* @async
|
|
2149
|
+
* @deprecated
|
|
2124
2150
|
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2125
2151
|
*/
|
|
2126
2152
|
async clearStencilAsync() {
|
|
2127
2153
|
|
|
2128
|
-
|
|
2154
|
+
warnOnce( 'Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
2155
|
+
|
|
2156
|
+
this.clear( false, false, true );
|
|
2157
|
+
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* Returns `true` if a framebuffer target is needed to perform tone mapping or color space conversion.
|
|
2162
|
+
* If this is the case, the renderer allocates an internal render target for that purpose.
|
|
2163
|
+
*
|
|
2164
|
+
*/
|
|
2165
|
+
get needsFrameBufferTarget() {
|
|
2166
|
+
|
|
2167
|
+
const useToneMapping = this.currentToneMapping !== NoToneMapping;
|
|
2168
|
+
const useColorSpace = this.currentColorSpace !== ColorManagement.workingColorSpace;
|
|
2169
|
+
|
|
2170
|
+
return useToneMapping || useColorSpace;
|
|
2171
|
+
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
/**
|
|
2175
|
+
* The number of samples used for multi-sample anti-aliasing (MSAA).
|
|
2176
|
+
*
|
|
2177
|
+
* @type {number}
|
|
2178
|
+
* @default 0
|
|
2179
|
+
*/
|
|
2180
|
+
get samples() {
|
|
2181
|
+
|
|
2182
|
+
return this._samples;
|
|
2183
|
+
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
/**
|
|
2187
|
+
* The current number of samples used for multi-sample anti-aliasing (MSAA).
|
|
2188
|
+
*
|
|
2189
|
+
* When rendering to a custom render target, the number of samples of that render target is used.
|
|
2190
|
+
* If the renderer needs an internal framebuffer target for tone mapping or color space conversion,
|
|
2191
|
+
* the number of samples is set to 0.
|
|
2192
|
+
*
|
|
2193
|
+
* @type {number}
|
|
2194
|
+
*/
|
|
2195
|
+
get currentSamples() {
|
|
2196
|
+
|
|
2197
|
+
let samples = this._samples;
|
|
2198
|
+
|
|
2199
|
+
if ( this._renderTarget !== null ) {
|
|
2200
|
+
|
|
2201
|
+
samples = this._renderTarget.samples;
|
|
2202
|
+
|
|
2203
|
+
} else if ( this.needsFrameBufferTarget ) {
|
|
2204
|
+
|
|
2205
|
+
samples = 0;
|
|
2206
|
+
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
return samples;
|
|
2129
2210
|
|
|
2130
2211
|
}
|
|
2131
2212
|
|
|
2132
2213
|
/**
|
|
2133
|
-
* The current
|
|
2134
|
-
* the
|
|
2214
|
+
* The current tone mapping of the renderer. When not producing screen output,
|
|
2215
|
+
* the tone mapping is always `NoToneMapping`.
|
|
2135
2216
|
*
|
|
2136
2217
|
* @type {number}
|
|
2137
2218
|
*/
|
|
@@ -2142,14 +2223,14 @@ class Renderer {
|
|
|
2142
2223
|
}
|
|
2143
2224
|
|
|
2144
2225
|
/**
|
|
2145
|
-
* The current
|
|
2146
|
-
* the
|
|
2226
|
+
* The current color space of the renderer. When not producing screen output,
|
|
2227
|
+
* the color space is always the working color space.
|
|
2147
2228
|
*
|
|
2148
2229
|
* @type {string}
|
|
2149
2230
|
*/
|
|
2150
2231
|
get currentColorSpace() {
|
|
2151
2232
|
|
|
2152
|
-
return this.isOutputTarget ? this.outputColorSpace :
|
|
2233
|
+
return this.isOutputTarget ? this.outputColorSpace : ColorManagement.workingColorSpace;
|
|
2153
2234
|
|
|
2154
2235
|
}
|
|
2155
2236
|
|
|
@@ -2170,25 +2251,30 @@ class Renderer {
|
|
|
2170
2251
|
*/
|
|
2171
2252
|
dispose() {
|
|
2172
2253
|
|
|
2173
|
-
this.
|
|
2174
|
-
this.backend.dispose();
|
|
2254
|
+
if ( this._initialized === true ) {
|
|
2175
2255
|
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
this._pipelines.dispose();
|
|
2179
|
-
this._nodes.dispose();
|
|
2180
|
-
this._bindings.dispose();
|
|
2181
|
-
this._renderLists.dispose();
|
|
2182
|
-
this._renderContexts.dispose();
|
|
2183
|
-
this._textures.dispose();
|
|
2256
|
+
this.info.dispose();
|
|
2257
|
+
this.backend.dispose();
|
|
2184
2258
|
|
|
2185
|
-
|
|
2259
|
+
this._animation.dispose();
|
|
2260
|
+
this._objects.dispose();
|
|
2261
|
+
this._geometries.dispose();
|
|
2262
|
+
this._pipelines.dispose();
|
|
2263
|
+
this._nodes.dispose();
|
|
2264
|
+
this._bindings.dispose();
|
|
2265
|
+
this._renderLists.dispose();
|
|
2266
|
+
this._renderContexts.dispose();
|
|
2267
|
+
this._textures.dispose();
|
|
2186
2268
|
|
|
2187
|
-
|
|
2269
|
+
if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
|
|
2188
2270
|
|
|
2189
|
-
|
|
2271
|
+
Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
|
|
2190
2272
|
|
|
2191
|
-
|
|
2273
|
+
if ( queryPool !== null ) queryPool.dispose();
|
|
2274
|
+
|
|
2275
|
+
} );
|
|
2276
|
+
|
|
2277
|
+
}
|
|
2192
2278
|
|
|
2193
2279
|
this.setRenderTarget( null );
|
|
2194
2280
|
this.setAnimationLoop( null );
|
|
@@ -2245,6 +2331,32 @@ class Renderer {
|
|
|
2245
2331
|
|
|
2246
2332
|
}
|
|
2247
2333
|
|
|
2334
|
+
/**
|
|
2335
|
+
* Sets the canvas target. The canvas target manages the HTML canvas
|
|
2336
|
+
* or the offscreen canvas the renderer draws into.
|
|
2337
|
+
*
|
|
2338
|
+
* @param {CanvasTarget} canvasTarget - The canvas target.
|
|
2339
|
+
*/
|
|
2340
|
+
setCanvasTarget( canvasTarget ) {
|
|
2341
|
+
|
|
2342
|
+
this._canvasTarget.removeEventListener( 'resize', this._onCanvasTargetResize );
|
|
2343
|
+
|
|
2344
|
+
this._canvasTarget = canvasTarget;
|
|
2345
|
+
this._canvasTarget.addEventListener( 'resize', this._onCanvasTargetResize );
|
|
2346
|
+
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
/**
|
|
2350
|
+
* Returns the current canvas target.
|
|
2351
|
+
*
|
|
2352
|
+
* @return {CanvasTarget} The current canvas target.
|
|
2353
|
+
*/
|
|
2354
|
+
getCanvasTarget() {
|
|
2355
|
+
|
|
2356
|
+
return this._canvasTarget;
|
|
2357
|
+
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2248
2360
|
/**
|
|
2249
2361
|
* Resets the renderer to the initial state before WebXR started.
|
|
2250
2362
|
*
|
|
@@ -2308,17 +2420,21 @@ class Renderer {
|
|
|
2308
2420
|
* if the renderer has been initialized.
|
|
2309
2421
|
*
|
|
2310
2422
|
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2423
|
+
* @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
|
|
2424
|
+
* - A single number representing count, or
|
|
2425
|
+
* - An array [x, y, z] representing dispatch size, or
|
|
2426
|
+
* - A IndirectStorageBufferAttribute for indirect dispatch size.
|
|
2311
2427
|
* @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
|
|
2312
2428
|
*/
|
|
2313
|
-
compute( computeNodes ) {
|
|
2429
|
+
compute( computeNodes, dispatchSize = null ) {
|
|
2314
2430
|
|
|
2315
2431
|
if ( this._isDeviceLost === true ) return;
|
|
2316
2432
|
|
|
2317
2433
|
if ( this._initialized === false ) {
|
|
2318
2434
|
|
|
2319
|
-
|
|
2435
|
+
warn( 'Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.' );
|
|
2320
2436
|
|
|
2321
|
-
return this.computeAsync( computeNodes );
|
|
2437
|
+
return this.computeAsync( computeNodes, dispatchSize );
|
|
2322
2438
|
|
|
2323
2439
|
}
|
|
2324
2440
|
|
|
@@ -2338,6 +2454,12 @@ class Renderer {
|
|
|
2338
2454
|
|
|
2339
2455
|
//
|
|
2340
2456
|
|
|
2457
|
+
this.backend.updateTimeStampUID( computeNodes );
|
|
2458
|
+
|
|
2459
|
+
this.inspector.beginCompute( this.backend.getTimestampUID( computeNodes ), computeNodes );
|
|
2460
|
+
|
|
2461
|
+
//
|
|
2462
|
+
|
|
2341
2463
|
const backend = this.backend;
|
|
2342
2464
|
const pipelines = this._pipelines;
|
|
2343
2465
|
const bindings = this._bindings;
|
|
@@ -2364,7 +2486,7 @@ class Renderer {
|
|
|
2364
2486
|
computeNode.removeEventListener( 'dispose', dispose );
|
|
2365
2487
|
|
|
2366
2488
|
pipelines.delete( computeNode );
|
|
2367
|
-
bindings.
|
|
2489
|
+
bindings.deleteForCompute( computeNode );
|
|
2368
2490
|
nodes.delete( computeNode );
|
|
2369
2491
|
|
|
2370
2492
|
};
|
|
@@ -2389,7 +2511,7 @@ class Renderer {
|
|
|
2389
2511
|
const computeBindings = bindings.getForCompute( computeNode );
|
|
2390
2512
|
const computePipeline = pipelines.getForCompute( computeNode, computeBindings );
|
|
2391
2513
|
|
|
2392
|
-
backend.compute( computeNodes, computeNode, computeBindings, computePipeline );
|
|
2514
|
+
backend.compute( computeNodes, computeNode, computeBindings, computePipeline, dispatchSize );
|
|
2393
2515
|
|
|
2394
2516
|
}
|
|
2395
2517
|
|
|
@@ -2399,6 +2521,10 @@ class Renderer {
|
|
|
2399
2521
|
|
|
2400
2522
|
nodeFrame.renderId = previousRenderId;
|
|
2401
2523
|
|
|
2524
|
+
//
|
|
2525
|
+
|
|
2526
|
+
this.inspector.finishCompute( this.backend.getTimestampUID( computeNodes ) );
|
|
2527
|
+
|
|
2402
2528
|
}
|
|
2403
2529
|
|
|
2404
2530
|
/**
|
|
@@ -2406,13 +2532,17 @@ class Renderer {
|
|
|
2406
2532
|
*
|
|
2407
2533
|
* @async
|
|
2408
2534
|
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2535
|
+
* @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
|
|
2536
|
+
* - A single number representing count, or
|
|
2537
|
+
* - An array [x, y, z] representing dispatch size, or
|
|
2538
|
+
* - A IndirectStorageBufferAttribute for indirect dispatch size.
|
|
2409
2539
|
* @return {Promise} A Promise that resolve when the compute has finished.
|
|
2410
2540
|
*/
|
|
2411
|
-
async computeAsync( computeNodes ) {
|
|
2541
|
+
async computeAsync( computeNodes, dispatchSize = null ) {
|
|
2412
2542
|
|
|
2413
2543
|
if ( this._initialized === false ) await this.init();
|
|
2414
2544
|
|
|
2415
|
-
this.compute( computeNodes );
|
|
2545
|
+
this.compute( computeNodes, dispatchSize );
|
|
2416
2546
|
|
|
2417
2547
|
}
|
|
2418
2548
|
|
|
@@ -2420,14 +2550,17 @@ class Renderer {
|
|
|
2420
2550
|
* Checks if the given feature is supported by the selected backend.
|
|
2421
2551
|
*
|
|
2422
2552
|
* @async
|
|
2553
|
+
* @deprecated
|
|
2423
2554
|
* @param {string} name - The feature's name.
|
|
2424
2555
|
* @return {Promise<boolean>} A Promise that resolves with a bool that indicates whether the feature is supported or not.
|
|
2425
2556
|
*/
|
|
2426
2557
|
async hasFeatureAsync( name ) {
|
|
2427
2558
|
|
|
2428
|
-
|
|
2559
|
+
warnOnce( 'Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
2429
2560
|
|
|
2430
|
-
|
|
2561
|
+
await this.init();
|
|
2562
|
+
|
|
2563
|
+
return this.hasFeature( name );
|
|
2431
2564
|
|
|
2432
2565
|
}
|
|
2433
2566
|
|
|
@@ -2450,9 +2583,7 @@ class Renderer {
|
|
|
2450
2583
|
|
|
2451
2584
|
if ( this._initialized === false ) {
|
|
2452
2585
|
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
return false;
|
|
2586
|
+
throw new Error( 'Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
|
|
2456
2587
|
|
|
2457
2588
|
}
|
|
2458
2589
|
|
|
@@ -2476,14 +2607,17 @@ class Renderer {
|
|
|
2476
2607
|
* (which can cause noticeable lags due to decode and GPU upload overhead).
|
|
2477
2608
|
*
|
|
2478
2609
|
* @async
|
|
2610
|
+
* @deprecated
|
|
2479
2611
|
* @param {Texture} texture - The texture.
|
|
2480
2612
|
* @return {Promise} A Promise that resolves when the texture has been initialized.
|
|
2481
2613
|
*/
|
|
2482
2614
|
async initTextureAsync( texture ) {
|
|
2483
2615
|
|
|
2484
|
-
|
|
2616
|
+
warnOnce( 'Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
|
|
2485
2617
|
|
|
2486
|
-
this.
|
|
2618
|
+
await this.init();
|
|
2619
|
+
|
|
2620
|
+
this.initTexture( texture );
|
|
2487
2621
|
|
|
2488
2622
|
}
|
|
2489
2623
|
|
|
@@ -2499,7 +2633,7 @@ class Renderer {
|
|
|
2499
2633
|
|
|
2500
2634
|
if ( this._initialized === false ) {
|
|
2501
2635
|
|
|
2502
|
-
|
|
2636
|
+
throw new Error( 'Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
|
|
2503
2637
|
|
|
2504
2638
|
}
|
|
2505
2639
|
|
|
@@ -2511,7 +2645,7 @@ class Renderer {
|
|
|
2511
2645
|
* Copies the current bound framebuffer into the given texture.
|
|
2512
2646
|
*
|
|
2513
2647
|
* @param {FramebufferTexture} framebufferTexture - The texture.
|
|
2514
|
-
* @param {?Vector2|Vector4} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
|
|
2648
|
+
* @param {?(Vector2|Vector4)} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
|
|
2515
2649
|
*/
|
|
2516
2650
|
copyFramebufferToTexture( framebufferTexture, rectangle = null ) {
|
|
2517
2651
|
|
|
@@ -2527,7 +2661,7 @@ class Renderer {
|
|
|
2527
2661
|
|
|
2528
2662
|
} else {
|
|
2529
2663
|
|
|
2530
|
-
|
|
2664
|
+
error( 'Renderer.copyFramebufferToTexture: Invalid rectangle.' );
|
|
2531
2665
|
|
|
2532
2666
|
return;
|
|
2533
2667
|
|
|
@@ -2568,6 +2702,8 @@ class Renderer {
|
|
|
2568
2702
|
|
|
2569
2703
|
this.backend.copyFramebufferToTexture( framebufferTexture, renderContext, rectangle );
|
|
2570
2704
|
|
|
2705
|
+
this._inspector.copyFramebufferToTexture( framebufferTexture );
|
|
2706
|
+
|
|
2571
2707
|
}
|
|
2572
2708
|
|
|
2573
2709
|
/**
|
|
@@ -2587,6 +2723,8 @@ class Renderer {
|
|
|
2587
2723
|
|
|
2588
2724
|
this.backend.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, srcLevel, dstLevel );
|
|
2589
2725
|
|
|
2726
|
+
this._inspector.copyTextureToTexture( srcTexture, dstTexture );
|
|
2727
|
+
|
|
2590
2728
|
}
|
|
2591
2729
|
|
|
2592
2730
|
/**
|
|
@@ -2664,7 +2802,7 @@ class Renderer {
|
|
|
2664
2802
|
|
|
2665
2803
|
} else if ( object.isLineLoop ) {
|
|
2666
2804
|
|
|
2667
|
-
|
|
2805
|
+
error( 'Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.' );
|
|
2668
2806
|
|
|
2669
2807
|
} else if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
2670
2808
|
|
|
@@ -2833,6 +2971,93 @@ class Renderer {
|
|
|
2833
2971
|
|
|
2834
2972
|
}
|
|
2835
2973
|
|
|
2974
|
+
/**
|
|
2975
|
+
* Retrieves shadow nodes for the given material. This is used to setup shadow passes.
|
|
2976
|
+
* The result is cached per material and updated when the material's version changes.
|
|
2977
|
+
*
|
|
2978
|
+
* @param {Material} material
|
|
2979
|
+
* @returns {Object} - The shadow nodes for the material.
|
|
2980
|
+
*/
|
|
2981
|
+
_getShadowNodes( material ) {
|
|
2982
|
+
|
|
2983
|
+
const version = material.version;
|
|
2984
|
+
|
|
2985
|
+
let cache = this._cacheShadowNodes.get( material );
|
|
2986
|
+
|
|
2987
|
+
if ( cache === undefined || cache.version !== version ) {
|
|
2988
|
+
|
|
2989
|
+
const hasMap = material.map !== null;
|
|
2990
|
+
const hasColorNode = material.colorNode && material.colorNode.isNode;
|
|
2991
|
+
const hasCastShadowNode = material.castShadowNode && material.castShadowNode.isNode;
|
|
2992
|
+
|
|
2993
|
+
let positionNode = null;
|
|
2994
|
+
let colorNode = null;
|
|
2995
|
+
let depthNode = null;
|
|
2996
|
+
|
|
2997
|
+
if ( hasMap || hasColorNode || hasCastShadowNode ) {
|
|
2998
|
+
|
|
2999
|
+
let shadowRGB;
|
|
3000
|
+
let shadowAlpha;
|
|
3001
|
+
|
|
3002
|
+
if ( hasCastShadowNode ) {
|
|
3003
|
+
|
|
3004
|
+
shadowRGB = material.castShadowNode.rgb;
|
|
3005
|
+
shadowAlpha = material.castShadowNode.a;
|
|
3006
|
+
|
|
3007
|
+
} else {
|
|
3008
|
+
|
|
3009
|
+
shadowRGB = vec3( 0 );
|
|
3010
|
+
shadowAlpha = float( 1 );
|
|
3011
|
+
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
if ( hasMap ) {
|
|
3015
|
+
|
|
3016
|
+
shadowAlpha = shadowAlpha.mul( reference( 'map', 'texture', material ).a );
|
|
3017
|
+
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
if ( hasColorNode ) {
|
|
3021
|
+
|
|
3022
|
+
shadowAlpha = shadowAlpha.mul( material.colorNode.a );
|
|
3023
|
+
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
colorNode = vec4( shadowRGB, shadowAlpha );
|
|
3027
|
+
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
if ( material.depthNode && material.depthNode.isNode ) {
|
|
3031
|
+
|
|
3032
|
+
depthNode = material.depthNode;
|
|
3033
|
+
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
if ( material.castShadowPositionNode && material.castShadowPositionNode.isNode ) {
|
|
3037
|
+
|
|
3038
|
+
positionNode = material.castShadowPositionNode;
|
|
3039
|
+
|
|
3040
|
+
} else if ( material.positionNode && material.positionNode.isNode ) {
|
|
3041
|
+
|
|
3042
|
+
positionNode = material.positionNode;
|
|
3043
|
+
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
cache = {
|
|
3047
|
+
version,
|
|
3048
|
+
colorNode,
|
|
3049
|
+
depthNode,
|
|
3050
|
+
positionNode
|
|
3051
|
+
};
|
|
3052
|
+
|
|
3053
|
+
this._cacheShadowNodes.set( material, cache );
|
|
3054
|
+
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
return cache;
|
|
3058
|
+
|
|
3059
|
+
}
|
|
3060
|
+
|
|
2836
3061
|
/**
|
|
2837
3062
|
* This method represents the default render object function that manages the render lifecycle
|
|
2838
3063
|
* of the object.
|
|
@@ -2849,9 +3074,11 @@ class Renderer {
|
|
|
2849
3074
|
*/
|
|
2850
3075
|
renderObject( object, scene, camera, geometry, material, group, lightsNode, clippingContext = null, passId = null ) {
|
|
2851
3076
|
|
|
2852
|
-
let
|
|
2853
|
-
let
|
|
2854
|
-
let
|
|
3077
|
+
let materialOverride = false;
|
|
3078
|
+
let materialColorNode;
|
|
3079
|
+
let materialDepthNode;
|
|
3080
|
+
let materialPositionNode;
|
|
3081
|
+
let materialSide;
|
|
2855
3082
|
|
|
2856
3083
|
//
|
|
2857
3084
|
|
|
@@ -2863,41 +3090,35 @@ class Renderer {
|
|
|
2863
3090
|
|
|
2864
3091
|
const overrideMaterial = scene.overrideMaterial;
|
|
2865
3092
|
|
|
3093
|
+
materialOverride = true;
|
|
3094
|
+
|
|
3095
|
+
// store original nodes
|
|
3096
|
+
materialColorNode = scene.overrideMaterial.colorNode;
|
|
3097
|
+
materialDepthNode = scene.overrideMaterial.depthNode;
|
|
3098
|
+
materialPositionNode = scene.overrideMaterial.positionNode;
|
|
3099
|
+
materialSide = scene.overrideMaterial.side;
|
|
3100
|
+
|
|
2866
3101
|
if ( material.positionNode && material.positionNode.isNode ) {
|
|
2867
3102
|
|
|
2868
|
-
overridePositionNode = overrideMaterial.positionNode;
|
|
2869
3103
|
overrideMaterial.positionNode = material.positionNode;
|
|
2870
3104
|
|
|
2871
3105
|
}
|
|
2872
3106
|
|
|
2873
3107
|
overrideMaterial.alphaTest = material.alphaTest;
|
|
2874
3108
|
overrideMaterial.alphaMap = material.alphaMap;
|
|
2875
|
-
overrideMaterial.transparent = material.transparent || material.transmission > 0
|
|
3109
|
+
overrideMaterial.transparent = material.transparent || material.transmission > 0 ||
|
|
3110
|
+
( material.transmissionNode && material.transmissionNode.isNode ) ||
|
|
3111
|
+
( material.backdropNode && material.backdropNode.isNode );
|
|
2876
3112
|
|
|
2877
3113
|
if ( overrideMaterial.isShadowPassMaterial ) {
|
|
2878
3114
|
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
if ( material.depthNode && material.depthNode.isNode ) {
|
|
2882
|
-
|
|
2883
|
-
overrideDepthNode = overrideMaterial.depthNode;
|
|
2884
|
-
overrideMaterial.depthNode = material.depthNode;
|
|
2885
|
-
|
|
2886
|
-
}
|
|
2887
|
-
|
|
2888
|
-
if ( material.castShadowNode && material.castShadowNode.isNode ) {
|
|
2889
|
-
|
|
2890
|
-
overrideColorNode = overrideMaterial.colorNode;
|
|
2891
|
-
overrideMaterial.colorNode = material.castShadowNode;
|
|
2892
|
-
|
|
2893
|
-
}
|
|
2894
|
-
|
|
2895
|
-
if ( material.castShadowPositionNode && material.castShadowPositionNode.isNode ) {
|
|
3115
|
+
const { colorNode, depthNode, positionNode } = this._getShadowNodes( material );
|
|
2896
3116
|
|
|
2897
|
-
|
|
2898
|
-
overrideMaterial.positionNode = material.castShadowPositionNode;
|
|
3117
|
+
overrideMaterial.side = material.shadowSide === null ? material.side : material.shadowSide;
|
|
2899
3118
|
|
|
2900
|
-
|
|
3119
|
+
if ( colorNode !== null ) overrideMaterial.colorNode = colorNode;
|
|
3120
|
+
if ( depthNode !== null ) overrideMaterial.depthNode = depthNode;
|
|
3121
|
+
if ( positionNode !== null ) overrideMaterial.positionNode = positionNode;
|
|
2901
3122
|
|
|
2902
3123
|
}
|
|
2903
3124
|
|
|
@@ -2925,21 +3146,12 @@ class Renderer {
|
|
|
2925
3146
|
|
|
2926
3147
|
//
|
|
2927
3148
|
|
|
2928
|
-
if (
|
|
3149
|
+
if ( materialOverride ) {
|
|
2929
3150
|
|
|
2930
|
-
scene.overrideMaterial.
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
if ( overrideDepthNode !== undefined ) {
|
|
2935
|
-
|
|
2936
|
-
scene.overrideMaterial.depthNode = overrideDepthNode;
|
|
2937
|
-
|
|
2938
|
-
}
|
|
2939
|
-
|
|
2940
|
-
if ( overrideColorNode !== undefined ) {
|
|
2941
|
-
|
|
2942
|
-
scene.overrideMaterial.colorNode = overrideColorNode;
|
|
3151
|
+
scene.overrideMaterial.colorNode = materialColorNode;
|
|
3152
|
+
scene.overrideMaterial.depthNode = materialDepthNode;
|
|
3153
|
+
scene.overrideMaterial.positionNode = materialPositionNode;
|
|
3154
|
+
scene.overrideMaterial.side = materialSide;
|
|
2943
3155
|
|
|
2944
3156
|
}
|
|
2945
3157
|
|
|
@@ -2961,7 +3173,7 @@ class Renderer {
|
|
|
2961
3173
|
* @param {LightsNode} lightsNode - The current lights node.
|
|
2962
3174
|
* @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2963
3175
|
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2964
|
-
* @param {
|
|
3176
|
+
* @param {string} [passId] - An optional ID for identifying the pass.
|
|
2965
3177
|
*/
|
|
2966
3178
|
_renderObjectDirect( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
2967
3179
|
|
|
@@ -3016,7 +3228,7 @@ class Renderer {
|
|
|
3016
3228
|
* @param {LightsNode} lightsNode - The current lights node.
|
|
3017
3229
|
* @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
3018
3230
|
* @param {ClippingContext} clippingContext - The clipping context.
|
|
3019
|
-
* @param {
|
|
3231
|
+
* @param {string} [passId] - An optional ID for identifying the pass.
|
|
3020
3232
|
*/
|
|
3021
3233
|
_createObjectPipeline( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
3022
3234
|
|
|
@@ -3039,6 +3251,17 @@ class Renderer {
|
|
|
3039
3251
|
|
|
3040
3252
|
}
|
|
3041
3253
|
|
|
3254
|
+
/**
|
|
3255
|
+
* Callback when the canvas has been resized.
|
|
3256
|
+
*
|
|
3257
|
+
* @private
|
|
3258
|
+
*/
|
|
3259
|
+
_onCanvasTargetResize() {
|
|
3260
|
+
|
|
3261
|
+
if ( this._initialized ) this.backend.updateSize();
|
|
3262
|
+
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3042
3265
|
/**
|
|
3043
3266
|
* Alias for `compileAsync()`.
|
|
3044
3267
|
*
|
|
@@ -3056,4 +3279,12 @@ class Renderer {
|
|
|
3056
3279
|
|
|
3057
3280
|
}
|
|
3058
3281
|
|
|
3282
|
+
/**
|
|
3283
|
+
* Animation loop parameter of `renderer.setAnimationLoop()`.
|
|
3284
|
+
*
|
|
3285
|
+
* @callback onAnimationCallback
|
|
3286
|
+
* @param {DOMHighResTimeStamp} time - A timestamp indicating the end time of the previous frame's rendering.
|
|
3287
|
+
* @param {XRFrame} [frame] - A reference to the current XR frame. Only relevant when using XR rendering.
|
|
3288
|
+
*/
|
|
3289
|
+
|
|
3059
3290
|
export default Renderer;
|