super-three 0.170.1 → 0.172.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +157 -49
- package/build/three.core.js +104 -42
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +53 -8
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +10 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +21191 -1008
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +21189 -1008
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +3 -2
- package/examples/jsm/controls/ArcballControls.js +28 -19
- 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 +11 -7
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -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 +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +22 -2
- 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 -1
- 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/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +10 -10
- package/examples/jsm/misc/Volume.js +20 -12
- package/examples/jsm/misc/VolumeSlice.js +2 -2
- 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 +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/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/SobelOperatorShader.js +1 -1
- 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 +2 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +9 -4
- 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/PerspectiveCamera.js +18 -2
- package/src/constants.js +1 -1
- 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/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/InstancedPointsNodeMaterial.js +72 -19
- 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 +474 -21
- package/src/materials/nodes/PointsNodeMaterial.js +22 -13
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +77 -19
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -0
- package/src/nodes/Nodes.js +1 -6
- package/src/nodes/TSL.js +2 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +24 -5
- package/src/nodes/accessors/BatchNode.js +39 -3
- 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 +49 -0
- 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/InstancedPointsMaterialNode.js +13 -0
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +302 -8
- 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 +59 -3
- package/src/nodes/accessors/Object3DNode.js +102 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +53 -4
- package/src/nodes/accessors/ReferenceBaseNode.js +188 -0
- package/src/nodes/accessors/ReferenceNode.js +202 -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 +168 -4
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +36 -0
- package/src/nodes/accessors/Texture3DNode.js +89 -5
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +309 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +223 -23
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +82 -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/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 +24 -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 +337 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +945 -15
- 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 +141 -0
- package/src/nodes/core/NodeVar.js +30 -0
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +33 -2
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +78 -0
- package/src/nodes/core/StructTypeNode.js +39 -1
- package/src/nodes/core/TempNode.js +30 -4
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +52 -0
- package/src/nodes/core/VaryingNode.js +83 -2
- package/src/nodes/core/constants.js +36 -0
- 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 +298 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +87 -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 +93 -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 +157 -1
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +126 -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 +240 -34
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +70 -3
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +614 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +233 -0
- 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 +1 -1
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/tsl/TSLBase.js +2 -2
- package/src/nodes/utils/ArrayElementNode.js +38 -2
- 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 +74 -1
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -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 +40 -0
- package/src/nodes/utils/Timer.js +19 -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 +1 -2
- package/src/objects/ClippingGroup.js +49 -0
- package/src/renderers/WebGLRenderer.js +23 -4
- package/src/renderers/common/Animation.js +63 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +467 -52
- package/src/renderers/common/Background.js +34 -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 +38 -1
- package/src/renderers/common/ClippingContext.js +107 -14
- package/src/renderers/common/Color4.js +36 -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 +98 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +87 -0
- package/src/renderers/common/Lighting.js +26 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +75 -3
- 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 +33 -10
- package/src/renderers/common/RenderContext.js +169 -4
- package/src/renderers/common/RenderContexts.js +42 -2
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +31 -0
- package/src/renderers/common/RenderObject.js +328 -4
- package/src/renderers/common/RenderObjects.js +101 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1096 -31
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +121 -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 +83 -0
- package/src/renderers/common/Uniform.js +188 -2
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +139 -2
- package/src/renderers/common/extras/PMREMGenerator.js +24 -3
- package/src/renderers/common/nodes/NodeBuilderState.js +95 -1
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +91 -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 +189 -0
- 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 +327 -60
- 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-fallback/WebGLBackend.js +547 -29
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +0 -1
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +480 -49
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +34 -0
- package/src/renderers/webgpu/WebGPURenderer.js +35 -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 +59 -11
- 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 +10 -8
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +9 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +30 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +7 -1
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -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/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- 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
|
@@ -1,22 +1,59 @@
|
|
|
1
1
|
import UniformBuffer from './UniformBuffer.js';
|
|
2
2
|
import { GPU_CHUNK_BYTES } from './Constants.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* This class represents a uniform buffer binding but with
|
|
6
|
+
* an API that allows to maintain individual uniform objects.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @augments UniformBuffer
|
|
10
|
+
*/
|
|
4
11
|
class UniformsGroup extends UniformBuffer {
|
|
5
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Constructs a new uniforms group.
|
|
15
|
+
*
|
|
16
|
+
* @param {String} name - The group's name.
|
|
17
|
+
*/
|
|
6
18
|
constructor( name ) {
|
|
7
19
|
|
|
8
20
|
super( name );
|
|
9
21
|
|
|
22
|
+
/**
|
|
23
|
+
* This flag can be used for type testing.
|
|
24
|
+
*
|
|
25
|
+
* @type {Boolean}
|
|
26
|
+
* @readonly
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
10
29
|
this.isUniformsGroup = true;
|
|
11
30
|
|
|
31
|
+
/**
|
|
32
|
+
* An array with the raw uniform values.
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
* @type {Array<Number>?}
|
|
36
|
+
* @default null
|
|
37
|
+
*/
|
|
12
38
|
this._values = null;
|
|
13
39
|
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
/**
|
|
41
|
+
* An array of uniform objects.
|
|
42
|
+
*
|
|
43
|
+
* The order of uniforms in this array must match the order of uniforms in the shader.
|
|
44
|
+
*
|
|
45
|
+
* @type {Array<Uniform>}
|
|
46
|
+
*/
|
|
16
47
|
this.uniforms = [];
|
|
17
48
|
|
|
18
49
|
}
|
|
19
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Adds a uniform to this group.
|
|
53
|
+
*
|
|
54
|
+
* @param {Uniform} uniform - The uniform to add.
|
|
55
|
+
* @return {UniformsGroup} A reference to this group.
|
|
56
|
+
*/
|
|
20
57
|
addUniform( uniform ) {
|
|
21
58
|
|
|
22
59
|
this.uniforms.push( uniform );
|
|
@@ -25,6 +62,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
25
62
|
|
|
26
63
|
}
|
|
27
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Removes a uniform from this group.
|
|
67
|
+
*
|
|
68
|
+
* @param {Uniform} uniform - The uniform to remove.
|
|
69
|
+
* @return {UniformsGroup} A reference to this group.
|
|
70
|
+
*/
|
|
28
71
|
removeUniform( uniform ) {
|
|
29
72
|
|
|
30
73
|
const index = this.uniforms.indexOf( uniform );
|
|
@@ -39,6 +82,11 @@ class UniformsGroup extends UniformBuffer {
|
|
|
39
82
|
|
|
40
83
|
}
|
|
41
84
|
|
|
85
|
+
/**
|
|
86
|
+
* An array with the raw uniform values.
|
|
87
|
+
*
|
|
88
|
+
* @type {Array<Number>}
|
|
89
|
+
*/
|
|
42
90
|
get values() {
|
|
43
91
|
|
|
44
92
|
if ( this._values === null ) {
|
|
@@ -51,6 +99,11 @@ class UniformsGroup extends UniformBuffer {
|
|
|
51
99
|
|
|
52
100
|
}
|
|
53
101
|
|
|
102
|
+
/**
|
|
103
|
+
* A Float32 array buffer with the uniform values.
|
|
104
|
+
*
|
|
105
|
+
* @type {Float32Array}
|
|
106
|
+
*/
|
|
54
107
|
get buffer() {
|
|
55
108
|
|
|
56
109
|
let buffer = this._buffer;
|
|
@@ -69,6 +122,11 @@ class UniformsGroup extends UniformBuffer {
|
|
|
69
122
|
|
|
70
123
|
}
|
|
71
124
|
|
|
125
|
+
/**
|
|
126
|
+
* The byte length of the buffer with correct buffer alignment.
|
|
127
|
+
*
|
|
128
|
+
* @type {Number}
|
|
129
|
+
*/
|
|
72
130
|
get byteLength() {
|
|
73
131
|
|
|
74
132
|
let offset = 0; // global buffer offset in bytes
|
|
@@ -110,6 +168,15 @@ class UniformsGroup extends UniformBuffer {
|
|
|
110
168
|
|
|
111
169
|
}
|
|
112
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Updates this group by updating each uniform object of
|
|
173
|
+
* the internal uniform list. The uniform objects check if their
|
|
174
|
+
* values has actually changed so this method only returns
|
|
175
|
+
* `true` if there is a real value change.
|
|
176
|
+
*
|
|
177
|
+
* @return {Boolean} Whether the uniforms have been updated and
|
|
178
|
+
* must be uploaded to the GPU.
|
|
179
|
+
*/
|
|
113
180
|
update() {
|
|
114
181
|
|
|
115
182
|
let updated = false;
|
|
@@ -128,6 +195,13 @@ class UniformsGroup extends UniformBuffer {
|
|
|
128
195
|
|
|
129
196
|
}
|
|
130
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Updates a given uniform by calling an update method matching
|
|
200
|
+
* the uniforms type.
|
|
201
|
+
*
|
|
202
|
+
* @param {Uniform} uniform - The uniform to update.
|
|
203
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
204
|
+
*/
|
|
131
205
|
updateByType( uniform ) {
|
|
132
206
|
|
|
133
207
|
if ( uniform.isNumberUniform ) return this.updateNumber( uniform );
|
|
@@ -142,6 +216,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
142
216
|
|
|
143
217
|
}
|
|
144
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Updates a given Number uniform.
|
|
221
|
+
*
|
|
222
|
+
* @param {NumberUniform} uniform - The Number uniform.
|
|
223
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
224
|
+
*/
|
|
145
225
|
updateNumber( uniform ) {
|
|
146
226
|
|
|
147
227
|
let updated = false;
|
|
@@ -164,6 +244,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
164
244
|
|
|
165
245
|
}
|
|
166
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Updates a given Vector2 uniform.
|
|
249
|
+
*
|
|
250
|
+
* @param {Vector2Uniform} uniform - The Vector2 uniform.
|
|
251
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
252
|
+
*/
|
|
167
253
|
updateVector2( uniform ) {
|
|
168
254
|
|
|
169
255
|
let updated = false;
|
|
@@ -188,6 +274,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
188
274
|
|
|
189
275
|
}
|
|
190
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Updates a given Vector3 uniform.
|
|
279
|
+
*
|
|
280
|
+
* @param {Vector3Uniform} uniform - The Vector3 uniform.
|
|
281
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
282
|
+
*/
|
|
191
283
|
updateVector3( uniform ) {
|
|
192
284
|
|
|
193
285
|
let updated = false;
|
|
@@ -213,6 +305,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
213
305
|
|
|
214
306
|
}
|
|
215
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Updates a given Vector4 uniform.
|
|
310
|
+
*
|
|
311
|
+
* @param {Vector4Uniform} uniform - The Vector4 uniform.
|
|
312
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
313
|
+
*/
|
|
216
314
|
updateVector4( uniform ) {
|
|
217
315
|
|
|
218
316
|
let updated = false;
|
|
@@ -239,6 +337,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
239
337
|
|
|
240
338
|
}
|
|
241
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Updates a given Color uniform.
|
|
342
|
+
*
|
|
343
|
+
* @param {ColorUniform} uniform - The Color uniform.
|
|
344
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
345
|
+
*/
|
|
242
346
|
updateColor( uniform ) {
|
|
243
347
|
|
|
244
348
|
let updated = false;
|
|
@@ -263,6 +367,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
263
367
|
|
|
264
368
|
}
|
|
265
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Updates a given Matrix3 uniform.
|
|
372
|
+
*
|
|
373
|
+
* @param {Matrix3Uniform} uniform - The Matrix3 uniform.
|
|
374
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
375
|
+
*/
|
|
266
376
|
updateMatrix3( uniform ) {
|
|
267
377
|
|
|
268
378
|
let updated = false;
|
|
@@ -295,6 +405,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
295
405
|
|
|
296
406
|
}
|
|
297
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Updates a given Matrix4 uniform.
|
|
410
|
+
*
|
|
411
|
+
* @param {Matrix4Uniform} uniform - The Matrix4 uniform.
|
|
412
|
+
* @return {Boolean} Whether the uniform has been updated or not.
|
|
413
|
+
*/
|
|
298
414
|
updateMatrix4( uniform ) {
|
|
299
415
|
|
|
300
416
|
let updated = false;
|
|
@@ -316,6 +432,12 @@ class UniformsGroup extends UniformBuffer {
|
|
|
316
432
|
|
|
317
433
|
}
|
|
318
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Returns a typed array that matches the given data type.
|
|
437
|
+
*
|
|
438
|
+
* @param {String} type - The data type.
|
|
439
|
+
* @return {TypedArray} The typed array.
|
|
440
|
+
*/
|
|
319
441
|
_getBufferForType( type ) {
|
|
320
442
|
|
|
321
443
|
if ( type === 'int' || type === 'ivec2' || type === 'ivec3' || type === 'ivec4' ) return new Int32Array( this.buffer.buffer );
|
|
@@ -326,6 +448,13 @@ class UniformsGroup extends UniformBuffer {
|
|
|
326
448
|
|
|
327
449
|
}
|
|
328
450
|
|
|
451
|
+
/**
|
|
452
|
+
* Sets the values of the second array to the first array.
|
|
453
|
+
*
|
|
454
|
+
* @param {TypedArray} a - The first array.
|
|
455
|
+
* @param {TypedArray} b - The second array.
|
|
456
|
+
* @param {Number} offset - An index offset for the first array.
|
|
457
|
+
*/
|
|
329
458
|
function setArray( a, b, offset ) {
|
|
330
459
|
|
|
331
460
|
for ( let i = 0, l = b.length; i < l; i ++ ) {
|
|
@@ -336,6 +465,14 @@ function setArray( a, b, offset ) {
|
|
|
336
465
|
|
|
337
466
|
}
|
|
338
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Returns `true` if the given arrays are equal.
|
|
470
|
+
*
|
|
471
|
+
* @param {TypedArray} a - The first array.
|
|
472
|
+
* @param {TypedArray} b - The second array.
|
|
473
|
+
* @param {Number} offset - An index offset for the first array.
|
|
474
|
+
* @return {Boolean} Whether the given arrays are equal or not.
|
|
475
|
+
*/
|
|
339
476
|
function arraysEqual( a, b, offset ) {
|
|
340
477
|
|
|
341
478
|
for ( let i = 0, l = b.length; i < l; i ++ ) {
|
|
@@ -78,7 +78,7 @@ const _faceLib = [
|
|
|
78
78
|
];
|
|
79
79
|
|
|
80
80
|
const direction = getDirection( uv(), attribute( 'faceIndex' ) ).normalize();
|
|
81
|
-
const outputDirection = vec3( direction.x, direction.y
|
|
81
|
+
const outputDirection = vec3( direction.x, direction.y, direction.z );
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* This class generates a Prefiltered, Mipmapped Radiance Environment Map
|
|
@@ -128,6 +128,13 @@ class PMREMGenerator {
|
|
|
128
128
|
* in radians to be applied to the scene before PMREM generation. Optional near
|
|
129
129
|
* and far planes ensure the scene is rendered in its entirety (the cubeCamera
|
|
130
130
|
* is placed at the origin).
|
|
131
|
+
*
|
|
132
|
+
* @param {Scene} scene - The scene to be captured.
|
|
133
|
+
* @param {Number} [sigma=0] - The blur radius in radians.
|
|
134
|
+
* @param {Number} [near=0.1] - The near plane distance.
|
|
135
|
+
* @param {Number} [far=100] - The far plane distance.
|
|
136
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
137
|
+
* @return {RenderTarget} The resulting PMREM.
|
|
131
138
|
*/
|
|
132
139
|
fromScene( scene, sigma = 0, near = 0.1, far = 100, renderTarget = null ) {
|
|
133
140
|
|
|
@@ -180,6 +187,10 @@ class PMREMGenerator {
|
|
|
180
187
|
* Generates a PMREM from an equirectangular texture, which can be either LDR
|
|
181
188
|
* or HDR. The ideal input image size is 1k (1024 x 512),
|
|
182
189
|
* as this matches best with the 256 x 256 cubemap output.
|
|
190
|
+
*
|
|
191
|
+
* @param {Texture} equirectangular - The equirectangular texture to be converted.
|
|
192
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
193
|
+
* @return {RenderTarget} The resulting PMREM.
|
|
183
194
|
*/
|
|
184
195
|
fromEquirectangular( equirectangular, renderTarget = null ) {
|
|
185
196
|
|
|
@@ -213,6 +224,10 @@ class PMREMGenerator {
|
|
|
213
224
|
* Generates a PMREM from an cubemap texture, which can be either LDR
|
|
214
225
|
* or HDR. The ideal input cube size is 256 x 256,
|
|
215
226
|
* as this matches best with the 256 x 256 cubemap output.
|
|
227
|
+
*
|
|
228
|
+
* @param {Texture} cubemap - The cubemap texture to be converted.
|
|
229
|
+
* @param {RenderTarget?} [renderTarget=null] - The render target to use.
|
|
230
|
+
* @return {RenderTarget} The resulting PMREM.
|
|
216
231
|
*/
|
|
217
232
|
fromCubemap( cubemap, renderTarget = null ) {
|
|
218
233
|
|
|
@@ -406,8 +421,8 @@ class PMREMGenerator {
|
|
|
406
421
|
cubeCamera.far = far;
|
|
407
422
|
|
|
408
423
|
// px, py, pz, nx, ny, nz
|
|
409
|
-
const upSign = [
|
|
410
|
-
const forwardSign = [ 1, 1, 1, - 1,
|
|
424
|
+
const upSign = [ 1, 1, 1, 1, - 1, 1 ];
|
|
425
|
+
const forwardSign = [ 1, - 1, 1, - 1, 1, - 1 ];
|
|
411
426
|
|
|
412
427
|
const renderer = this._renderer;
|
|
413
428
|
|
|
@@ -562,6 +577,12 @@ class PMREMGenerator {
|
|
|
562
577
|
* the blur latitudinally (around the poles), and then longitudinally (towards
|
|
563
578
|
* the poles) to approximate the orthogonally-separable blur. It is least
|
|
564
579
|
* accurate at the poles, but still does a decent job.
|
|
580
|
+
*
|
|
581
|
+
* @param {RenderTarget} cubeUVRenderTarget - The cubemap render target.
|
|
582
|
+
* @param {Number} lodIn - The input level-of-detail.
|
|
583
|
+
* @param {Number} lodOut - The output level-of-detail.
|
|
584
|
+
* @param {Number} sigma - The blur radius in radians.
|
|
585
|
+
* @param {Vector3} [poleAxis] - The pole axis.
|
|
565
586
|
*/
|
|
566
587
|
_blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) {
|
|
567
588
|
|
|
@@ -1,34 +1,128 @@
|
|
|
1
1
|
import BindGroup from '../BindGroup.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* This module represents the state of a node builder after it was
|
|
5
|
+
* used to build the nodes for a render object. The state holds the
|
|
6
|
+
* results of the build for further processing in the renderer.
|
|
7
|
+
*
|
|
8
|
+
* Render objects with identical cache keys share the same node builder state.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
3
12
|
class NodeBuilderState {
|
|
4
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new node builder state.
|
|
16
|
+
*
|
|
17
|
+
* @param {String?} vertexShader - The native vertex shader code.
|
|
18
|
+
* @param {String?} fragmentShader - The native fragment shader code.
|
|
19
|
+
* @param {String?} computeShader - The native compute shader code.
|
|
20
|
+
* @param {Array<NodeAttribute>} nodeAttributes - An array of node attributes.
|
|
21
|
+
* @param {Array<BindGroup>} bindings - An array of bind groups.
|
|
22
|
+
* @param {Array<Node>} updateNodes - An array of nodes that implement their `update()` method.
|
|
23
|
+
* @param {Array<Node>} updateBeforeNodes - An array of nodes that implement their `updateBefore()` method.
|
|
24
|
+
* @param {Array<Node>} updateAfterNodes - An array of nodes that implement their `updateAfter()` method.
|
|
25
|
+
* @param {NodeMaterialObserver} monitor - A node material observer.
|
|
26
|
+
* @param {Array<Object>} transforms - An array with transform attribute objects. Only relevant when using compute shaders with WebGL 2.
|
|
27
|
+
*/
|
|
5
28
|
constructor( vertexShader, fragmentShader, computeShader, nodeAttributes, bindings, updateNodes, updateBeforeNodes, updateAfterNodes, monitor, transforms = [] ) {
|
|
6
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The native vertex shader code.
|
|
32
|
+
*
|
|
33
|
+
* @type {String}
|
|
34
|
+
*/
|
|
7
35
|
this.vertexShader = vertexShader;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The native fragment shader code.
|
|
39
|
+
*
|
|
40
|
+
* @type {String}
|
|
41
|
+
*/
|
|
8
42
|
this.fragmentShader = fragmentShader;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The native compute shader code.
|
|
46
|
+
*
|
|
47
|
+
* @type {String}
|
|
48
|
+
*/
|
|
9
49
|
this.computeShader = computeShader;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An array with transform attribute objects.
|
|
53
|
+
* Only relevant when using compute shaders with WebGL 2.
|
|
54
|
+
*
|
|
55
|
+
* @type {Array<Object>}
|
|
56
|
+
*/
|
|
10
57
|
this.transforms = transforms;
|
|
11
58
|
|
|
59
|
+
/**
|
|
60
|
+
* An array of node attributes representing
|
|
61
|
+
* the attributes of the shaders.
|
|
62
|
+
*
|
|
63
|
+
* @type {Array<NodeAttribute>}
|
|
64
|
+
*/
|
|
12
65
|
this.nodeAttributes = nodeAttributes;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* An array of bind groups representing the uniform or storage
|
|
69
|
+
* buffers, texture or samplers of the shader.
|
|
70
|
+
*
|
|
71
|
+
* @type {Array<BindGroup>}
|
|
72
|
+
*/
|
|
13
73
|
this.bindings = bindings;
|
|
14
74
|
|
|
75
|
+
/**
|
|
76
|
+
* An array of nodes that implement their `update()` method.
|
|
77
|
+
*
|
|
78
|
+
* @type {Array<Node>}
|
|
79
|
+
*/
|
|
15
80
|
this.updateNodes = updateNodes;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* An array of nodes that implement their `updateBefore()` method.
|
|
84
|
+
*
|
|
85
|
+
* @type {Array<Node>}
|
|
86
|
+
*/
|
|
16
87
|
this.updateBeforeNodes = updateBeforeNodes;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An array of nodes that implement their `updateAfter()` method.
|
|
91
|
+
*
|
|
92
|
+
* @type {Array<Node>}
|
|
93
|
+
*/
|
|
17
94
|
this.updateAfterNodes = updateAfterNodes;
|
|
18
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A node material observer.
|
|
98
|
+
*
|
|
99
|
+
* @type {NodeMaterialObserver}
|
|
100
|
+
*/
|
|
19
101
|
this.monitor = monitor;
|
|
20
102
|
|
|
103
|
+
/**
|
|
104
|
+
* How often this state is used by render objects.
|
|
105
|
+
*
|
|
106
|
+
* @type {Number}
|
|
107
|
+
*/
|
|
21
108
|
this.usedTimes = 0;
|
|
22
109
|
|
|
23
110
|
}
|
|
24
111
|
|
|
112
|
+
/**
|
|
113
|
+
* This method is used to create a array of bind groups based
|
|
114
|
+
* on the existing bind groups of this state. Shared groups are
|
|
115
|
+
* not cloned.
|
|
116
|
+
*
|
|
117
|
+
* @return {Array<BindGroup>} A array of bind groups.
|
|
118
|
+
*/
|
|
25
119
|
createBindings() {
|
|
26
120
|
|
|
27
121
|
const bindings = [];
|
|
28
122
|
|
|
29
123
|
for ( const instanceGroup of this.bindings ) {
|
|
30
124
|
|
|
31
|
-
const shared = instanceGroup.bindings[ 0 ].groupNode.shared;
|
|
125
|
+
const shared = instanceGroup.bindings[ 0 ].groupNode.shared; // TODO: Is it safe to always check the first binding in the group?
|
|
32
126
|
|
|
33
127
|
if ( shared !== true ) {
|
|
34
128
|
|
|
@@ -1,13 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The purpose of a node library is to assign node implementations
|
|
3
|
+
* to existing library features. In `WebGPURenderer` lights, materials
|
|
4
|
+
* which are not based on `NodeMaterial` as well as tone mapping techniques
|
|
5
|
+
* are implemented with node-based modules.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
1
9
|
class NodeLibrary {
|
|
2
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new node library.
|
|
13
|
+
*/
|
|
3
14
|
constructor() {
|
|
4
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A weak map that maps lights to light nodes.
|
|
18
|
+
*
|
|
19
|
+
* @type {WeakMap<Light.constructor,AnalyticLightNode.constructor>}
|
|
20
|
+
*/
|
|
5
21
|
this.lightNodes = new WeakMap();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A map that maps materials to node materials.
|
|
25
|
+
*
|
|
26
|
+
* @type {WeakMap<String,NodeMaterial.constructor>}
|
|
27
|
+
*/
|
|
6
28
|
this.materialNodes = new Map();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A map that maps tone mapping techniques (constants)
|
|
32
|
+
* to tone mapping node functions.
|
|
33
|
+
*
|
|
34
|
+
* @type {WeakMap<Number,Function>}
|
|
35
|
+
*/
|
|
7
36
|
this.toneMappingNodes = new Map();
|
|
8
37
|
|
|
9
38
|
}
|
|
10
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Returns a matching node material instance for the given material object.
|
|
42
|
+
*
|
|
43
|
+
* This method also assigns/copies the properties of the given material object
|
|
44
|
+
* to the node material. This is done to make sure the current material
|
|
45
|
+
* configuration carries over to the node version.
|
|
46
|
+
*
|
|
47
|
+
* @param {Material} material - A material.
|
|
48
|
+
* @return {NodeMaterial} The corresponding node material.
|
|
49
|
+
*/
|
|
11
50
|
fromMaterial( material ) {
|
|
12
51
|
|
|
13
52
|
if ( material.isNodeMaterial ) return material;
|
|
@@ -32,42 +71,85 @@ class NodeLibrary {
|
|
|
32
71
|
|
|
33
72
|
}
|
|
34
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Adds a tone mapping node function for a tone mapping technique (constant).
|
|
76
|
+
*
|
|
77
|
+
* @param {Function} toneMappingNode - The tone mapping node function.
|
|
78
|
+
* @param {Number} toneMapping - The tone mapping.
|
|
79
|
+
*/
|
|
35
80
|
addToneMapping( toneMappingNode, toneMapping ) {
|
|
36
81
|
|
|
37
82
|
this.addType( toneMappingNode, toneMapping, this.toneMappingNodes );
|
|
38
83
|
|
|
39
84
|
}
|
|
40
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Returns a tone mapping node function for a tone mapping technique (constant).
|
|
88
|
+
*
|
|
89
|
+
* @param {Number} toneMapping - The tone mapping.
|
|
90
|
+
* @return {Function?} The tone mapping node function. Returns `null` if no node function is found.
|
|
91
|
+
*/
|
|
41
92
|
getToneMappingFunction( toneMapping ) {
|
|
42
93
|
|
|
43
94
|
return this.toneMappingNodes.get( toneMapping ) || null;
|
|
44
95
|
|
|
45
96
|
}
|
|
46
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Returns a node material class definition for a material type.
|
|
100
|
+
*
|
|
101
|
+
* @param {Sring} materialType - The material type.
|
|
102
|
+
* @return {NodeMaterial.constructor?} The node material class definition. Returns `null` if no node material is found.
|
|
103
|
+
*/
|
|
47
104
|
getMaterialNodeClass( materialType ) {
|
|
48
105
|
|
|
49
106
|
return this.materialNodes.get( materialType ) || null;
|
|
50
107
|
|
|
51
108
|
}
|
|
52
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Adds a node material class definition for a given material type.
|
|
112
|
+
*
|
|
113
|
+
* @param {NodeMaterial.constructor} materialNodeClass - The node material class definition.
|
|
114
|
+
* @param {Sring} materialClassType - The material type.
|
|
115
|
+
*/
|
|
53
116
|
addMaterial( materialNodeClass, materialClassType ) {
|
|
54
117
|
|
|
55
118
|
this.addType( materialNodeClass, materialClassType, this.materialNodes );
|
|
56
119
|
|
|
57
120
|
}
|
|
58
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Returns a light node class definition for a light class definition.
|
|
124
|
+
*
|
|
125
|
+
* @param {Light.constructor} light - The light class definition.
|
|
126
|
+
* @return {AnalyticLightNode.constructor?} The light node class definition. Returns `null` if no light node is found.
|
|
127
|
+
*/
|
|
59
128
|
getLightNodeClass( light ) {
|
|
60
129
|
|
|
61
130
|
return this.lightNodes.get( light ) || null;
|
|
62
131
|
|
|
63
132
|
}
|
|
64
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Adds a light node class definition for a given light class definition.
|
|
136
|
+
*
|
|
137
|
+
* @param {AnalyticLightNode.constructor} lightNodeClass - The light node class definition.
|
|
138
|
+
* @param {Light.constructor} lightClass - The light class definition.
|
|
139
|
+
*/
|
|
65
140
|
addLight( lightNodeClass, lightClass ) {
|
|
66
141
|
|
|
67
142
|
this.addClass( lightNodeClass, lightClass, this.lightNodes );
|
|
68
143
|
|
|
69
144
|
}
|
|
70
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Adds a node class definition for the given type to the provided type library.
|
|
148
|
+
*
|
|
149
|
+
* @param {Any} nodeClass - The node class definition.
|
|
150
|
+
* @param {String} type - The object type.
|
|
151
|
+
* @param {Map} library - The type library.
|
|
152
|
+
*/
|
|
71
153
|
addType( nodeClass, type, library ) {
|
|
72
154
|
|
|
73
155
|
if ( library.has( type ) ) {
|
|
@@ -84,6 +166,13 @@ class NodeLibrary {
|
|
|
84
166
|
|
|
85
167
|
}
|
|
86
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Adds a node class definition for the given class definition to the provided type library.
|
|
171
|
+
*
|
|
172
|
+
* @param {Any} nodeClass - The node class definition.
|
|
173
|
+
* @param {Any} baseClass - The class definition.
|
|
174
|
+
* @param {WeakMap} library - The type library.
|
|
175
|
+
*/
|
|
87
176
|
addClass( nodeClass, baseClass, library ) {
|
|
88
177
|
|
|
89
178
|
if ( library.has( baseClass ) ) {
|