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
|
@@ -3,34 +3,98 @@ import ChainMap from '../ChainMap.js';
|
|
|
3
3
|
import NodeBuilderState from './NodeBuilderState.js';
|
|
4
4
|
import { cubeMapNode } from '../../../nodes/utils/CubeMapNode.js';
|
|
5
5
|
import { NodeFrame } from '../../../nodes/Nodes.js';
|
|
6
|
-
import { objectGroup, renderGroup, frameGroup, cubeTexture, texture,
|
|
6
|
+
import { objectGroup, renderGroup, frameGroup, cubeTexture, texture, fog, rangeFogFactor, densityFogFactor, reference, pmremTexture, screenUV } from '../../../nodes/TSL.js';
|
|
7
7
|
|
|
8
8
|
import { CubeUVReflectionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../../constants.js';
|
|
9
9
|
import { hashArray } from '../../../nodes/core/NodeUtils.js';
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const _outputNodeMap = new WeakMap();
|
|
12
|
+
const _chainKeys = [];
|
|
13
|
+
const _cacheKeyValues = [];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This renderer module manages node-related objects and is the
|
|
17
|
+
* primary interface between the renderer and the node system.
|
|
18
|
+
*
|
|
19
|
+
* @private
|
|
20
|
+
* @augments DataMap
|
|
21
|
+
*/
|
|
13
22
|
class Nodes extends DataMap {
|
|
14
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Constructs a new nodes management component.
|
|
26
|
+
*
|
|
27
|
+
* @param {Renderer} renderer - The renderer.
|
|
28
|
+
* @param {Backend} backend - The renderer's backend.
|
|
29
|
+
*/
|
|
15
30
|
constructor( renderer, backend ) {
|
|
16
31
|
|
|
17
32
|
super();
|
|
18
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The renderer.
|
|
36
|
+
*
|
|
37
|
+
* @type {Renderer}
|
|
38
|
+
*/
|
|
19
39
|
this.renderer = renderer;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The renderer's backend.
|
|
43
|
+
*
|
|
44
|
+
* @type {Backend}
|
|
45
|
+
*/
|
|
20
46
|
this.backend = backend;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The node frame.
|
|
50
|
+
*
|
|
51
|
+
* @type {Renderer}
|
|
52
|
+
*/
|
|
21
53
|
this.nodeFrame = new NodeFrame();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A cache for managing node builder states.
|
|
57
|
+
*
|
|
58
|
+
* @type {Map<Number,NodeBuilderState>}
|
|
59
|
+
*/
|
|
22
60
|
this.nodeBuilderCache = new Map();
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A cache for managing data cache key data.
|
|
64
|
+
*
|
|
65
|
+
* @type {ChainMap}
|
|
66
|
+
*/
|
|
23
67
|
this.callHashCache = new ChainMap();
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A cache for managing node uniforms group data.
|
|
71
|
+
*
|
|
72
|
+
* @type {ChainMap}
|
|
73
|
+
*/
|
|
24
74
|
this.groupsData = new ChainMap();
|
|
25
75
|
|
|
76
|
+
/**
|
|
77
|
+
* A cache for managing node objects of
|
|
78
|
+
* scene properties like fog or environments.
|
|
79
|
+
*
|
|
80
|
+
* @type {Object<String,WeakMap>}
|
|
81
|
+
*/
|
|
82
|
+
this.cacheLib = {};
|
|
83
|
+
|
|
26
84
|
}
|
|
27
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Returns `true` if the given node uniforms group must be updated or not.
|
|
88
|
+
*
|
|
89
|
+
* @param {NodeUniformsGroup} nodeUniformsGroup - The node uniforms group.
|
|
90
|
+
* @return {Boolean} Whether the node uniforms group requires an update or not.
|
|
91
|
+
*/
|
|
28
92
|
updateGroup( nodeUniformsGroup ) {
|
|
29
93
|
|
|
30
94
|
const groupNode = nodeUniformsGroup.groupNode;
|
|
31
95
|
const name = groupNode.name;
|
|
32
96
|
|
|
33
|
-
// objectGroup is
|
|
97
|
+
// objectGroup is always updated
|
|
34
98
|
|
|
35
99
|
if ( name === objectGroup.name ) return true;
|
|
36
100
|
|
|
@@ -74,10 +138,13 @@ class Nodes extends DataMap {
|
|
|
74
138
|
|
|
75
139
|
// other groups are updated just when groupNode.needsUpdate is true
|
|
76
140
|
|
|
77
|
-
|
|
141
|
+
_chainKeys[ 0 ] = groupNode;
|
|
142
|
+
_chainKeys[ 1 ] = nodeUniformsGroup;
|
|
78
143
|
|
|
79
|
-
let groupData = this.groupsData.get(
|
|
80
|
-
if ( groupData === undefined ) this.groupsData.set(
|
|
144
|
+
let groupData = this.groupsData.get( _chainKeys );
|
|
145
|
+
if ( groupData === undefined ) this.groupsData.set( _chainKeys, groupData = {} );
|
|
146
|
+
|
|
147
|
+
_chainKeys.length = 0;
|
|
81
148
|
|
|
82
149
|
if ( groupData.version !== groupNode.version ) {
|
|
83
150
|
|
|
@@ -91,12 +158,24 @@ class Nodes extends DataMap {
|
|
|
91
158
|
|
|
92
159
|
}
|
|
93
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Returns the cache key for the given render object.
|
|
163
|
+
*
|
|
164
|
+
* @param {RenderObject} renderObject - The render object.
|
|
165
|
+
* @return {Number} The cache key.
|
|
166
|
+
*/
|
|
94
167
|
getForRenderCacheKey( renderObject ) {
|
|
95
168
|
|
|
96
169
|
return renderObject.initialCacheKey;
|
|
97
170
|
|
|
98
171
|
}
|
|
99
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Returns a node builder state for the given render object.
|
|
175
|
+
*
|
|
176
|
+
* @param {RenderObject} renderObject - The render object.
|
|
177
|
+
* @return {NodeBuilderState} The node builder state.
|
|
178
|
+
*/
|
|
100
179
|
getForRender( renderObject ) {
|
|
101
180
|
|
|
102
181
|
const renderObjectData = this.get( renderObject );
|
|
@@ -140,6 +219,12 @@ class Nodes extends DataMap {
|
|
|
140
219
|
|
|
141
220
|
}
|
|
142
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Deletes the given object from the internal data map
|
|
224
|
+
*
|
|
225
|
+
* @param {Any} object - The object to delete.
|
|
226
|
+
* @return {Object?} The deleted dictionary.
|
|
227
|
+
*/
|
|
143
228
|
delete( object ) {
|
|
144
229
|
|
|
145
230
|
if ( object.isRenderObject ) {
|
|
@@ -159,6 +244,12 @@ class Nodes extends DataMap {
|
|
|
159
244
|
|
|
160
245
|
}
|
|
161
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Returns a node builder state for the given compute node.
|
|
249
|
+
*
|
|
250
|
+
* @param {Node} computeNode - The compute node.
|
|
251
|
+
* @return {NodeBuilderState} The node builder state.
|
|
252
|
+
*/
|
|
162
253
|
getForCompute( computeNode ) {
|
|
163
254
|
|
|
164
255
|
const computeData = this.get( computeNode );
|
|
@@ -180,6 +271,13 @@ class Nodes extends DataMap {
|
|
|
180
271
|
|
|
181
272
|
}
|
|
182
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Creates a node builder state for the given node builder.
|
|
276
|
+
*
|
|
277
|
+
* @private
|
|
278
|
+
* @param {NodeBuilder} nodeBuilder - The node builder.
|
|
279
|
+
* @return {NodeBuilderState} The node builder state.
|
|
280
|
+
*/
|
|
183
281
|
_createNodeBuilderState( nodeBuilder ) {
|
|
184
282
|
|
|
185
283
|
return new NodeBuilderState(
|
|
@@ -191,77 +289,155 @@ class Nodes extends DataMap {
|
|
|
191
289
|
nodeBuilder.updateNodes,
|
|
192
290
|
nodeBuilder.updateBeforeNodes,
|
|
193
291
|
nodeBuilder.updateAfterNodes,
|
|
194
|
-
nodeBuilder.
|
|
292
|
+
nodeBuilder.observer,
|
|
195
293
|
nodeBuilder.transforms
|
|
196
294
|
);
|
|
197
295
|
|
|
198
296
|
}
|
|
199
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Returns an environment node for the current configured
|
|
300
|
+
* scene environment.
|
|
301
|
+
*
|
|
302
|
+
* @param {Scene} scene - The scene.
|
|
303
|
+
* @return {Node} A node representing the current scene environment.
|
|
304
|
+
*/
|
|
200
305
|
getEnvironmentNode( scene ) {
|
|
201
306
|
|
|
202
|
-
|
|
307
|
+
this.updateEnvironment( scene );
|
|
308
|
+
|
|
309
|
+
let environmentNode = null;
|
|
310
|
+
|
|
311
|
+
if ( scene.environmentNode && scene.environmentNode.isNode ) {
|
|
312
|
+
|
|
313
|
+
environmentNode = scene.environmentNode;
|
|
314
|
+
|
|
315
|
+
} else {
|
|
316
|
+
|
|
317
|
+
const sceneData = this.get( scene );
|
|
318
|
+
|
|
319
|
+
if ( sceneData.environmentNode ) {
|
|
320
|
+
|
|
321
|
+
environmentNode = sceneData.environmentNode;
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return environmentNode;
|
|
203
328
|
|
|
204
329
|
}
|
|
205
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Returns a background node for the current configured
|
|
333
|
+
* scene background.
|
|
334
|
+
*
|
|
335
|
+
* @param {Scene} scene - The scene.
|
|
336
|
+
* @return {Node} A node representing the current scene background.
|
|
337
|
+
*/
|
|
206
338
|
getBackgroundNode( scene ) {
|
|
207
339
|
|
|
208
|
-
|
|
340
|
+
this.updateBackground( scene );
|
|
341
|
+
|
|
342
|
+
let backgroundNode = null;
|
|
343
|
+
|
|
344
|
+
if ( scene.backgroundNode && scene.backgroundNode.isNode ) {
|
|
345
|
+
|
|
346
|
+
backgroundNode = scene.backgroundNode;
|
|
347
|
+
|
|
348
|
+
} else {
|
|
349
|
+
|
|
350
|
+
const sceneData = this.get( scene );
|
|
351
|
+
|
|
352
|
+
if ( sceneData.backgroundNode ) {
|
|
353
|
+
|
|
354
|
+
backgroundNode = sceneData.backgroundNode;
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return backgroundNode;
|
|
209
361
|
|
|
210
362
|
}
|
|
211
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Returns a fog node for the current configured scene fog.
|
|
366
|
+
*
|
|
367
|
+
* @param {Scene} scene - The scene.
|
|
368
|
+
* @return {Node} A node representing the current scene fog.
|
|
369
|
+
*/
|
|
212
370
|
getFogNode( scene ) {
|
|
213
371
|
|
|
372
|
+
this.updateFog( scene );
|
|
373
|
+
|
|
214
374
|
return scene.fogNode || this.get( scene ).fogNode || null;
|
|
215
375
|
|
|
216
376
|
}
|
|
217
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Returns a cache key for the given scene and lights node.
|
|
380
|
+
* This key is used by `RenderObject` as a part of the dynamic
|
|
381
|
+
* cache key (a key that must be checked every time the render
|
|
382
|
+
* objects is drawn).
|
|
383
|
+
*
|
|
384
|
+
* @param {Scene} scene - The scene.
|
|
385
|
+
* @param {LightsNode} lightsNode - The lights node.
|
|
386
|
+
* @return {Number} The cache key.
|
|
387
|
+
*/
|
|
218
388
|
getCacheKey( scene, lightsNode ) {
|
|
219
389
|
|
|
220
|
-
|
|
390
|
+
_chainKeys[ 0 ] = scene;
|
|
391
|
+
_chainKeys[ 1 ] = lightsNode;
|
|
392
|
+
|
|
221
393
|
const callId = this.renderer.info.calls;
|
|
222
394
|
|
|
223
|
-
|
|
395
|
+
const cacheKeyData = this.callHashCache.get( _chainKeys ) || {};
|
|
224
396
|
|
|
225
|
-
if ( cacheKeyData
|
|
397
|
+
if ( cacheKeyData.callId !== callId ) {
|
|
226
398
|
|
|
227
399
|
const environmentNode = this.getEnvironmentNode( scene );
|
|
228
400
|
const fogNode = this.getFogNode( scene );
|
|
229
401
|
|
|
230
|
-
|
|
402
|
+
if ( lightsNode ) _cacheKeyValues.push( lightsNode.getCacheKey( true ) );
|
|
403
|
+
if ( environmentNode ) _cacheKeyValues.push( environmentNode.getCacheKey() );
|
|
404
|
+
if ( fogNode ) _cacheKeyValues.push( fogNode.getCacheKey() );
|
|
231
405
|
|
|
232
|
-
|
|
233
|
-
if ( environmentNode ) values.push( environmentNode.getCacheKey() );
|
|
234
|
-
if ( fogNode ) values.push( fogNode.getCacheKey() );
|
|
406
|
+
_cacheKeyValues.push( this.renderer.shadowMap.enabled ? 1 : 0 );
|
|
235
407
|
|
|
236
|
-
|
|
408
|
+
cacheKeyData.callId = callId;
|
|
409
|
+
cacheKeyData.cacheKey = hashArray( _cacheKeyValues );
|
|
237
410
|
|
|
238
|
-
cacheKeyData
|
|
239
|
-
callId,
|
|
240
|
-
cacheKey: hashArray( values )
|
|
241
|
-
};
|
|
411
|
+
this.callHashCache.set( _chainKeys, cacheKeyData );
|
|
242
412
|
|
|
243
|
-
|
|
413
|
+
_cacheKeyValues.length = 0;
|
|
244
414
|
|
|
245
415
|
}
|
|
246
416
|
|
|
247
|
-
|
|
417
|
+
_chainKeys.length = 0;
|
|
248
418
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
updateScene( scene ) {
|
|
252
|
-
|
|
253
|
-
this.updateEnvironment( scene );
|
|
254
|
-
this.updateFog( scene );
|
|
255
|
-
this.updateBackground( scene );
|
|
419
|
+
return cacheKeyData.cacheKey;
|
|
256
420
|
|
|
257
421
|
}
|
|
258
422
|
|
|
423
|
+
/**
|
|
424
|
+
* A boolean that indicates whether tone mapping should be enabled
|
|
425
|
+
* or not.
|
|
426
|
+
*
|
|
427
|
+
* @type {Boolean}
|
|
428
|
+
*/
|
|
259
429
|
get isToneMappingState() {
|
|
260
430
|
|
|
261
431
|
return this.renderer.getRenderTarget() ? false : true;
|
|
262
432
|
|
|
263
433
|
}
|
|
264
434
|
|
|
435
|
+
/**
|
|
436
|
+
* If a scene background is configured, this method makes sure to
|
|
437
|
+
* represent the background with a corresponding node-based implementation.
|
|
438
|
+
*
|
|
439
|
+
* @param {Scene} scene - The scene.
|
|
440
|
+
*/
|
|
265
441
|
updateBackground( scene ) {
|
|
266
442
|
|
|
267
443
|
const sceneData = this.get( scene );
|
|
@@ -273,41 +449,43 @@ class Nodes extends DataMap {
|
|
|
273
449
|
|
|
274
450
|
if ( sceneData.background !== background || forceUpdate ) {
|
|
275
451
|
|
|
276
|
-
|
|
452
|
+
const backgroundNode = this.getCacheNode( 'background', background, () => {
|
|
277
453
|
|
|
278
|
-
|
|
454
|
+
if ( background.isCubeTexture === true || ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping || background.mapping === CubeUVReflectionMapping ) ) {
|
|
279
455
|
|
|
280
|
-
|
|
456
|
+
if ( scene.backgroundBlurriness > 0 || background.mapping === CubeUVReflectionMapping ) {
|
|
281
457
|
|
|
282
|
-
|
|
458
|
+
return pmremTexture( background );
|
|
283
459
|
|
|
284
|
-
|
|
460
|
+
} else {
|
|
285
461
|
|
|
286
|
-
|
|
462
|
+
let envMap;
|
|
287
463
|
|
|
288
|
-
|
|
464
|
+
if ( background.isCubeTexture === true ) {
|
|
289
465
|
|
|
290
|
-
|
|
466
|
+
envMap = cubeTexture( background );
|
|
291
467
|
|
|
292
|
-
|
|
468
|
+
} else {
|
|
293
469
|
|
|
294
|
-
|
|
470
|
+
envMap = texture( background );
|
|
295
471
|
|
|
296
|
-
|
|
472
|
+
}
|
|
297
473
|
|
|
298
|
-
|
|
474
|
+
return cubeMapNode( envMap );
|
|
299
475
|
|
|
300
|
-
|
|
476
|
+
}
|
|
301
477
|
|
|
302
|
-
|
|
478
|
+
} else if ( background.isTexture === true ) {
|
|
303
479
|
|
|
304
|
-
|
|
480
|
+
return texture( background, screenUV.flipY() ).setUpdateMatrix( true );
|
|
305
481
|
|
|
306
|
-
|
|
482
|
+
} else if ( background.isColor !== true ) {
|
|
307
483
|
|
|
308
|
-
|
|
484
|
+
console.error( 'WebGPUNodes: Unsupported background configuration.', background );
|
|
309
485
|
|
|
310
|
-
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
}, forceUpdate );
|
|
311
489
|
|
|
312
490
|
sceneData.backgroundNode = backgroundNode;
|
|
313
491
|
sceneData.background = background;
|
|
@@ -324,40 +502,75 @@ class Nodes extends DataMap {
|
|
|
324
502
|
|
|
325
503
|
}
|
|
326
504
|
|
|
505
|
+
/**
|
|
506
|
+
* This method is part of the caching of nodes which are used to represents the
|
|
507
|
+
* scene's background, fog or environment.
|
|
508
|
+
*
|
|
509
|
+
* @param {String} type - The type of object to cache.
|
|
510
|
+
* @param {Object} object - The object.
|
|
511
|
+
* @param {Function} callback - A callback that produces a node representation for the given object.
|
|
512
|
+
* @param {Boolean} [forceUpdate=false] - Whether an update should be enforced or not.
|
|
513
|
+
* @return {Node} The node representation.
|
|
514
|
+
*/
|
|
515
|
+
getCacheNode( type, object, callback, forceUpdate = false ) {
|
|
516
|
+
|
|
517
|
+
const nodeCache = this.cacheLib[ type ] || ( this.cacheLib[ type ] = new WeakMap() );
|
|
518
|
+
|
|
519
|
+
let node = nodeCache.get( object );
|
|
520
|
+
|
|
521
|
+
if ( node === undefined || forceUpdate ) {
|
|
522
|
+
|
|
523
|
+
node = callback();
|
|
524
|
+
nodeCache.set( object, node );
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return node;
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* If a scene fog is configured, this method makes sure to
|
|
534
|
+
* represent the fog with a corresponding node-based implementation.
|
|
535
|
+
*
|
|
536
|
+
* @param {Scene} scene - The scene.
|
|
537
|
+
*/
|
|
327
538
|
updateFog( scene ) {
|
|
328
539
|
|
|
329
540
|
const sceneData = this.get( scene );
|
|
330
|
-
const
|
|
541
|
+
const sceneFog = scene.fog;
|
|
331
542
|
|
|
332
|
-
if (
|
|
543
|
+
if ( sceneFog ) {
|
|
333
544
|
|
|
334
|
-
if ( sceneData.fog !==
|
|
545
|
+
if ( sceneData.fog !== sceneFog ) {
|
|
335
546
|
|
|
336
|
-
|
|
547
|
+
const fogNode = this.getCacheNode( 'fog', sceneFog, () => {
|
|
337
548
|
|
|
338
|
-
|
|
549
|
+
if ( sceneFog.isFogExp2 ) {
|
|
339
550
|
|
|
340
|
-
|
|
341
|
-
|
|
551
|
+
const color = reference( 'color', 'color', sceneFog ).setGroup( renderGroup );
|
|
552
|
+
const density = reference( 'density', 'float', sceneFog ).setGroup( renderGroup );
|
|
342
553
|
|
|
343
|
-
|
|
554
|
+
return fog( color, densityFogFactor( density ) );
|
|
344
555
|
|
|
345
|
-
|
|
556
|
+
} else if ( sceneFog.isFog ) {
|
|
346
557
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
558
|
+
const color = reference( 'color', 'color', sceneFog ).setGroup( renderGroup );
|
|
559
|
+
const near = reference( 'near', 'float', sceneFog ).setGroup( renderGroup );
|
|
560
|
+
const far = reference( 'far', 'float', sceneFog ).setGroup( renderGroup );
|
|
350
561
|
|
|
351
|
-
|
|
562
|
+
return fog( color, rangeFogFactor( near, far ) );
|
|
563
|
+
|
|
564
|
+
} else {
|
|
352
565
|
|
|
353
|
-
|
|
566
|
+
console.error( 'THREE.Renderer: Unsupported fog configuration.', sceneFog );
|
|
354
567
|
|
|
355
|
-
|
|
568
|
+
}
|
|
356
569
|
|
|
357
|
-
}
|
|
570
|
+
} );
|
|
358
571
|
|
|
359
572
|
sceneData.fogNode = fogNode;
|
|
360
|
-
sceneData.fog =
|
|
573
|
+
sceneData.fog = sceneFog;
|
|
361
574
|
|
|
362
575
|
}
|
|
363
576
|
|
|
@@ -370,6 +583,12 @@ class Nodes extends DataMap {
|
|
|
370
583
|
|
|
371
584
|
}
|
|
372
585
|
|
|
586
|
+
/**
|
|
587
|
+
* If a scene environment is configured, this method makes sure to
|
|
588
|
+
* represent the environment with a corresponding node-based implementation.
|
|
589
|
+
*
|
|
590
|
+
* @param {Scene} scene - The scene.
|
|
591
|
+
*/
|
|
373
592
|
updateEnvironment( scene ) {
|
|
374
593
|
|
|
375
594
|
const sceneData = this.get( scene );
|
|
@@ -379,21 +598,23 @@ class Nodes extends DataMap {
|
|
|
379
598
|
|
|
380
599
|
if ( sceneData.environment !== environment ) {
|
|
381
600
|
|
|
382
|
-
|
|
601
|
+
const environmentNode = this.getCacheNode( 'environment', environment, () => {
|
|
602
|
+
|
|
603
|
+
if ( environment.isCubeTexture === true ) {
|
|
383
604
|
|
|
384
|
-
|
|
605
|
+
return cubeTexture( environment );
|
|
385
606
|
|
|
386
|
-
|
|
607
|
+
} else if ( environment.isTexture === true ) {
|
|
387
608
|
|
|
388
|
-
|
|
609
|
+
return texture( environment );
|
|
389
610
|
|
|
390
|
-
|
|
611
|
+
} else {
|
|
391
612
|
|
|
392
|
-
|
|
613
|
+
console.error( 'Nodes: Unsupported environment configuration.', environment );
|
|
393
614
|
|
|
394
|
-
|
|
615
|
+
}
|
|
395
616
|
|
|
396
|
-
}
|
|
617
|
+
} );
|
|
397
618
|
|
|
398
619
|
sceneData.environmentNode = environmentNode;
|
|
399
620
|
sceneData.environment = environment;
|
|
@@ -428,6 +649,11 @@ class Nodes extends DataMap {
|
|
|
428
649
|
|
|
429
650
|
}
|
|
430
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Returns the current output cache key.
|
|
654
|
+
*
|
|
655
|
+
* @return {String} The output cache key.
|
|
656
|
+
*/
|
|
431
657
|
getOutputCacheKey() {
|
|
432
658
|
|
|
433
659
|
const renderer = this.renderer;
|
|
@@ -436,27 +662,47 @@ class Nodes extends DataMap {
|
|
|
436
662
|
|
|
437
663
|
}
|
|
438
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Checks if the output configuration (tone mapping and color space) for
|
|
667
|
+
* the given target has changed.
|
|
668
|
+
*
|
|
669
|
+
* @param {Texture} outputTarget - The output target.
|
|
670
|
+
* @return {Boolean} Whether the output configuration has changed or not.
|
|
671
|
+
*/
|
|
439
672
|
hasOutputChange( outputTarget ) {
|
|
440
673
|
|
|
441
|
-
const cacheKey =
|
|
674
|
+
const cacheKey = _outputNodeMap.get( outputTarget );
|
|
442
675
|
|
|
443
676
|
return cacheKey !== this.getOutputCacheKey();
|
|
444
677
|
|
|
445
678
|
}
|
|
446
679
|
|
|
447
|
-
|
|
680
|
+
/**
|
|
681
|
+
* Returns a node that represents the output configuration (tone mapping and
|
|
682
|
+
* color space) for the current target.
|
|
683
|
+
*
|
|
684
|
+
* @param {Texture} outputTarget - The output target.
|
|
685
|
+
* @return {Node} The output node.
|
|
686
|
+
*/
|
|
687
|
+
getOutputNode( outputTarget ) {
|
|
448
688
|
|
|
449
689
|
const renderer = this.renderer;
|
|
450
690
|
const cacheKey = this.getOutputCacheKey();
|
|
451
691
|
|
|
452
|
-
const output = texture(
|
|
692
|
+
const output = texture( outputTarget, screenUV ).renderOutput( renderer.toneMapping, renderer.currentColorSpace );
|
|
453
693
|
|
|
454
|
-
|
|
694
|
+
_outputNodeMap.set( outputTarget, cacheKey );
|
|
455
695
|
|
|
456
696
|
return output;
|
|
457
697
|
|
|
458
698
|
}
|
|
459
699
|
|
|
700
|
+
/**
|
|
701
|
+
* Triggers the call of `updateBefore()` methods
|
|
702
|
+
* for all nodes of the given render object.
|
|
703
|
+
*
|
|
704
|
+
* @param {RenderObject} renderObject - The render object.
|
|
705
|
+
*/
|
|
460
706
|
updateBefore( renderObject ) {
|
|
461
707
|
|
|
462
708
|
const nodeBuilder = renderObject.getNodeBuilderState();
|
|
@@ -471,6 +717,12 @@ class Nodes extends DataMap {
|
|
|
471
717
|
|
|
472
718
|
}
|
|
473
719
|
|
|
720
|
+
/**
|
|
721
|
+
* Triggers the call of `updateAfter()` methods
|
|
722
|
+
* for all nodes of the given render object.
|
|
723
|
+
*
|
|
724
|
+
* @param {RenderObject} renderObject - The render object.
|
|
725
|
+
*/
|
|
474
726
|
updateAfter( renderObject ) {
|
|
475
727
|
|
|
476
728
|
const nodeBuilder = renderObject.getNodeBuilderState();
|
|
@@ -485,6 +737,12 @@ class Nodes extends DataMap {
|
|
|
485
737
|
|
|
486
738
|
}
|
|
487
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Triggers the call of `update()` methods
|
|
742
|
+
* for all nodes of the given compute node.
|
|
743
|
+
*
|
|
744
|
+
* @param {Node} computeNode - The compute node.
|
|
745
|
+
*/
|
|
488
746
|
updateForCompute( computeNode ) {
|
|
489
747
|
|
|
490
748
|
const nodeFrame = this.getNodeFrame();
|
|
@@ -498,6 +756,12 @@ class Nodes extends DataMap {
|
|
|
498
756
|
|
|
499
757
|
}
|
|
500
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Triggers the call of `update()` methods
|
|
761
|
+
* for all nodes of the given compute node.
|
|
762
|
+
*
|
|
763
|
+
* @param {RenderObject} renderObject - The render object.
|
|
764
|
+
*/
|
|
501
765
|
updateForRender( renderObject ) {
|
|
502
766
|
|
|
503
767
|
const nodeFrame = this.getNodeFrameForRender( renderObject );
|
|
@@ -511,6 +775,12 @@ class Nodes extends DataMap {
|
|
|
511
775
|
|
|
512
776
|
}
|
|
513
777
|
|
|
778
|
+
/**
|
|
779
|
+
* Returns `true` if the given render object requires a refresh.
|
|
780
|
+
*
|
|
781
|
+
* @param {RenderObject} renderObject - The render object.
|
|
782
|
+
* @return {Boolean} Whether the given render object requires a refresh or not.
|
|
783
|
+
*/
|
|
514
784
|
needsRefresh( renderObject ) {
|
|
515
785
|
|
|
516
786
|
const nodeFrame = this.getNodeFrameForRender( renderObject );
|
|
@@ -520,12 +790,16 @@ class Nodes extends DataMap {
|
|
|
520
790
|
|
|
521
791
|
}
|
|
522
792
|
|
|
793
|
+
/**
|
|
794
|
+
* Frees the internal resources.
|
|
795
|
+
*/
|
|
523
796
|
dispose() {
|
|
524
797
|
|
|
525
798
|
super.dispose();
|
|
526
799
|
|
|
527
800
|
this.nodeFrame = new NodeFrame();
|
|
528
801
|
this.nodeBuilderCache = new Map();
|
|
802
|
+
this.cacheLib = {};
|
|
529
803
|
|
|
530
804
|
}
|
|
531
805
|
|
|
@@ -286,7 +286,7 @@ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in m
|
|
|
286
286
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
287
287
|
|
|
288
288
|
/*
|
|
289
|
-
// alternate method of adjusting for horizon clipping (see
|
|
289
|
+
// alternate method of adjusting for horizon clipping (see reference)
|
|
290
290
|
// refactoring required
|
|
291
291
|
float len = length( vectorFormFactor );
|
|
292
292
|
float z = vectorFormFactor.z / len;
|
|
@@ -351,7 +351,7 @@ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 no
|
|
|
351
351
|
|
|
352
352
|
#endif
|
|
353
353
|
|
|
354
|
-
// This is a curve-fit
|
|
354
|
+
// This is a curve-fit approximation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
|
355
355
|
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
|
|
356
356
|
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
357
357
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|