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
|
@@ -26,7 +26,7 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
26
26
|
/**
|
|
27
27
|
* Constructs a new reference element node.
|
|
28
28
|
*
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {ReferenceBaseNode?} referenceNode - The reference node.
|
|
30
30
|
* @param {Node} indexNode - The index node that defines the element access.
|
|
31
31
|
*/
|
|
32
32
|
constructor( referenceNode, indexNode ) {
|
|
@@ -37,7 +37,7 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
37
37
|
* Similar to {@link module:ReferenceBaseNode~ReferenceBaseNode#reference}, an additional
|
|
38
38
|
* property references to the current node.
|
|
39
39
|
*
|
|
40
|
-
* @type {
|
|
40
|
+
* @type {ReferenceBaseNode?}
|
|
41
41
|
* @default null
|
|
42
42
|
*/
|
|
43
43
|
this.referenceNode = referenceNode;
|
|
@@ -57,7 +57,6 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
57
57
|
* This method is overwritten since the node type is inferred from
|
|
58
58
|
* the uniform type of the reference node.
|
|
59
59
|
*
|
|
60
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
61
60
|
* @return {String} The node type.
|
|
62
61
|
*/
|
|
63
62
|
getNodeType() {
|
|
@@ -286,7 +285,6 @@ class ReferenceBaseNode extends Node {
|
|
|
286
285
|
/**
|
|
287
286
|
* The output of the reference node is the internal uniform node.
|
|
288
287
|
*
|
|
289
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
290
288
|
* @return {UniformNode} The output node.
|
|
291
289
|
*/
|
|
292
290
|
setup() {
|
|
@@ -30,7 +30,7 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
30
30
|
/**
|
|
31
31
|
* Constructs a new reference element node.
|
|
32
32
|
*
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {ReferenceNode?} referenceNode - The reference node.
|
|
34
34
|
* @param {Node} indexNode - The index node that defines the element access.
|
|
35
35
|
*/
|
|
36
36
|
constructor( referenceNode, indexNode ) {
|
|
@@ -41,7 +41,7 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
41
41
|
* Similar to {@link module:ReferenceNode~ReferenceNode#reference}, an additional
|
|
42
42
|
* property references to the current node.
|
|
43
43
|
*
|
|
44
|
-
* @type {
|
|
44
|
+
* @type {ReferenceNode?}
|
|
45
45
|
* @default null
|
|
46
46
|
*/
|
|
47
47
|
this.referenceNode = referenceNode;
|
|
@@ -61,7 +61,6 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
61
61
|
* This method is overwritten since the node type is inferred from
|
|
62
62
|
* the uniform type of the reference node.
|
|
63
63
|
*
|
|
64
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
65
64
|
* @return {String} The node type.
|
|
66
65
|
*/
|
|
67
66
|
getNodeType() {
|
|
@@ -50,19 +50,30 @@ class StorageBufferNode extends BufferNode {
|
|
|
50
50
|
* Constructs a new storage buffer node.
|
|
51
51
|
*
|
|
52
52
|
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
53
|
-
* @param {String?} [bufferType=null] - The buffer type (e.g. `'vec3'`).
|
|
53
|
+
* @param {(String|Struct)?} [bufferType=null] - The buffer type (e.g. `'vec3'`).
|
|
54
54
|
* @param {Number} [bufferCount=0] - The buffer count.
|
|
55
55
|
*/
|
|
56
56
|
constructor( value, bufferType = null, bufferCount = 0 ) {
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
let nodeType, structTypeNode = null;
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
if ( bufferType && bufferType.isStruct ) {
|
|
61
|
+
|
|
62
|
+
nodeType = 'struct';
|
|
63
|
+
structTypeNode = bufferType.layout;
|
|
64
|
+
|
|
65
|
+
} else if ( bufferType === null && ( value.isStorageBufferAttribute || value.isStorageInstancedBufferAttribute ) ) {
|
|
66
|
+
|
|
67
|
+
nodeType = getTypeFromLength( value.itemSize );
|
|
61
68
|
bufferCount = value.count;
|
|
62
69
|
|
|
70
|
+
} else {
|
|
71
|
+
|
|
72
|
+
nodeType = bufferType;
|
|
73
|
+
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
super( value,
|
|
76
|
+
super( value, nodeType, bufferCount );
|
|
66
77
|
|
|
67
78
|
/**
|
|
68
79
|
* This flag can be used for type testing.
|
|
@@ -73,6 +84,15 @@ class StorageBufferNode extends BufferNode {
|
|
|
73
84
|
*/
|
|
74
85
|
this.isStorageBufferNode = true;
|
|
75
86
|
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The buffer struct type.
|
|
90
|
+
*
|
|
91
|
+
* @type {structTypeNode?}
|
|
92
|
+
* @default null
|
|
93
|
+
*/
|
|
94
|
+
this.structTypeNode = structTypeNode;
|
|
95
|
+
|
|
76
96
|
/**
|
|
77
97
|
* The access type of the texture node.
|
|
78
98
|
*
|
|
@@ -293,6 +313,12 @@ class StorageBufferNode extends BufferNode {
|
|
|
293
313
|
*/
|
|
294
314
|
getNodeType( builder ) {
|
|
295
315
|
|
|
316
|
+
if ( this.structTypeNode !== null ) {
|
|
317
|
+
|
|
318
|
+
return this.structTypeNode.getNodeType( builder );
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
296
322
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
297
323
|
|
|
298
324
|
return super.getNodeType( builder );
|
|
@@ -313,6 +339,8 @@ class StorageBufferNode extends BufferNode {
|
|
|
313
339
|
*/
|
|
314
340
|
generate( builder ) {
|
|
315
341
|
|
|
342
|
+
if ( this.structTypeNode !== null ) this.structTypeNode.build( builder );
|
|
343
|
+
|
|
316
344
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
317
345
|
|
|
318
346
|
return super.generate( builder );
|
|
@@ -338,12 +366,21 @@ export default StorageBufferNode;
|
|
|
338
366
|
*
|
|
339
367
|
* @function
|
|
340
368
|
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
341
|
-
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
369
|
+
* @param {(String|Struct)?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
342
370
|
* @param {Number} [count=0] - The buffer count.
|
|
343
371
|
* @returns {StorageBufferNode}
|
|
344
372
|
*/
|
|
345
373
|
export const storage = ( value, type = null, count = 0 ) => nodeObject( new StorageBufferNode( value, type, count ) );
|
|
346
374
|
|
|
375
|
+
/**
|
|
376
|
+
* @function
|
|
377
|
+
* @deprecated since r171. Use `storage().setPBO( true )` instead.
|
|
378
|
+
*
|
|
379
|
+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
380
|
+
* @param {String?} type - The buffer type (e.g. `'vec3'`).
|
|
381
|
+
* @param {Number} count - The buffer count.
|
|
382
|
+
* @returns {StorageBufferNode}
|
|
383
|
+
*/
|
|
347
384
|
export const storageObject = ( value, type, count ) => { // @deprecated, r171
|
|
348
385
|
|
|
349
386
|
console.warn( 'THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.' );
|
|
@@ -34,14 +34,14 @@ export const tangentLocal = /*@__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLoc
|
|
|
34
34
|
*
|
|
35
35
|
* @type {Node<vec3>}
|
|
36
36
|
*/
|
|
37
|
-
export const tangentView = /*@__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.
|
|
37
|
+
export const tangentView = /*@__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.toVarying( 'v_tangentView' ).normalize().toVar( 'tangentView' );
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* TSL object that represents the vertex tangent in world space of the current rendered object.
|
|
41
41
|
*
|
|
42
42
|
* @type {Node<vec3>}
|
|
43
43
|
*/
|
|
44
|
-
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).
|
|
44
|
+
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).toVarying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* TSL object that represents the transformed vertex tangent in view space of the current rendered object.
|
|
@@ -115,7 +115,7 @@ class Texture3DNode extends TextureNode {
|
|
|
115
115
|
*
|
|
116
116
|
* @param {Boolean} value - The update toggle.
|
|
117
117
|
*/
|
|
118
|
-
setUpdateMatrix( /*
|
|
118
|
+
setUpdateMatrix( /*value*/ ) { } // Ignore .updateMatrix for 3d TextureNode
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* Overwrites the default implementation to return the unmodified uv node.
|
|
@@ -384,11 +384,11 @@ class TextureNode extends UniformNode {
|
|
|
384
384
|
* @param {NodeBuilder} builder - The current node builder.
|
|
385
385
|
* @param {String} textureProperty - The texture property.
|
|
386
386
|
* @param {String} uvSnippet - The uv snippet.
|
|
387
|
-
* @param {String} levelSnippet - The level snippet.
|
|
388
|
-
* @param {String} biasSnippet - The bias snippet.
|
|
389
|
-
* @param {String} depthSnippet - The depth snippet.
|
|
390
|
-
* @param {String} compareSnippet - The compare snippet.
|
|
391
|
-
* @param {String} gradSnippet - The grad snippet.
|
|
387
|
+
* @param {String?} levelSnippet - The level snippet.
|
|
388
|
+
* @param {String?} biasSnippet - The bias snippet.
|
|
389
|
+
* @param {String?} depthSnippet - The depth snippet.
|
|
390
|
+
* @param {String?} compareSnippet - The compare snippet.
|
|
391
|
+
* @param {Array<String>?} gradSnippet - The grad snippet.
|
|
392
392
|
* @return {String} The generated code snippet.
|
|
393
393
|
*/
|
|
394
394
|
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet ) {
|
|
@@ -521,6 +521,13 @@ class TextureNode extends UniformNode {
|
|
|
521
521
|
|
|
522
522
|
// @TODO: Move to TSL
|
|
523
523
|
|
|
524
|
+
/**
|
|
525
|
+
* @function
|
|
526
|
+
* @deprecated since r172. Use {@link TextureNode#sample} instead.
|
|
527
|
+
*
|
|
528
|
+
* @param {Node} uvNode - The uv node.
|
|
529
|
+
* @return {TextureNode} A texture node representing the texture sample.
|
|
530
|
+
*/
|
|
524
531
|
uv( uvNode ) { // @deprecated, r172
|
|
525
532
|
|
|
526
533
|
console.warn( 'THREE.TextureNode: .uv() has been renamed. Use .sample() instead.' );
|
|
@@ -343,13 +343,19 @@ export default UniformArrayNode;
|
|
|
343
343
|
*
|
|
344
344
|
* @function
|
|
345
345
|
* @param {Array<Any>} values - Array-like data.
|
|
346
|
-
* @param {String} nodeType - The data type of the array elements.
|
|
346
|
+
* @param {String?} nodeType - The data type of the array elements.
|
|
347
347
|
* @returns {UniformArrayNode}
|
|
348
348
|
*/
|
|
349
349
|
export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );
|
|
350
350
|
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
/**
|
|
352
|
+
* @function
|
|
353
|
+
* @deprecated since r168. Use {@link uniformArray} instead.
|
|
354
|
+
*
|
|
355
|
+
* @param {Array<Any>} values - Array-like data.
|
|
356
|
+
* @param {String} nodeType - The data type of the array elements.
|
|
357
|
+
* @returns {UniformArrayNode}
|
|
358
|
+
*/
|
|
353
359
|
export const uniforms = ( values, nodeType ) => { // @deprecated, r168
|
|
354
360
|
|
|
355
361
|
console.warn( 'TSL.UniformArrayNode: uniforms() has been renamed to uniformArray().' );
|
|
@@ -66,7 +66,7 @@ class Parameters {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* Defines the
|
|
69
|
+
* Defines the resources (e.g. namespaces) of scriptable nodes.
|
|
70
70
|
*
|
|
71
71
|
* @type {Resources}
|
|
72
72
|
*/
|
|
@@ -287,7 +287,7 @@ class ScriptableNode extends Node {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
|
-
* Returns a
|
|
290
|
+
* Returns a parameter for the given name
|
|
291
291
|
*
|
|
292
292
|
* @param {String} name - The name of the parameter.
|
|
293
293
|
* @return {ScriptableValueNode} The node value.
|
|
@@ -416,7 +416,7 @@ class ScriptableNode extends Node {
|
|
|
416
416
|
*
|
|
417
417
|
* @param {String} name - The function name.
|
|
418
418
|
* @param {...Any} params - A list of parameters.
|
|
419
|
-
* @return {Any} The result of the function call.
|
|
419
|
+
* @return {Promise<Any>} The result of the function call.
|
|
420
420
|
*/
|
|
421
421
|
async callAsync( name, ...params ) {
|
|
422
422
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import TempNode from './TempNode.js';
|
|
2
|
+
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
3
|
+
|
|
4
|
+
/** @module ArrayNode **/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ArrayNode represents a collection of nodes, typically created using the {@link module:TSL~array} function.
|
|
8
|
+
* ```js
|
|
9
|
+
* const colors = array( [
|
|
10
|
+
* vec3( 1, 0, 0 ),
|
|
11
|
+
* vec3( 0, 1, 0 ),
|
|
12
|
+
* vec3( 0, 0, 1 )
|
|
13
|
+
* ] );
|
|
14
|
+
*
|
|
15
|
+
* const redColor = tintColors.element( 0 );
|
|
16
|
+
*
|
|
17
|
+
* @augments Node
|
|
18
|
+
*/
|
|
19
|
+
class ArrayNode extends TempNode {
|
|
20
|
+
|
|
21
|
+
static get type() {
|
|
22
|
+
|
|
23
|
+
return 'ArrayNode';
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new array node.
|
|
29
|
+
*
|
|
30
|
+
* @param {String} [nodeType] - The data type of the elements.
|
|
31
|
+
* @param {Number} [count] - Size of the array.
|
|
32
|
+
* @param {Array<Node>?} [values=null] - Array default values.
|
|
33
|
+
*/
|
|
34
|
+
constructor( nodeType, count, values = null ) {
|
|
35
|
+
|
|
36
|
+
super( nodeType );
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Array size.
|
|
40
|
+
*
|
|
41
|
+
* @type {Array<Node>}
|
|
42
|
+
*/
|
|
43
|
+
this.count = count;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Array default values.
|
|
47
|
+
*
|
|
48
|
+
* @type {Array<Node>}
|
|
49
|
+
*/
|
|
50
|
+
this.values = values;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This flag can be used for type testing.
|
|
54
|
+
*
|
|
55
|
+
* @type {Boolean}
|
|
56
|
+
* @readonly
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
this.isArrayNode = true;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getNodeType( builder ) {
|
|
64
|
+
|
|
65
|
+
if ( this.nodeType === null ) {
|
|
66
|
+
|
|
67
|
+
this.nodeType = this.values[ 0 ].getNodeType( builder );
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return this.nodeType;
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getElementType( builder ) {
|
|
76
|
+
|
|
77
|
+
return this.getNodeType( builder );
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
generate( builder ) {
|
|
82
|
+
|
|
83
|
+
const type = this.getNodeType( builder );
|
|
84
|
+
|
|
85
|
+
return builder.generateArray( type, this.count, this.values );
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default ArrayNode;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* TSL function for creating an array node.
|
|
95
|
+
*
|
|
96
|
+
* @function
|
|
97
|
+
* @param {String|Array<Node>} nodeTypeOrValues - A string representing the element type (e.g., 'vec3')
|
|
98
|
+
* or an array containing the default values (e.g., [ vec3() ]).
|
|
99
|
+
* @param {Number?} [count] - Size of the array.
|
|
100
|
+
* @returns {ArrayNode}
|
|
101
|
+
*/
|
|
102
|
+
export const array = ( ...params ) => {
|
|
103
|
+
|
|
104
|
+
let node;
|
|
105
|
+
|
|
106
|
+
if ( params.length === 1 ) {
|
|
107
|
+
|
|
108
|
+
const values = params[ 0 ];
|
|
109
|
+
|
|
110
|
+
node = new ArrayNode( null, values.length, values );
|
|
111
|
+
|
|
112
|
+
} else {
|
|
113
|
+
|
|
114
|
+
const nodeType = params[ 0 ];
|
|
115
|
+
const count = params[ 1 ];
|
|
116
|
+
|
|
117
|
+
node = new ArrayNode( nodeType, count );
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return nodeObject( node );
|
|
122
|
+
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
addMethodChaining( 'toArray', ( node, count ) => array( Array( count ).fill( node ) ) );
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import InputNode from './InputNode.js';
|
|
2
2
|
|
|
3
|
+
const _regNum = /float|u?int/;
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Class for representing a constant value in the shader.
|
|
5
7
|
*
|
|
@@ -50,6 +52,12 @@ class ConstNode extends InputNode {
|
|
|
50
52
|
|
|
51
53
|
const type = this.getNodeType( builder );
|
|
52
54
|
|
|
55
|
+
if ( _regNum.test( type ) && _regNum.test( output ) ) {
|
|
56
|
+
|
|
57
|
+
return builder.generateConst( output, this.value );
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
return builder.format( this.generateConst( builder ), type, output );
|
|
54
62
|
|
|
55
63
|
}
|
package/src/nodes/core/Node.js
CHANGED
|
@@ -416,6 +416,19 @@ class Node extends EventDispatcher {
|
|
|
416
416
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
/**
|
|
420
|
+
* Returns the node member type for the given name.
|
|
421
|
+
*
|
|
422
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
423
|
+
* @param {String} name - The name of the member.
|
|
424
|
+
* @return {String} The type of the node.
|
|
425
|
+
*/
|
|
426
|
+
getMemberType( /*uilder, name*/ ) {
|
|
427
|
+
|
|
428
|
+
return 'void';
|
|
429
|
+
|
|
430
|
+
}
|
|
431
|
+
|
|
419
432
|
/**
|
|
420
433
|
* Returns the node's type.
|
|
421
434
|
*
|
|
@@ -691,7 +704,7 @@ class Node extends EventDispatcher {
|
|
|
691
704
|
/**
|
|
692
705
|
* Returns the child nodes as a JSON object.
|
|
693
706
|
*
|
|
694
|
-
* @return {Object}
|
|
707
|
+
* @return {Array<Object>} An iterable list of serialized child objects as JSON.
|
|
695
708
|
*/
|
|
696
709
|
getSerializeChildren() {
|
|
697
710
|
|