super-three 0.167.0 → 0.169.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 +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- 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 +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- 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/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import SpotLightNode from './SpotLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
2
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
|
-
import { vec2 } from '../
|
|
5
|
-
import { addNodeClass } from '../core/Node.js';
|
|
6
|
-
|
|
7
|
-
import IESSpotLight from '../../lights/webgpu/IESSpotLight.js';
|
|
3
|
+
import { vec2 } from '../tsl/TSLBase.js';
|
|
8
4
|
|
|
9
5
|
class IESSpotLightNode extends SpotLightNode {
|
|
10
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'IESSpotLightNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
11
13
|
getSpotAttenuation( angleCosine ) {
|
|
12
14
|
|
|
13
15
|
const iesMap = this.light.iesMap;
|
|
@@ -33,7 +35,3 @@ class IESSpotLightNode extends SpotLightNode {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
export default IESSpotLightNode;
|
|
36
|
-
|
|
37
|
-
addNodeClass( 'IESSpotLightNode', IESSpotLightNode );
|
|
38
|
-
|
|
39
|
-
addLightNode( IESSpotLight, IESSpotLightNode );
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
2
|
|
|
4
3
|
class IrradianceNode extends LightingNode {
|
|
5
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'IrradianceNode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
constructor( node ) {
|
|
7
12
|
|
|
8
13
|
super();
|
|
@@ -20,5 +25,3 @@ class IrradianceNode extends LightingNode {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export default IrradianceNode;
|
|
23
|
-
|
|
24
|
-
addNodeClass( 'IrradianceNode', IrradianceNode );
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
+
import { normalWorld } from '../accessors/Normal.js';
|
|
3
|
+
import { uniformArray } from '../accessors/UniformArrayNode.js';
|
|
4
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
5
|
+
import getShIrradianceAt from '../functions/material/getShIrradianceAt.js';
|
|
6
|
+
|
|
7
|
+
class LightProbeNode extends AnalyticLightNode {
|
|
8
|
+
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'LightProbeNode';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
constructor( light = null ) {
|
|
16
|
+
|
|
17
|
+
super( light );
|
|
18
|
+
|
|
19
|
+
const array = [];
|
|
20
|
+
|
|
21
|
+
for ( let i = 0; i < 9; i ++ ) array.push( new Vector3() );
|
|
22
|
+
|
|
23
|
+
this.lightProbe = uniformArray( array );
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
update( frame ) {
|
|
28
|
+
|
|
29
|
+
const { light } = this;
|
|
30
|
+
|
|
31
|
+
super.update( frame );
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
for ( let i = 0; i < 9; i ++ ) {
|
|
36
|
+
|
|
37
|
+
this.lightProbe.array[ i ].copy( light.sh.coefficients[ i ] ).multiplyScalar( light.intensity );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setup( builder ) {
|
|
44
|
+
|
|
45
|
+
const irradiance = getShIrradianceAt( normalWorld, this.lightProbe );
|
|
46
|
+
|
|
47
|
+
builder.context.irradiance.addAssign( irradiance );
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default LightProbeNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
2
2
|
|
|
3
|
-
export const getDistanceAttenuation =
|
|
3
|
+
export const getDistanceAttenuation = /*@__PURE__*/ Fn( ( inputs ) => {
|
|
4
4
|
|
|
5
5
|
const { lightDistance, cutoffDistance, decayExponent } = inputs;
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ export const getDistanceAttenuation = tslFn( ( inputs ) => {
|
|
|
9
9
|
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
|
|
10
10
|
const distanceFalloff = lightDistance.pow( decayExponent ).max( 0.01 ).reciprocal();
|
|
11
11
|
|
|
12
|
-
return cutoffDistance.greaterThan( 0 ).
|
|
12
|
+
return cutoffDistance.greaterThan( 0 ).select(
|
|
13
13
|
distanceFalloff.mul( lightDistance.div( cutoffDistance ).pow4().oneMinus().clamp().pow2() ),
|
|
14
14
|
distanceFalloff
|
|
15
15
|
);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import ContextNode from '../core/ContextNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeProxy, float, vec3 } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
class LightingContextNode extends ContextNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'LightingContextNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( node, lightingModel = null, backdropNode = null, backdropAlphaNode = null ) {
|
|
8
13
|
|
|
9
14
|
super( node );
|
|
@@ -12,7 +17,7 @@ class LightingContextNode extends ContextNode {
|
|
|
12
17
|
this.backdropNode = backdropNode;
|
|
13
18
|
this.backdropAlphaNode = backdropAlphaNode;
|
|
14
19
|
|
|
15
|
-
this.
|
|
20
|
+
this._value = null;
|
|
16
21
|
|
|
17
22
|
}
|
|
18
23
|
|
|
@@ -20,10 +25,10 @@ class LightingContextNode extends ContextNode {
|
|
|
20
25
|
|
|
21
26
|
const { backdropNode, backdropAlphaNode } = this;
|
|
22
27
|
|
|
23
|
-
const directDiffuse = vec3().
|
|
24
|
-
directSpecular = vec3().
|
|
25
|
-
indirectDiffuse = vec3().
|
|
26
|
-
indirectSpecular = vec3().
|
|
28
|
+
const directDiffuse = vec3().toVar( 'directDiffuse' ),
|
|
29
|
+
directSpecular = vec3().toVar( 'directSpecular' ),
|
|
30
|
+
indirectDiffuse = vec3().toVar( 'indirectDiffuse' ),
|
|
31
|
+
indirectSpecular = vec3().toVar( 'indirectSpecular' );
|
|
27
32
|
|
|
28
33
|
const reflectedLight = {
|
|
29
34
|
directDiffuse,
|
|
@@ -33,10 +38,10 @@ class LightingContextNode extends ContextNode {
|
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
const context = {
|
|
36
|
-
radiance: vec3().
|
|
37
|
-
irradiance: vec3().
|
|
38
|
-
iblIrradiance: vec3().
|
|
39
|
-
ambientOcclusion: float( 1 ).
|
|
41
|
+
radiance: vec3().toVar( 'radiance' ),
|
|
42
|
+
irradiance: vec3().toVar( 'irradiance' ),
|
|
43
|
+
iblIrradiance: vec3().toVar( 'iblIrradiance' ),
|
|
44
|
+
ambientOcclusion: float( 1 ).toVar( 'ambientOcclusion' ),
|
|
40
45
|
reflectedLight,
|
|
41
46
|
backdrop: backdropNode,
|
|
42
47
|
backdropAlpha: backdropAlphaNode
|
|
@@ -48,8 +53,8 @@ class LightingContextNode extends ContextNode {
|
|
|
48
53
|
|
|
49
54
|
setup( builder ) {
|
|
50
55
|
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
56
|
+
this.value = this._value || ( this._value = this.getContext() );
|
|
57
|
+
this.value.lightingModel = this.lightingModel || builder.context.lightingModel;
|
|
53
58
|
|
|
54
59
|
return super.setup( builder );
|
|
55
60
|
|
|
@@ -59,8 +64,4 @@ class LightingContextNode extends ContextNode {
|
|
|
59
64
|
|
|
60
65
|
export default LightingContextNode;
|
|
61
66
|
|
|
62
|
-
export const lightingContext = nodeProxy( LightingContextNode );
|
|
63
|
-
|
|
64
|
-
addNodeElement( 'lightingContext', lightingContext );
|
|
65
|
-
|
|
66
|
-
addNodeClass( 'LightingContextNode', LightingContextNode );
|
|
67
|
+
export const lightingContext = /*@__PURE__*/ nodeProxy( LightingContextNode );
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
|
|
3
3
|
class LightingNode extends Node {
|
|
4
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'LightingNode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
constructor() {
|
|
6
12
|
|
|
7
13
|
super( 'vec3' );
|
|
@@ -19,5 +25,3 @@ class LightingNode extends Node {
|
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export default LightingNode;
|
|
22
|
-
|
|
23
|
-
addNodeClass( 'LightingNode', LightingNode );
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
|
-
import
|
|
3
|
-
import { nodeObject, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
4
|
-
|
|
5
|
-
const LightNodes = new WeakMap();
|
|
2
|
+
import { nodeObject, nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
6
3
|
|
|
7
4
|
const sortLights = ( lights ) => {
|
|
8
5
|
|
|
@@ -10,46 +7,69 @@ const sortLights = ( lights ) => {
|
|
|
10
7
|
|
|
11
8
|
};
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
const getLightNodeById = ( id, lightNodes ) => {
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
for ( const lightNode of lightNodes ) {
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
if ( lightNode.isAnalyticLightNode && lightNode.light.id === id ) {
|
|
15
|
+
|
|
16
|
+
return lightNode;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return null;
|
|
23
|
+
|
|
24
|
+
};
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
this.totalSpecularNode = vec3().temp( 'totalSpecular' );
|
|
26
|
+
const _lightsNodeRef = /*@__PURE__*/ new WeakMap();
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
class LightsNode extends Node {
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
static get type() {
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
return 'LightsNode';
|
|
27
33
|
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
constructor( lights = [] ) {
|
|
37
|
+
|
|
38
|
+
super( 'vec3' );
|
|
39
|
+
|
|
40
|
+
this.totalDiffuseNode = vec3().toVar( 'totalDiffuse' );
|
|
41
|
+
this.totalSpecularNode = vec3().toVar( 'totalSpecular' );
|
|
42
|
+
|
|
43
|
+
this.outgoingLightNode = vec3().toVar( 'outgoingLight' );
|
|
44
|
+
|
|
45
|
+
this._lights = lights;
|
|
31
46
|
|
|
32
|
-
|
|
47
|
+
this._lightNodes = null;
|
|
48
|
+
this._lightNodesHash = null;
|
|
49
|
+
|
|
50
|
+
this.global = true;
|
|
33
51
|
|
|
34
52
|
}
|
|
35
53
|
|
|
36
|
-
getHash() {
|
|
54
|
+
getHash( builder ) {
|
|
55
|
+
|
|
56
|
+
if ( this._lightNodesHash === null ) {
|
|
37
57
|
|
|
38
|
-
|
|
58
|
+
if ( this._lightNodes === null ) this.setupLightsNode( builder );
|
|
39
59
|
|
|
40
60
|
const hash = [];
|
|
41
61
|
|
|
42
|
-
for ( const lightNode of this.
|
|
62
|
+
for ( const lightNode of this._lightNodes ) {
|
|
43
63
|
|
|
44
64
|
hash.push( lightNode.getHash() );
|
|
45
65
|
|
|
46
66
|
}
|
|
47
67
|
|
|
48
|
-
this.
|
|
68
|
+
this._lightNodesHash = 'lights-' + hash.join( ',' );
|
|
49
69
|
|
|
50
70
|
}
|
|
51
71
|
|
|
52
|
-
return this.
|
|
72
|
+
return this._lightNodesHash;
|
|
53
73
|
|
|
54
74
|
}
|
|
55
75
|
|
|
@@ -65,8 +85,71 @@ class LightsNode extends Node {
|
|
|
65
85
|
|
|
66
86
|
}
|
|
67
87
|
|
|
88
|
+
setupLightsNode( builder ) {
|
|
89
|
+
|
|
90
|
+
const lightNodes = [];
|
|
91
|
+
|
|
92
|
+
const previousLightNodes = this._lightNodes;
|
|
93
|
+
|
|
94
|
+
const lights = sortLights( this._lights );
|
|
95
|
+
const nodeLibrary = builder.renderer.nodes.library;
|
|
96
|
+
|
|
97
|
+
for ( const light of lights ) {
|
|
98
|
+
|
|
99
|
+
if ( light.isNode ) {
|
|
100
|
+
|
|
101
|
+
lightNodes.push( nodeObject( light ) );
|
|
102
|
+
|
|
103
|
+
} else {
|
|
104
|
+
|
|
105
|
+
let lightNode = null;
|
|
106
|
+
|
|
107
|
+
if ( previousLightNodes !== null ) {
|
|
108
|
+
|
|
109
|
+
lightNode = getLightNodeById( light.id, previousLightNodes ); // resuse existing light node
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if ( lightNode === null ) {
|
|
114
|
+
|
|
115
|
+
const lightNodeClass = nodeLibrary.getLightNodeClass( light.constructor );
|
|
116
|
+
|
|
117
|
+
if ( lightNodeClass === null ) {
|
|
118
|
+
|
|
119
|
+
console.warn( `LightsNode.setupNodeLights: Light node not found for ${ light.constructor.name }` );
|
|
120
|
+
continue;
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let lightNode = null;
|
|
125
|
+
|
|
126
|
+
if ( ! _lightsNodeRef.has( light ) ) {
|
|
127
|
+
|
|
128
|
+
lightNode = new lightNodeClass( light );
|
|
129
|
+
_lightsNodeRef.set( light, lightNode );
|
|
130
|
+
|
|
131
|
+
} else {
|
|
132
|
+
|
|
133
|
+
lightNode = _lightsNodeRef.get( light );
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
lightNodes.push( lightNode );
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this._lightNodes = lightNodes;
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
68
149
|
setup( builder ) {
|
|
69
150
|
|
|
151
|
+
if ( this._lightNodes === null ) this.setupLightsNode( builder );
|
|
152
|
+
|
|
70
153
|
const context = builder.context;
|
|
71
154
|
const lightingModel = context.lightingModel;
|
|
72
155
|
|
|
@@ -74,7 +157,7 @@ class LightsNode extends Node {
|
|
|
74
157
|
|
|
75
158
|
if ( lightingModel ) {
|
|
76
159
|
|
|
77
|
-
const {
|
|
160
|
+
const { _lightNodes, totalDiffuseNode, totalSpecularNode } = this;
|
|
78
161
|
|
|
79
162
|
context.outgoingLight = outgoingLightNode;
|
|
80
163
|
|
|
@@ -91,7 +174,7 @@ class LightsNode extends Node {
|
|
|
91
174
|
|
|
92
175
|
// lights
|
|
93
176
|
|
|
94
|
-
for ( const lightNode of
|
|
177
|
+
for ( const lightNode of _lightNodes ) {
|
|
95
178
|
|
|
96
179
|
lightNode.build( builder );
|
|
97
180
|
|
|
@@ -143,49 +226,20 @@ class LightsNode extends Node {
|
|
|
143
226
|
|
|
144
227
|
}
|
|
145
228
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
for ( const lightNode of this.lightNodes ) {
|
|
149
|
-
|
|
150
|
-
if ( lightNode.isAnalyticLightNode && lightNode.light.id === id ) {
|
|
229
|
+
setLights( lights ) {
|
|
151
230
|
|
|
152
|
-
|
|
231
|
+
this._lights = lights;
|
|
153
232
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
233
|
+
this._lightNodes = null;
|
|
234
|
+
this._lightNodesHash = null;
|
|
157
235
|
|
|
158
|
-
return
|
|
236
|
+
return this;
|
|
159
237
|
|
|
160
238
|
}
|
|
161
239
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const lightNodes = [];
|
|
240
|
+
getLights() {
|
|
165
241
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
for ( const light of lights ) {
|
|
169
|
-
|
|
170
|
-
let lightNode = this._getLightNodeById( light.id );
|
|
171
|
-
|
|
172
|
-
if ( lightNode === null ) {
|
|
173
|
-
|
|
174
|
-
const lightClass = light.constructor;
|
|
175
|
-
const lightNodeClass = LightNodes.has( lightClass ) ? LightNodes.get( lightClass ) : AnalyticLightNode;
|
|
176
|
-
|
|
177
|
-
lightNode = nodeObject( new lightNodeClass( light ) );
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
lightNodes.push( lightNode );
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
this.lightNodes = lightNodes;
|
|
186
|
-
this._hash = null;
|
|
187
|
-
|
|
188
|
-
return this;
|
|
242
|
+
return this._lights;
|
|
189
243
|
|
|
190
244
|
}
|
|
191
245
|
|
|
@@ -193,21 +247,4 @@ class LightsNode extends Node {
|
|
|
193
247
|
|
|
194
248
|
export default LightsNode;
|
|
195
249
|
|
|
196
|
-
export const lights =
|
|
197
|
-
export const lightsNode = nodeProxy( LightsNode );
|
|
198
|
-
|
|
199
|
-
export function addLightNode( lightClass, lightNodeClass ) {
|
|
200
|
-
|
|
201
|
-
if ( LightNodes.has( lightClass ) ) {
|
|
202
|
-
|
|
203
|
-
console.warn( `Redefinition of light node ${ lightNodeClass.type }` );
|
|
204
|
-
return;
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if ( typeof lightClass !== 'function' ) throw new Error( `Light ${ lightClass.name } is not a class` );
|
|
209
|
-
if ( typeof lightNodeClass !== 'function' || ! lightNodeClass.type ) throw new Error( `Light node ${ lightNodeClass.type } is not a class` );
|
|
210
|
-
|
|
211
|
-
LightNodes.set( lightClass, lightNodeClass );
|
|
212
|
-
|
|
213
|
-
}
|
|
250
|
+
export const lights = /*@__PURE__*/ nodeProxy( LightsNode );
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
2
|
import { getDistanceAttenuation } from './LightUtils.js';
|
|
4
3
|
import { uniform } from '../core/UniformNode.js';
|
|
5
|
-
import {
|
|
6
|
-
import { positionView } from '../accessors/
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { PointLight } from '../../lights/PointLight.js';
|
|
4
|
+
import { lightViewPosition } from '../accessors/Lights.js';
|
|
5
|
+
import { positionView } from '../accessors/Position.js';
|
|
6
|
+
import { renderGroup } from '../TSL.js';
|
|
10
7
|
|
|
11
8
|
class PointLightNode extends AnalyticLightNode {
|
|
12
9
|
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'PointLightNode';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
13
16
|
constructor( light = null ) {
|
|
14
17
|
|
|
15
18
|
super( light );
|
|
16
19
|
|
|
17
|
-
this.cutoffDistanceNode = uniform( 0 );
|
|
18
|
-
this.decayExponentNode = uniform( 0 );
|
|
20
|
+
this.cutoffDistanceNode = uniform( 0 ).setGroup( renderGroup );
|
|
21
|
+
this.decayExponentNode = uniform( 0 ).setGroup( renderGroup );
|
|
19
22
|
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -36,7 +39,7 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
36
39
|
|
|
37
40
|
const lightingModel = builder.context.lightingModel;
|
|
38
41
|
|
|
39
|
-
const lVector =
|
|
42
|
+
const lVector = lightViewPosition( light ).sub( positionView ); // @TODO: Add it into LightNode
|
|
40
43
|
|
|
41
44
|
const lightDirection = lVector.normalize();
|
|
42
45
|
const lightDistance = lVector.length();
|
|
@@ -62,7 +65,3 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export default PointLightNode;
|
|
65
|
-
|
|
66
|
-
addNodeClass( 'PointLightNode', PointLightNode );
|
|
67
|
-
|
|
68
|
-
addLightNode( PointLight, PointLightNode );
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
2
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
3
|
import { uniform } from '../core/UniformNode.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { lightViewPosition } from '../accessors/Lights.js';
|
|
5
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
7
6
|
|
|
8
|
-
import { RectAreaLight } from '../../lights/RectAreaLight.js';
|
|
9
7
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
10
8
|
import { Vector3 } from '../../math/Vector3.js';
|
|
11
9
|
|
|
@@ -16,12 +14,18 @@ let ltcLib = null;
|
|
|
16
14
|
|
|
17
15
|
class RectAreaLightNode extends AnalyticLightNode {
|
|
18
16
|
|
|
17
|
+
static get type() {
|
|
18
|
+
|
|
19
|
+
return 'RectAreaLightNode';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
constructor( light = null ) {
|
|
20
24
|
|
|
21
25
|
super( light );
|
|
22
26
|
|
|
23
|
-
this.halfHeight = uniform( new Vector3() );
|
|
24
|
-
this.halfWidth = uniform( new Vector3() );
|
|
27
|
+
this.halfHeight = uniform( new Vector3() ).setGroup( renderGroup );
|
|
28
|
+
this.halfWidth = uniform( new Vector3() ).setGroup( renderGroup );
|
|
25
29
|
|
|
26
30
|
}
|
|
27
31
|
|
|
@@ -67,7 +71,7 @@ class RectAreaLightNode extends AnalyticLightNode {
|
|
|
67
71
|
const { colorNode, light } = this;
|
|
68
72
|
const lightingModel = builder.context.lightingModel;
|
|
69
73
|
|
|
70
|
-
const lightPosition =
|
|
74
|
+
const lightPosition = lightViewPosition( light );
|
|
71
75
|
const reflectedLight = builder.context.reflectedLight;
|
|
72
76
|
|
|
73
77
|
lightingModel.directRectArea( {
|
|
@@ -91,7 +95,3 @@ class RectAreaLightNode extends AnalyticLightNode {
|
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
export default RectAreaLightNode;
|
|
94
|
-
|
|
95
|
-
addNodeClass( 'RectAreaLightNode', RectAreaLightNode );
|
|
96
|
-
|
|
97
|
-
addLightNode( RectAreaLight, RectAreaLightNode );
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { lightTargetDirection } from './LightNode.js';
|
|
3
|
-
import { addLightNode } from './LightsNode.js';
|
|
4
2
|
import { getDistanceAttenuation } from './LightUtils.js';
|
|
5
3
|
import { uniform } from '../core/UniformNode.js';
|
|
6
4
|
import { smoothstep } from '../math/MathNode.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { SpotLight } from '../../lights/SpotLight.js';
|
|
5
|
+
import { positionView } from '../accessors/Position.js';
|
|
6
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
7
|
+
import { lightViewPosition, lightTargetDirection } from '../accessors/Lights.js';
|
|
12
8
|
|
|
13
9
|
class SpotLightNode extends AnalyticLightNode {
|
|
14
10
|
|
|
11
|
+
static get type() {
|
|
12
|
+
|
|
13
|
+
return 'SpotLightNode';
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
15
17
|
constructor( light = null ) {
|
|
16
18
|
|
|
17
19
|
super( light );
|
|
18
20
|
|
|
19
|
-
this.coneCosNode = uniform( 0 );
|
|
20
|
-
this.penumbraCosNode = uniform( 0 );
|
|
21
|
+
this.coneCosNode = uniform( 0 ).setGroup( renderGroup );
|
|
22
|
+
this.penumbraCosNode = uniform( 0 ).setGroup( renderGroup );
|
|
21
23
|
|
|
22
|
-
this.cutoffDistanceNode = uniform( 0 );
|
|
23
|
-
this.decayExponentNode = uniform( 0 );
|
|
24
|
+
this.cutoffDistanceNode = uniform( 0 ).setGroup( renderGroup );
|
|
25
|
+
this.decayExponentNode = uniform( 0 ).setGroup( renderGroup );
|
|
24
26
|
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -54,7 +56,7 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
54
56
|
|
|
55
57
|
const { colorNode, cutoffDistanceNode, decayExponentNode, light } = this;
|
|
56
58
|
|
|
57
|
-
const lVector =
|
|
59
|
+
const lVector = lightViewPosition( light ).sub( positionView ); // @TODO: Add it into LightNode
|
|
58
60
|
|
|
59
61
|
const lightDirection = lVector.normalize();
|
|
60
62
|
const angleCos = lightDirection.dot( lightTargetDirection( light ) );
|
|
@@ -83,7 +85,3 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
export default SpotLightNode;
|
|
86
|
-
|
|
87
|
-
addNodeClass( 'SpotLightNode', SpotLightNode );
|
|
88
|
-
|
|
89
|
-
addLightNode( SpotLight, SpotLightNode );
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
import { mx_hsvtorgb, mx_rgbtohsv } from './lib/mx_hsv.js';
|
|
8
8
|
import { mx_srgb_texture_to_lin_rec709 } from './lib/mx_transform_color.js';
|
|
9
9
|
import { mix, smoothstep } from '../math/MathNode.js';
|
|
10
|
-
import { uv } from '../accessors/
|
|
11
|
-
import { float, vec2, vec4, int } from '../
|
|
10
|
+
import { uv } from '../accessors/UV.js';
|
|
11
|
+
import { float, vec2, vec4, int } from '../tsl/TSLBase.js';
|
|
12
12
|
|
|
13
13
|
export const mx_aastep = ( threshold, value ) => {
|
|
14
14
|
|