super-three 0.165.0 → 0.168.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/build/three.cjs +854 -410
- package/build/three.module.js +849 -411
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +77755 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +5 -2
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +13 -4
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/helpers/ViewHelper.js +51 -2
- package/examples/jsm/libs/tween.module.js +64 -75
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/FBXLoader.js +23 -45
- package/examples/jsm/loaders/GLTFLoader.js +10 -4
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +10 -10
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VTKLoader.js +76 -3
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +8 -6
- package/src/Three.WebGPU.js +200 -0
- package/src/Three.js +3 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +22 -22
- package/src/extras/Controls.js +32 -0
- package/src/extras/TextureUtils.js +210 -0
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/ObjectLoader.js +33 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +6 -4
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +2 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +2 -1
- package/src/materials/Material.js +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/InstancedPointsNodeMaterial.js +36 -27
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +37 -40
- package/src/materials/nodes/LineBasicNodeMaterial.js +27 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +10 -11
- package/src/materials/nodes/MeshBasicNodeMaterial.js +73 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +43 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +53 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +74 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshPhysicalNodeMaterial.js +22 -20
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshStandardNodeMaterial.js +28 -11
- package/src/materials/nodes/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +142 -96
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +1 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +5 -6
- package/src/materials/nodes/ShadowNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/SpriteNodeMaterial.js +13 -13
- package/{examples/jsm/nodes/materials → src/materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +176 -0
- package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +124 -0
- package/{examples/jsm/nodes/accessors/BitangentNode.js → src/nodes/accessors/Bitangent.js} +9 -9
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +41 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/Camera.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +76 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +66 -49
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +37 -0
- package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +35 -31
- package/src/nodes/accessors/Normal.js +62 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +11 -11
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +14 -8
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +6 -6
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +187 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +54 -6
- package/{examples/jsm → src}/nodes/accessors/StorageTextureNode.js +16 -7
- package/src/nodes/accessors/Tangent.js +22 -0
- package/{examples/jsm → src}/nodes/accessors/Texture3DNode.js +11 -11
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +69 -37
- package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +4 -6
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +24 -9
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +6 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +4 -4
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +5 -23
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +18 -6
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +6 -7
- package/{examples/jsm → src}/nodes/core/AssignNode.js +5 -5
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +22 -21
- package/{examples/jsm → src}/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +46 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/ContextNode.js +17 -11
- package/{examples/jsm → src}/nodes/core/IndexNode.js +17 -6
- package/{examples/jsm → src}/nodes/core/InputNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +82 -0
- package/{examples/jsm → src}/nodes/core/Node.js +57 -31
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +216 -65
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +7 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +4 -4
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +84 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +26 -10
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/TempNode.js +4 -4
- package/src/nodes/core/UniformGroupNode.js +55 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +14 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +8 -12
- package/{examples/jsm → src}/nodes/core/VaryingNode.js +13 -5
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +27 -35
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +27 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +335 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +85 -0
- package/src/nodes/display/DenoiseNode.js +201 -0
- package/src/nodes/display/DepthOfFieldNode.js +121 -0
- package/src/nodes/display/DotScreenNode.js +63 -0
- package/src/nodes/display/FXAANode.js +329 -0
- package/src/nodes/display/FilmNode.js +53 -0
- package/src/nodes/display/FrontFacingNode.js +41 -0
- package/src/nodes/display/GTAONode.js +328 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +44 -24
- package/src/nodes/display/Lut3DNode.js +54 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +9 -11
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +367 -0
- package/src/nodes/display/PixelationPassNode.js +206 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +50 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +123 -0
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +66 -0
- package/src/nodes/display/TransitionNode.js +77 -0
- package/src/nodes/display/ViewportDepthNode.js +121 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +30 -0
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +28 -26
- package/src/nodes/display/ViewportSharedTextureNode.js +36 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +12 -12
- package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +4 -6
- package/{examples/jsm → src}/nodes/fog/FogNode.js +5 -7
- package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +4 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +10 -8
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +73 -31
- package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +1 -1
- package/{examples/jsm → src}/nodes/functions/ToonLightingModel.js +6 -4
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +23 -10
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +24 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +354 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +27 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +3 -9
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +23 -21
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +4 -7
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +3 -8
- package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +2 -2
- package/{examples/jsm → src}/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +64 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +4 -2
- package/src/nodes/lighting/LightsNode.js +231 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +4 -10
- package/src/nodes/lighting/RectAreaLightNode.js +93 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +4 -10
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +43 -46
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +31 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +404 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +100 -58
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +60 -16
- package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +106 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +7 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +19 -12
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +6 -6
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +12 -6
- package/{examples/jsm → src}/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +17 -4
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +7 -7
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +4 -12
- package/{examples/jsm → src}/nodes/utils/SetNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +4 -6
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +5 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +169 -190
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +60 -23
- package/{examples/jsm → src}/renderers/common/Attributes.js +2 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +12 -4
- package/src/renderers/common/BindGroup.js +18 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +45 -32
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +18 -7
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +34 -6
- package/src/renderers/common/PostProcessing.js +90 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +8 -3
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderObject.js +45 -12
- package/{examples/jsm → src}/renderers/common/Renderer.js +151 -73
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +14 -14
- package/{examples/jsm → src}/renderers/common/Uniform.js +9 -4
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +25 -25
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +8 -7
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +69 -21
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +16 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +6 -0
- package/src/renderers/webgl/WebGLProgram.js +27 -1
- package/src/renderers/webgl/WebGLPrograms.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -57
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +242 -120
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +227 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +22 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +62 -23
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +242 -136
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +9 -9
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +281 -107
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +64 -33
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +4 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -36
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +76 -44
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +42 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -0
- package/src/renderers/webxr/WebXRManager.js +37 -24
- package/src/textures/CompressedArrayTexture.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/nodes/Nodes.js +0 -202
- package/examples/jsm/nodes/accessors/BatchNode.js +0 -78
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -12
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -36
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -14
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -10
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -6
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -23
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/PropertyNode.js +0 -83
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -40
- package/examples/jsm/nodes/display/PassNode.js +0 -201
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -188
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -37
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -256
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -215
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +0 -52
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -38
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +0 -34
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/renderers/common/PostProcessing.js +0 -33
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- /package/{examples/jsm/nodes/accessors/UVNode.js → src/nodes/accessors/UV.js} +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Animation.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ChainMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipelines.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundle.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundles.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderObjects.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBufferRenderer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
2
|
+
import LightingNode from './LightingNode.js';
|
|
3
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
4
|
+
import { uniform } from '../core/UniformNode.js';
|
|
5
|
+
import { float, vec2, vec3, vec4 } from '../tsl/TSLBase.js';
|
|
6
|
+
import { reference } from '../accessors/ReferenceNode.js';
|
|
7
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
8
|
+
import { positionWorld } from '../accessors/Position.js';
|
|
9
|
+
import { normalWorld } from '../accessors/Normal.js';
|
|
10
|
+
import { mix, fract } from '../math/MathNode.js';
|
|
11
|
+
import { add } from '../math/OperatorNode.js';
|
|
12
|
+
import { Color } from '../../math/Color.js';
|
|
13
|
+
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
14
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
15
|
+
import { LessCompare, WebGPUCoordinateSystem } from '../../constants.js';
|
|
16
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
17
|
+
|
|
18
|
+
const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
19
|
+
|
|
20
|
+
return texture( depthTexture, shadowCoord.xy ).compare( shadowCoord.z );
|
|
21
|
+
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
const PCFShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
25
|
+
|
|
26
|
+
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
27
|
+
|
|
28
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
29
|
+
const radius = reference( 'radius', 'float', shadow );
|
|
30
|
+
|
|
31
|
+
const texelSize = vec2( 1 ).div( mapSize );
|
|
32
|
+
const dx0 = texelSize.x.negate().mul( radius );
|
|
33
|
+
const dy0 = texelSize.y.negate().mul( radius );
|
|
34
|
+
const dx1 = texelSize.x.mul( radius );
|
|
35
|
+
const dy1 = texelSize.y.mul( radius );
|
|
36
|
+
const dx2 = dx0.div( 2 );
|
|
37
|
+
const dy2 = dy0.div( 2 );
|
|
38
|
+
const dx3 = dx1.div( 2 );
|
|
39
|
+
const dy3 = dy1.div( 2 );
|
|
40
|
+
|
|
41
|
+
return add(
|
|
42
|
+
depthCompare( shadowCoord.xy.add( vec2( dx0, dy0 ) ), shadowCoord.z ),
|
|
43
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy0 ) ), shadowCoord.z ),
|
|
44
|
+
depthCompare( shadowCoord.xy.add( vec2( dx1, dy0 ) ), shadowCoord.z ),
|
|
45
|
+
depthCompare( shadowCoord.xy.add( vec2( dx2, dy2 ) ), shadowCoord.z ),
|
|
46
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy2 ) ), shadowCoord.z ),
|
|
47
|
+
depthCompare( shadowCoord.xy.add( vec2( dx3, dy2 ) ), shadowCoord.z ),
|
|
48
|
+
depthCompare( shadowCoord.xy.add( vec2( dx0, 0 ) ), shadowCoord.z ),
|
|
49
|
+
depthCompare( shadowCoord.xy.add( vec2( dx2, 0 ) ), shadowCoord.z ),
|
|
50
|
+
depthCompare( shadowCoord.xy, shadowCoord.z ),
|
|
51
|
+
depthCompare( shadowCoord.xy.add( vec2( dx3, 0 ) ), shadowCoord.z ),
|
|
52
|
+
depthCompare( shadowCoord.xy.add( vec2( dx1, 0 ) ), shadowCoord.z ),
|
|
53
|
+
depthCompare( shadowCoord.xy.add( vec2( dx2, dy3 ) ), shadowCoord.z ),
|
|
54
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy3 ) ), shadowCoord.z ),
|
|
55
|
+
depthCompare( shadowCoord.xy.add( vec2( dx3, dy3 ) ), shadowCoord.z ),
|
|
56
|
+
depthCompare( shadowCoord.xy.add( vec2( dx0, dy1 ) ), shadowCoord.z ),
|
|
57
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy1 ) ), shadowCoord.z ),
|
|
58
|
+
depthCompare( shadowCoord.xy.add( vec2( dx1, dy1 ) ), shadowCoord.z )
|
|
59
|
+
).mul( 1 / 17 );
|
|
60
|
+
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
const PCFSoftShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
64
|
+
|
|
65
|
+
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
66
|
+
|
|
67
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
68
|
+
|
|
69
|
+
const texelSize = vec2( 1 ).div( mapSize );
|
|
70
|
+
const dx = texelSize.x;
|
|
71
|
+
const dy = texelSize.y;
|
|
72
|
+
|
|
73
|
+
const uv = shadowCoord.xy;
|
|
74
|
+
const f = fract( uv.mul( mapSize ).add( 0.5 ) );
|
|
75
|
+
uv.subAssign( f.mul( texelSize ) );
|
|
76
|
+
|
|
77
|
+
return add(
|
|
78
|
+
depthCompare( uv, shadowCoord.z ),
|
|
79
|
+
depthCompare( uv.add( vec2( dx, 0 ) ), shadowCoord.z ),
|
|
80
|
+
depthCompare( uv.add( vec2( 0, dy ) ), shadowCoord.z ),
|
|
81
|
+
depthCompare( uv.add( texelSize ), shadowCoord.z ),
|
|
82
|
+
mix(
|
|
83
|
+
depthCompare( uv.add( vec2( dx.negate(), 0 ) ), shadowCoord.z ),
|
|
84
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), 0 ) ), shadowCoord.z ),
|
|
85
|
+
f.x
|
|
86
|
+
),
|
|
87
|
+
mix(
|
|
88
|
+
depthCompare( uv.add( vec2( dx.negate(), dy ) ), shadowCoord.z ),
|
|
89
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), dy ) ), shadowCoord.z ),
|
|
90
|
+
f.x
|
|
91
|
+
),
|
|
92
|
+
mix(
|
|
93
|
+
depthCompare( uv.add( vec2( 0, dy.negate() ) ), shadowCoord.z ),
|
|
94
|
+
depthCompare( uv.add( vec2( 0, dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
95
|
+
f.y
|
|
96
|
+
),
|
|
97
|
+
mix(
|
|
98
|
+
depthCompare( uv.add( vec2( dx, dy.negate() ) ), shadowCoord.z ),
|
|
99
|
+
depthCompare( uv.add( vec2( dx, dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
100
|
+
f.y
|
|
101
|
+
),
|
|
102
|
+
mix(
|
|
103
|
+
mix(
|
|
104
|
+
depthCompare( uv.add( vec2( dx.negate(), dy.negate() ) ), shadowCoord.z ),
|
|
105
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), dy.negate() ) ), shadowCoord.z ),
|
|
106
|
+
f.x
|
|
107
|
+
),
|
|
108
|
+
mix(
|
|
109
|
+
depthCompare( uv.add( vec2( dx.negate(), dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
110
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
111
|
+
f.x
|
|
112
|
+
),
|
|
113
|
+
f.y
|
|
114
|
+
)
|
|
115
|
+
).mul( 1 / 9 );
|
|
116
|
+
|
|
117
|
+
} );
|
|
118
|
+
|
|
119
|
+
const shadowFilterLib = [ BasicShadowMap, PCFShadowMap, PCFSoftShadowMap ];
|
|
120
|
+
|
|
121
|
+
//
|
|
122
|
+
|
|
123
|
+
let overrideMaterial = null;
|
|
124
|
+
|
|
125
|
+
class AnalyticLightNode extends LightingNode {
|
|
126
|
+
|
|
127
|
+
constructor( light = null ) {
|
|
128
|
+
|
|
129
|
+
super();
|
|
130
|
+
|
|
131
|
+
this.updateType = NodeUpdateType.FRAME;
|
|
132
|
+
|
|
133
|
+
this.light = light;
|
|
134
|
+
|
|
135
|
+
this.color = new Color();
|
|
136
|
+
this.colorNode = uniform( this.color );
|
|
137
|
+
|
|
138
|
+
this.baseColorNode = null;
|
|
139
|
+
|
|
140
|
+
this.shadowMap = null;
|
|
141
|
+
this.shadowNode = null;
|
|
142
|
+
this.shadowColorNode = null;
|
|
143
|
+
|
|
144
|
+
this.isAnalyticLightNode = true;
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getCacheKey() {
|
|
149
|
+
|
|
150
|
+
return super.getCacheKey() + '-' + ( this.light.id + '-' + ( this.light.castShadow ? '1' : '0' ) );
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getHash() {
|
|
155
|
+
|
|
156
|
+
return this.light.uuid;
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
setupShadow( builder ) {
|
|
161
|
+
|
|
162
|
+
const { object, renderer } = builder;
|
|
163
|
+
|
|
164
|
+
let shadowColorNode = this.shadowColorNode;
|
|
165
|
+
|
|
166
|
+
if ( shadowColorNode === null ) {
|
|
167
|
+
|
|
168
|
+
if ( overrideMaterial === null ) {
|
|
169
|
+
|
|
170
|
+
overrideMaterial = new NodeMaterial();
|
|
171
|
+
overrideMaterial.fragmentNode = vec4( 0, 0, 0, 1 );
|
|
172
|
+
overrideMaterial.isShadowNodeMaterial = true; // Use to avoid other overrideMaterial override material.fragmentNode unintentionally when using material.shadowNode
|
|
173
|
+
overrideMaterial.name = 'ShadowMaterial';
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const depthTexture = new DepthTexture();
|
|
178
|
+
depthTexture.compareFunction = LessCompare;
|
|
179
|
+
|
|
180
|
+
const shadow = this.light.shadow;
|
|
181
|
+
const shadowMap = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height );
|
|
182
|
+
shadowMap.depthTexture = depthTexture;
|
|
183
|
+
|
|
184
|
+
shadow.camera.updateProjectionMatrix();
|
|
185
|
+
|
|
186
|
+
//
|
|
187
|
+
|
|
188
|
+
const shadowIntensity = reference( 'intensity', 'float', shadow );
|
|
189
|
+
const bias = reference( 'bias', 'float', shadow );
|
|
190
|
+
const normalBias = reference( 'normalBias', 'float', shadow );
|
|
191
|
+
|
|
192
|
+
const position = object.material.shadowPositionNode || positionWorld;
|
|
193
|
+
|
|
194
|
+
let shadowCoord = uniform( shadow.matrix ).mul( position.add( normalWorld.mul( normalBias ) ) );
|
|
195
|
+
shadowCoord = shadowCoord.xyz.div( shadowCoord.w );
|
|
196
|
+
|
|
197
|
+
let coordZ = shadowCoord.z.add( bias );
|
|
198
|
+
|
|
199
|
+
if ( renderer.coordinateSystem === WebGPUCoordinateSystem ) {
|
|
200
|
+
|
|
201
|
+
coordZ = coordZ.mul( 2 ).sub( 1 ); // WebGPU: Convertion [ 0, 1 ] to [ - 1, 1 ]
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
shadowCoord = vec3(
|
|
206
|
+
shadowCoord.x,
|
|
207
|
+
shadowCoord.y.oneMinus(), // follow webgpu standards
|
|
208
|
+
coordZ
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const frustumTest = shadowCoord.x.greaterThanEqual( 0 )
|
|
212
|
+
.and( shadowCoord.x.lessThanEqual( 1 ) )
|
|
213
|
+
.and( shadowCoord.y.greaterThanEqual( 0 ) )
|
|
214
|
+
.and( shadowCoord.y.lessThanEqual( 1 ) )
|
|
215
|
+
.and( shadowCoord.z.lessThanEqual( 1 ) );
|
|
216
|
+
|
|
217
|
+
//
|
|
218
|
+
|
|
219
|
+
const filterFn = shadow.filterNode || shadowFilterLib[ renderer.shadowMap.type ] || null;
|
|
220
|
+
|
|
221
|
+
if ( filterFn === null ) {
|
|
222
|
+
|
|
223
|
+
throw new Error( 'THREE.WebGPURenderer: Shadow map type not supported yet.' );
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const shadowColor = texture( shadowMap.texture, shadowCoord );
|
|
228
|
+
const shadowNode = frustumTest.select( filterFn( { depthTexture, shadowCoord, shadow } ), float( 1 ) );
|
|
229
|
+
|
|
230
|
+
this.shadowMap = shadowMap;
|
|
231
|
+
|
|
232
|
+
this.shadowNode = shadowNode;
|
|
233
|
+
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode.rgb.mix( shadowColor, 1 ), shadowIntensity.mul( shadowColor.a ) ) );
|
|
234
|
+
|
|
235
|
+
this.baseColorNode = this.colorNode;
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
//
|
|
240
|
+
|
|
241
|
+
this.colorNode = shadowColorNode;
|
|
242
|
+
|
|
243
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
setup( builder ) {
|
|
248
|
+
|
|
249
|
+
this.colorNode = this.baseColorNode || this.colorNode;
|
|
250
|
+
|
|
251
|
+
if ( this.light.castShadow ) {
|
|
252
|
+
|
|
253
|
+
if ( builder.object.receiveShadow ) {
|
|
254
|
+
|
|
255
|
+
this.setupShadow( builder );
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
} else if ( this.shadowNode !== null ) {
|
|
260
|
+
|
|
261
|
+
this.disposeShadow();
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
updateShadow( frame ) {
|
|
268
|
+
|
|
269
|
+
const { shadowMap, light } = this;
|
|
270
|
+
const { renderer, scene, camera } = frame;
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
const depthVersion = shadowMap.depthTexture.version;
|
|
274
|
+
this._depthVersionCached = depthVersion;
|
|
275
|
+
|
|
276
|
+
const currentOverrideMaterial = scene.overrideMaterial;
|
|
277
|
+
|
|
278
|
+
scene.overrideMaterial = overrideMaterial;
|
|
279
|
+
|
|
280
|
+
shadowMap.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
281
|
+
|
|
282
|
+
light.shadow.updateMatrices( light );
|
|
283
|
+
light.shadow.camera.layers.mask = camera.layers.mask;
|
|
284
|
+
|
|
285
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
286
|
+
const currentRenderObjectFunction = renderer.getRenderObjectFunction();
|
|
287
|
+
|
|
288
|
+
renderer.setRenderObjectFunction( ( object, ...params ) => {
|
|
289
|
+
|
|
290
|
+
if ( object.castShadow === true ) {
|
|
291
|
+
|
|
292
|
+
renderer.renderObject( object, ...params );
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
} );
|
|
297
|
+
|
|
298
|
+
renderer.setRenderTarget( shadowMap );
|
|
299
|
+
renderer.render( scene, light.shadow.camera );
|
|
300
|
+
|
|
301
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
302
|
+
renderer.setRenderObjectFunction( currentRenderObjectFunction );
|
|
303
|
+
|
|
304
|
+
scene.overrideMaterial = currentOverrideMaterial;
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
disposeShadow() {
|
|
309
|
+
|
|
310
|
+
this.shadowMap.dispose();
|
|
311
|
+
this.shadowMap = null;
|
|
312
|
+
|
|
313
|
+
this.shadowNode = null;
|
|
314
|
+
this.shadowColorNode = null;
|
|
315
|
+
|
|
316
|
+
this.baseColorNode = null;
|
|
317
|
+
|
|
318
|
+
this.updateBeforeType = NodeUpdateType.NONE;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
updateBefore( frame ) {
|
|
323
|
+
|
|
324
|
+
const shadow = this.light.shadow;
|
|
325
|
+
|
|
326
|
+
const needsUpdate = shadow.needsUpdate || shadow.autoUpdate;
|
|
327
|
+
|
|
328
|
+
if ( needsUpdate ) {
|
|
329
|
+
|
|
330
|
+
this.updateShadow( frame );
|
|
331
|
+
|
|
332
|
+
if ( this.shadowMap.depthTexture.version === this._depthVersionCached ) {
|
|
333
|
+
|
|
334
|
+
shadow.needsUpdate = false;
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
update( /*frame*/ ) {
|
|
343
|
+
|
|
344
|
+
const { light } = this;
|
|
345
|
+
|
|
346
|
+
this.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export default AnalyticLightNode;
|
|
353
|
+
|
|
354
|
+
AnalyticLightNode.type = /*@__PURE__*/ registerNode( 'AnalyticLight', AnalyticLightNode );
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
2
|
+
import LightingNode from './LightingNode.js';
|
|
3
|
+
import { cubeMapNode } from '../utils/CubeMapNode.js';
|
|
4
|
+
|
|
5
|
+
class BasicEnvironmentNode extends LightingNode {
|
|
6
|
+
|
|
7
|
+
constructor( envNode = null ) {
|
|
8
|
+
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.envNode = envNode;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setup( builder ) {
|
|
16
|
+
|
|
17
|
+
// environment property is used in the finish() method of BasicLightingModel
|
|
18
|
+
|
|
19
|
+
builder.context.environment = cubeMapNode( this.envNode );
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default BasicEnvironmentNode;
|
|
26
|
+
|
|
27
|
+
BasicEnvironmentNode.type = /*@__PURE__*/ registerNode( 'BasicEnvironment', BasicEnvironmentNode );
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
2
|
+
import LightingNode from './LightingNode.js';
|
|
3
|
+
import { float } from '../tsl/TSLBase.js';
|
|
4
|
+
|
|
5
|
+
class BasicLightMapNode extends LightingNode {
|
|
6
|
+
|
|
7
|
+
constructor( lightMapNode = null ) {
|
|
8
|
+
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.lightMapNode = lightMapNode;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setup( builder ) {
|
|
16
|
+
|
|
17
|
+
// irradianceLightMap property is used in the indirectDiffuse() method of BasicLightingModel
|
|
18
|
+
|
|
19
|
+
const RECIPROCAL_PI = float( 1 / Math.PI );
|
|
20
|
+
|
|
21
|
+
builder.context.irradianceLightMap = this.lightMapNode.mul( RECIPROCAL_PI );
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default BasicLightMapNode;
|
|
28
|
+
|
|
29
|
+
BasicLightMapNode.type = /*@__PURE__*/ registerNode( 'BasicLightMap', BasicLightMapNode );
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
3
|
import { lightTargetDirection } from './LightNode.js';
|
|
3
|
-
import { addLightNode } from './LightsNode.js';
|
|
4
|
-
import { addNodeClass } from '../core/Node.js';
|
|
5
|
-
|
|
6
|
-
import { DirectionalLight } from 'three';
|
|
7
4
|
|
|
8
5
|
class DirectionalLightNode extends AnalyticLightNode {
|
|
9
6
|
|
|
@@ -26,8 +23,7 @@ class DirectionalLightNode extends AnalyticLightNode {
|
|
|
26
23
|
lightingModel.direct( {
|
|
27
24
|
lightDirection,
|
|
28
25
|
lightColor,
|
|
29
|
-
reflectedLight
|
|
30
|
-
shadowMask: this.shadowMaskNode
|
|
26
|
+
reflectedLight
|
|
31
27
|
}, builder.stack, builder );
|
|
32
28
|
|
|
33
29
|
}
|
|
@@ -36,6 +32,4 @@ class DirectionalLightNode extends AnalyticLightNode {
|
|
|
36
32
|
|
|
37
33
|
export default DirectionalLightNode;
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
addLightNode( DirectionalLight, DirectionalLightNode );
|
|
35
|
+
DirectionalLightNode.type = /*@__PURE__*/ registerNode( 'DirectionalLight', DirectionalLightNode );
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
3
|
import { cache } from '../core/CacheNode.js';
|
|
3
|
-
import { context } from '../core/ContextNode.js';
|
|
4
4
|
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
|
|
5
|
-
import { cameraViewMatrix } from '../accessors/
|
|
6
|
-
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/
|
|
7
|
-
import { positionViewDirection } from '../accessors/
|
|
8
|
-
import {
|
|
9
|
-
import { float } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { cameraViewMatrix } from '../accessors/Camera.js';
|
|
6
|
+
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/Normal.js';
|
|
7
|
+
import { positionViewDirection } from '../accessors/Position.js';
|
|
8
|
+
import { float } from '../tsl/TSLBase.js';
|
|
10
9
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
11
10
|
import { transformedBentNormalView } from '../accessors/AccessorsUtils.js';
|
|
12
11
|
import { pmremTexture } from '../pmrem/PMREMNode.js';
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const _envNodeCache = new WeakMap();
|
|
15
14
|
|
|
16
15
|
class EnvironmentNode extends LightingNode {
|
|
17
16
|
|
|
@@ -25,17 +24,21 @@ class EnvironmentNode extends LightingNode {
|
|
|
25
24
|
|
|
26
25
|
setup( builder ) {
|
|
27
26
|
|
|
27
|
+
const { material } = builder;
|
|
28
|
+
|
|
28
29
|
let envNode = this.envNode;
|
|
29
30
|
|
|
30
|
-
if ( envNode.isTextureNode ) {
|
|
31
|
+
if ( envNode.isTextureNode || envNode.isMaterialReferenceNode ) {
|
|
32
|
+
|
|
33
|
+
const value = ( envNode.isTextureNode ) ? envNode.value : material[ envNode.property ];
|
|
31
34
|
|
|
32
|
-
let cacheEnvNode =
|
|
35
|
+
let cacheEnvNode = _envNodeCache.get( value );
|
|
33
36
|
|
|
34
37
|
if ( cacheEnvNode === undefined ) {
|
|
35
38
|
|
|
36
|
-
cacheEnvNode = pmremTexture(
|
|
39
|
+
cacheEnvNode = pmremTexture( value );
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
_envNodeCache.set( value, cacheEnvNode );
|
|
39
42
|
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -45,24 +48,23 @@ class EnvironmentNode extends LightingNode {
|
|
|
45
48
|
|
|
46
49
|
//
|
|
47
50
|
|
|
48
|
-
const { material } = builder;
|
|
49
|
-
|
|
50
51
|
const envMap = material.envMap;
|
|
51
52
|
const intensity = envMap ? reference( 'envMapIntensity', 'float', builder.material ) : reference( 'environmentIntensity', 'float', builder.scene ); // @TODO: Add materialEnvIntensity in MaterialNode
|
|
52
53
|
|
|
53
54
|
const useAnisotropy = material.useAnisotropy === true || material.anisotropy > 0;
|
|
54
55
|
const radianceNormalView = useAnisotropy ? transformedBentNormalView : transformedNormalView;
|
|
55
56
|
|
|
56
|
-
const radiance = context(
|
|
57
|
-
const irradiance = context(
|
|
57
|
+
const radiance = envNode.context( createRadianceContext( roughness, radianceNormalView ) ).mul( intensity );
|
|
58
|
+
const irradiance = envNode.context( createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
|
|
58
59
|
|
|
59
60
|
const isolateRadiance = cache( radiance );
|
|
61
|
+
const isolateIrradiance = cache( irradiance );
|
|
60
62
|
|
|
61
63
|
//
|
|
62
64
|
|
|
63
65
|
builder.context.radiance.addAssign( isolateRadiance );
|
|
64
66
|
|
|
65
|
-
builder.context.iblIrradiance.addAssign(
|
|
67
|
+
builder.context.iblIrradiance.addAssign( isolateIrradiance );
|
|
66
68
|
|
|
67
69
|
//
|
|
68
70
|
|
|
@@ -70,7 +72,7 @@ class EnvironmentNode extends LightingNode {
|
|
|
70
72
|
|
|
71
73
|
if ( clearcoatRadiance ) {
|
|
72
74
|
|
|
73
|
-
const clearcoatRadianceContext = context(
|
|
75
|
+
const clearcoatRadianceContext = envNode.context( createRadianceContext( clearcoatRoughness, transformedClearcoatNormalView ) ).mul( intensity );
|
|
74
76
|
const isolateClearcoatRadiance = cache( clearcoatRadianceContext );
|
|
75
77
|
|
|
76
78
|
clearcoatRadiance.addAssign( isolateClearcoatRadiance );
|
|
@@ -81,6 +83,10 @@ class EnvironmentNode extends LightingNode {
|
|
|
81
83
|
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
export default EnvironmentNode;
|
|
87
|
+
|
|
88
|
+
EnvironmentNode.type = /*@__PURE__*/ registerNode( 'Environment', EnvironmentNode );
|
|
89
|
+
|
|
84
90
|
const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
85
91
|
|
|
86
92
|
let reflectVec = null;
|
|
@@ -127,7 +133,3 @@ const createIrradianceContext = ( normalWorldNode ) => {
|
|
|
127
133
|
};
|
|
128
134
|
|
|
129
135
|
};
|
|
130
|
-
|
|
131
|
-
export default EnvironmentNode;
|
|
132
|
-
|
|
133
|
-
addNodeClass( 'EnvironmentNode', EnvironmentNode );
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
4
|
import { mix } from '../math/MathNode.js';
|
|
5
|
-
import { normalView } from '../accessors/
|
|
5
|
+
import { normalView } from '../accessors/Normal.js';
|
|
6
6
|
import { objectPosition } from '../accessors/Object3DNode.js';
|
|
7
|
-
import { addNodeClass } from '../core/Node.js';
|
|
8
7
|
|
|
9
|
-
import { Color
|
|
8
|
+
import { Color } from '../../math/Color.js';
|
|
10
9
|
|
|
11
10
|
class HemisphereLightNode extends AnalyticLightNode {
|
|
12
11
|
|
|
@@ -50,6 +49,4 @@ class HemisphereLightNode extends AnalyticLightNode {
|
|
|
50
49
|
|
|
51
50
|
export default HemisphereLightNode;
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
addLightNode( HemisphereLight, HemisphereLightNode );
|
|
52
|
+
HemisphereLightNode.type = /*@__PURE__*/ registerNode( 'HemisphereLight', HemisphereLightNode );
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import SpotLightNode from './SpotLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
|
-
import { vec2 } from '../
|
|
5
|
-
import { addNodeClass } from '../core/Node.js';
|
|
6
|
-
|
|
7
|
-
import IESSpotLight from '../../lights/IESSpotLight.js';
|
|
4
|
+
import { vec2 } from '../tsl/TSLBase.js';
|
|
8
5
|
|
|
9
6
|
class IESSpotLightNode extends SpotLightNode {
|
|
10
7
|
|
|
@@ -34,6 +31,4 @@ class IESSpotLightNode extends SpotLightNode {
|
|
|
34
31
|
|
|
35
32
|
export default IESSpotLightNode;
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
addLightNode( IESSpotLight, IESSpotLightNode );
|
|
34
|
+
IESSpotLightNode.type = /*@__PURE__*/ registerNode( 'IESSpotLight', IESSpotLightNode );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
|
|
4
4
|
class IrradianceNode extends LightingNode {
|
|
5
5
|
|
|
@@ -21,4 +21,4 @@ class IrradianceNode extends LightingNode {
|
|
|
21
21
|
|
|
22
22
|
export default IrradianceNode;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
IrradianceNode.type = /*@__PURE__*/ registerNode( 'Irradiance', IrradianceNode );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Node, {
|
|
2
|
-
import { nodeProxy } from '../
|
|
1
|
+
import Node, { registerNode } from '../core/Node.js';
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
3
3
|
import { objectPosition } from '../accessors/Object3DNode.js';
|
|
4
|
-
import { cameraViewMatrix } from '../accessors/
|
|
4
|
+
import { cameraViewMatrix } from '../accessors/Camera.js';
|
|
5
5
|
|
|
6
6
|
class LightNode extends Node {
|
|
7
7
|
|
|
@@ -52,6 +52,6 @@ LightNode.TARGET_DIRECTION = 'targetDirection';
|
|
|
52
52
|
|
|
53
53
|
export default LightNode;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
LightNode.type = /*@__PURE__*/ registerNode( 'Light', LightNode );
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
export const lightTargetDirection = /*@__PURE__*/ nodeProxy( LightNode, LightNode.TARGET_DIRECTION );
|