super-three 0.172.0 → 0.173.1
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/LICENSE +1 -1
- package/build/three.cjs +439 -380
- package/build/three.core.js +413 -41
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +28 -344
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +11 -3
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +7550 -1798
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +7551 -1798
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +6 -5
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +23 -21
- package/examples/jsm/exporters/GLTFExporter.js +26 -25
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/loaders/GCodeLoader.js +3 -1
- package/examples/jsm/loaders/GLTFLoader.js +0 -2
- package/examples/jsm/loaders/TDSLoader.js +0 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +4 -3
- package/examples/jsm/misc/Volume.js +7 -5
- package/examples/jsm/misc/VolumeSlice.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +25 -20
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/EffectComposer.js +23 -2
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/Pass.js +6 -1
- package/examples/jsm/shaders/OutputShader.js +5 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +9 -1
- package/src/cameras/ArrayCamera.js +1 -0
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- package/src/extras/ImageUtils.js +1 -11
- package/src/loaders/nodes/NodeObjectLoader.js +1 -1
- package/src/materials/nodes/MeshBasicNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +5 -5
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +109 -7
- package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
- package/src/materials/nodes/VolumeNodeMaterial.js +3 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +8 -0
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/Arrays.js +30 -8
- package/src/nodes/accessors/BatchNode.js +3 -3
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +64 -3
- package/src/nodes/accessors/InstanceNode.js +1 -1
- package/src/nodes/accessors/MaterialNode.js +9 -9
- package/src/nodes/accessors/ModelViewProjectionNode.js +1 -1
- package/src/nodes/accessors/Normal.js +6 -2
- package/src/nodes/accessors/Object3DNode.js +0 -1
- package/src/nodes/accessors/Position.js +6 -6
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -4
- package/src/nodes/accessors/ReferenceNode.js +2 -3
- package/src/nodes/accessors/StorageBufferNode.js +42 -5
- package/src/nodes/accessors/Tangent.js +2 -2
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -5
- package/src/nodes/accessors/UniformArrayNode.js +9 -3
- package/src/nodes/accessors/VelocityNode.js +0 -2
- package/src/nodes/code/ScriptableNode.js +3 -3
- package/src/nodes/core/ArrayNode.js +125 -0
- package/src/nodes/core/ConstNode.js +8 -0
- package/src/nodes/core/Node.js +14 -1
- package/src/nodes/core/NodeBuilder.js +229 -19
- package/src/nodes/core/NodeUtils.js +11 -1
- package/src/nodes/core/NodeVar.js +17 -1
- package/src/nodes/core/OutputStructNode.js +19 -9
- package/src/nodes/core/StackNode.js +20 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +82 -21
- package/src/nodes/core/TempNode.js +1 -1
- package/src/nodes/core/VarNode.js +94 -7
- package/src/nodes/core/VaryingNode.js +19 -3
- package/src/nodes/display/BlendModes.js +88 -1
- package/src/nodes/display/BumpMapNode.js +6 -6
- package/src/nodes/display/NormalMapNode.js +6 -6
- package/src/nodes/display/PassNode.js +3 -1
- package/src/nodes/display/ScreenNode.js +9 -0
- package/src/nodes/fog/Fog.js +17 -0
- package/src/nodes/gpgpu/AtomicFunctionNode.js +20 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +8 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +8 -1
- package/src/nodes/math/MathNode.js +14 -1
- package/src/nodes/math/OperatorNode.js +96 -18
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/LoopNode.js +8 -1
- package/src/nodes/utils/MemberNode.js +68 -0
- package/src/nodes/utils/StorageArrayElementNode.js +14 -0
- package/src/nodes/utils/Timer.js +21 -0
- package/src/objects/BatchedMesh.js +1 -1
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +7 -0
- package/src/renderers/common/Animation.js +23 -1
- package/src/renderers/common/Backend.js +58 -15
- package/src/renderers/common/Background.js +14 -0
- package/src/renderers/common/Binding.js +1 -1
- package/src/renderers/common/BufferUtils.js +1 -1
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +9 -7
- package/src/renderers/common/ClippingContext.js +1 -1
- package/src/renderers/common/Color4.js +7 -3
- package/src/renderers/common/Geometries.js +2 -23
- package/src/renderers/common/Info.js +1 -45
- package/src/renderers/common/Lighting.js +8 -6
- package/src/renderers/common/Pipelines.js +3 -3
- package/src/renderers/common/PostProcessing.js +24 -8
- package/src/renderers/common/QuadMesh.js +1 -1
- package/src/renderers/common/RenderBundles.js +9 -3
- package/src/renderers/common/RenderContext.js +37 -3
- package/src/renderers/common/RenderContexts.js +30 -17
- package/src/renderers/common/RenderList.js +2 -2
- package/src/renderers/common/RenderLists.js +9 -3
- package/src/renderers/common/RenderObject.js +76 -17
- package/src/renderers/common/RenderObjects.js +9 -7
- package/src/renderers/common/Renderer.js +86 -67
- package/src/renderers/common/SampledTexture.js +0 -1
- package/src/renderers/common/StorageBufferAttribute.js +1 -1
- package/src/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/src/renderers/common/StorageTexture.js +1 -1
- package/src/renderers/common/Textures.js +14 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +37 -1
- package/src/renderers/common/UniformsGroup.js +2 -0
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +53 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -1
- package/src/renderers/common/nodes/NodeUniform.js +54 -2
- package/src/renderers/common/nodes/Nodes.js +25 -18
- package/src/renderers/webgl/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +295 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -17
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +57 -0
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +167 -21
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +132 -149
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +6 -4
- package/src/renderers/webgpu/WebGPURenderer.js +5 -4
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +615 -41
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +85 -6
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +85 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +257 -9
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +86 -4
- package/src/renderers/webxr/WebXRManager.js +13 -2
- package/src/textures/VideoFrameTexture.js +35 -0
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -209
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -37
|
@@ -1,10 +1,40 @@
|
|
|
1
|
+
|
|
1
2
|
import Node from './Node.js';
|
|
3
|
+
import { getLengthFromType } from './NodeUtils.js';
|
|
4
|
+
|
|
5
|
+
/** @module StructTypeNode **/
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* Generates a layout for struct members.
|
|
9
|
+
* This function takes an object representing struct members and returns an array of member layouts.
|
|
10
|
+
* Each member layout includes the member's name, type, and whether it is atomic.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object.<string, string|Object>} members - An object where keys are member names and values are either types (as strings) or objects with type and atomic properties.
|
|
13
|
+
* @returns {Array.<{name: string, type: string, atomic: boolean}>} An array of member layouts.
|
|
14
|
+
*/
|
|
15
|
+
function getMembersLayout( members ) {
|
|
16
|
+
|
|
17
|
+
return Object.entries( members ).map( ( [ name, value ] ) => {
|
|
18
|
+
|
|
19
|
+
if ( typeof value === 'string' ) {
|
|
20
|
+
|
|
21
|
+
return { name, type: value, atomic: false };
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { name, type: value.type, atomic: value.atomic || false };
|
|
26
|
+
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents a struct type node in the node-based system.
|
|
33
|
+
* This class is used to define and manage the layout and types of struct members.
|
|
34
|
+
* It extends the base Node class and provides methods to get the length of the struct,
|
|
35
|
+
* retrieve member types, and generate the struct type for a builder.
|
|
36
|
+
*
|
|
37
|
+
* @augments Node
|
|
8
38
|
*/
|
|
9
39
|
class StructTypeNode extends Node {
|
|
10
40
|
|
|
@@ -15,29 +45,29 @@ class StructTypeNode extends Node {
|
|
|
15
45
|
}
|
|
16
46
|
|
|
17
47
|
/**
|
|
18
|
-
*
|
|
48
|
+
* Creates an instance of StructTypeNode.
|
|
19
49
|
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
50
|
+
* @param {Object} membersLayout - The layout of the members for the struct.
|
|
51
|
+
* @param {string} [name=null] - The optional name of the struct.
|
|
22
52
|
*/
|
|
23
|
-
constructor(
|
|
53
|
+
constructor( membersLayout, name = null ) {
|
|
24
54
|
|
|
25
|
-
super();
|
|
55
|
+
super( 'struct' );
|
|
26
56
|
|
|
27
57
|
/**
|
|
28
|
-
* The
|
|
58
|
+
* The layout of the members for the struct
|
|
29
59
|
*
|
|
30
|
-
* @type {
|
|
60
|
+
* @type {Array.<{name: string, type: string, atomic: boolean}>}
|
|
31
61
|
*/
|
|
32
|
-
this.
|
|
33
|
-
|
|
62
|
+
this.membersLayout = getMembersLayout( membersLayout );
|
|
34
63
|
|
|
35
64
|
/**
|
|
36
|
-
*
|
|
65
|
+
* The name of the struct.
|
|
37
66
|
*
|
|
38
|
-
* @type {
|
|
67
|
+
* @type {String}
|
|
68
|
+
* @default null
|
|
39
69
|
*/
|
|
40
|
-
this.
|
|
70
|
+
this.name = name;
|
|
41
71
|
|
|
42
72
|
/**
|
|
43
73
|
* This flag can be used for type testing.
|
|
@@ -46,18 +76,49 @@ class StructTypeNode extends Node {
|
|
|
46
76
|
* @readonly
|
|
47
77
|
* @default true
|
|
48
78
|
*/
|
|
49
|
-
this.
|
|
79
|
+
this.isStructLayoutNode = true;
|
|
50
80
|
|
|
51
81
|
}
|
|
52
82
|
|
|
53
83
|
/**
|
|
54
|
-
* Returns the
|
|
84
|
+
* Returns the length of the struct.
|
|
85
|
+
* The length is calculated by summing the lengths of the struct's members.
|
|
55
86
|
*
|
|
56
|
-
* @
|
|
87
|
+
* @returns {Number} The length of the struct.
|
|
57
88
|
*/
|
|
58
|
-
|
|
89
|
+
getLength() {
|
|
90
|
+
|
|
91
|
+
let length = 0;
|
|
92
|
+
|
|
93
|
+
for ( const member of this.membersLayout ) {
|
|
94
|
+
|
|
95
|
+
length += getLengthFromType( member.type );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return length;
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getMemberType( builder, name ) {
|
|
104
|
+
|
|
105
|
+
const member = this.membersLayout.find( m => m.name === name );
|
|
106
|
+
|
|
107
|
+
return member ? member.type : 'void';
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getNodeType( builder ) {
|
|
112
|
+
|
|
113
|
+
const structType = builder.getStructTypeFromNode( this, this.membersLayout, this.name );
|
|
114
|
+
|
|
115
|
+
return structType.name;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
generate( builder ) {
|
|
59
120
|
|
|
60
|
-
return this.
|
|
121
|
+
return this.getNodeType( builder );
|
|
61
122
|
|
|
62
123
|
}
|
|
63
124
|
|
|
@@ -68,7 +68,7 @@ class TempNode extends Node {
|
|
|
68
68
|
const nodeVar = builder.getVarFromNode( this, null, type );
|
|
69
69
|
const propertyName = builder.getPropertyName( nodeVar );
|
|
70
70
|
|
|
71
|
-
builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
|
|
71
|
+
builder.addLineFlowCode( `${ propertyName } = ${ snippet }`, this );
|
|
72
72
|
|
|
73
73
|
nodeData.snippet = snippet;
|
|
74
74
|
nodeData.propertyName = propertyName;
|
|
@@ -26,8 +26,9 @@ class VarNode extends Node {
|
|
|
26
26
|
*
|
|
27
27
|
* @param {Node} node - The node for which a variable should be created.
|
|
28
28
|
* @param {String?} name - The name of the variable in the shader.
|
|
29
|
+
* @param {Boolean?} readOnly - The read-only flag.
|
|
29
30
|
*/
|
|
30
|
-
constructor( node, name = null ) {
|
|
31
|
+
constructor( node, name = null, readOnly = false ) {
|
|
31
32
|
|
|
32
33
|
super();
|
|
33
34
|
|
|
@@ -64,6 +65,15 @@ class VarNode extends Node {
|
|
|
64
65
|
*/
|
|
65
66
|
this.isVarNode = true;
|
|
66
67
|
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* The read-only flag.
|
|
71
|
+
*
|
|
72
|
+
* @type {Boolean}
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
this.readOnly = readOnly;
|
|
76
|
+
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
getHash( builder ) {
|
|
@@ -72,6 +82,18 @@ class VarNode extends Node {
|
|
|
72
82
|
|
|
73
83
|
}
|
|
74
84
|
|
|
85
|
+
getMemberType( builder, name ) {
|
|
86
|
+
|
|
87
|
+
return this.node.getMemberType( builder, name );
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getElementType( builder ) {
|
|
92
|
+
|
|
93
|
+
return this.node.getElementType( builder );
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
75
97
|
getNodeType( builder ) {
|
|
76
98
|
|
|
77
99
|
return this.node.getNodeType( builder );
|
|
@@ -80,15 +102,50 @@ class VarNode extends Node {
|
|
|
80
102
|
|
|
81
103
|
generate( builder ) {
|
|
82
104
|
|
|
83
|
-
const { node, name } = this;
|
|
105
|
+
const { node, name, readOnly } = this;
|
|
106
|
+
const { renderer } = builder;
|
|
107
|
+
|
|
108
|
+
const isWebGPUBackend = renderer.backend.isWebGPUBackend === true;
|
|
109
|
+
|
|
110
|
+
let isDeterministic = false;
|
|
111
|
+
let shouldTreatAsReadOnly = false;
|
|
112
|
+
|
|
113
|
+
if ( readOnly ) {
|
|
114
|
+
|
|
115
|
+
isDeterministic = builder.isDeterministic( node );
|
|
116
|
+
|
|
117
|
+
shouldTreatAsReadOnly = isWebGPUBackend ? readOnly : isDeterministic;
|
|
84
118
|
|
|
85
|
-
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const vectorType = builder.getVectorType( this.getNodeType( builder ) );
|
|
122
|
+
const snippet = node.build( builder, vectorType );
|
|
123
|
+
|
|
124
|
+
const nodeVar = builder.getVarFromNode( this, name, vectorType, undefined, shouldTreatAsReadOnly );
|
|
86
125
|
|
|
87
126
|
const propertyName = builder.getPropertyName( nodeVar );
|
|
88
127
|
|
|
89
|
-
|
|
128
|
+
let declarationPrefix = propertyName;
|
|
129
|
+
|
|
130
|
+
if ( shouldTreatAsReadOnly ) {
|
|
131
|
+
|
|
132
|
+
if ( isWebGPUBackend ) {
|
|
133
|
+
|
|
134
|
+
declarationPrefix = isDeterministic
|
|
135
|
+
? `const ${ propertyName }`
|
|
136
|
+
: `let ${ propertyName }`;
|
|
137
|
+
|
|
138
|
+
} else {
|
|
90
139
|
|
|
91
|
-
|
|
140
|
+
const count = builder.getArrayCount( node );
|
|
141
|
+
|
|
142
|
+
declarationPrefix = `const ${ builder.getVar( nodeVar.type, propertyName, count ) }`;
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
builder.addLineFlowCode( `${ declarationPrefix } = ${ snippet }`, this );
|
|
92
149
|
|
|
93
150
|
return propertyName;
|
|
94
151
|
|
|
@@ -108,13 +165,43 @@ export default VarNode;
|
|
|
108
165
|
*/
|
|
109
166
|
const createVar = /*@__PURE__*/ nodeProxy( VarNode );
|
|
110
167
|
|
|
111
|
-
|
|
168
|
+
/**
|
|
169
|
+
* TSL function for creating a var node.
|
|
170
|
+
*
|
|
171
|
+
* @function
|
|
172
|
+
* @param {Node} node - The node for which a variable should be created.
|
|
173
|
+
* @param {String?} name - The name of the variable in the shader.
|
|
174
|
+
* @returns {VarNode}
|
|
175
|
+
*/
|
|
176
|
+
export const Var = ( node, name = null ) => createVar( node, name ).append();
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* TSL function for creating a const node.
|
|
180
|
+
*
|
|
181
|
+
* @function
|
|
182
|
+
* @param {Node} node - The node for which a constant should be created.
|
|
183
|
+
* @param {String?} name - The name of the constant in the shader.
|
|
184
|
+
* @returns {VarNode}
|
|
185
|
+
*/
|
|
186
|
+
export const Const = ( node, name = null ) => createVar( node, name, true ).append();
|
|
187
|
+
|
|
188
|
+
// Method chaining
|
|
189
|
+
|
|
190
|
+
addMethodChaining( 'toVar', Var );
|
|
191
|
+
addMethodChaining( 'toConst', Const );
|
|
112
192
|
|
|
113
193
|
// Deprecated
|
|
114
194
|
|
|
195
|
+
/**
|
|
196
|
+
* @function
|
|
197
|
+
* @deprecated since r170. Use `Var( node )` or `node.toVar()` instead.
|
|
198
|
+
*
|
|
199
|
+
* @param {Any} node
|
|
200
|
+
* @returns {VarNode}
|
|
201
|
+
*/
|
|
115
202
|
export const temp = ( node ) => { // @deprecated, r170
|
|
116
203
|
|
|
117
|
-
console.warn( 'TSL: "temp" is deprecated. Use ".toVar()" instead.' );
|
|
204
|
+
console.warn( 'TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.' );
|
|
118
205
|
|
|
119
206
|
return createVar( node );
|
|
120
207
|
|
|
@@ -9,7 +9,7 @@ import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
|
9
9
|
* existing nodes like the following:
|
|
10
10
|
*
|
|
11
11
|
* ```js
|
|
12
|
-
* const positionLocal = positionGeometry.
|
|
12
|
+
* const positionLocal = positionGeometry.toVarying( 'vPositionLocal' );
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
* @augments Node
|
|
@@ -185,5 +185,21 @@ export const varying = /*@__PURE__*/ nodeProxy( VaryingNode );
|
|
|
185
185
|
*/
|
|
186
186
|
export const vertexStage = ( node ) => varying( node );
|
|
187
187
|
|
|
188
|
-
addMethodChaining( '
|
|
189
|
-
addMethodChaining( '
|
|
188
|
+
addMethodChaining( 'toVarying', varying );
|
|
189
|
+
addMethodChaining( 'toVertexStage', vertexStage );
|
|
190
|
+
|
|
191
|
+
// Deprecated
|
|
192
|
+
|
|
193
|
+
addMethodChaining( 'varying', ( ...params ) => { // @deprecated, r173
|
|
194
|
+
|
|
195
|
+
console.warn( 'TSL.VaryingNode: .varying() has been renamed to .toVarying().' );
|
|
196
|
+
return varying( ...params );
|
|
197
|
+
|
|
198
|
+
} );
|
|
199
|
+
|
|
200
|
+
addMethodChaining( 'vertexStage', ( ...params ) => { // @deprecated, r173
|
|
201
|
+
|
|
202
|
+
console.warn( 'TSL.VaryingNode: .vertexStage() has been renamed to .toVertexStage().' );
|
|
203
|
+
return varying( ...params );
|
|
204
|
+
|
|
205
|
+
} );
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { Fn, vec4 } from '../tsl/TSLBase.js';
|
|
2
2
|
import { mix, min, step } from '../math/MathNode.js';
|
|
3
3
|
|
|
4
|
+
/** @module BlendModes **/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a "Color Burn" blend mode.
|
|
8
|
+
*
|
|
9
|
+
* It's designed to darken the base layer's colors based on the color of the blend layer.
|
|
10
|
+
* It significantly increases the contrast of the base layer, making the colors more vibrant and saturated.
|
|
11
|
+
* The darker the color in the blend layer, the stronger the darkening and contrast effect on the base layer.
|
|
12
|
+
*
|
|
13
|
+
* @method
|
|
14
|
+
* @param {Node<vec3>} base - The base color.
|
|
15
|
+
* @param {Node<vec3>} blend - The blend color. A white (#ffffff) blend color does not alter the base color.
|
|
16
|
+
* @return {Node<vec3>} The result.
|
|
17
|
+
*/
|
|
4
18
|
export const blendBurn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
5
19
|
|
|
6
20
|
return min( 1.0, base.oneMinus().div( blend ) ).oneMinus();
|
|
@@ -14,6 +28,18 @@ export const blendBurn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
|
14
28
|
]
|
|
15
29
|
} );
|
|
16
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Represents a "Color Dodge" blend mode.
|
|
33
|
+
*
|
|
34
|
+
* It's designed to lighten the base layer's colors based on the color of the blend layer.
|
|
35
|
+
* It significantly increases the brightness of the base layer, making the colors lighter and more vibrant.
|
|
36
|
+
* The brighter the color in the blend layer, the stronger the lightening and contrast effect on the base layer.
|
|
37
|
+
*
|
|
38
|
+
* @method
|
|
39
|
+
* @param {Node<vec3>} base - The base color.
|
|
40
|
+
* @param {Node<vec3>} blend - The blend color. A black (#000000) blend color does not alter the base color.
|
|
41
|
+
* @return {Node<vec3>} The result.
|
|
42
|
+
*/
|
|
17
43
|
export const blendDodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
18
44
|
|
|
19
45
|
return min( base.div( blend.oneMinus() ), 1.0 );
|
|
@@ -27,6 +53,18 @@ export const blendDodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
|
27
53
|
]
|
|
28
54
|
} );
|
|
29
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Represents a "Screen" blend mode.
|
|
58
|
+
*
|
|
59
|
+
* Similar to `blendDodge()`, this mode also lightens the base layer's colors based on the color of the blend layer.
|
|
60
|
+
* The "Screen" blend mode is better for general brightening whereas the "Dodge" results in more subtle and nuanced
|
|
61
|
+
* effects.
|
|
62
|
+
*
|
|
63
|
+
* @method
|
|
64
|
+
* @param {Node<vec3>} base - The base color.
|
|
65
|
+
* @param {Node<vec3>} blend - The blend color. A black (#000000) blend color does not alter the base color.
|
|
66
|
+
* @return {Node<vec3>} The result.
|
|
67
|
+
*/
|
|
30
68
|
export const blendScreen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
31
69
|
|
|
32
70
|
return base.oneMinus().mul( blend.oneMinus() ).oneMinus();
|
|
@@ -40,6 +78,18 @@ export const blendScreen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
|
40
78
|
]
|
|
41
79
|
} );
|
|
42
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Represents a "Overlay" blend mode.
|
|
83
|
+
*
|
|
84
|
+
* It's designed to increase the contrast of the base layer based on the color of the blend layer.
|
|
85
|
+
* It amplifies the existing colors and contrast in the base layer, making lighter areas lighter and darker areas darker.
|
|
86
|
+
* The color of the blend layer significantly influences the resulting contrast and color shift in the base layer.
|
|
87
|
+
*
|
|
88
|
+
* @method
|
|
89
|
+
* @param {Node<vec3>} base - The base color.
|
|
90
|
+
* @param {Node<vec3>} blend - The blend color
|
|
91
|
+
* @return {Node<vec3>} The result.
|
|
92
|
+
*/
|
|
43
93
|
export const blendOverlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
44
94
|
|
|
45
95
|
return mix( base.mul( 2.0 ).mul( blend ), base.oneMinus().mul( 2.0 ).mul( blend.oneMinus() ).oneMinus(), step( 0.5, base ) );
|
|
@@ -53,6 +103,15 @@ export const blendOverlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
|
53
103
|
]
|
|
54
104
|
} );
|
|
55
105
|
|
|
106
|
+
/**
|
|
107
|
+
* This function blends two color based on their alpha values by replicating the behavior of `THREE.NormalBlending`.
|
|
108
|
+
* It assumes both input colors have non-preumiltiplied alpha.
|
|
109
|
+
*
|
|
110
|
+
* @method
|
|
111
|
+
* @param {Node<vec4>} base - The base color.
|
|
112
|
+
* @param {Node<vec4>} blend - The blend color
|
|
113
|
+
* @return {Node<vec4>} The result.
|
|
114
|
+
*/
|
|
56
115
|
export const blendColor = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
57
116
|
|
|
58
117
|
const outAlpha = blend.a.add( base.a.mul( blend.a.oneMinus() ) );
|
|
@@ -68,8 +127,15 @@ export const blendColor = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
|
68
127
|
]
|
|
69
128
|
} );
|
|
70
129
|
|
|
71
|
-
//
|
|
130
|
+
// Deprecated
|
|
72
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @function
|
|
134
|
+
* @deprecated since r171. Use {@link blendBurn} instead.
|
|
135
|
+
*
|
|
136
|
+
* @param {...any} params
|
|
137
|
+
* @returns {Function}
|
|
138
|
+
*/
|
|
73
139
|
export const burn = ( ...params ) => { // @deprecated, r171
|
|
74
140
|
|
|
75
141
|
console.warn( 'THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.' );
|
|
@@ -77,6 +143,13 @@ export const burn = ( ...params ) => { // @deprecated, r171
|
|
|
77
143
|
|
|
78
144
|
};
|
|
79
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @function
|
|
148
|
+
* @deprecated since r171. Use {@link blendDodge} instead.
|
|
149
|
+
*
|
|
150
|
+
* @param {...any} params
|
|
151
|
+
* @returns {Function}
|
|
152
|
+
*/
|
|
80
153
|
export const dodge = ( ...params ) => { // @deprecated, r171
|
|
81
154
|
|
|
82
155
|
console.warn( 'THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.' );
|
|
@@ -84,6 +157,13 @@ export const dodge = ( ...params ) => { // @deprecated, r171
|
|
|
84
157
|
|
|
85
158
|
};
|
|
86
159
|
|
|
160
|
+
/**
|
|
161
|
+
* @method
|
|
162
|
+
* @deprecated since r171. Use {@link blendScreen} instead.
|
|
163
|
+
*
|
|
164
|
+
* @param {...any} params
|
|
165
|
+
* @returns {Function}
|
|
166
|
+
*/
|
|
87
167
|
export const screen = ( ...params ) => { // @deprecated, r171
|
|
88
168
|
|
|
89
169
|
console.warn( 'THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.' );
|
|
@@ -91,6 +171,13 @@ export const screen = ( ...params ) => { // @deprecated, r171
|
|
|
91
171
|
|
|
92
172
|
};
|
|
93
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @method
|
|
176
|
+
* @deprecated since r171. Use {@link blendOverlay} instead.
|
|
177
|
+
*
|
|
178
|
+
* @param {...any} params
|
|
179
|
+
* @returns {Function}
|
|
180
|
+
*/
|
|
94
181
|
export const overlay = ( ...params ) => { // @deprecated, r171
|
|
95
182
|
|
|
96
183
|
console.warn( 'THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.' );
|
|
@@ -66,8 +66,8 @@ class BumpMapNode extends TempNode {
|
|
|
66
66
|
/**
|
|
67
67
|
* Constructs a new bump map node.
|
|
68
68
|
*
|
|
69
|
-
* @param {Node} textureNode - Represents the bump map data.
|
|
70
|
-
* @param {Node
|
|
69
|
+
* @param {Node<float>} textureNode - Represents the bump map data.
|
|
70
|
+
* @param {Node<float>?} [scaleNode=null] - Controls the intensity of the bump effect.
|
|
71
71
|
*/
|
|
72
72
|
constructor( textureNode, scaleNode = null ) {
|
|
73
73
|
|
|
@@ -76,14 +76,14 @@ class BumpMapNode extends TempNode {
|
|
|
76
76
|
/**
|
|
77
77
|
* Represents the bump map data.
|
|
78
78
|
*
|
|
79
|
-
* @type {Node}
|
|
79
|
+
* @type {Node<float>}
|
|
80
80
|
*/
|
|
81
81
|
this.textureNode = textureNode;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Controls the intensity of the bump effect.
|
|
85
85
|
*
|
|
86
|
-
* @type {Node
|
|
86
|
+
* @type {Node<float>?}
|
|
87
87
|
* @default null
|
|
88
88
|
*/
|
|
89
89
|
this.scaleNode = scaleNode;
|
|
@@ -111,8 +111,8 @@ export default BumpMapNode;
|
|
|
111
111
|
* TSL function for creating a bump map node.
|
|
112
112
|
*
|
|
113
113
|
* @function
|
|
114
|
-
* @param {Node} textureNode - Represents the bump map data.
|
|
115
|
-
* @param {Node
|
|
114
|
+
* @param {Node<float>} textureNode - Represents the bump map data.
|
|
115
|
+
* @param {Node<float>?} [scaleNode=null] - Controls the intensity of the bump effect.
|
|
116
116
|
* @returns {BumpMapNode}
|
|
117
117
|
*/
|
|
118
118
|
export const bumpMap = /*@__PURE__*/ nodeProxy( BumpMapNode );
|
|
@@ -59,8 +59,8 @@ class NormalMapNode extends TempNode {
|
|
|
59
59
|
/**
|
|
60
60
|
* Constructs a new normal map node.
|
|
61
61
|
*
|
|
62
|
-
* @param {Node} node - Represents the normal map data.
|
|
63
|
-
* @param {Node
|
|
62
|
+
* @param {Node<vec3>} node - Represents the normal map data.
|
|
63
|
+
* @param {Node<vec2>?} [scaleNode=null] - Controls the intensity of the effect.
|
|
64
64
|
*/
|
|
65
65
|
constructor( node, scaleNode = null ) {
|
|
66
66
|
|
|
@@ -69,14 +69,14 @@ class NormalMapNode extends TempNode {
|
|
|
69
69
|
/**
|
|
70
70
|
* Represents the normal map data.
|
|
71
71
|
*
|
|
72
|
-
* @type {Node}
|
|
72
|
+
* @type {Node<vec3>}
|
|
73
73
|
*/
|
|
74
74
|
this.node = node;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Controls the intensity of the effect.
|
|
78
78
|
*
|
|
79
|
-
* @type {Node
|
|
79
|
+
* @type {Node<vec2>?}
|
|
80
80
|
* @default null
|
|
81
81
|
*/
|
|
82
82
|
this.scaleNode = scaleNode;
|
|
@@ -142,8 +142,8 @@ export default NormalMapNode;
|
|
|
142
142
|
* TSL function for creating a normal map node.
|
|
143
143
|
*
|
|
144
144
|
* @function
|
|
145
|
-
* @param {Node} node - Represents the normal map data.
|
|
146
|
-
* @param {Node
|
|
145
|
+
* @param {Node<vec3>} node - Represents the normal map data.
|
|
146
|
+
* @param {Node<vec2>?} [scaleNode=null] - Controls the intensity of the effect.
|
|
147
147
|
* @returns {NormalMapNode}
|
|
148
148
|
*/
|
|
149
149
|
export const normalMap = /*@__PURE__*/ nodeProxy( NormalMapNode );
|
|
@@ -546,13 +546,15 @@ class PassNode extends TempNode {
|
|
|
546
546
|
|
|
547
547
|
this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples;
|
|
548
548
|
|
|
549
|
-
// Disable MSAA for WebGL backend for now
|
|
549
|
+
// TODO: Disable MSAA for WebGL backend for now
|
|
550
550
|
if ( renderer.backend.isWebGLBackend === true ) {
|
|
551
551
|
|
|
552
552
|
this.renderTarget.samples = 0;
|
|
553
553
|
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
+
this.renderTarget.texture.type = renderer.getColorBufferType();
|
|
557
|
+
|
|
556
558
|
return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode();
|
|
557
559
|
|
|
558
560
|
}
|
|
@@ -243,6 +243,9 @@ export const viewportUV = /*@__PURE__*/ viewportCoordinate.div( viewportSize );
|
|
|
243
243
|
|
|
244
244
|
// Deprecated
|
|
245
245
|
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated since r169. Use {@link screenSize} instead.
|
|
248
|
+
*/
|
|
246
249
|
export const viewportResolution = /*@__PURE__*/ ( Fn( () => { // @deprecated, r169
|
|
247
250
|
|
|
248
251
|
console.warn( 'TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.' );
|
|
@@ -251,6 +254,9 @@ export const viewportResolution = /*@__PURE__*/ ( Fn( () => { // @deprecated, r1
|
|
|
251
254
|
|
|
252
255
|
}, 'vec2' ).once() )();
|
|
253
256
|
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated since r168. Use {@link screenUV} instead.
|
|
259
|
+
*/
|
|
254
260
|
export const viewportTopLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168
|
|
255
261
|
|
|
256
262
|
console.warn( 'TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.' );
|
|
@@ -259,6 +265,9 @@ export const viewportTopLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168
|
|
|
259
265
|
|
|
260
266
|
}, 'vec2' ).once() )();
|
|
261
267
|
|
|
268
|
+
/**
|
|
269
|
+
* @deprecated since r168. Use `screenUV.flipY()` instead.
|
|
270
|
+
*/
|
|
262
271
|
export const viewportBottomLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168
|
|
263
272
|
|
|
264
273
|
console.warn( 'TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.' );
|
package/src/nodes/fog/Fog.js
CHANGED
|
@@ -78,6 +78,15 @@ export const fog = Fn( ( [ color, factor ] ) => {
|
|
|
78
78
|
|
|
79
79
|
// Deprecated
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @function
|
|
83
|
+
* @deprecated since r171. Use `fog( color, rangeFogFactor( near, far ) )` instead.
|
|
84
|
+
*
|
|
85
|
+
* @param {Node} color
|
|
86
|
+
* @param {Node} near
|
|
87
|
+
* @param {Node} far
|
|
88
|
+
* @returns {Function}
|
|
89
|
+
*/
|
|
81
90
|
export function rangeFog( color, near, far ) { // @deprecated, r171
|
|
82
91
|
|
|
83
92
|
console.warn( 'THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.' );
|
|
@@ -85,6 +94,14 @@ export function rangeFog( color, near, far ) { // @deprecated, r171
|
|
|
85
94
|
|
|
86
95
|
}
|
|
87
96
|
|
|
97
|
+
/**
|
|
98
|
+
* @function
|
|
99
|
+
* @deprecated since r171. Use `fog( color, densityFogFactor( density ) )` instead.
|
|
100
|
+
*
|
|
101
|
+
* @param {Node} color
|
|
102
|
+
* @param {Node} density
|
|
103
|
+
* @returns {Function}
|
|
104
|
+
*/
|
|
88
105
|
export function densityFog( color, density ) { // @deprecated, r171
|
|
89
106
|
|
|
90
107
|
console.warn( 'THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.' );
|
|
@@ -5,10 +5,10 @@ import { nodeProxy } from '../tsl/TSLCore.js';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* `AtomicFunctionNode` represents any function that can operate on atomic variable types
|
|
8
|
-
* within a shader. In an atomic function, any
|
|
9
|
-
* occur as an
|
|
8
|
+
* within a shader. In an atomic function, any modification to an atomic variable will
|
|
9
|
+
* occur as an indivisible step with a defined order relative to other modifications.
|
|
10
10
|
* Accordingly, even if multiple atomic functions are modifying an atomic variable at once
|
|
11
|
-
* atomic operations will not
|
|
11
|
+
* atomic operations will not interfere with each other.
|
|
12
12
|
*
|
|
13
13
|
* This node can only be used with a WebGPU backend.
|
|
14
14
|
*
|
|
@@ -103,7 +103,13 @@ class AtomicFunctionNode extends TempNode {
|
|
|
103
103
|
const params = [];
|
|
104
104
|
|
|
105
105
|
params.push( `&${ a.build( builder, inputType ) }` );
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
if ( b !== null ) {
|
|
108
|
+
|
|
109
|
+
params.push( b.build( builder, inputType ) );
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
}
|
|
107
113
|
|
|
108
114
|
const methodSnippet = `${ builder.getMethod( method, type ) }( ${params.join( ', ' )} )`;
|
|
109
115
|
|
|
@@ -166,6 +172,16 @@ export const atomicFunc = ( method, pointerNode, valueNode, storeNode = null ) =
|
|
|
166
172
|
|
|
167
173
|
};
|
|
168
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Loads the value stored in the atomic variable.
|
|
177
|
+
*
|
|
178
|
+
* @function
|
|
179
|
+
* @param {Node} pointerNode - An atomic variable or element of an atomic buffer.
|
|
180
|
+
* @param {Node?} [storeNode=null] - A variable storing the return value of an atomic operation, typically the value of the atomic variable before the operation.
|
|
181
|
+
* @returns {AtomicFunctionNode}
|
|
182
|
+
*/
|
|
183
|
+
export const atomicLoad = ( pointerNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_LOAD, pointerNode, null, storeNode );
|
|
184
|
+
|
|
169
185
|
/**
|
|
170
186
|
* Stores a value in the atomic variable.
|
|
171
187
|
*
|