super-three 0.171.0 → 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
|
@@ -4,7 +4,7 @@ import { NormalBlending } from '../../constants.js';
|
|
|
4
4
|
import { getNodeChildren, getCacheKey } from '../../nodes/core/NodeUtils.js';
|
|
5
5
|
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
6
6
|
import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
7
|
-
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap,
|
|
7
|
+
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAO } from '../../nodes/accessors/MaterialNode.js';
|
|
8
8
|
import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
|
|
9
9
|
import { normalLocal } from '../../nodes/accessors/Normal.js';
|
|
10
10
|
import { instancedMesh } from '../../nodes/accessors/InstancedMeshNode.js';
|
|
@@ -19,11 +19,17 @@ import AONode from '../../nodes/lighting/AONode.js';
|
|
|
19
19
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
20
20
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
21
21
|
import { depth, viewZToLogarithmicDepth, viewZToOrthographicDepth } from '../../nodes/display/ViewportDepthNode.js';
|
|
22
|
-
import { cameraFar, cameraNear } from '../../nodes/accessors/Camera.js';
|
|
22
|
+
import { cameraFar, cameraNear, cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
23
23
|
import { clipping, clippingAlpha, hardwareClipping } from '../../nodes/accessors/ClippingNode.js';
|
|
24
24
|
import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
|
|
25
25
|
import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
|
|
26
|
+
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Base class for all node materials.
|
|
30
|
+
*
|
|
31
|
+
* @augments Material
|
|
32
|
+
*/
|
|
27
33
|
class NodeMaterial extends Material {
|
|
28
34
|
|
|
29
35
|
static get type() {
|
|
@@ -32,6 +38,11 @@ class NodeMaterial extends Material {
|
|
|
32
38
|
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Represents the type of the node material.
|
|
43
|
+
*
|
|
44
|
+
* @type {String}
|
|
45
|
+
*/
|
|
35
46
|
get type() {
|
|
36
47
|
|
|
37
48
|
return this.constructor.type;
|
|
@@ -40,66 +51,364 @@ class NodeMaterial extends Material {
|
|
|
40
51
|
|
|
41
52
|
set type( _value ) { /* */ }
|
|
42
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Constructs a new node material.
|
|
56
|
+
*/
|
|
43
57
|
constructor() {
|
|
44
58
|
|
|
45
59
|
super();
|
|
46
60
|
|
|
61
|
+
/**
|
|
62
|
+
* This flag can be used for type testing.
|
|
63
|
+
*
|
|
64
|
+
* @type {Boolean}
|
|
65
|
+
* @readonly
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
47
68
|
this.isNodeMaterial = true;
|
|
48
69
|
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Whether this material is affected by fog or not.
|
|
72
|
+
*
|
|
73
|
+
* @type {Boolean}
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
51
76
|
this.fog = true;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether this material is affected by lights or not.
|
|
80
|
+
*
|
|
81
|
+
* @type {Boolean}
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
52
84
|
this.lights = false;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Whether this material uses hardware clipping or not.
|
|
88
|
+
* This property is managed by the engine and should not be
|
|
89
|
+
* modified by apps.
|
|
90
|
+
*
|
|
91
|
+
* @type {Boolean}
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
53
94
|
this.hardwareClipping = false;
|
|
54
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Node materials which set their `lights` property to `true`
|
|
98
|
+
* are affected by all lights of the scene. Sometimes selective
|
|
99
|
+
* lighting is wanted which means only _some_ lights in the scene
|
|
100
|
+
* affect a material. This can be achieved by creating an instance
|
|
101
|
+
* of {@link module:LightsNode~LightsNode} with a list of selective
|
|
102
|
+
* lights and assign the node to this property.
|
|
103
|
+
*
|
|
104
|
+
* ```js
|
|
105
|
+
* const customLightsNode = lights( [ light1, light2 ] );
|
|
106
|
+
* material.lightsNode = customLightsNode;
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @type {LightsNode?}
|
|
110
|
+
* @default null
|
|
111
|
+
*/
|
|
55
112
|
this.lightsNode = null;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The environment of node materials can be defined by an environment
|
|
116
|
+
* map assigned to the `envMap` property or by `Scene.environment`
|
|
117
|
+
* if the node material is a PBR material. This node property allows to overwrite
|
|
118
|
+
* the default behavior and define the environment with a custom node.
|
|
119
|
+
*
|
|
120
|
+
* ```js
|
|
121
|
+
* material.envNode = pmremTexture( renderTarget.texture );
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @type {Node<vec3>?}
|
|
125
|
+
* @default null
|
|
126
|
+
*/
|
|
56
127
|
this.envNode = null;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The lighting of node materials might be influenced by ambient occlusion.
|
|
131
|
+
* The default AO is inferred from an ambient occlusion map assigned to `aoMap`
|
|
132
|
+
* and the respective `aoMapIntensity`. This node property allows to overwrite
|
|
133
|
+
* the default and define the ambient occlusion with a custom node instead.
|
|
134
|
+
*
|
|
135
|
+
* If you don't want to overwrite the diffuse color but modify the existing
|
|
136
|
+
* values instead, use {@link module:MaterialNode.materialAO}.
|
|
137
|
+
*
|
|
138
|
+
* @type {Node<float>?}
|
|
139
|
+
* @default null
|
|
140
|
+
*/
|
|
57
141
|
this.aoNode = null;
|
|
58
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The diffuse color of node materials is by default inferred from the
|
|
145
|
+
* `color` and `map` properties. This node property allows to overwrite the default
|
|
146
|
+
* and define the diffuse color with a node instead.
|
|
147
|
+
*
|
|
148
|
+
* ```js
|
|
149
|
+
* material.colorNode = color( 0xff0000 ); // define red color
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* If you don't want to overwrite the diffuse color but modify the existing
|
|
153
|
+
* values instead, use {@link module:MaterialNode.materialColor}.
|
|
154
|
+
*
|
|
155
|
+
* ```js
|
|
156
|
+
* material.colorNode = materialColor.mul( color( 0xff0000 ) ); // give diffuse colors a red tint
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @type {Node<vec3>?}
|
|
160
|
+
* @default null
|
|
161
|
+
*/
|
|
59
162
|
this.colorNode = null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The normals of node materials are by default inferred from the `normalMap`/`normalScale`
|
|
166
|
+
* or `bumpMap`/`bumpScale` properties. This node property allows to overwrite the default
|
|
167
|
+
* and define the normals with a node instead.
|
|
168
|
+
*
|
|
169
|
+
* If you don't want to overwrite the normals but modify the existing values instead,
|
|
170
|
+
* use {@link module:MaterialNode.materialNormal}.
|
|
171
|
+
*
|
|
172
|
+
* @type {Node<vec3>?}
|
|
173
|
+
* @default null
|
|
174
|
+
*/
|
|
60
175
|
this.normalNode = null;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The opacity of node materials is by default inferred from the `opacity`
|
|
179
|
+
* and `alphaMap` properties. This node property allows to overwrite the default
|
|
180
|
+
* and define the opacity with a node instead.
|
|
181
|
+
*
|
|
182
|
+
* If you don't want to overwrite the normals but modify the existing
|
|
183
|
+
* value instead, use {@link module:MaterialNode.materialOpacity}.
|
|
184
|
+
*
|
|
185
|
+
* @type {Node<float>?}
|
|
186
|
+
* @default null
|
|
187
|
+
*/
|
|
61
188
|
this.opacityNode = null;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* This node can be used to to implement a variety of filter-like effects. The idea is
|
|
192
|
+
* to store the current rendering into a texture e.g. via `viewportSharedTexture()`, use it
|
|
193
|
+
* to create an arbitrary effect and then assign the node composition to this property.
|
|
194
|
+
* Everything behind the object using this material will now be affected by a filter.
|
|
195
|
+
*
|
|
196
|
+
* ```js
|
|
197
|
+
* const material = new NodeMaterial()
|
|
198
|
+
* material.transparent = true;
|
|
199
|
+
*
|
|
200
|
+
* // everything behind the object will be monochromatic
|
|
201
|
+
* material.backdropNode = viewportSharedTexture().rgb.saturation( 0 );
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* Backdrop computations are part of the lighting so only lit materials can use this property.
|
|
205
|
+
*
|
|
206
|
+
* @type {Node<vec3>?}
|
|
207
|
+
* @default null
|
|
208
|
+
*/
|
|
62
209
|
this.backdropNode = null;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* This node allows to modulate the influence of `backdropNode` to the outgoing light.
|
|
213
|
+
*
|
|
214
|
+
* @type {Node<float>?}
|
|
215
|
+
* @default null
|
|
216
|
+
*/
|
|
63
217
|
this.backdropAlphaNode = null;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The alpha test of node materials is by default inferred from the `alphaTest`
|
|
221
|
+
* property. This node property allows to overwrite the default and define the
|
|
222
|
+
* alpha test with a node instead.
|
|
223
|
+
*
|
|
224
|
+
* If you don't want to overwrite the alpha test but modify the existing
|
|
225
|
+
* value instead, use {@link module:MaterialNode.materialAlphaTest}.
|
|
226
|
+
*
|
|
227
|
+
* @type {Node<float>?}
|
|
228
|
+
* @default null
|
|
229
|
+
*/
|
|
64
230
|
this.alphaTestNode = null;
|
|
65
231
|
|
|
232
|
+
/**
|
|
233
|
+
* The local vertex positions are computed based on multiple factors like the
|
|
234
|
+
* attribute data, morphing or skinning. This node property allows to overwrite
|
|
235
|
+
* the default and define local vertex positions with nodes instead.
|
|
236
|
+
*
|
|
237
|
+
* If you don't want to overwrite the vertex positions but modify the existing
|
|
238
|
+
* values instead, use {@link module:Position.positionLocal}.
|
|
239
|
+
*
|
|
240
|
+
*```js
|
|
241
|
+
* material.positionNode = positionLocal.add( displace );
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @type {Node<vec3>?}
|
|
245
|
+
* @default null
|
|
246
|
+
*/
|
|
66
247
|
this.positionNode = null;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* This node property is intended for logic which modifies geometry data once or per animation step.
|
|
251
|
+
* Apps usually place such logic randomly in initialization routines or in the animation loop.
|
|
252
|
+
* `geometryNode` is intended as a dedicated API so there is an intended spot where goemetry modiciations
|
|
253
|
+
* can be implemented.
|
|
254
|
+
*
|
|
255
|
+
* The idea is to assign a `Fn` definition that holds the geometry modification logic. A typical example
|
|
256
|
+
* would be a GPU based particle system that provides a node material for usage on app level. The particle
|
|
257
|
+
* simulation would be implemented as compute shaders and managed inside a `Fn` function. This function is
|
|
258
|
+
* eventually assigned to `geometryNode`.
|
|
259
|
+
*
|
|
260
|
+
* @type {Function}
|
|
261
|
+
* @default null
|
|
262
|
+
*/
|
|
67
263
|
this.geometryNode = null;
|
|
68
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Allows to overwrite depth values in the fragment shader.
|
|
267
|
+
*
|
|
268
|
+
* @type {Node<float>?}
|
|
269
|
+
* @default null
|
|
270
|
+
*/
|
|
69
271
|
this.depthNode = null;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Allows to overwrite the position used for shadow map rendering which
|
|
275
|
+
* is by default {@link module:Position.positionWorld}, the vertex position
|
|
276
|
+
* in world space.
|
|
277
|
+
*
|
|
278
|
+
* @type {Node<float>?}
|
|
279
|
+
* @default null
|
|
280
|
+
*/
|
|
70
281
|
this.shadowPositionNode = null;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* This node can be used to influence how an object using this node material
|
|
285
|
+
* receive shadows.
|
|
286
|
+
*
|
|
287
|
+
* ```js
|
|
288
|
+
* const totalShadows = float( 1 ).toVar();
|
|
289
|
+
* material.receivedShadowNode = Fn( ( [ shadow ] ) => {
|
|
290
|
+
* totalShadows.mulAssign( shadow );
|
|
291
|
+
* //return float( 1 ); // bypass received shadows
|
|
292
|
+
* return shadow.mix( color( 0xff0000 ), 1 ); // modify shadow color
|
|
293
|
+
* } );
|
|
294
|
+
*
|
|
295
|
+
* @type {Node<vec4>?}
|
|
296
|
+
* @default null
|
|
297
|
+
*/
|
|
71
298
|
this.receivedShadowNode = null;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* This node can be used to influence how an object using this node material
|
|
302
|
+
* casts shadows. To apply a color to shadows, you can simply do:
|
|
303
|
+
*
|
|
304
|
+
* ```js
|
|
305
|
+
* material.castShadowNode = vec4( 1, 0, 0, 1 );
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* Which can be nice to fake colored shadows of semi-transparent objects. It
|
|
309
|
+
* is also common to use the property with `Fn` function so checks are performed
|
|
310
|
+
* per fragment.
|
|
311
|
+
*
|
|
312
|
+
* ```js
|
|
313
|
+
* materialCustomShadow.castShadowNode = Fn( () => {
|
|
314
|
+
* hash( vertexIndex ).greaterThan( 0.5 ).discard();
|
|
315
|
+
* return materialColor;
|
|
316
|
+
* } )();
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
319
|
+
* @type {Node<vec4>?}
|
|
320
|
+
* @default null
|
|
321
|
+
*/
|
|
72
322
|
this.castShadowNode = null;
|
|
73
323
|
|
|
324
|
+
/**
|
|
325
|
+
* This node can be used to define the final output of the material.
|
|
326
|
+
*
|
|
327
|
+
* TODO: Explain the differences to `fragmentNode`.
|
|
328
|
+
*
|
|
329
|
+
* @type {Node<vec4>?}
|
|
330
|
+
* @default null
|
|
331
|
+
*/
|
|
74
332
|
this.outputNode = null;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* MRT configuration is done on renderer or pass level. This node allows to
|
|
336
|
+
* overwrite what values are written into MRT targets on material level. This
|
|
337
|
+
* can be useful for implementing selective FX features that should only affect
|
|
338
|
+
* specific objects.
|
|
339
|
+
*
|
|
340
|
+
* @type {MRTNode?}
|
|
341
|
+
* @default null
|
|
342
|
+
*/
|
|
75
343
|
this.mrtNode = null;
|
|
76
344
|
|
|
345
|
+
/**
|
|
346
|
+
* This node property can be used if you need complete freedom in implementing
|
|
347
|
+
* the fragment shader. Assigning a node will replace the built-in material
|
|
348
|
+
* logic used in the fragment stage.
|
|
349
|
+
*
|
|
350
|
+
* @type {Node<vec4>?}
|
|
351
|
+
* @default null
|
|
352
|
+
*/
|
|
77
353
|
this.fragmentNode = null;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* This node property can be used if you need complete freedom in implementing
|
|
357
|
+
* the vertex shader. Assigning a node will replace the built-in material logic
|
|
358
|
+
* used in the vertex stage.
|
|
359
|
+
*
|
|
360
|
+
* @type {Node<vec4>?}
|
|
361
|
+
* @default null
|
|
362
|
+
*/
|
|
78
363
|
this.vertexNode = null;
|
|
79
364
|
|
|
80
365
|
}
|
|
81
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Allows to define a custom cache key that influence the material key computation
|
|
369
|
+
* for render objects.
|
|
370
|
+
*
|
|
371
|
+
* @return {String} The custom cache key.
|
|
372
|
+
*/
|
|
82
373
|
customProgramCacheKey() {
|
|
83
374
|
|
|
84
375
|
return this.type + getCacheKey( this );
|
|
85
376
|
|
|
86
377
|
}
|
|
87
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Builds this material with the given node builder.
|
|
381
|
+
*
|
|
382
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
383
|
+
*/
|
|
88
384
|
build( builder ) {
|
|
89
385
|
|
|
90
386
|
this.setup( builder );
|
|
91
387
|
|
|
92
388
|
}
|
|
93
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Setups a node material observer with the given builder.
|
|
392
|
+
*
|
|
393
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
394
|
+
* @return {NodeMaterialObserver} The node material observer.
|
|
395
|
+
*/
|
|
94
396
|
setupObserver( builder ) {
|
|
95
397
|
|
|
96
398
|
return new NodeMaterialObserver( builder );
|
|
97
399
|
|
|
98
400
|
}
|
|
99
401
|
|
|
402
|
+
/**
|
|
403
|
+
* Setups the vertex and fragment stage of this node material.
|
|
404
|
+
*
|
|
405
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
406
|
+
*/
|
|
100
407
|
setup( builder ) {
|
|
101
408
|
|
|
102
409
|
builder.context.setupNormal = () => this.setupNormal( builder );
|
|
410
|
+
builder.context.setupPositionView = () => this.setupPositionView( builder );
|
|
411
|
+
builder.context.setupModelViewProjection = () => this.setupModelViewProjection( builder );
|
|
103
412
|
|
|
104
413
|
const renderer = builder.renderer;
|
|
105
414
|
const renderTarget = renderer.getRenderTarget();
|
|
@@ -108,7 +417,11 @@ class NodeMaterial extends Material {
|
|
|
108
417
|
|
|
109
418
|
builder.addStack();
|
|
110
419
|
|
|
111
|
-
|
|
420
|
+
const vertexNode = this.vertexNode || this.setupVertex( builder );
|
|
421
|
+
|
|
422
|
+
builder.stack.outputNode = vertexNode;
|
|
423
|
+
|
|
424
|
+
this.setupHardwareClipping( builder );
|
|
112
425
|
|
|
113
426
|
if ( this.geometryNode !== null ) {
|
|
114
427
|
|
|
@@ -126,7 +439,7 @@ class NodeMaterial extends Material {
|
|
|
126
439
|
|
|
127
440
|
const clippingNode = this.setupClipping( builder );
|
|
128
441
|
|
|
129
|
-
if ( this.depthWrite === true ) {
|
|
442
|
+
if ( this.depthWrite === true || this.depthTest === true ) {
|
|
130
443
|
|
|
131
444
|
// only write depth if depth buffer is configured
|
|
132
445
|
|
|
@@ -214,6 +527,12 @@ class NodeMaterial extends Material {
|
|
|
214
527
|
|
|
215
528
|
}
|
|
216
529
|
|
|
530
|
+
/**
|
|
531
|
+
* Setups the clipping node.
|
|
532
|
+
*
|
|
533
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
534
|
+
* @return {ClippingNode} The clipping node.
|
|
535
|
+
*/
|
|
217
536
|
setupClipping( builder ) {
|
|
218
537
|
|
|
219
538
|
if ( builder.clippingContext === null ) return null;
|
|
@@ -243,6 +562,11 @@ class NodeMaterial extends Material {
|
|
|
243
562
|
|
|
244
563
|
}
|
|
245
564
|
|
|
565
|
+
/**
|
|
566
|
+
* Setups the hardware clipping if available on the current device.
|
|
567
|
+
*
|
|
568
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
569
|
+
*/
|
|
246
570
|
setupHardwareClipping( builder ) {
|
|
247
571
|
|
|
248
572
|
this.hardwareClipping = false;
|
|
@@ -265,6 +589,11 @@ class NodeMaterial extends Material {
|
|
|
265
589
|
|
|
266
590
|
}
|
|
267
591
|
|
|
592
|
+
/**
|
|
593
|
+
* Setups the depth of this material.
|
|
594
|
+
*
|
|
595
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
596
|
+
*/
|
|
268
597
|
setupDepth( builder ) {
|
|
269
598
|
|
|
270
599
|
const { renderer, camera } = builder;
|
|
@@ -305,14 +634,58 @@ class NodeMaterial extends Material {
|
|
|
305
634
|
|
|
306
635
|
}
|
|
307
636
|
|
|
308
|
-
|
|
637
|
+
/**
|
|
638
|
+
* Setups the position node in view space. This method exists
|
|
639
|
+
* so derived node materials can modifiy the implementation e.g. sprite materials.
|
|
640
|
+
*
|
|
641
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
642
|
+
* @return {Node<vec3>} The position in view space.
|
|
643
|
+
*/
|
|
644
|
+
setupPositionView( /*builder*/ ) {
|
|
645
|
+
|
|
646
|
+
return modelViewMatrix.mul( positionLocal ).xyz;
|
|
647
|
+
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Setups the position in clip space.
|
|
652
|
+
*
|
|
653
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
654
|
+
* @return {Node<vec4>} The position in view space.
|
|
655
|
+
*/
|
|
656
|
+
setupModelViewProjection( /*builder*/ ) {
|
|
657
|
+
|
|
658
|
+
return cameraProjectionMatrix.mul( positionView );
|
|
309
659
|
|
|
310
|
-
|
|
311
|
-
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Setups the logic for the vertex stage.
|
|
664
|
+
*
|
|
665
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
666
|
+
* @return {Node<vec4>} The position in clip space.
|
|
667
|
+
*/
|
|
668
|
+
setupVertex( builder ) {
|
|
312
669
|
|
|
313
670
|
builder.addStack();
|
|
314
671
|
|
|
315
|
-
|
|
672
|
+
this.setupPosition( builder );
|
|
673
|
+
|
|
674
|
+
builder.context.vertex = builder.removeStack();
|
|
675
|
+
|
|
676
|
+
return modelViewProjection;
|
|
677
|
+
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Setups the computation of the position in local space.
|
|
682
|
+
*
|
|
683
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
684
|
+
* @return {Node<vec3>} The position in local space.
|
|
685
|
+
*/
|
|
686
|
+
setupPosition( builder ) {
|
|
687
|
+
|
|
688
|
+
const { object, geometry } = builder;
|
|
316
689
|
|
|
317
690
|
if ( geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color ) {
|
|
318
691
|
|
|
@@ -350,21 +723,20 @@ class NodeMaterial extends Material {
|
|
|
350
723
|
|
|
351
724
|
if ( this.positionNode !== null ) {
|
|
352
725
|
|
|
353
|
-
positionLocal.assign( this.positionNode );
|
|
726
|
+
positionLocal.assign( this.positionNode.context( { isPositionNodeInput: true } ) );
|
|
354
727
|
|
|
355
728
|
}
|
|
356
729
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const mvp = modelViewProjection();
|
|
360
|
-
|
|
361
|
-
builder.context.vertex = builder.removeStack();
|
|
362
|
-
builder.context.mvp = mvp;
|
|
363
|
-
|
|
364
|
-
return mvp;
|
|
730
|
+
return positionLocal;
|
|
365
731
|
|
|
366
732
|
}
|
|
367
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Setups the computation of the material's diffuse color.
|
|
736
|
+
*
|
|
737
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
738
|
+
* @param {BufferGeometry} geometry - The geometry.
|
|
739
|
+
*/
|
|
368
740
|
setupDiffuseColor( { object, geometry } ) {
|
|
369
741
|
|
|
370
742
|
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
|
|
@@ -431,24 +803,47 @@ class NodeMaterial extends Material {
|
|
|
431
803
|
|
|
432
804
|
}
|
|
433
805
|
|
|
806
|
+
/**
|
|
807
|
+
* Abstract interface method that can be implemented by derived materials
|
|
808
|
+
* to setup material-specific node variables.
|
|
809
|
+
*
|
|
810
|
+
* @abstract
|
|
811
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
812
|
+
*/
|
|
434
813
|
setupVariants( /*builder*/ ) {
|
|
435
814
|
|
|
436
815
|
// Interface function.
|
|
437
816
|
|
|
438
817
|
}
|
|
439
818
|
|
|
819
|
+
/**
|
|
820
|
+
* Setups the outgoing light node variable
|
|
821
|
+
*
|
|
822
|
+
* @return {Node<vec3>} The outgoing light node.
|
|
823
|
+
*/
|
|
440
824
|
setupOutgoingLight() {
|
|
441
825
|
|
|
442
826
|
return ( this.lights === true ) ? vec3( 0 ) : diffuseColor.rgb;
|
|
443
827
|
|
|
444
828
|
}
|
|
445
829
|
|
|
830
|
+
/**
|
|
831
|
+
* Setups the normal node from the material.
|
|
832
|
+
*
|
|
833
|
+
* @return {Node<vec3>} The normal node.
|
|
834
|
+
*/
|
|
446
835
|
setupNormal() {
|
|
447
836
|
|
|
448
837
|
return this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
449
838
|
|
|
450
839
|
}
|
|
451
840
|
|
|
841
|
+
/**
|
|
842
|
+
* Setups the environment node from the material.
|
|
843
|
+
*
|
|
844
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
845
|
+
* @return {Node<vec4>} The environment node.
|
|
846
|
+
*/
|
|
452
847
|
setupEnvironment( /*builder*/ ) {
|
|
453
848
|
|
|
454
849
|
let node = null;
|
|
@@ -467,6 +862,12 @@ class NodeMaterial extends Material {
|
|
|
467
862
|
|
|
468
863
|
}
|
|
469
864
|
|
|
865
|
+
/**
|
|
866
|
+
* Setups the light map node from the material.
|
|
867
|
+
*
|
|
868
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
869
|
+
* @return {Node<vec3>} The light map node.
|
|
870
|
+
*/
|
|
470
871
|
setupLightMap( builder ) {
|
|
471
872
|
|
|
472
873
|
let node = null;
|
|
@@ -481,6 +882,12 @@ class NodeMaterial extends Material {
|
|
|
481
882
|
|
|
482
883
|
}
|
|
483
884
|
|
|
885
|
+
/**
|
|
886
|
+
* Setups the lights node based on the scene, environment and material.
|
|
887
|
+
*
|
|
888
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
889
|
+
* @return {LightsNode} The lights node.
|
|
890
|
+
*/
|
|
484
891
|
setupLights( builder ) {
|
|
485
892
|
|
|
486
893
|
const materialLightsNode = [];
|
|
@@ -505,7 +912,7 @@ class NodeMaterial extends Material {
|
|
|
505
912
|
|
|
506
913
|
if ( this.aoNode !== null || builder.material.aoMap ) {
|
|
507
914
|
|
|
508
|
-
const aoNode = this.aoNode !== null ? this.aoNode :
|
|
915
|
+
const aoNode = this.aoNode !== null ? this.aoNode : materialAO;
|
|
509
916
|
|
|
510
917
|
materialLightsNode.push( new AONode( aoNode ) );
|
|
511
918
|
|
|
@@ -523,12 +930,26 @@ class NodeMaterial extends Material {
|
|
|
523
930
|
|
|
524
931
|
}
|
|
525
932
|
|
|
933
|
+
/**
|
|
934
|
+
* This method should be implemented by most derived materials
|
|
935
|
+
* since it defines the material's lighting model.
|
|
936
|
+
*
|
|
937
|
+
* @abstract
|
|
938
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
939
|
+
* @return {LightingModel} The lighting model.
|
|
940
|
+
*/
|
|
526
941
|
setupLightingModel( /*builder*/ ) {
|
|
527
942
|
|
|
528
943
|
// Interface function.
|
|
529
944
|
|
|
530
945
|
}
|
|
531
946
|
|
|
947
|
+
/**
|
|
948
|
+
* Setups the outgoing light node.
|
|
949
|
+
*
|
|
950
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
951
|
+
* @return {Node<vec3>} The outgoing light node.
|
|
952
|
+
*/
|
|
532
953
|
setupLighting( builder ) {
|
|
533
954
|
|
|
534
955
|
const { material } = builder;
|
|
@@ -568,6 +989,13 @@ class NodeMaterial extends Material {
|
|
|
568
989
|
|
|
569
990
|
}
|
|
570
991
|
|
|
992
|
+
/**
|
|
993
|
+
* Setups the output node.
|
|
994
|
+
*
|
|
995
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
996
|
+
* @param {Node<vec4>} outputNode - The existing output node.
|
|
997
|
+
* @return {Node<vec4>} The output node.
|
|
998
|
+
*/
|
|
571
999
|
setupOutput( builder, outputNode ) {
|
|
572
1000
|
|
|
573
1001
|
// FOG
|
|
@@ -576,7 +1004,13 @@ class NodeMaterial extends Material {
|
|
|
576
1004
|
|
|
577
1005
|
const fogNode = builder.fogNode;
|
|
578
1006
|
|
|
579
|
-
if ( fogNode )
|
|
1007
|
+
if ( fogNode ) {
|
|
1008
|
+
|
|
1009
|
+
output.assign( outputNode );
|
|
1010
|
+
|
|
1011
|
+
outputNode = vec4( fogNode );
|
|
1012
|
+
|
|
1013
|
+
}
|
|
580
1014
|
|
|
581
1015
|
}
|
|
582
1016
|
|
|
@@ -584,6 +1018,13 @@ class NodeMaterial extends Material {
|
|
|
584
1018
|
|
|
585
1019
|
}
|
|
586
1020
|
|
|
1021
|
+
/**
|
|
1022
|
+
* Most classic material types have a node pendant e.g. for `MeshBasicMaterial`
|
|
1023
|
+
* there is `MeshBasicNodeMaterial`. This utility method is intended for
|
|
1024
|
+
* defining all material properties of the classic type in the node type.
|
|
1025
|
+
*
|
|
1026
|
+
* @param {Material} material - The material to copy properties with their values to this node material.
|
|
1027
|
+
*/
|
|
587
1028
|
setDefaultValues( material ) {
|
|
588
1029
|
|
|
589
1030
|
// This approach is to reuse the native refreshUniforms*
|
|
@@ -618,6 +1059,12 @@ class NodeMaterial extends Material {
|
|
|
618
1059
|
|
|
619
1060
|
}
|
|
620
1061
|
|
|
1062
|
+
/**
|
|
1063
|
+
* Serializes this material to JSON.
|
|
1064
|
+
*
|
|
1065
|
+
* @param {(Object|String)?} meta - The meta information for serialization.
|
|
1066
|
+
* @return {Object} The serialized node.
|
|
1067
|
+
*/
|
|
621
1068
|
toJSON( meta ) {
|
|
622
1069
|
|
|
623
1070
|
const isRoot = ( meta === undefined || typeof meta === 'string' );
|
|
@@ -677,6 +1124,12 @@ class NodeMaterial extends Material {
|
|
|
677
1124
|
|
|
678
1125
|
}
|
|
679
1126
|
|
|
1127
|
+
/**
|
|
1128
|
+
* Copies the properties of the given node material to this instance.
|
|
1129
|
+
*
|
|
1130
|
+
* @param {NodeMaterial} source - The material to copy.
|
|
1131
|
+
* @return {NodeMaterial} A reference to this node material.
|
|
1132
|
+
*/
|
|
680
1133
|
copy( source ) {
|
|
681
1134
|
|
|
682
1135
|
this.lightsNode = source.lightsNode;
|