super-three 0.171.0 → 0.173.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 +1 -1
- package/build/three.cjs +594 -427
- package/build/three.core.js +515 -81
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +79 -350
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +20 -7
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +29362 -3427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +29361 -3427
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +9 -7
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +48 -37
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +34 -29
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +4 -2
- package/examples/jsm/loaders/GLTFLoader.js +22 -4
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -2
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +14 -13
- package/examples/jsm/misc/Volume.js +27 -17
- package/examples/jsm/misc/VolumeSlice.js +7 -5
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +29 -24
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/OutputShader.js +5 -1
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +4 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +18 -5
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/ArrayCamera.js +1 -0
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/ImageUtils.js +1 -11
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +476 -23
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +121 -10
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +78 -20
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +95 -0
- package/src/nodes/Nodes.js +5 -6
- package/src/nodes/TSL.js +6 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +47 -6
- package/src/nodes/accessors/BatchNode.js +42 -6
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +113 -3
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +306 -12
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +65 -5
- package/src/nodes/accessors/Object3DNode.js +101 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +56 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +186 -0
- package/src/nodes/accessors/ReferenceNode.js +201 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +209 -8
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +38 -2
- package/src/nodes/accessors/Texture3DNode.js +91 -7
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +316 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +231 -25
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +80 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/ArrayNode.js +125 -0
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +350 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1166 -26
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +152 -1
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +51 -10
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +98 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +105 -6
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +146 -7
- package/src/nodes/core/VaryingNode.js +100 -3
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BlendModes.js +88 -1
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +300 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +96 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +110 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +174 -2
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +134 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +241 -35
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +78 -4
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +627 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +329 -18
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +2 -2
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +3 -2
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +39 -3
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +82 -2
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/MemberNode.js +68 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +54 -0
- package/src/nodes/utils/Timer.js +40 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/objects/ClippingGroup.js +49 -0
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +30 -4
- package/src/renderers/common/Animation.js +85 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +502 -44
- package/src/renderers/common/Background.js +48 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +45 -6
- package/src/renderers/common/ClippingContext.js +108 -15
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +91 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +78 -35
- package/src/renderers/common/Lighting.js +34 -6
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +99 -11
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +39 -10
- package/src/renderers/common/RenderContext.js +201 -2
- package/src/renderers/common/RenderContexts.js +59 -6
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +40 -3
- package/src/renderers/common/RenderObject.js +400 -17
- package/src/renderers/common/RenderObjects.js +103 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1170 -86
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +120 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +97 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +225 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +141 -2
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +76 -10
- package/src/renderers/common/nodes/NodeBuilderState.js +99 -5
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +90 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +243 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +352 -78
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +819 -116
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -18
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +58 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +168 -22
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +578 -164
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +36 -0
- package/src/renderers/webgpu/WebGPURenderer.js +36 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +674 -52
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +95 -14
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +94 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +262 -18
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +116 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +19 -2
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/src/textures/VideoFrameTexture.js +35 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/renderers/common/PostProcessingUtils.js +0 -86
|
@@ -16,6 +16,7 @@ import QuadMesh from './QuadMesh.js';
|
|
|
16
16
|
import RenderBundles from './RenderBundles.js';
|
|
17
17
|
import NodeLibrary from './nodes/NodeLibrary.js';
|
|
18
18
|
import Lighting from './Lighting.js';
|
|
19
|
+
import XRManager from './XRManager.js';
|
|
19
20
|
|
|
20
21
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
21
22
|
|
|
@@ -27,6 +28,8 @@ import { Vector4 } from '../../math/Vector4.js';
|
|
|
27
28
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
28
29
|
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, LinearSRGBColorSpace, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
|
|
29
30
|
|
|
31
|
+
/** @module Renderer **/
|
|
32
|
+
|
|
30
33
|
const _scene = /*@__PURE__*/ new Scene();
|
|
31
34
|
const _drawingBufferSize = /*@__PURE__*/ new Vector2();
|
|
32
35
|
const _screen = /*@__PURE__*/ new Vector4();
|
|
@@ -34,10 +37,36 @@ const _frustum = /*@__PURE__*/ new Frustum();
|
|
|
34
37
|
const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
|
|
35
38
|
const _vector4 = /*@__PURE__*/ new Vector4();
|
|
36
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Base class for renderers.
|
|
42
|
+
*/
|
|
37
43
|
class Renderer {
|
|
38
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a new renderer.
|
|
47
|
+
*
|
|
48
|
+
* @param {Backend} backend - The backend the renderer is targeting (e.g. WebGPU or WebGL 2).
|
|
49
|
+
* @param {Object} parameters - The configuration parameter.
|
|
50
|
+
* @param {Boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
51
|
+
* @param {Boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
52
|
+
* @param {Boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
53
|
+
* @param {Boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
54
|
+
* @param {Boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
|
|
55
|
+
* @param {Number} [parameters.samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0
|
|
56
|
+
* to overwrite the default.
|
|
57
|
+
* @param {Function?} [parameters.getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
|
|
58
|
+
* @param {Number} [parameters.colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
|
|
59
|
+
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
|
|
60
|
+
*/
|
|
39
61
|
constructor( backend, parameters = {} ) {
|
|
40
62
|
|
|
63
|
+
/**
|
|
64
|
+
* This flag can be used for type testing.
|
|
65
|
+
*
|
|
66
|
+
* @type {Boolean}
|
|
67
|
+
* @readonly
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
41
70
|
this.isRenderer = true;
|
|
42
71
|
|
|
43
72
|
//
|
|
@@ -49,35 +78,146 @@ class Renderer {
|
|
|
49
78
|
stencil = false,
|
|
50
79
|
antialias = false,
|
|
51
80
|
samples = 0,
|
|
52
|
-
getFallback = null
|
|
81
|
+
getFallback = null,
|
|
82
|
+
colorBufferType = HalfFloatType
|
|
53
83
|
} = parameters;
|
|
54
84
|
|
|
55
|
-
|
|
85
|
+
/**
|
|
86
|
+
* A reference to the canvas element the renderer is drawing to.
|
|
87
|
+
* This value of this property will automatically be created by
|
|
88
|
+
* the renderer.
|
|
89
|
+
*
|
|
90
|
+
* @type {HTMLCanvasElement|OffscreenCanvas}
|
|
91
|
+
*/
|
|
56
92
|
this.domElement = backend.getDomElement();
|
|
57
93
|
|
|
94
|
+
/**
|
|
95
|
+
* A reference to the current backend.
|
|
96
|
+
*
|
|
97
|
+
* @type {Backend}
|
|
98
|
+
*/
|
|
58
99
|
this.backend = backend;
|
|
59
100
|
|
|
101
|
+
/**
|
|
102
|
+
* The number of MSAA samples.
|
|
103
|
+
*
|
|
104
|
+
* @type {Number}
|
|
105
|
+
* @default 0
|
|
106
|
+
*/
|
|
60
107
|
this.samples = samples || ( antialias === true ) ? 4 : 0;
|
|
61
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Whether the renderer should automatically clear the current rendering target
|
|
111
|
+
* before execute a `render()` call. The target can be the canvas (default framebuffer)
|
|
112
|
+
* or the current bound render target (custom framebuffer).
|
|
113
|
+
*
|
|
114
|
+
* @type {Boolean}
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
62
117
|
this.autoClear = true;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* When `autoClear` is set to `true`, this property defines whether the renderer
|
|
121
|
+
* should clear the color buffer.
|
|
122
|
+
*
|
|
123
|
+
* @type {Boolean}
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
63
126
|
this.autoClearColor = true;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* When `autoClear` is set to `true`, this property defines whether the renderer
|
|
130
|
+
* should clear the depth buffer.
|
|
131
|
+
*
|
|
132
|
+
* @type {Boolean}
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
64
135
|
this.autoClearDepth = true;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* When `autoClear` is set to `true`, this property defines whether the renderer
|
|
139
|
+
* should clear the stencil buffer.
|
|
140
|
+
*
|
|
141
|
+
* @type {Boolean}
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
65
144
|
this.autoClearStencil = true;
|
|
66
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Whether the default framebuffer should be transparent or opaque.
|
|
148
|
+
*
|
|
149
|
+
* @type {Boolean}
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
67
152
|
this.alpha = alpha;
|
|
68
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Whether logarithmic depth buffer is enabled or not.
|
|
156
|
+
*
|
|
157
|
+
* @type {Boolean}
|
|
158
|
+
* @default false
|
|
159
|
+
*/
|
|
69
160
|
this.logarithmicDepthBuffer = logarithmicDepthBuffer;
|
|
70
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Defines the output color space of the renderer.
|
|
164
|
+
*
|
|
165
|
+
* @type {String}
|
|
166
|
+
* @default SRGBColorSpace
|
|
167
|
+
*/
|
|
71
168
|
this.outputColorSpace = SRGBColorSpace;
|
|
72
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Defines the tone mapping of the renderer.
|
|
172
|
+
*
|
|
173
|
+
* @type {Number}
|
|
174
|
+
* @default NoToneMapping
|
|
175
|
+
*/
|
|
73
176
|
this.toneMapping = NoToneMapping;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Defines the tone mapping exposure.
|
|
180
|
+
*
|
|
181
|
+
* @type {Number}
|
|
182
|
+
* @default 1
|
|
183
|
+
*/
|
|
74
184
|
this.toneMappingExposure = 1.0;
|
|
75
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Whether the renderer should sort its render lists or not.
|
|
188
|
+
*
|
|
189
|
+
* Note: Sorting is used to attempt to properly render objects that have some degree of transparency.
|
|
190
|
+
* By definition, sorting objects may not work in all cases. Depending on the needs of application,
|
|
191
|
+
* it may be necessary to turn off sorting and use other methods to deal with transparency rendering
|
|
192
|
+
* e.g. manually determining each object's rendering order.
|
|
193
|
+
*
|
|
194
|
+
* @type {Boolean}
|
|
195
|
+
* @default true
|
|
196
|
+
*/
|
|
76
197
|
this.sortObjects = true;
|
|
77
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Whether the default framebuffer should have a depth buffer or not.
|
|
201
|
+
*
|
|
202
|
+
* @type {Boolean}
|
|
203
|
+
* @default true
|
|
204
|
+
*/
|
|
78
205
|
this.depth = depth;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Whether the default framebuffer should have a stencil buffer or not.
|
|
209
|
+
*
|
|
210
|
+
* @type {Boolean}
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
79
213
|
this.stencil = stencil;
|
|
80
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Holds a series of statistical information about the GPU memory
|
|
217
|
+
* and the rendering process. Useful for debugging and monitoring.
|
|
218
|
+
*
|
|
219
|
+
* @type {Info}
|
|
220
|
+
*/
|
|
81
221
|
this.info = new Info();
|
|
82
222
|
|
|
83
223
|
this.nodes = {
|
|
@@ -85,82 +225,458 @@ class Renderer {
|
|
|
85
225
|
modelNormalViewMatrix: null
|
|
86
226
|
};
|
|
87
227
|
|
|
228
|
+
/**
|
|
229
|
+
* The node library defines how certain library objects like materials, lights
|
|
230
|
+
* or tone mapping functions are mapped to node types. This is required since
|
|
231
|
+
* although instances of classes like `MeshBasicMaterial` or `PointLight` can
|
|
232
|
+
* be part of the scene graph, they are internally represented as nodes for
|
|
233
|
+
* further processing.
|
|
234
|
+
*
|
|
235
|
+
* @type {NodeLibrary}
|
|
236
|
+
*/
|
|
88
237
|
this.library = new NodeLibrary();
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A map-like data structure for managing lights.
|
|
241
|
+
*
|
|
242
|
+
* @type {Lighting}
|
|
243
|
+
*/
|
|
89
244
|
this.lighting = new Lighting();
|
|
90
245
|
|
|
91
246
|
// internals
|
|
92
247
|
|
|
248
|
+
/**
|
|
249
|
+
* This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
|
|
250
|
+
*
|
|
251
|
+
* @private
|
|
252
|
+
* @type {Function}
|
|
253
|
+
*/
|
|
93
254
|
this._getFallback = getFallback;
|
|
94
255
|
|
|
256
|
+
/**
|
|
257
|
+
* The renderer's pixel ration.
|
|
258
|
+
*
|
|
259
|
+
* @private
|
|
260
|
+
* @type {Number}
|
|
261
|
+
* @default 1
|
|
262
|
+
*/
|
|
95
263
|
this._pixelRatio = 1;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The width of the renderer's default framebuffer in logical pixel unit.
|
|
267
|
+
*
|
|
268
|
+
* @private
|
|
269
|
+
* @type {Number}
|
|
270
|
+
*/
|
|
96
271
|
this._width = this.domElement.width;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The height of the renderer's default framebuffer in logical pixel unit.
|
|
275
|
+
*
|
|
276
|
+
* @private
|
|
277
|
+
* @type {Number}
|
|
278
|
+
*/
|
|
97
279
|
this._height = this.domElement.height;
|
|
98
280
|
|
|
281
|
+
/**
|
|
282
|
+
* The viewport of the renderer in logical pixel unit.
|
|
283
|
+
*
|
|
284
|
+
* @private
|
|
285
|
+
* @type {Vector4}
|
|
286
|
+
*/
|
|
99
287
|
this._viewport = new Vector4( 0, 0, this._width, this._height );
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The scissor rectangle of the renderer in logical pixel unit.
|
|
291
|
+
*
|
|
292
|
+
* @private
|
|
293
|
+
* @type {Vector4}
|
|
294
|
+
*/
|
|
100
295
|
this._scissor = new Vector4( 0, 0, this._width, this._height );
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Whether the scissor test should be enabled or not.
|
|
299
|
+
*
|
|
300
|
+
* @private
|
|
301
|
+
* @type {Boolean}
|
|
302
|
+
*/
|
|
101
303
|
this._scissorTest = false;
|
|
102
304
|
|
|
305
|
+
/**
|
|
306
|
+
* A reference to a renderer module for managing shader attributes.
|
|
307
|
+
*
|
|
308
|
+
* @private
|
|
309
|
+
* @type {Attributes?}
|
|
310
|
+
* @default null
|
|
311
|
+
*/
|
|
103
312
|
this._attributes = null;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* A reference to a renderer module for managing geometries.
|
|
316
|
+
*
|
|
317
|
+
* @private
|
|
318
|
+
* @type {Geometries?}
|
|
319
|
+
* @default null
|
|
320
|
+
*/
|
|
104
321
|
this._geometries = null;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* A reference to a renderer module for managing node related logic.
|
|
325
|
+
*
|
|
326
|
+
* @private
|
|
327
|
+
* @type {Nodes?}
|
|
328
|
+
* @default null
|
|
329
|
+
*/
|
|
105
330
|
this._nodes = null;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* A reference to a renderer module for managing the internal animation loop.
|
|
334
|
+
*
|
|
335
|
+
* @private
|
|
336
|
+
* @type {Animation?}
|
|
337
|
+
* @default null
|
|
338
|
+
*/
|
|
106
339
|
this._animation = null;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* A reference to a renderer module for managing shader program bindings.
|
|
343
|
+
*
|
|
344
|
+
* @private
|
|
345
|
+
* @type {Bindings?}
|
|
346
|
+
* @default null
|
|
347
|
+
*/
|
|
107
348
|
this._bindings = null;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* A reference to a renderer module for managing render objects.
|
|
352
|
+
*
|
|
353
|
+
* @private
|
|
354
|
+
* @type {RenderObjects?}
|
|
355
|
+
* @default null
|
|
356
|
+
*/
|
|
108
357
|
this._objects = null;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* A reference to a renderer module for managing render and compute pipelines.
|
|
361
|
+
*
|
|
362
|
+
* @private
|
|
363
|
+
* @type {Pipelines?}
|
|
364
|
+
* @default null
|
|
365
|
+
*/
|
|
109
366
|
this._pipelines = null;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* A reference to a renderer module for managing render bundles.
|
|
370
|
+
*
|
|
371
|
+
* @private
|
|
372
|
+
* @type {RenderBundles?}
|
|
373
|
+
* @default null
|
|
374
|
+
*/
|
|
110
375
|
this._bundles = null;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* A reference to a renderer module for managing render lists.
|
|
379
|
+
*
|
|
380
|
+
* @private
|
|
381
|
+
* @type {RenderLists?}
|
|
382
|
+
* @default null
|
|
383
|
+
*/
|
|
111
384
|
this._renderLists = null;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* A reference to a renderer module for managing render contexts.
|
|
388
|
+
*
|
|
389
|
+
* @private
|
|
390
|
+
* @type {RenderContexts?}
|
|
391
|
+
* @default null
|
|
392
|
+
*/
|
|
112
393
|
this._renderContexts = null;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* A reference to a renderer module for managing textures.
|
|
397
|
+
*
|
|
398
|
+
* @private
|
|
399
|
+
* @type {Textures?}
|
|
400
|
+
* @default null
|
|
401
|
+
*/
|
|
113
402
|
this._textures = null;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* A reference to a renderer module for backgrounds.
|
|
406
|
+
*
|
|
407
|
+
* @private
|
|
408
|
+
* @type {Background?}
|
|
409
|
+
* @default null
|
|
410
|
+
*/
|
|
114
411
|
this._background = null;
|
|
115
412
|
|
|
413
|
+
/**
|
|
414
|
+
* This fullscreen quad is used for internal render passes
|
|
415
|
+
* like the tone mapping and color space output pass.
|
|
416
|
+
*
|
|
417
|
+
* @private
|
|
418
|
+
* @type {QuadMesh}
|
|
419
|
+
*/
|
|
116
420
|
this._quad = new QuadMesh( new NodeMaterial() );
|
|
117
|
-
this._quad.material.
|
|
118
|
-
|
|
421
|
+
this._quad.material.name = 'Renderer_output';
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* A reference to the current render context.
|
|
425
|
+
*
|
|
426
|
+
* @private
|
|
427
|
+
* @type {RenderContext?}
|
|
428
|
+
* @default null
|
|
429
|
+
*/
|
|
119
430
|
this._currentRenderContext = null;
|
|
120
431
|
|
|
432
|
+
/**
|
|
433
|
+
* A custom sort function for the opaque render list.
|
|
434
|
+
*
|
|
435
|
+
* @private
|
|
436
|
+
* @type {Function?}
|
|
437
|
+
* @default null
|
|
438
|
+
*/
|
|
121
439
|
this._opaqueSort = null;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* A custom sort function for the transparent render list.
|
|
443
|
+
*
|
|
444
|
+
* @private
|
|
445
|
+
* @type {Function?}
|
|
446
|
+
* @default null
|
|
447
|
+
*/
|
|
122
448
|
this._transparentSort = null;
|
|
123
449
|
|
|
450
|
+
/**
|
|
451
|
+
* The framebuffer target.
|
|
452
|
+
*
|
|
453
|
+
* @private
|
|
454
|
+
* @type {RenderTarget?}
|
|
455
|
+
* @default null
|
|
456
|
+
*/
|
|
124
457
|
this._frameBufferTarget = null;
|
|
125
458
|
|
|
126
459
|
const alphaClear = this.alpha === true ? 0 : 1;
|
|
127
460
|
|
|
461
|
+
/**
|
|
462
|
+
* The clear color value.
|
|
463
|
+
*
|
|
464
|
+
* @private
|
|
465
|
+
* @type {Color4}
|
|
466
|
+
*/
|
|
128
467
|
this._clearColor = new Color4( 0, 0, 0, alphaClear );
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* The clear depth value.
|
|
471
|
+
*
|
|
472
|
+
* @private
|
|
473
|
+
* @type {Number}
|
|
474
|
+
* @default 1
|
|
475
|
+
*/
|
|
129
476
|
this._clearDepth = 1;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The clear stencil value.
|
|
480
|
+
*
|
|
481
|
+
* @private
|
|
482
|
+
* @type {Number}
|
|
483
|
+
* @default 0
|
|
484
|
+
*/
|
|
130
485
|
this._clearStencil = 0;
|
|
131
486
|
|
|
487
|
+
/**
|
|
488
|
+
* The current render target.
|
|
489
|
+
*
|
|
490
|
+
* @private
|
|
491
|
+
* @type {RenderTarget?}
|
|
492
|
+
* @default null
|
|
493
|
+
*/
|
|
132
494
|
this._renderTarget = null;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* The active cube face.
|
|
498
|
+
*
|
|
499
|
+
* @private
|
|
500
|
+
* @type {Number}
|
|
501
|
+
* @default 0
|
|
502
|
+
*/
|
|
133
503
|
this._activeCubeFace = 0;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* The active mipmap level.
|
|
507
|
+
*
|
|
508
|
+
* @private
|
|
509
|
+
* @type {Number}
|
|
510
|
+
* @default 0
|
|
511
|
+
*/
|
|
134
512
|
this._activeMipmapLevel = 0;
|
|
135
513
|
|
|
514
|
+
/**
|
|
515
|
+
* The MRT setting.
|
|
516
|
+
*
|
|
517
|
+
* @private
|
|
518
|
+
* @type {MRTNode?}
|
|
519
|
+
* @default null
|
|
520
|
+
*/
|
|
136
521
|
this._mrt = null;
|
|
137
522
|
|
|
523
|
+
/**
|
|
524
|
+
* This function defines how a render object is going
|
|
525
|
+
* to be rendered.
|
|
526
|
+
*
|
|
527
|
+
* @private
|
|
528
|
+
* @type {Function?}
|
|
529
|
+
* @default null
|
|
530
|
+
*/
|
|
138
531
|
this._renderObjectFunction = null;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Used to keep track of the current render object function.
|
|
535
|
+
*
|
|
536
|
+
* @private
|
|
537
|
+
* @type {Function?}
|
|
538
|
+
* @default null
|
|
539
|
+
*/
|
|
139
540
|
this._currentRenderObjectFunction = null;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Used to keep track of the current render bundle.
|
|
544
|
+
*
|
|
545
|
+
* @private
|
|
546
|
+
* @type {RenderBundle?}
|
|
547
|
+
* @default null
|
|
548
|
+
*/
|
|
140
549
|
this._currentRenderBundle = null;
|
|
141
550
|
|
|
551
|
+
/**
|
|
552
|
+
* Next to `_renderObjectFunction()`, this function provides another hook
|
|
553
|
+
* for influencing the render process of a render object. It is meant for internal
|
|
554
|
+
* use and only relevant for `compileAsync()` right now. Instead of using
|
|
555
|
+
* the default logic of `_renderObjectDirect()` which actually draws the render object,
|
|
556
|
+
* a different function might be used which performs no draw but just the node
|
|
557
|
+
* and pipeline updates.
|
|
558
|
+
*
|
|
559
|
+
* @private
|
|
560
|
+
* @type {Function?}
|
|
561
|
+
* @default null
|
|
562
|
+
*/
|
|
142
563
|
this._handleObjectFunction = this._renderObjectDirect;
|
|
143
564
|
|
|
565
|
+
/**
|
|
566
|
+
* Indicates whether the device has been lost or not. In WebGL terms, the device
|
|
567
|
+
* lost is considered as a context lost. When this is set to `true`, rendering
|
|
568
|
+
* isn't possible anymore.
|
|
569
|
+
*
|
|
570
|
+
* @private
|
|
571
|
+
* @type {Boolean}
|
|
572
|
+
* @default false
|
|
573
|
+
*/
|
|
144
574
|
this._isDeviceLost = false;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* A callback function that defines what should happen when a device/context lost occurs.
|
|
578
|
+
*
|
|
579
|
+
* @type {Function}
|
|
580
|
+
*/
|
|
145
581
|
this.onDeviceLost = this._onDeviceLost;
|
|
146
582
|
|
|
583
|
+
/**
|
|
584
|
+
* Defines the type of color buffers. The default `HalfFloatType` is recommend for
|
|
585
|
+
* best quality. To save memory and bandwidth, `UnsignedByteType` might be used.
|
|
586
|
+
* This will reduce rendering quality though.
|
|
587
|
+
*
|
|
588
|
+
* @private
|
|
589
|
+
* @type {Number}
|
|
590
|
+
* @default HalfFloatType
|
|
591
|
+
*/
|
|
592
|
+
this._colorBufferType = colorBufferType;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Whether the renderer has been initialized or not.
|
|
596
|
+
*
|
|
597
|
+
* @private
|
|
598
|
+
* @type {Boolean}
|
|
599
|
+
* @default false
|
|
600
|
+
*/
|
|
147
601
|
this._initialized = false;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* A reference to the promise which initializes the renderer.
|
|
605
|
+
*
|
|
606
|
+
* @private
|
|
607
|
+
* @type {Promise?}
|
|
608
|
+
* @default null
|
|
609
|
+
*/
|
|
148
610
|
this._initPromise = null;
|
|
149
611
|
|
|
612
|
+
/**
|
|
613
|
+
* An array of compilation promises which are used in `compileAsync()`.
|
|
614
|
+
*
|
|
615
|
+
* @private
|
|
616
|
+
* @type {Array<Promise>?}
|
|
617
|
+
* @default null
|
|
618
|
+
*/
|
|
150
619
|
this._compilationPromises = null;
|
|
151
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Whether the renderer should render transparent render objects or not.
|
|
623
|
+
*
|
|
624
|
+
* @type {Boolean}
|
|
625
|
+
* @default true
|
|
626
|
+
*/
|
|
152
627
|
this.transparent = true;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Whether the renderer should render opaque render objects or not.
|
|
631
|
+
*
|
|
632
|
+
* @type {Boolean}
|
|
633
|
+
* @default true
|
|
634
|
+
*/
|
|
153
635
|
this.opaque = true;
|
|
154
636
|
|
|
637
|
+
/**
|
|
638
|
+
* Shadow map configuration
|
|
639
|
+
* @typedef {Object} ShadowMapConfig
|
|
640
|
+
* @property {Boolean} enabled - Whether to globally enable shadows or not.
|
|
641
|
+
* @property {Number} type - The shadow map type.
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* The renderer's shadow configuration.
|
|
646
|
+
*
|
|
647
|
+
* @type {module:Renderer~ShadowMapConfig}
|
|
648
|
+
*/
|
|
155
649
|
this.shadowMap = {
|
|
156
650
|
enabled: false,
|
|
157
651
|
type: PCFShadowMap
|
|
158
652
|
};
|
|
159
653
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
654
|
+
/**
|
|
655
|
+
* XR configuration.
|
|
656
|
+
* @typedef {Object} XRConfig
|
|
657
|
+
* @property {Boolean} enabled - Whether to globally enable XR or not.
|
|
658
|
+
*/
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* The renderer's XR manager.
|
|
662
|
+
*
|
|
663
|
+
* @type {XRManager}
|
|
664
|
+
*/
|
|
665
|
+
this.xr = new XRManager( this );
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Debug configuration.
|
|
669
|
+
* @typedef {Object} DebugConfig
|
|
670
|
+
* @property {Boolean} checkShaderErrors - Whether shader errors should be checked or not.
|
|
671
|
+
* @property {Function} onShaderError - A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now.
|
|
672
|
+
* @property {Function} getShaderAsync - Allows the get the raw shader code for the given scene, camera and 3D object.
|
|
673
|
+
*/
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* The renderer's debug configuration.
|
|
677
|
+
*
|
|
678
|
+
* @type {module:Renderer~DebugConfig}
|
|
679
|
+
*/
|
|
164
680
|
this.debug = {
|
|
165
681
|
checkShaderErrors: true,
|
|
166
682
|
onShaderError: null,
|
|
@@ -184,6 +700,12 @@ class Renderer {
|
|
|
184
700
|
|
|
185
701
|
}
|
|
186
702
|
|
|
703
|
+
/**
|
|
704
|
+
* Initializes the renderer so it is ready for usage.
|
|
705
|
+
*
|
|
706
|
+
* @async
|
|
707
|
+
* @return {Promise} A Promise that resolves when the renderer has been initialized.
|
|
708
|
+
*/
|
|
187
709
|
async init() {
|
|
188
710
|
|
|
189
711
|
if ( this._initialized ) {
|
|
@@ -259,12 +781,35 @@ class Renderer {
|
|
|
259
781
|
|
|
260
782
|
}
|
|
261
783
|
|
|
784
|
+
/**
|
|
785
|
+
* The coordinate system of the renderer. The value of this property
|
|
786
|
+
* depends on the selected backend. Either `THREE.WebGLCoordinateSystem` or
|
|
787
|
+
* `THREE.WebGPUCoordinateSystem`.
|
|
788
|
+
*
|
|
789
|
+
* @readonly
|
|
790
|
+
* @type {Number}
|
|
791
|
+
*/
|
|
262
792
|
get coordinateSystem() {
|
|
263
793
|
|
|
264
794
|
return this.backend.coordinateSystem;
|
|
265
795
|
|
|
266
796
|
}
|
|
267
797
|
|
|
798
|
+
/**
|
|
799
|
+
* Compiles all materials in the given scene. This can be useful to avoid a
|
|
800
|
+
* phenomenon which is called "shader compilation stutter", which occurs when
|
|
801
|
+
* rendering an object with a new shader for the first time.
|
|
802
|
+
*
|
|
803
|
+
* If you want to add a 3D object to an existing scene, use the third optional
|
|
804
|
+
* parameter for applying the target scene. Note that the (target) scene's lighting
|
|
805
|
+
* and environment must be configured before calling this method.
|
|
806
|
+
*
|
|
807
|
+
* @async
|
|
808
|
+
* @param {Object3D} scene - The scene or 3D object to precompile.
|
|
809
|
+
* @param {Camera} camera - The camera that is used to render the scene.
|
|
810
|
+
* @param {Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
|
|
811
|
+
* @return {Promise<Array>} A Promise that resolves when the compile has been finished.
|
|
812
|
+
*/
|
|
268
813
|
async compileAsync( scene, camera, targetScene = null ) {
|
|
269
814
|
|
|
270
815
|
if ( this._isDeviceLost === true ) return;
|
|
@@ -361,10 +906,6 @@ class Renderer {
|
|
|
361
906
|
|
|
362
907
|
//
|
|
363
908
|
|
|
364
|
-
this._nodes.updateScene( sceneRef );
|
|
365
|
-
|
|
366
|
-
//
|
|
367
|
-
|
|
368
909
|
this._background.update( sceneRef, renderList, renderContext );
|
|
369
910
|
|
|
370
911
|
// process render lists
|
|
@@ -393,22 +934,41 @@ class Renderer {
|
|
|
393
934
|
|
|
394
935
|
}
|
|
395
936
|
|
|
937
|
+
/**
|
|
938
|
+
* Renders the scene in an async fashion.
|
|
939
|
+
*
|
|
940
|
+
* @async
|
|
941
|
+
* @param {Object3D} scene - The scene or 3D object to render.
|
|
942
|
+
* @param {Camera} camera - The camera.
|
|
943
|
+
* @return {Promise} A Promise that resolves when the render has been finished.
|
|
944
|
+
*/
|
|
396
945
|
async renderAsync( scene, camera ) {
|
|
397
946
|
|
|
398
947
|
if ( this._initialized === false ) await this.init();
|
|
399
948
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
await this.backend.resolveTimestampAsync( renderContext, 'render' );
|
|
949
|
+
this._renderScene( scene, camera );
|
|
403
950
|
|
|
404
951
|
}
|
|
405
952
|
|
|
953
|
+
/**
|
|
954
|
+
* Can be used to synchronize CPU operations with GPU tasks. So when this method is called,
|
|
955
|
+
* the CPU waits for the GPU to complete its operation (e.g. a compute task).
|
|
956
|
+
*
|
|
957
|
+
* @async
|
|
958
|
+
* @return {Promise} A Promise that resolves when synchronization has been finished.
|
|
959
|
+
*/
|
|
406
960
|
async waitForGPU() {
|
|
407
961
|
|
|
408
962
|
await this.backend.waitForGPU();
|
|
409
963
|
|
|
410
964
|
}
|
|
411
965
|
|
|
966
|
+
/**
|
|
967
|
+
* Sets the given MRT configuration.
|
|
968
|
+
*
|
|
969
|
+
* @param {MRTNode} mrt - The MRT node to set.
|
|
970
|
+
* @return {Renderer} A reference to this renderer.
|
|
971
|
+
*/
|
|
412
972
|
setMRT( mrt ) {
|
|
413
973
|
|
|
414
974
|
this._mrt = mrt;
|
|
@@ -417,12 +977,34 @@ class Renderer {
|
|
|
417
977
|
|
|
418
978
|
}
|
|
419
979
|
|
|
980
|
+
/**
|
|
981
|
+
* Returns the MRT configuration.
|
|
982
|
+
*
|
|
983
|
+
* @return {MRTNode} The MRT configuration.
|
|
984
|
+
*/
|
|
420
985
|
getMRT() {
|
|
421
986
|
|
|
422
987
|
return this._mrt;
|
|
423
988
|
|
|
424
989
|
}
|
|
425
990
|
|
|
991
|
+
/**
|
|
992
|
+
* Returns the color buffer type.
|
|
993
|
+
*
|
|
994
|
+
* @return {Number} The color buffer type.
|
|
995
|
+
*/
|
|
996
|
+
getColorBufferType() {
|
|
997
|
+
|
|
998
|
+
return this._colorBufferType;
|
|
999
|
+
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Default implementation of the device lost callback.
|
|
1004
|
+
*
|
|
1005
|
+
* @private
|
|
1006
|
+
* @param {Object} info - Information about the context lost.
|
|
1007
|
+
*/
|
|
426
1008
|
_onDeviceLost( info ) {
|
|
427
1009
|
|
|
428
1010
|
let errorMessage = `THREE.WebGPURenderer: ${info.api} Device Lost:\n\nMessage: ${info.message}`;
|
|
@@ -439,7 +1021,14 @@ class Renderer {
|
|
|
439
1021
|
|
|
440
1022
|
}
|
|
441
1023
|
|
|
442
|
-
|
|
1024
|
+
/**
|
|
1025
|
+
* Renders the given render bundle.
|
|
1026
|
+
*
|
|
1027
|
+
* @private
|
|
1028
|
+
* @param {Object} bundle - Render bundle data.
|
|
1029
|
+
* @param {Scene} sceneRef - The scene the render bundle belongs to.
|
|
1030
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
1031
|
+
*/
|
|
443
1032
|
_renderBundle( bundle, sceneRef, lightsNode ) {
|
|
444
1033
|
|
|
445
1034
|
const { bundleGroup, camera, renderList } = bundle;
|
|
@@ -511,6 +1100,18 @@ class Renderer {
|
|
|
511
1100
|
|
|
512
1101
|
}
|
|
513
1102
|
|
|
1103
|
+
/**
|
|
1104
|
+
* Renders the scene or 3D object with the given camera. This method can only be called
|
|
1105
|
+
* if the renderer has been initialized.
|
|
1106
|
+
*
|
|
1107
|
+
* The target of the method is the default framebuffer (meaning the canvas)
|
|
1108
|
+
* or alternatively a render target when specified via `setRenderTarget()`.
|
|
1109
|
+
*
|
|
1110
|
+
* @param {Object3D} scene - The scene or 3D object to render.
|
|
1111
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
1112
|
+
* @return {Promise?} A Promise that resolve when the scene has been rendered.
|
|
1113
|
+
* Only returned when the renderer has not been initialized.
|
|
1114
|
+
*/
|
|
514
1115
|
render( scene, camera ) {
|
|
515
1116
|
|
|
516
1117
|
if ( this._initialized === false ) {
|
|
@@ -525,6 +1126,14 @@ class Renderer {
|
|
|
525
1126
|
|
|
526
1127
|
}
|
|
527
1128
|
|
|
1129
|
+
/**
|
|
1130
|
+
* Returns an internal render target which is used when computing the output tone mapping
|
|
1131
|
+
* and color space conversion. Unlike in `WebGLRenderer`, this is done in a separate render
|
|
1132
|
+
* pass and not inline to achieve more correct results.
|
|
1133
|
+
*
|
|
1134
|
+
* @private
|
|
1135
|
+
* @return {RenderTarget?} The render target. The method returns `null` if no output conversion should be applied.
|
|
1136
|
+
*/
|
|
528
1137
|
_getFrameBufferTarget() {
|
|
529
1138
|
|
|
530
1139
|
const { currentToneMapping, currentColorSpace } = this;
|
|
@@ -544,7 +1153,7 @@ class Renderer {
|
|
|
544
1153
|
frameBufferTarget = new RenderTarget( width, height, {
|
|
545
1154
|
depthBuffer: depth,
|
|
546
1155
|
stencilBuffer: stencil,
|
|
547
|
-
type:
|
|
1156
|
+
type: this._colorBufferType,
|
|
548
1157
|
format: RGBAFormat,
|
|
549
1158
|
colorSpace: LinearSRGBColorSpace,
|
|
550
1159
|
generateMipmaps: false,
|
|
@@ -572,6 +1181,15 @@ class Renderer {
|
|
|
572
1181
|
|
|
573
1182
|
}
|
|
574
1183
|
|
|
1184
|
+
/**
|
|
1185
|
+
* Renders the scene or 3D object with the given camera.
|
|
1186
|
+
*
|
|
1187
|
+
* @private
|
|
1188
|
+
* @param {Object3D} scene - The scene or 3D object to render.
|
|
1189
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
1190
|
+
* @param {Boolean} [useFrameBufferTarget=true] - Whether to use a framebuffer target or not.
|
|
1191
|
+
* @return {RenderContext} The current render context.
|
|
1192
|
+
*/
|
|
575
1193
|
_renderScene( scene, camera, useFrameBufferTarget = true ) {
|
|
576
1194
|
|
|
577
1195
|
if ( this._isDeviceLost === true ) return;
|
|
@@ -629,13 +1247,24 @@ class Renderer {
|
|
|
629
1247
|
//
|
|
630
1248
|
|
|
631
1249
|
const coordinateSystem = this.coordinateSystem;
|
|
1250
|
+
const xr = this.xr;
|
|
632
1251
|
|
|
633
|
-
if ( camera.coordinateSystem !== coordinateSystem ) {
|
|
1252
|
+
if ( camera.coordinateSystem !== coordinateSystem && xr.isPresenting === false ) {
|
|
634
1253
|
|
|
635
1254
|
camera.coordinateSystem = coordinateSystem;
|
|
636
|
-
|
|
637
1255
|
camera.updateProjectionMatrix();
|
|
638
1256
|
|
|
1257
|
+
if ( camera.isArrayCamera ) {
|
|
1258
|
+
|
|
1259
|
+
for ( const subCamera of camera.cameras ) {
|
|
1260
|
+
|
|
1261
|
+
subCamera.coordinateSystem = coordinateSystem;
|
|
1262
|
+
subCamera.updateProjectionMatrix();
|
|
1263
|
+
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
}
|
|
1267
|
+
|
|
639
1268
|
}
|
|
640
1269
|
|
|
641
1270
|
//
|
|
@@ -644,6 +1273,13 @@ class Renderer {
|
|
|
644
1273
|
|
|
645
1274
|
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
646
1275
|
|
|
1276
|
+
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
1277
|
+
|
|
1278
|
+
if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
|
|
1279
|
+
camera = xr.getCamera(); // use XR camera for rendering
|
|
1280
|
+
|
|
1281
|
+
}
|
|
1282
|
+
|
|
647
1283
|
//
|
|
648
1284
|
|
|
649
1285
|
let viewport = this._viewport;
|
|
@@ -737,10 +1373,6 @@ class Renderer {
|
|
|
737
1373
|
|
|
738
1374
|
//
|
|
739
1375
|
|
|
740
|
-
this._nodes.updateScene( sceneRef );
|
|
741
|
-
|
|
742
|
-
//
|
|
743
|
-
|
|
744
1376
|
this._background.update( sceneRef, renderList, renderContext );
|
|
745
1377
|
|
|
746
1378
|
//
|
|
@@ -801,24 +1433,48 @@ class Renderer {
|
|
|
801
1433
|
|
|
802
1434
|
}
|
|
803
1435
|
|
|
1436
|
+
/**
|
|
1437
|
+
* Returns the maximum available anisotropy for texture filtering.
|
|
1438
|
+
*
|
|
1439
|
+
* @return {Number} The maximum available anisotropy.
|
|
1440
|
+
*/
|
|
804
1441
|
getMaxAnisotropy() {
|
|
805
1442
|
|
|
806
1443
|
return this.backend.getMaxAnisotropy();
|
|
807
1444
|
|
|
808
1445
|
}
|
|
809
1446
|
|
|
1447
|
+
/**
|
|
1448
|
+
* Returns the active cube face.
|
|
1449
|
+
*
|
|
1450
|
+
* @return {Number} The active cube face.
|
|
1451
|
+
*/
|
|
810
1452
|
getActiveCubeFace() {
|
|
811
1453
|
|
|
812
1454
|
return this._activeCubeFace;
|
|
813
1455
|
|
|
814
1456
|
}
|
|
815
1457
|
|
|
1458
|
+
/**
|
|
1459
|
+
* Returns the active mipmap level.
|
|
1460
|
+
*
|
|
1461
|
+
* @return {Number} The active mipmap level.
|
|
1462
|
+
*/
|
|
816
1463
|
getActiveMipmapLevel() {
|
|
817
1464
|
|
|
818
1465
|
return this._activeMipmapLevel;
|
|
819
1466
|
|
|
820
1467
|
}
|
|
821
1468
|
|
|
1469
|
+
/**
|
|
1470
|
+
* Applications are advised to always define the animation loop
|
|
1471
|
+
* with this method and not manually with `requestAnimationFrame()`
|
|
1472
|
+
* for best compatibility.
|
|
1473
|
+
*
|
|
1474
|
+
* @async
|
|
1475
|
+
* @param {Function} callback - The application's animation loop.
|
|
1476
|
+
* @return {Promise} A Promise that resolves when the set has been executed.
|
|
1477
|
+
*/
|
|
822
1478
|
async setAnimationLoop( callback ) {
|
|
823
1479
|
|
|
824
1480
|
if ( this._initialized === false ) await this.init();
|
|
@@ -827,36 +1483,71 @@ class Renderer {
|
|
|
827
1483
|
|
|
828
1484
|
}
|
|
829
1485
|
|
|
1486
|
+
/**
|
|
1487
|
+
* Can be used to transfer buffer data from a storage buffer attribute
|
|
1488
|
+
* from the GPU to the CPU in context of compute shaders.
|
|
1489
|
+
*
|
|
1490
|
+
* @async
|
|
1491
|
+
* @param {StorageBufferAttribute} attribute - The storage buffer attribute.
|
|
1492
|
+
* @return {Promise<ArrayBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
1493
|
+
*/
|
|
830
1494
|
async getArrayBufferAsync( attribute ) {
|
|
831
1495
|
|
|
832
1496
|
return await this.backend.getArrayBufferAsync( attribute );
|
|
833
1497
|
|
|
834
1498
|
}
|
|
835
1499
|
|
|
1500
|
+
/**
|
|
1501
|
+
* Returns the rendering context.
|
|
1502
|
+
*
|
|
1503
|
+
* @return {GPUCanvasContext|WebGL2RenderingContext} The rendering context.
|
|
1504
|
+
*/
|
|
836
1505
|
getContext() {
|
|
837
1506
|
|
|
838
1507
|
return this.backend.getContext();
|
|
839
1508
|
|
|
840
1509
|
}
|
|
841
1510
|
|
|
1511
|
+
/**
|
|
1512
|
+
* Returns the pixel ratio.
|
|
1513
|
+
*
|
|
1514
|
+
* @return {Number} The pixel ratio.
|
|
1515
|
+
*/
|
|
842
1516
|
getPixelRatio() {
|
|
843
1517
|
|
|
844
1518
|
return this._pixelRatio;
|
|
845
1519
|
|
|
846
1520
|
}
|
|
847
1521
|
|
|
1522
|
+
/**
|
|
1523
|
+
* Returns the drawing buffer size in physical pixels. This method honors the pixel ratio.
|
|
1524
|
+
*
|
|
1525
|
+
* @param {Vector2} target - The method writes the result in this target object.
|
|
1526
|
+
* @return {Vector2} The drawing buffer size.
|
|
1527
|
+
*/
|
|
848
1528
|
getDrawingBufferSize( target ) {
|
|
849
1529
|
|
|
850
1530
|
return target.set( this._width * this._pixelRatio, this._height * this._pixelRatio ).floor();
|
|
851
1531
|
|
|
852
1532
|
}
|
|
853
1533
|
|
|
1534
|
+
/**
|
|
1535
|
+
* Returns the renderer's size in logical pixels. This method does not honor the pixel ratio.
|
|
1536
|
+
*
|
|
1537
|
+
* @param {Vector2} target - The method writes the result in this target object.
|
|
1538
|
+
* @return {Vector2} The drawing buffer size.
|
|
1539
|
+
*/
|
|
854
1540
|
getSize( target ) {
|
|
855
1541
|
|
|
856
1542
|
return target.set( this._width, this._height );
|
|
857
1543
|
|
|
858
1544
|
}
|
|
859
1545
|
|
|
1546
|
+
/**
|
|
1547
|
+
* Sets the given pixel ration and resizes the canvas if necessary.
|
|
1548
|
+
*
|
|
1549
|
+
* @param {Number} [value=1] - The pixel ratio.
|
|
1550
|
+
*/
|
|
860
1551
|
setPixelRatio( value = 1 ) {
|
|
861
1552
|
|
|
862
1553
|
if ( this._pixelRatio === value ) return;
|
|
@@ -867,6 +1558,19 @@ class Renderer {
|
|
|
867
1558
|
|
|
868
1559
|
}
|
|
869
1560
|
|
|
1561
|
+
/**
|
|
1562
|
+
* This method allows to define the drawing buffer size by specifying
|
|
1563
|
+
* width, height and pixel ratio all at once. The size of the drawing
|
|
1564
|
+
* buffer is computed with this formula:
|
|
1565
|
+
* ````
|
|
1566
|
+
* size.x = width * pixelRatio;
|
|
1567
|
+
* size.y = height * pixelRatio;
|
|
1568
|
+
*```
|
|
1569
|
+
*
|
|
1570
|
+
* @param {Number} width - The width in logical pixels.
|
|
1571
|
+
* @param {Number} height - The height in logical pixels.
|
|
1572
|
+
* @param {Number} pixelRatio - The pixel ratio.
|
|
1573
|
+
*/
|
|
870
1574
|
setDrawingBufferSize( width, height, pixelRatio ) {
|
|
871
1575
|
|
|
872
1576
|
this._width = width;
|
|
@@ -883,6 +1587,13 @@ class Renderer {
|
|
|
883
1587
|
|
|
884
1588
|
}
|
|
885
1589
|
|
|
1590
|
+
/**
|
|
1591
|
+
* Sets the size of the renderer.
|
|
1592
|
+
*
|
|
1593
|
+
* @param {Number} width - The width in logical pixels.
|
|
1594
|
+
* @param {Number} height - The height in logical pixels.
|
|
1595
|
+
* @param {Boolean} [updateStyle=true] - Whether to update the `style` attribute of the canvas or not.
|
|
1596
|
+
*/
|
|
886
1597
|
setSize( width, height, updateStyle = true ) {
|
|
887
1598
|
|
|
888
1599
|
this._width = width;
|
|
@@ -904,18 +1615,36 @@ class Renderer {
|
|
|
904
1615
|
|
|
905
1616
|
}
|
|
906
1617
|
|
|
1618
|
+
/**
|
|
1619
|
+
* Defines a manual sort function for the opaque render list.
|
|
1620
|
+
* Pass `null` to use the default sort.
|
|
1621
|
+
*
|
|
1622
|
+
* @param {Function} method - The sort function.
|
|
1623
|
+
*/
|
|
907
1624
|
setOpaqueSort( method ) {
|
|
908
1625
|
|
|
909
1626
|
this._opaqueSort = method;
|
|
910
1627
|
|
|
911
1628
|
}
|
|
912
1629
|
|
|
1630
|
+
/**
|
|
1631
|
+
* Defines a manual sort function for the transparent render list.
|
|
1632
|
+
* Pass `null` to use the default sort.
|
|
1633
|
+
*
|
|
1634
|
+
* @param {Function} method - The sort function.
|
|
1635
|
+
*/
|
|
913
1636
|
setTransparentSort( method ) {
|
|
914
1637
|
|
|
915
1638
|
this._transparentSort = method;
|
|
916
1639
|
|
|
917
1640
|
}
|
|
918
1641
|
|
|
1642
|
+
/**
|
|
1643
|
+
* Returns the scissor rectangle.
|
|
1644
|
+
*
|
|
1645
|
+
* @param {Vector4} target - The method writes the result in this target object.
|
|
1646
|
+
* @return {Vector4} The scissor rectangle.
|
|
1647
|
+
*/
|
|
919
1648
|
getScissor( target ) {
|
|
920
1649
|
|
|
921
1650
|
const scissor = this._scissor;
|
|
@@ -929,6 +1658,15 @@ class Renderer {
|
|
|
929
1658
|
|
|
930
1659
|
}
|
|
931
1660
|
|
|
1661
|
+
/**
|
|
1662
|
+
* Defines the scissor rectangle.
|
|
1663
|
+
*
|
|
1664
|
+
* @param {Number | Vector4} x - The horizontal coordinate for the lower left corner of the box in logical pixel unit.
|
|
1665
|
+
* Instead of passing four arguments, the method also works with a single four-dimensional vector.
|
|
1666
|
+
* @param {Number} y - The vertical coordinate for the lower left corner of the box in logical pixel unit.
|
|
1667
|
+
* @param {Number} width - The width of the scissor box in logical pixel unit.
|
|
1668
|
+
* @param {Number} height - The height of the scissor box in logical pixel unit.
|
|
1669
|
+
*/
|
|
932
1670
|
setScissor( x, y, width, height ) {
|
|
933
1671
|
|
|
934
1672
|
const scissor = this._scissor;
|
|
@@ -945,12 +1683,22 @@ class Renderer {
|
|
|
945
1683
|
|
|
946
1684
|
}
|
|
947
1685
|
|
|
1686
|
+
/**
|
|
1687
|
+
* Returns the scissor test value.
|
|
1688
|
+
*
|
|
1689
|
+
* @return {Boolean} Whether the scissor test should be enabled or not.
|
|
1690
|
+
*/
|
|
948
1691
|
getScissorTest() {
|
|
949
1692
|
|
|
950
1693
|
return this._scissorTest;
|
|
951
1694
|
|
|
952
1695
|
}
|
|
953
1696
|
|
|
1697
|
+
/**
|
|
1698
|
+
* Defines the scissor test.
|
|
1699
|
+
*
|
|
1700
|
+
* @param {Boolean} boolean - Whether the scissor test should be enabled or not.
|
|
1701
|
+
*/
|
|
954
1702
|
setScissorTest( boolean ) {
|
|
955
1703
|
|
|
956
1704
|
this._scissorTest = boolean;
|
|
@@ -959,12 +1707,28 @@ class Renderer {
|
|
|
959
1707
|
|
|
960
1708
|
}
|
|
961
1709
|
|
|
1710
|
+
/**
|
|
1711
|
+
* Returns the viewport definition.
|
|
1712
|
+
*
|
|
1713
|
+
* @param {Vector4} target - The method writes the result in this target object.
|
|
1714
|
+
* @return {Vector4} The viewport definition.
|
|
1715
|
+
*/
|
|
962
1716
|
getViewport( target ) {
|
|
963
1717
|
|
|
964
1718
|
return target.copy( this._viewport );
|
|
965
1719
|
|
|
966
1720
|
}
|
|
967
1721
|
|
|
1722
|
+
/**
|
|
1723
|
+
* Defines the viewport.
|
|
1724
|
+
*
|
|
1725
|
+
* @param {Number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
|
|
1726
|
+
* @param {Number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
|
|
1727
|
+
* @param {Number} width - The width of the viewport in logical pixel unit.
|
|
1728
|
+
* @param {Number} height - The height of the viewport in logical pixel unit.
|
|
1729
|
+
* @param {Number} minDepth - The minimum depth value of the viewport. WebGPU only.
|
|
1730
|
+
* @param {Number} maxDepth - The maximum depth value of the viewport. WebGPU only.
|
|
1731
|
+
*/
|
|
968
1732
|
setViewport( x, y, width, height, minDepth = 0, maxDepth = 1 ) {
|
|
969
1733
|
|
|
970
1734
|
const viewport = this._viewport;
|
|
@@ -984,12 +1748,24 @@ class Renderer {
|
|
|
984
1748
|
|
|
985
1749
|
}
|
|
986
1750
|
|
|
1751
|
+
/**
|
|
1752
|
+
* Returns the clear color.
|
|
1753
|
+
*
|
|
1754
|
+
* @param {Color} target - The method writes the result in this target object.
|
|
1755
|
+
* @return {Color} The clear color.
|
|
1756
|
+
*/
|
|
987
1757
|
getClearColor( target ) {
|
|
988
1758
|
|
|
989
1759
|
return target.copy( this._clearColor );
|
|
990
1760
|
|
|
991
1761
|
}
|
|
992
1762
|
|
|
1763
|
+
/**
|
|
1764
|
+
* Defines the clear color and optionally the clear alpha.
|
|
1765
|
+
*
|
|
1766
|
+
* @param {Color} color - The clear color.
|
|
1767
|
+
* @param {Number} [alpha=1] - The clear alpha.
|
|
1768
|
+
*/
|
|
993
1769
|
setClearColor( color, alpha = 1 ) {
|
|
994
1770
|
|
|
995
1771
|
this._clearColor.set( color );
|
|
@@ -997,42 +1773,80 @@ class Renderer {
|
|
|
997
1773
|
|
|
998
1774
|
}
|
|
999
1775
|
|
|
1776
|
+
/**
|
|
1777
|
+
* Returns the clear alpha.
|
|
1778
|
+
*
|
|
1779
|
+
* @return {Number} The clear alpha.
|
|
1780
|
+
*/
|
|
1000
1781
|
getClearAlpha() {
|
|
1001
1782
|
|
|
1002
1783
|
return this._clearColor.a;
|
|
1003
1784
|
|
|
1004
1785
|
}
|
|
1005
1786
|
|
|
1787
|
+
/**
|
|
1788
|
+
* Defines the clear alpha.
|
|
1789
|
+
*
|
|
1790
|
+
* @param {Number} alpha - The clear alpha.
|
|
1791
|
+
*/
|
|
1006
1792
|
setClearAlpha( alpha ) {
|
|
1007
1793
|
|
|
1008
1794
|
this._clearColor.a = alpha;
|
|
1009
1795
|
|
|
1010
1796
|
}
|
|
1011
1797
|
|
|
1798
|
+
/**
|
|
1799
|
+
* Returns the clear depth.
|
|
1800
|
+
*
|
|
1801
|
+
* @return {Number} The clear depth.
|
|
1802
|
+
*/
|
|
1012
1803
|
getClearDepth() {
|
|
1013
1804
|
|
|
1014
1805
|
return this._clearDepth;
|
|
1015
1806
|
|
|
1016
1807
|
}
|
|
1017
1808
|
|
|
1809
|
+
/**
|
|
1810
|
+
* Defines the clear depth.
|
|
1811
|
+
*
|
|
1812
|
+
* @param {Number} depth - The clear depth.
|
|
1813
|
+
*/
|
|
1018
1814
|
setClearDepth( depth ) {
|
|
1019
1815
|
|
|
1020
1816
|
this._clearDepth = depth;
|
|
1021
1817
|
|
|
1022
1818
|
}
|
|
1023
1819
|
|
|
1820
|
+
/**
|
|
1821
|
+
* Returns the clear stencil.
|
|
1822
|
+
*
|
|
1823
|
+
* @return {Number} The clear stencil.
|
|
1824
|
+
*/
|
|
1024
1825
|
getClearStencil() {
|
|
1025
1826
|
|
|
1026
1827
|
return this._clearStencil;
|
|
1027
1828
|
|
|
1028
1829
|
}
|
|
1029
1830
|
|
|
1831
|
+
/**
|
|
1832
|
+
* Defines the clear stencil.
|
|
1833
|
+
*
|
|
1834
|
+
* @param {Number} stencil - The clear stencil.
|
|
1835
|
+
*/
|
|
1030
1836
|
setClearStencil( stencil ) {
|
|
1031
1837
|
|
|
1032
1838
|
this._clearStencil = stencil;
|
|
1033
1839
|
|
|
1034
1840
|
}
|
|
1035
1841
|
|
|
1842
|
+
/**
|
|
1843
|
+
* This method performs an occlusion query for the given 3D object.
|
|
1844
|
+
* It returns `true` if the given 3D object is fully occluded by other
|
|
1845
|
+
* 3D objects in the scene.
|
|
1846
|
+
*
|
|
1847
|
+
* @param {Object3D} object - The 3D object to test.
|
|
1848
|
+
* @return {Boolean} Whether the 3D object is fully occluded or not.
|
|
1849
|
+
*/
|
|
1036
1850
|
isOccluded( object ) {
|
|
1037
1851
|
|
|
1038
1852
|
const renderContext = this._currentRenderContext;
|
|
@@ -1041,6 +1855,15 @@ class Renderer {
|
|
|
1041
1855
|
|
|
1042
1856
|
}
|
|
1043
1857
|
|
|
1858
|
+
/**
|
|
1859
|
+
* Performs a manual clear operation. This method ignores `autoClear` properties.
|
|
1860
|
+
*
|
|
1861
|
+
* @param {Boolean} [color=true] - Whether the color buffer should be cleared or not.
|
|
1862
|
+
* @param {Boolean} [depth=true] - Whether the depth buffer should be cleared or not.
|
|
1863
|
+
* @param {Boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
|
|
1864
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1865
|
+
* Only returned when the renderer has not been initialized.
|
|
1866
|
+
*/
|
|
1044
1867
|
clear( color = true, depth = true, stencil = true ) {
|
|
1045
1868
|
|
|
1046
1869
|
if ( this._initialized === false ) {
|
|
@@ -1053,17 +1876,29 @@ class Renderer {
|
|
|
1053
1876
|
|
|
1054
1877
|
const renderTarget = this._renderTarget || this._getFrameBufferTarget();
|
|
1055
1878
|
|
|
1056
|
-
let
|
|
1879
|
+
let renderContext = null;
|
|
1057
1880
|
|
|
1058
1881
|
if ( renderTarget !== null ) {
|
|
1059
1882
|
|
|
1060
1883
|
this._textures.updateRenderTarget( renderTarget );
|
|
1061
1884
|
|
|
1062
|
-
renderTargetData = this._textures.get( renderTarget );
|
|
1885
|
+
const renderTargetData = this._textures.get( renderTarget );
|
|
1886
|
+
|
|
1887
|
+
renderContext = this._renderContexts.getForClear( renderTarget );
|
|
1888
|
+
renderContext.textures = renderTargetData.textures;
|
|
1889
|
+
renderContext.depthTexture = renderTargetData.depthTexture;
|
|
1890
|
+
renderContext.width = renderTargetData.width;
|
|
1891
|
+
renderContext.height = renderTargetData.height;
|
|
1892
|
+
renderContext.renderTarget = renderTarget;
|
|
1893
|
+
renderContext.depth = renderTarget.depthBuffer;
|
|
1894
|
+
renderContext.stencil = renderTarget.stencilBuffer;
|
|
1063
1895
|
|
|
1064
1896
|
}
|
|
1065
1897
|
|
|
1066
|
-
|
|
1898
|
+
// #30329
|
|
1899
|
+
renderContext.clearColorValue = this._clearColor;
|
|
1900
|
+
|
|
1901
|
+
this.backend.clear( color, depth, stencil, renderContext );
|
|
1067
1902
|
|
|
1068
1903
|
if ( renderTarget !== null && this._renderTarget === null ) {
|
|
1069
1904
|
|
|
@@ -1085,24 +1920,51 @@ class Renderer {
|
|
|
1085
1920
|
|
|
1086
1921
|
}
|
|
1087
1922
|
|
|
1923
|
+
/**
|
|
1924
|
+
* Performs a manual clear operation of the color buffer. This method ignores `autoClear` properties.
|
|
1925
|
+
*
|
|
1926
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1927
|
+
* Only returned when the renderer has not been initialized.
|
|
1928
|
+
*/
|
|
1088
1929
|
clearColor() {
|
|
1089
1930
|
|
|
1090
1931
|
return this.clear( true, false, false );
|
|
1091
1932
|
|
|
1092
1933
|
}
|
|
1093
1934
|
|
|
1935
|
+
/**
|
|
1936
|
+
* Performs a manual clear operation of the depth buffer. This method ignores `autoClear` properties.
|
|
1937
|
+
*
|
|
1938
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1939
|
+
* Only returned when the renderer has not been initialized.
|
|
1940
|
+
*/
|
|
1094
1941
|
clearDepth() {
|
|
1095
1942
|
|
|
1096
1943
|
return this.clear( false, true, false );
|
|
1097
1944
|
|
|
1098
1945
|
}
|
|
1099
1946
|
|
|
1947
|
+
/**
|
|
1948
|
+
* Performs a manual clear operation of the stencil buffer. This method ignores `autoClear` properties.
|
|
1949
|
+
*
|
|
1950
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1951
|
+
* Only returned when the renderer has not been initialized.
|
|
1952
|
+
*/
|
|
1100
1953
|
clearStencil() {
|
|
1101
1954
|
|
|
1102
1955
|
return this.clear( false, false, true );
|
|
1103
1956
|
|
|
1104
1957
|
}
|
|
1105
1958
|
|
|
1959
|
+
/**
|
|
1960
|
+
* Async version of {@link module:Renderer~Renderer#clear}.
|
|
1961
|
+
*
|
|
1962
|
+
* @async
|
|
1963
|
+
* @param {Boolean} [color=true] - Whether the color buffer should be cleared or not.
|
|
1964
|
+
* @param {Boolean} [depth=true] - Whether the depth buffer should be cleared or not.
|
|
1965
|
+
* @param {Boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
|
|
1966
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1967
|
+
*/
|
|
1106
1968
|
async clearAsync( color = true, depth = true, stencil = true ) {
|
|
1107
1969
|
|
|
1108
1970
|
if ( this._initialized === false ) await this.init();
|
|
@@ -1111,36 +1973,70 @@ class Renderer {
|
|
|
1111
1973
|
|
|
1112
1974
|
}
|
|
1113
1975
|
|
|
1114
|
-
|
|
1976
|
+
/**
|
|
1977
|
+
* Async version of {@link module:Renderer~Renderer#clearColor}.
|
|
1978
|
+
*
|
|
1979
|
+
* @async
|
|
1980
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1981
|
+
*/
|
|
1982
|
+
async clearColorAsync() {
|
|
1115
1983
|
|
|
1116
|
-
|
|
1984
|
+
this.clearAsync( true, false, false );
|
|
1117
1985
|
|
|
1118
1986
|
}
|
|
1119
1987
|
|
|
1120
|
-
|
|
1988
|
+
/**
|
|
1989
|
+
* Async version of {@link module:Renderer~Renderer#clearDepth}.
|
|
1990
|
+
*
|
|
1991
|
+
* @async
|
|
1992
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
1993
|
+
*/
|
|
1994
|
+
async clearDepthAsync() {
|
|
1121
1995
|
|
|
1122
|
-
|
|
1996
|
+
this.clearAsync( false, true, false );
|
|
1123
1997
|
|
|
1124
1998
|
}
|
|
1125
1999
|
|
|
1126
|
-
|
|
2000
|
+
/**
|
|
2001
|
+
* Async version of {@link module:Renderer~Renderer#clearStencil}.
|
|
2002
|
+
*
|
|
2003
|
+
* @async
|
|
2004
|
+
* @return {Promise} A Promise that resolves when the clear operation has been executed.
|
|
2005
|
+
*/
|
|
2006
|
+
async clearStencilAsync() {
|
|
1127
2007
|
|
|
1128
|
-
|
|
2008
|
+
this.clearAsync( false, false, true );
|
|
1129
2009
|
|
|
1130
2010
|
}
|
|
1131
2011
|
|
|
2012
|
+
/**
|
|
2013
|
+
* The current output tone mapping of the renderer. When a render target is set,
|
|
2014
|
+
* the output tone mapping is always `NoToneMapping`.
|
|
2015
|
+
*
|
|
2016
|
+
* @type {Number}
|
|
2017
|
+
*/
|
|
1132
2018
|
get currentToneMapping() {
|
|
1133
2019
|
|
|
1134
2020
|
return this._renderTarget !== null ? NoToneMapping : this.toneMapping;
|
|
1135
2021
|
|
|
1136
2022
|
}
|
|
1137
2023
|
|
|
2024
|
+
/**
|
|
2025
|
+
* The current output color space of the renderer. When a render target is set,
|
|
2026
|
+
* the output color space is always `LinearSRGBColorSpace`.
|
|
2027
|
+
*
|
|
2028
|
+
* @type {String}
|
|
2029
|
+
*/
|
|
1138
2030
|
get currentColorSpace() {
|
|
1139
2031
|
|
|
1140
2032
|
return this._renderTarget !== null ? LinearSRGBColorSpace : this.outputColorSpace;
|
|
1141
2033
|
|
|
1142
2034
|
}
|
|
1143
2035
|
|
|
2036
|
+
/**
|
|
2037
|
+
* Frees all internal resources of the renderer. Call this method if the renderer
|
|
2038
|
+
* is no longer in use by your app.
|
|
2039
|
+
*/
|
|
1144
2040
|
dispose() {
|
|
1145
2041
|
|
|
1146
2042
|
this.info.dispose();
|
|
@@ -1155,11 +2051,28 @@ class Renderer {
|
|
|
1155
2051
|
this._renderContexts.dispose();
|
|
1156
2052
|
this._textures.dispose();
|
|
1157
2053
|
|
|
2054
|
+
if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
|
|
2055
|
+
|
|
2056
|
+
Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
|
|
2057
|
+
|
|
2058
|
+
if ( queryPool !== null ) queryPool.dispose();
|
|
2059
|
+
|
|
2060
|
+
} );
|
|
2061
|
+
|
|
1158
2062
|
this.setRenderTarget( null );
|
|
1159
2063
|
this.setAnimationLoop( null );
|
|
1160
2064
|
|
|
1161
2065
|
}
|
|
1162
2066
|
|
|
2067
|
+
/**
|
|
2068
|
+
* Sets the given render target. Calling this method means the renderer does not
|
|
2069
|
+
* target the default framebuffer (meaning the canvas) anymore but a custom framebuffer.
|
|
2070
|
+
* Use `null` as the first argument to reset the state.
|
|
2071
|
+
*
|
|
2072
|
+
* @param {RenderTarget?} renderTarget - The render target to set.
|
|
2073
|
+
* @param {Number} [activeCubeFace=0] - The active cube face.
|
|
2074
|
+
* @param {Number} [activeMipmapLevel=0] - The active mipmap level.
|
|
2075
|
+
*/
|
|
1163
2076
|
setRenderTarget( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
|
|
1164
2077
|
|
|
1165
2078
|
this._renderTarget = renderTarget;
|
|
@@ -1168,27 +2081,70 @@ class Renderer {
|
|
|
1168
2081
|
|
|
1169
2082
|
}
|
|
1170
2083
|
|
|
2084
|
+
/**
|
|
2085
|
+
* Returns the current render target.
|
|
2086
|
+
*
|
|
2087
|
+
* @return {RenderTarget?} The render target. Returns `null` if no render target is set.
|
|
2088
|
+
*/
|
|
1171
2089
|
getRenderTarget() {
|
|
1172
2090
|
|
|
1173
2091
|
return this._renderTarget;
|
|
1174
2092
|
|
|
1175
2093
|
}
|
|
1176
2094
|
|
|
2095
|
+
/**
|
|
2096
|
+
* Callback for {@link module:Renderer~Renderer#setRenderObjectFunction}.
|
|
2097
|
+
*
|
|
2098
|
+
* @callback renderObjectFunction
|
|
2099
|
+
* @param {Object3D} object - The 3D object.
|
|
2100
|
+
* @param {Scene} scene - The scene the 3D object belongs to.
|
|
2101
|
+
* @param {Camera} camera - The camera the object should be rendered with.
|
|
2102
|
+
* @param {BufferGeometry} geometry - The object's geometry.
|
|
2103
|
+
* @param {Material} material - The object's material.
|
|
2104
|
+
* @param {Object?} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2105
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2106
|
+
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2107
|
+
* @param {String?} [passId=null] - An optional ID for identifying the pass.
|
|
2108
|
+
*/
|
|
2109
|
+
|
|
2110
|
+
/**
|
|
2111
|
+
* Sets the given render object function. Calling this method overwrites the default implementation
|
|
2112
|
+
* which is {@link module:Renderer~Renderer#renderObject}. Defining a custom function can be useful
|
|
2113
|
+
* if you want to modify the way objects are rendered. For example you can define things like "every
|
|
2114
|
+
* object that has material of a certain type should perform a pre-pass with a special overwrite material".
|
|
2115
|
+
* The custom function must always call `renderObject()` in its implementation.
|
|
2116
|
+
*
|
|
2117
|
+
* Use `null` as the first argument to reset the state.
|
|
2118
|
+
*
|
|
2119
|
+
* @param {module:Renderer~renderObjectFunction?} renderObjectFunction - The render object function.
|
|
2120
|
+
*/
|
|
1177
2121
|
setRenderObjectFunction( renderObjectFunction ) {
|
|
1178
2122
|
|
|
1179
2123
|
this._renderObjectFunction = renderObjectFunction;
|
|
1180
2124
|
|
|
1181
2125
|
}
|
|
1182
2126
|
|
|
2127
|
+
/**
|
|
2128
|
+
* Returns the current render object function.
|
|
2129
|
+
*
|
|
2130
|
+
* @return {Function?} The current render object function. Returns `null` if no function is set.
|
|
2131
|
+
*/
|
|
1183
2132
|
getRenderObjectFunction() {
|
|
1184
2133
|
|
|
1185
2134
|
return this._renderObjectFunction;
|
|
1186
2135
|
|
|
1187
2136
|
}
|
|
1188
2137
|
|
|
2138
|
+
/**
|
|
2139
|
+
* Execute a single or an array of compute nodes. This method can only be called
|
|
2140
|
+
* if the renderer has been initialized.
|
|
2141
|
+
*
|
|
2142
|
+
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2143
|
+
* @return {Promise?} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
|
|
2144
|
+
*/
|
|
1189
2145
|
compute( computeNodes ) {
|
|
1190
2146
|
|
|
1191
|
-
if ( this.
|
|
2147
|
+
if ( this._isDeviceLost === true ) return;
|
|
1192
2148
|
|
|
1193
2149
|
if ( this._initialized === false ) {
|
|
1194
2150
|
|
|
@@ -1277,16 +2233,28 @@ class Renderer {
|
|
|
1277
2233
|
|
|
1278
2234
|
}
|
|
1279
2235
|
|
|
2236
|
+
/**
|
|
2237
|
+
* Execute a single or an array of compute nodes.
|
|
2238
|
+
*
|
|
2239
|
+
* @async
|
|
2240
|
+
* @param {Node|Array<Node>} computeNodes - The compute node(s).
|
|
2241
|
+
* @return {Promise} A Promise that resolve when the compute has finished.
|
|
2242
|
+
*/
|
|
1280
2243
|
async computeAsync( computeNodes ) {
|
|
1281
2244
|
|
|
1282
2245
|
if ( this._initialized === false ) await this.init();
|
|
1283
2246
|
|
|
1284
2247
|
this.compute( computeNodes );
|
|
1285
2248
|
|
|
1286
|
-
await this.backend.resolveTimestampAsync( computeNodes, 'compute' );
|
|
1287
|
-
|
|
1288
2249
|
}
|
|
1289
2250
|
|
|
2251
|
+
/**
|
|
2252
|
+
* Checks if the given feature is supported by the selected backend.
|
|
2253
|
+
*
|
|
2254
|
+
* @async
|
|
2255
|
+
* @param {String} name - The feature's name.
|
|
2256
|
+
* @return {Promise<Boolean>} A Promise that resolves with a bool that indicates whether the feature is supported or not.
|
|
2257
|
+
*/
|
|
1290
2258
|
async hasFeatureAsync( name ) {
|
|
1291
2259
|
|
|
1292
2260
|
if ( this._initialized === false ) await this.init();
|
|
@@ -1295,6 +2263,21 @@ class Renderer {
|
|
|
1295
2263
|
|
|
1296
2264
|
}
|
|
1297
2265
|
|
|
2266
|
+
async resolveTimestampsAsync( type = 'render' ) {
|
|
2267
|
+
|
|
2268
|
+
if ( this._initialized === false ) await this.init();
|
|
2269
|
+
|
|
2270
|
+
return this.backend.resolveTimestampsAsync( type );
|
|
2271
|
+
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
/**
|
|
2275
|
+
* Checks if the given feature is supported by the selected backend. If the
|
|
2276
|
+
* renderer has not been initialized, this method always returns `false`.
|
|
2277
|
+
*
|
|
2278
|
+
* @param {String} name - The feature's name.
|
|
2279
|
+
* @return {Boolean} Whether the feature is supported or not.
|
|
2280
|
+
*/
|
|
1298
2281
|
hasFeature( name ) {
|
|
1299
2282
|
|
|
1300
2283
|
if ( this._initialized === false ) {
|
|
@@ -1309,12 +2292,25 @@ class Renderer {
|
|
|
1309
2292
|
|
|
1310
2293
|
}
|
|
1311
2294
|
|
|
2295
|
+
/**
|
|
2296
|
+
* Returns `true` when the renderer has been initialized.
|
|
2297
|
+
*
|
|
2298
|
+
* @return {Boolean} Whether the renderer has been initialized or not.
|
|
2299
|
+
*/
|
|
1312
2300
|
hasInitialized() {
|
|
1313
2301
|
|
|
1314
2302
|
return this._initialized;
|
|
1315
2303
|
|
|
1316
2304
|
}
|
|
1317
2305
|
|
|
2306
|
+
/**
|
|
2307
|
+
* Initializes the given textures. Useful for preloading a texture rather than waiting until first render
|
|
2308
|
+
* (which can cause noticeable lags due to decode and GPU upload overhead).
|
|
2309
|
+
*
|
|
2310
|
+
* @async
|
|
2311
|
+
* @param {Texture} texture - The texture.
|
|
2312
|
+
* @return {Promise} A Promise that resolves when the texture has been initialized.
|
|
2313
|
+
*/
|
|
1318
2314
|
async initTextureAsync( texture ) {
|
|
1319
2315
|
|
|
1320
2316
|
if ( this._initialized === false ) await this.init();
|
|
@@ -1323,20 +2319,32 @@ class Renderer {
|
|
|
1323
2319
|
|
|
1324
2320
|
}
|
|
1325
2321
|
|
|
2322
|
+
/**
|
|
2323
|
+
* Initializes the given textures. Useful for preloading a texture rather than waiting until first render
|
|
2324
|
+
* (which can cause noticeable lags due to decode and GPU upload overhead).
|
|
2325
|
+
*
|
|
2326
|
+
* This method can only be used if the renderer has been initialized.
|
|
2327
|
+
*
|
|
2328
|
+
* @param {Texture} texture - The texture.
|
|
2329
|
+
*/
|
|
1326
2330
|
initTexture( texture ) {
|
|
1327
2331
|
|
|
1328
2332
|
if ( this._initialized === false ) {
|
|
1329
2333
|
|
|
1330
2334
|
console.warn( 'THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead.' );
|
|
1331
2335
|
|
|
1332
|
-
return false;
|
|
1333
|
-
|
|
1334
2336
|
}
|
|
1335
2337
|
|
|
1336
2338
|
this._textures.updateTexture( texture );
|
|
1337
2339
|
|
|
1338
2340
|
}
|
|
1339
2341
|
|
|
2342
|
+
/**
|
|
2343
|
+
* Copies the current bound framebuffer into the given texture.
|
|
2344
|
+
*
|
|
2345
|
+
* @param {FramebufferTexture} framebufferTexture - The texture.
|
|
2346
|
+
* @param {Vector2|Vector4} rectangle - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
|
|
2347
|
+
*/
|
|
1340
2348
|
copyFramebufferToTexture( framebufferTexture, rectangle = null ) {
|
|
1341
2349
|
|
|
1342
2350
|
if ( rectangle !== null ) {
|
|
@@ -1394,6 +2402,15 @@ class Renderer {
|
|
|
1394
2402
|
|
|
1395
2403
|
}
|
|
1396
2404
|
|
|
2405
|
+
/**
|
|
2406
|
+
* Copies data of source texture into a destination texture.
|
|
2407
|
+
*
|
|
2408
|
+
* @param {Texture} srcTexture - The source texture.
|
|
2409
|
+
* @param {Texture} dstTexture - The destination texture.
|
|
2410
|
+
* @param {Box2|Box3} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
|
|
2411
|
+
* @param {Vector2|Vector3} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
|
|
2412
|
+
* @param {Number} level - The mipmap level to copy.
|
|
2413
|
+
*/
|
|
1397
2414
|
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
1398
2415
|
|
|
1399
2416
|
this._textures.updateTexture( srcTexture );
|
|
@@ -1403,12 +2420,35 @@ class Renderer {
|
|
|
1403
2420
|
|
|
1404
2421
|
}
|
|
1405
2422
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
2423
|
+
/**
|
|
2424
|
+
* Reads pixel data from the given render target.
|
|
2425
|
+
*
|
|
2426
|
+
* @async
|
|
2427
|
+
* @param {RenderTarget} renderTarget - The render target to read from.
|
|
2428
|
+
* @param {Number} x - The `x` coordinate of the copy region's origin.
|
|
2429
|
+
* @param {Number} y - The `y` coordinate of the copy region's origin.
|
|
2430
|
+
* @param {Number} width - The width of the copy region.
|
|
2431
|
+
* @param {Number} height - The height of the copy region.
|
|
2432
|
+
* @param {Number} [textureIndex=0] - The texture index of a MRT render target.
|
|
2433
|
+
* @param {Number} [faceIndex=0] - The active cube face index.
|
|
2434
|
+
* @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
|
|
2435
|
+
*/
|
|
2436
|
+
async readRenderTargetPixelsAsync( renderTarget, x, y, width, height, textureIndex = 0, faceIndex = 0 ) {
|
|
2437
|
+
|
|
2438
|
+
return this.backend.copyTextureToBuffer( renderTarget.textures[ textureIndex ], x, y, width, height, faceIndex );
|
|
2439
|
+
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
/**
|
|
2443
|
+
* Analyzes the given 3D object's hierarchy and builds render lists from the
|
|
2444
|
+
* processed hierarchy.
|
|
2445
|
+
*
|
|
2446
|
+
* @param {Object3D} object - The 3D object to process (usually a scene).
|
|
2447
|
+
* @param {Camera} camera - The camera the object is rendered with.
|
|
2448
|
+
* @param {Number} groupOrder - The group order is derived from the `renderOrder` of groups and is used to group 3D objects within groups.
|
|
2449
|
+
* @param {RenderList} renderList - The current render list.
|
|
2450
|
+
* @param {ClippingContext} clippingContext - The current clipping context.
|
|
2451
|
+
*/
|
|
1412
2452
|
_projectObject( object, camera, groupOrder, renderList, clippingContext ) {
|
|
1413
2453
|
|
|
1414
2454
|
if ( object.visible === false ) return;
|
|
@@ -1530,6 +2570,14 @@ class Renderer {
|
|
|
1530
2570
|
|
|
1531
2571
|
}
|
|
1532
2572
|
|
|
2573
|
+
/**
|
|
2574
|
+
* Renders the given render bundles.
|
|
2575
|
+
*
|
|
2576
|
+
* @private
|
|
2577
|
+
* @param {Array<Object>} bundles - Array with render bundle data.
|
|
2578
|
+
* @param {Scene} sceneRef - The scene the render bundles belong to.
|
|
2579
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2580
|
+
*/
|
|
1533
2581
|
_renderBundles( bundles, sceneRef, lightsNode ) {
|
|
1534
2582
|
|
|
1535
2583
|
for ( const bundle of bundles ) {
|
|
@@ -1540,6 +2588,16 @@ class Renderer {
|
|
|
1540
2588
|
|
|
1541
2589
|
}
|
|
1542
2590
|
|
|
2591
|
+
/**
|
|
2592
|
+
* Renders the transparent objects from the given render lists.
|
|
2593
|
+
*
|
|
2594
|
+
* @private
|
|
2595
|
+
* @param {Array<Object>} renderList - The transparent render list.
|
|
2596
|
+
* @param {Array<Object>} doublePassList - The list of transparent objects which require a double pass (e.g. because of transmission).
|
|
2597
|
+
* @param {Camera} camera - The camera the render list should be rendered with.
|
|
2598
|
+
* @param {Scene} scene - The scene the render list belongs to.
|
|
2599
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2600
|
+
*/
|
|
1543
2601
|
_renderTransparents( renderList, doublePassList, camera, scene, lightsNode ) {
|
|
1544
2602
|
|
|
1545
2603
|
if ( doublePassList.length > 0 ) {
|
|
@@ -1580,56 +2638,42 @@ class Renderer {
|
|
|
1580
2638
|
|
|
1581
2639
|
}
|
|
1582
2640
|
|
|
2641
|
+
/**
|
|
2642
|
+
* Renders the objects from the given render list.
|
|
2643
|
+
*
|
|
2644
|
+
* @private
|
|
2645
|
+
* @param {Array<Object>} renderList - The render list.
|
|
2646
|
+
* @param {Camera} camera - The camera the render list should be rendered with.
|
|
2647
|
+
* @param {Scene} scene - The scene the render list belongs to.
|
|
2648
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2649
|
+
* @param {String?} [passId=null] - An optional ID for identifying the pass.
|
|
2650
|
+
*/
|
|
1583
2651
|
_renderObjects( renderList, camera, scene, lightsNode, passId = null ) {
|
|
1584
2652
|
|
|
1585
|
-
// process renderable objects
|
|
1586
|
-
|
|
1587
2653
|
for ( let i = 0, il = renderList.length; i < il; i ++ ) {
|
|
1588
2654
|
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
// @TODO: Add support for multiple materials per object. This will require to extract
|
|
1592
|
-
// the material from the renderItem object and pass it with its group data to renderObject().
|
|
1593
|
-
|
|
1594
|
-
const { object, geometry, material, group, clippingContext } = renderItem;
|
|
1595
|
-
|
|
1596
|
-
if ( camera.isArrayCamera ) {
|
|
1597
|
-
|
|
1598
|
-
const cameras = camera.cameras;
|
|
1599
|
-
|
|
1600
|
-
for ( let j = 0, jl = cameras.length; j < jl; j ++ ) {
|
|
1601
|
-
|
|
1602
|
-
const camera2 = cameras[ j ];
|
|
1603
|
-
|
|
1604
|
-
if ( object.layers.test( camera2.layers ) ) {
|
|
2655
|
+
const { object, geometry, material, group, clippingContext } = renderList[ i ];
|
|
1605
2656
|
|
|
1606
|
-
|
|
1607
|
-
const minDepth = ( vp.minDepth === undefined ) ? 0 : vp.minDepth;
|
|
1608
|
-
const maxDepth = ( vp.maxDepth === undefined ) ? 1 : vp.maxDepth;
|
|
1609
|
-
|
|
1610
|
-
const viewportValue = this._currentRenderContext.viewportValue;
|
|
1611
|
-
viewportValue.copy( vp ).multiplyScalar( this._pixelRatio ).floor();
|
|
1612
|
-
viewportValue.minDepth = minDepth;
|
|
1613
|
-
viewportValue.maxDepth = maxDepth;
|
|
1614
|
-
|
|
1615
|
-
this.backend.updateViewport( this._currentRenderContext );
|
|
1616
|
-
|
|
1617
|
-
this._currentRenderObjectFunction( object, scene, camera2, geometry, material, group, lightsNode, clippingContext, passId );
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
} else {
|
|
1624
|
-
|
|
1625
|
-
this._currentRenderObjectFunction( object, scene, camera, geometry, material, group, lightsNode, clippingContext, passId );
|
|
1626
|
-
|
|
1627
|
-
}
|
|
2657
|
+
this._currentRenderObjectFunction( object, scene, camera, geometry, material, group, lightsNode, clippingContext, passId );
|
|
1628
2658
|
|
|
1629
2659
|
}
|
|
1630
2660
|
|
|
1631
2661
|
}
|
|
1632
2662
|
|
|
2663
|
+
/**
|
|
2664
|
+
* This method represents the default render object function that manages the render lifecycle
|
|
2665
|
+
* of the object.
|
|
2666
|
+
*
|
|
2667
|
+
* @param {Object3D} object - The 3D object.
|
|
2668
|
+
* @param {Scene} scene - The scene the 3D object belongs to.
|
|
2669
|
+
* @param {Camera} camera - The camera the object should be rendered with.
|
|
2670
|
+
* @param {BufferGeometry} geometry - The object's geometry.
|
|
2671
|
+
* @param {Material} material - The object's material.
|
|
2672
|
+
* @param {Object?} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2673
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2674
|
+
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2675
|
+
* @param {String?} [passId=null] - An optional ID for identifying the pass.
|
|
2676
|
+
*/
|
|
1633
2677
|
renderObject( object, scene, camera, geometry, material, group, lightsNode, clippingContext = null, passId = null ) {
|
|
1634
2678
|
|
|
1635
2679
|
let overridePositionNode;
|
|
@@ -1655,8 +2699,9 @@ class Renderer {
|
|
|
1655
2699
|
|
|
1656
2700
|
overrideMaterial.alphaTest = material.alphaTest;
|
|
1657
2701
|
overrideMaterial.alphaMap = material.alphaMap;
|
|
2702
|
+
overrideMaterial.transparent = material.transparent || material.transmission > 0;
|
|
1658
2703
|
|
|
1659
|
-
if ( overrideMaterial.
|
|
2704
|
+
if ( overrideMaterial.isShadowPassMaterial ) {
|
|
1660
2705
|
|
|
1661
2706
|
overrideMaterial.side = material.shadowSide === null ? material.side : material.shadowSide;
|
|
1662
2707
|
|
|
@@ -1724,6 +2769,20 @@ class Renderer {
|
|
|
1724
2769
|
|
|
1725
2770
|
}
|
|
1726
2771
|
|
|
2772
|
+
/**
|
|
2773
|
+
* This method represents the default `_handleObjectFunction` implementation which creates
|
|
2774
|
+
* a render object from the given data and performs the draw command with the selected backend.
|
|
2775
|
+
*
|
|
2776
|
+
* @private
|
|
2777
|
+
* @param {Object3D} object - The 3D object.
|
|
2778
|
+
* @param {Material} material - The object's material.
|
|
2779
|
+
* @param {Scene} scene - The scene the 3D object belongs to.
|
|
2780
|
+
* @param {Camera} camera - The camera the object should be rendered with.
|
|
2781
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2782
|
+
* @param {{start: Number, count: Number}?} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2783
|
+
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2784
|
+
* @param {String?} [passId=null] - An optional ID for identifying the pass.
|
|
2785
|
+
*/
|
|
1727
2786
|
_renderObjectDirect( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
1728
2787
|
|
|
1729
2788
|
const renderObject = this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, clippingContext, passId );
|
|
@@ -1755,7 +2814,7 @@ class Renderer {
|
|
|
1755
2814
|
|
|
1756
2815
|
renderBundleData.renderObjects.push( renderObject );
|
|
1757
2816
|
|
|
1758
|
-
renderObject.bundle = this._currentRenderBundle.
|
|
2817
|
+
renderObject.bundle = this._currentRenderBundle.bundleGroup;
|
|
1759
2818
|
|
|
1760
2819
|
}
|
|
1761
2820
|
|
|
@@ -1765,9 +2824,25 @@ class Renderer {
|
|
|
1765
2824
|
|
|
1766
2825
|
}
|
|
1767
2826
|
|
|
1768
|
-
|
|
2827
|
+
/**
|
|
2828
|
+
* A different implementation for `_handleObjectFunction` which only makes sure the object is ready for rendering.
|
|
2829
|
+
* Used in `compileAsync()`.
|
|
2830
|
+
*
|
|
2831
|
+
* @private
|
|
2832
|
+
* @param {Object3D} object - The 3D object.
|
|
2833
|
+
* @param {Material} material - The object's material.
|
|
2834
|
+
* @param {Scene} scene - The scene the 3D object belongs to.
|
|
2835
|
+
* @param {Camera} camera - The camera the object should be rendered with.
|
|
2836
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
2837
|
+
* @param {{start: Number, count: Number}?} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
|
|
2838
|
+
* @param {ClippingContext} clippingContext - The clipping context.
|
|
2839
|
+
* @param {String?} [passId=null] - An optional ID for identifying the pass.
|
|
2840
|
+
*/
|
|
2841
|
+
_createObjectPipeline( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
|
|
1769
2842
|
|
|
1770
2843
|
const renderObject = this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, clippingContext, passId );
|
|
2844
|
+
renderObject.drawRange = object.geometry.drawRange;
|
|
2845
|
+
renderObject.group = group;
|
|
1771
2846
|
|
|
1772
2847
|
//
|
|
1773
2848
|
|
|
@@ -1784,6 +2859,15 @@ class Renderer {
|
|
|
1784
2859
|
|
|
1785
2860
|
}
|
|
1786
2861
|
|
|
2862
|
+
/**
|
|
2863
|
+
* Alias for `compileAsync()`.
|
|
2864
|
+
*
|
|
2865
|
+
* @method
|
|
2866
|
+
* @param {Object3D} scene - The scene or 3D object to precompile.
|
|
2867
|
+
* @param {Camera} camera - The camera that is used to render the scene.
|
|
2868
|
+
* @param {Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
|
|
2869
|
+
* @return {Promise} A Promise that resolves when the compile has been finished.
|
|
2870
|
+
*/
|
|
1787
2871
|
get compile() {
|
|
1788
2872
|
|
|
1789
2873
|
return this.compileAsync;
|