super-three 0.167.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 +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- 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/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 +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- 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/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/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 +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- 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 +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- 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 +32 -31
- 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/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- 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} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -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 +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/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 +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- 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/ClippingContext.js +14 -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 +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- 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 +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- 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 +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- 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/materials/MeshNormalNodeMaterial.js +0 -40
- 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/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import Node from '../core/Node.js';
|
|
2
|
-
import
|
|
3
|
-
import { nodeObject, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
4
|
-
|
|
5
|
-
const LightNodes = new WeakMap();
|
|
1
|
+
import Node, { registerNode } from '../core/Node.js';
|
|
2
|
+
import { nodeObject, nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
6
3
|
|
|
7
4
|
const sortLights = ( lights ) => {
|
|
8
5
|
|
|
@@ -10,46 +7,61 @@ 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
|
+
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
this.totalSpecularNode = vec3().temp( 'totalSpecular' );
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
return null;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
class LightsNode extends Node {
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
constructor( lights = [] ) {
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
super( 'vec3' );
|
|
31
|
+
|
|
32
|
+
this.totalDiffuseNode = vec3().toVar( 'totalDiffuse' );
|
|
33
|
+
this.totalSpecularNode = vec3().toVar( 'totalSpecular' );
|
|
34
|
+
|
|
35
|
+
this.outgoingLightNode = vec3().toVar( 'outgoingLight' );
|
|
36
|
+
|
|
37
|
+
this._lights = lights;
|
|
38
|
+
|
|
39
|
+
this._lightNodes = null;
|
|
40
|
+
this._lightNodesHash = null;
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
this.global = true;
|
|
33
43
|
|
|
34
44
|
}
|
|
35
45
|
|
|
36
|
-
getHash() {
|
|
46
|
+
getHash( builder ) {
|
|
37
47
|
|
|
38
|
-
if ( this.
|
|
48
|
+
if ( this._lightNodesHash === null ) {
|
|
49
|
+
|
|
50
|
+
if ( this._lightNodes === null ) this.setupLightsNode( builder );
|
|
39
51
|
|
|
40
52
|
const hash = [];
|
|
41
53
|
|
|
42
|
-
for ( const lightNode of this.
|
|
54
|
+
for ( const lightNode of this._lightNodes ) {
|
|
43
55
|
|
|
44
56
|
hash.push( lightNode.getHash() );
|
|
45
57
|
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
this.
|
|
60
|
+
this._lightNodesHash = 'lights-' + hash.join( ',' );
|
|
49
61
|
|
|
50
62
|
}
|
|
51
63
|
|
|
52
|
-
return this.
|
|
64
|
+
return this._lightNodesHash;
|
|
53
65
|
|
|
54
66
|
}
|
|
55
67
|
|
|
@@ -65,8 +77,58 @@ class LightsNode extends Node {
|
|
|
65
77
|
|
|
66
78
|
}
|
|
67
79
|
|
|
80
|
+
setupLightsNode( builder ) {
|
|
81
|
+
|
|
82
|
+
const lightNodes = [];
|
|
83
|
+
|
|
84
|
+
const previousLightNodes = this._lightNodes;
|
|
85
|
+
|
|
86
|
+
const lights = sortLights( this._lights );
|
|
87
|
+
const nodeLibrary = builder.renderer.nodes.library;
|
|
88
|
+
|
|
89
|
+
for ( const light of lights ) {
|
|
90
|
+
|
|
91
|
+
if ( light.isNode ) {
|
|
92
|
+
|
|
93
|
+
lightNodes.push( nodeObject( light ) );
|
|
94
|
+
|
|
95
|
+
} else {
|
|
96
|
+
|
|
97
|
+
let lightNode = null;
|
|
98
|
+
|
|
99
|
+
if ( previousLightNodes !== null ) {
|
|
100
|
+
|
|
101
|
+
lightNode = getLightNodeById( light.id, previousLightNodes ); // resuse existing light node
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if ( lightNode === null ) {
|
|
106
|
+
|
|
107
|
+
const lightNodeClass = nodeLibrary.getLightNodeClass( light.constructor );
|
|
108
|
+
|
|
109
|
+
if ( lightNodeClass === undefined ) {
|
|
110
|
+
|
|
111
|
+
console.warn( `LightsNode.setupNodeLights: Light node not found for ${ light.constructor.name }` );
|
|
112
|
+
continue;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
lightNodes.push( nodeObject( new lightNodeClass( light ) ) );
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this._lightNodes = lightNodes;
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
68
128
|
setup( builder ) {
|
|
69
129
|
|
|
130
|
+
if ( this._lightNodes === null ) this.setupLightsNode( builder );
|
|
131
|
+
|
|
70
132
|
const context = builder.context;
|
|
71
133
|
const lightingModel = context.lightingModel;
|
|
72
134
|
|
|
@@ -74,7 +136,7 @@ class LightsNode extends Node {
|
|
|
74
136
|
|
|
75
137
|
if ( lightingModel ) {
|
|
76
138
|
|
|
77
|
-
const {
|
|
139
|
+
const { _lightNodes, totalDiffuseNode, totalSpecularNode } = this;
|
|
78
140
|
|
|
79
141
|
context.outgoingLight = outgoingLightNode;
|
|
80
142
|
|
|
@@ -91,7 +153,7 @@ class LightsNode extends Node {
|
|
|
91
153
|
|
|
92
154
|
// lights
|
|
93
155
|
|
|
94
|
-
for ( const lightNode of
|
|
156
|
+
for ( const lightNode of _lightNodes ) {
|
|
95
157
|
|
|
96
158
|
lightNode.build( builder );
|
|
97
159
|
|
|
@@ -143,49 +205,20 @@ class LightsNode extends Node {
|
|
|
143
205
|
|
|
144
206
|
}
|
|
145
207
|
|
|
146
|
-
|
|
208
|
+
setLights( lights ) {
|
|
147
209
|
|
|
148
|
-
|
|
210
|
+
this._lights = lights;
|
|
149
211
|
|
|
150
|
-
|
|
212
|
+
this._lightNodes = null;
|
|
213
|
+
this._lightNodesHash = null;
|
|
151
214
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return null;
|
|
215
|
+
return this;
|
|
159
216
|
|
|
160
217
|
}
|
|
161
218
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const lightNodes = [];
|
|
165
|
-
|
|
166
|
-
lights = sortLights( lights );
|
|
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 );
|
|
219
|
+
getLights() {
|
|
182
220
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this.lightNodes = lightNodes;
|
|
186
|
-
this._hash = null;
|
|
187
|
-
|
|
188
|
-
return this;
|
|
221
|
+
return this._lights;
|
|
189
222
|
|
|
190
223
|
}
|
|
191
224
|
|
|
@@ -193,21 +226,6 @@ class LightsNode extends Node {
|
|
|
193
226
|
|
|
194
227
|
export default LightsNode;
|
|
195
228
|
|
|
196
|
-
|
|
197
|
-
export const lightsNode = nodeProxy( LightsNode );
|
|
198
|
-
|
|
199
|
-
export function addLightNode( lightClass, lightNodeClass ) {
|
|
200
|
-
|
|
201
|
-
if ( LightNodes.has( lightClass ) ) {
|
|
229
|
+
LightsNode.type = /*@__PURE__*/ registerNode( 'Lights', LightsNode );
|
|
202
230
|
|
|
203
|
-
|
|
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
|
-
}
|
|
231
|
+
export const lights = /*@__PURE__*/ nodeProxy( LightsNode );
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { getDistanceAttenuation } from './LightUtils.js';
|
|
4
4
|
import { uniform } from '../core/UniformNode.js';
|
|
5
5
|
import { objectViewPosition } from '../accessors/Object3DNode.js';
|
|
6
|
-
import { positionView } from '../accessors/
|
|
7
|
-
import { addNodeClass } from '../core/Node.js';
|
|
8
|
-
|
|
9
|
-
import { PointLight } from '../../lights/PointLight.js';
|
|
6
|
+
import { positionView } from '../accessors/Position.js';
|
|
10
7
|
|
|
11
8
|
class PointLightNode extends AnalyticLightNode {
|
|
12
9
|
|
|
@@ -63,6 +60,4 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
63
60
|
|
|
64
61
|
export default PointLightNode;
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
addLightNode( PointLight, PointLightNode );
|
|
63
|
+
PointLightNode.type = /*@__PURE__*/ registerNode( 'PointLight', PointLightNode );
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
4
|
import { uniform } from '../core/UniformNode.js';
|
|
5
5
|
import { objectViewPosition } from '../accessors/Object3DNode.js';
|
|
6
|
-
import { addNodeClass } from '../core/Node.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
|
|
|
@@ -92,6 +90,4 @@ class RectAreaLightNode extends AnalyticLightNode {
|
|
|
92
90
|
|
|
93
91
|
export default RectAreaLightNode;
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
addLightNode( RectAreaLight, RectAreaLightNode );
|
|
93
|
+
RectAreaLightNode.type = /*@__PURE__*/ registerNode( 'RectAreaLight', RectAreaLightNode );
|
|
@@ -1,14 +1,11 @@
|
|
|
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
4
|
import { getDistanceAttenuation } from './LightUtils.js';
|
|
5
5
|
import { uniform } from '../core/UniformNode.js';
|
|
6
6
|
import { smoothstep } from '../math/MathNode.js';
|
|
7
7
|
import { objectViewPosition } from '../accessors/Object3DNode.js';
|
|
8
|
-
import { positionView } from '../accessors/
|
|
9
|
-
import { addNodeClass } from '../core/Node.js';
|
|
10
|
-
|
|
11
|
-
import { SpotLight } from '../../lights/SpotLight.js';
|
|
8
|
+
import { positionView } from '../accessors/Position.js';
|
|
12
9
|
|
|
13
10
|
class SpotLightNode extends AnalyticLightNode {
|
|
14
11
|
|
|
@@ -84,6 +81,4 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
84
81
|
|
|
85
82
|
export default SpotLightNode;
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
addLightNode( SpotLight, SpotLightNode );
|
|
84
|
+
SpotLightNode.type = /*@__PURE__*/ registerNode( '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
|
|
|
@@ -1,56 +1,61 @@
|
|
|
1
1
|
// Three.js Transpiler
|
|
2
2
|
// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_hsv.glsl
|
|
3
3
|
|
|
4
|
-
import { int, float, vec3, If,
|
|
5
|
-
import { add
|
|
4
|
+
import { int, float, vec3, If, Fn } from '../../tsl/TSLBase.js';
|
|
5
|
+
import { add } from '../../math/OperatorNode.js';
|
|
6
6
|
import { floor, trunc, max, min } from '../../math/MathNode.js';
|
|
7
7
|
|
|
8
|
-
export const mx_hsvtorgb =
|
|
8
|
+
export const mx_hsvtorgb = /*@__PURE__*/ Fn( ( [ hsv ] ) => {
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
10
|
+
const s = hsv.y;
|
|
11
|
+
const v = hsv.z;
|
|
12
|
+
|
|
13
|
+
const result = vec3().toVar();
|
|
14
14
|
|
|
15
15
|
If( s.lessThan( 0.0001 ), () => {
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
result.assign( vec3( v, v, v ) );
|
|
18
18
|
|
|
19
|
-
} ).
|
|
19
|
+
} ).Else( () => {
|
|
20
20
|
|
|
21
|
-
h
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
21
|
+
let h = hsv.x;
|
|
22
|
+
h = h.sub( floor( h ) ).mul( 6.0 ).toVar(); // TODO: check what .toVar() is needed in node system cache
|
|
23
|
+
const hi = int( trunc( h ) );
|
|
24
|
+
const f = h.sub( float( hi ) );
|
|
25
|
+
const p = v.mul( s.oneMinus() );
|
|
26
|
+
const q = v.mul( s.mul( f ).oneMinus() );
|
|
27
|
+
const t = v.mul( s.mul( f.oneMinus() ).oneMinus() );
|
|
27
28
|
|
|
28
29
|
If( hi.equal( int( 0 ) ), () => {
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
result.assign( vec3( v, t, p ) );
|
|
31
32
|
|
|
32
|
-
} ).
|
|
33
|
+
} ).ElseIf( hi.equal( int( 1 ) ), () => {
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
result.assign( vec3( q, v, p ) );
|
|
35
36
|
|
|
36
|
-
} ).
|
|
37
|
+
} ).ElseIf( hi.equal( int( 2 ) ), () => {
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
result.assign( vec3( p, v, t ) );
|
|
39
40
|
|
|
40
|
-
} ).
|
|
41
|
+
} ).ElseIf( hi.equal( int( 3 ) ), () => {
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
result.assign( vec3( p, q, v ) );
|
|
43
44
|
|
|
44
|
-
} ).
|
|
45
|
+
} ).ElseIf( hi.equal( int( 4 ) ), () => {
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
result.assign( vec3( t, p, v ) );
|
|
47
48
|
|
|
48
|
-
} )
|
|
49
|
+
} ).Else( () => {
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
result.assign( vec3( v, p, q ) );
|
|
52
|
+
|
|
53
|
+
} );
|
|
51
54
|
|
|
52
55
|
} );
|
|
53
56
|
|
|
57
|
+
return result;
|
|
58
|
+
|
|
54
59
|
} ).setLayout( {
|
|
55
60
|
name: 'mx_hsvtorgb',
|
|
56
61
|
type: 'vec3',
|
|
@@ -59,7 +64,7 @@ export const mx_hsvtorgb = /*#__PURE__*/ tslFn( ( [ hsv_immutable ] ) => {
|
|
|
59
64
|
]
|
|
60
65
|
} );
|
|
61
66
|
|
|
62
|
-
export const mx_rgbtohsv =
|
|
67
|
+
export const mx_rgbtohsv = /*@__PURE__*/ Fn( ( [ c_immutable ] ) => {
|
|
63
68
|
|
|
64
69
|
const c = vec3( c_immutable ).toVar();
|
|
65
70
|
const r = float( c.x ).toVar();
|
|
@@ -75,7 +80,7 @@ export const mx_rgbtohsv = /*#__PURE__*/ tslFn( ( [ c_immutable ] ) => {
|
|
|
75
80
|
|
|
76
81
|
s.assign( delta.div( maxcomp ) );
|
|
77
82
|
|
|
78
|
-
} ).
|
|
83
|
+
} ).Else( () => {
|
|
79
84
|
|
|
80
85
|
s.assign( 0.0 );
|
|
81
86
|
|
|
@@ -85,17 +90,17 @@ export const mx_rgbtohsv = /*#__PURE__*/ tslFn( ( [ c_immutable ] ) => {
|
|
|
85
90
|
|
|
86
91
|
h.assign( 0.0 );
|
|
87
92
|
|
|
88
|
-
} ).
|
|
93
|
+
} ).Else( () => {
|
|
89
94
|
|
|
90
95
|
If( r.greaterThanEqual( maxcomp ), () => {
|
|
91
96
|
|
|
92
97
|
h.assign( g.sub( b ).div( delta ) );
|
|
93
98
|
|
|
94
|
-
} ).
|
|
99
|
+
} ).ElseIf( g.greaterThanEqual( maxcomp ), () => {
|
|
95
100
|
|
|
96
101
|
h.assign( add( 2.0, b.sub( r ).div( delta ) ) );
|
|
97
102
|
|
|
98
|
-
} ).
|
|
103
|
+
} ).Else( () => {
|
|
99
104
|
|
|
100
105
|
h.assign( add( 4.0, r.sub( g ).div( delta ) ) );
|
|
101
106
|
|