From 10cc7d1bb3b7e22df913adb9916bbf15cbd51210 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sun, 15 Dec 2024 15:58:02 -0500 Subject: [PATCH] Node: Document more modules. (#1432) * Examples: Fix typos. * Update three.js * Add src * Update patch and delete src * Update declarations * Add examples * Update patch and delete examples --- examples-testing/changes.patch | 24 +- src-testing/changes.patch | 427 +++++++++++------- three.js | 2 +- types/three/src/nodes/core/Node.d.ts | 17 +- types/three/src/nodes/core/NodeAttribute.d.ts | 2 +- .../three/src/nodes/core/StructTypeNode.d.ts | 20 +- types/three/src/objects/ClippingGroup.d.ts | 2 +- 7 files changed, 309 insertions(+), 185 deletions(-) diff --git a/examples-testing/changes.patch b/examples-testing/changes.patch index 16913097c..7d8185b62 100644 --- a/examples-testing/changes.patch +++ b/examples-testing/changes.patch @@ -2253,7 +2253,7 @@ index a2f9f379..4ad49d3c 100644 init(); diff --git a/examples-testing/examples/webgl_buffergeometry_instancing.ts b/examples-testing/examples/webgl_buffergeometry_instancing.ts -index a5b90ae6..df382735 100644 +index b27f500f..c9432b18 100644 --- a/examples-testing/examples/webgl_buffergeometry_instancing.ts +++ b/examples-testing/examples/webgl_buffergeometry_instancing.ts @@ -3,14 +3,14 @@ import * as THREE from 'three'; @@ -3336,7 +3336,7 @@ index edd158fa..6f58c70a 100644 function animate() { diff --git a/examples-testing/examples/webgl_custom_attributes_points3.ts b/examples-testing/examples/webgl_custom_attributes_points3.ts -index 1b46a805..e5798e30 100644 +index 1bca8ccd..66f12591 100644 --- a/examples-testing/examples/webgl_custom_attributes_points3.ts +++ b/examples-testing/examples/webgl_custom_attributes_points3.ts @@ -4,11 +4,11 @@ import Stats from 'three/addons/libs/stats.module.js'; @@ -3361,7 +3361,7 @@ index 1b46a805..e5798e30 100644 - let boxGeometry1 = new THREE.BoxGeometry(radius, 0.1 * radius, 0.1 * radius, 50, 5, 5); + let boxGeometry1: THREE.BufferGeometry = new THREE.BoxGeometry(radius, 0.1 * radius, 0.1 * radius, 50, 5, 5); - // if normal and uv attributes are not removed, mergeVertices() can't consolidate indentical vertices with different normal/uv data + // if normal and uv attributes are not removed, mergeVertices() can't consolidate identical vertices with different normal/uv data @@ -62,7 +62,7 @@ function init() { const quaternion = new THREE.Quaternion(); @@ -3829,7 +3829,7 @@ index 6b013852..382a9b7a 100644 map.needsUpdate = true; } diff --git a/examples-testing/examples/webgl_geometry_convex.ts b/examples-testing/examples/webgl_geometry_convex.ts -index ade9cb80..87ea7be3 100644 +index 09516c07..fe904221 100644 --- a/examples-testing/examples/webgl_geometry_convex.ts +++ b/examples-testing/examples/webgl_geometry_convex.ts @@ -4,7 +4,7 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; @@ -3848,7 +3848,7 @@ index ade9cb80..87ea7be3 100644 - let dodecahedronGeometry = new THREE.DodecahedronGeometry(10); + let dodecahedronGeometry: THREE.BufferGeometry = new THREE.DodecahedronGeometry(10); - // if normal and uv attributes are not removed, mergeVertices() can't consolidate indentical vertices with different normal/uv data + // if normal and uv attributes are not removed, mergeVertices() can't consolidate identical vertices with different normal/uv data diff --git a/examples-testing/examples/webgl_geometry_cube.ts b/examples-testing/examples/webgl_geometry_cube.ts index 572601ac..136a3141 100644 @@ -5642,7 +5642,7 @@ index b137c550..891e5541 100644 pointer.y = -(event.clientY / window.innerHeight) * 2 + 1; } diff --git a/examples-testing/examples/webgl_interactive_points.ts b/examples-testing/examples/webgl_interactive_points.ts -index 93113b86..e090fb6c 100644 +index b6be0df0..2bc27dae 100644 --- a/examples-testing/examples/webgl_interactive_points.ts +++ b/examples-testing/examples/webgl_interactive_points.ts @@ -4,19 +4,19 @@ import Stats from 'three/addons/libs/stats.module.js'; @@ -5677,7 +5677,7 @@ index 93113b86..e090fb6c 100644 - let boxGeometry = new THREE.BoxGeometry(200, 200, 200, 16, 16, 16); + let boxGeometry: THREE.BufferGeometry = new THREE.BoxGeometry(200, 200, 200, 16, 16, 16); - // if normal and uv attributes are not removed, mergeVertices() can't consolidate indentical vertices with different normal/uv data + // if normal and uv attributes are not removed, mergeVertices() can't consolidate identical vertices with different normal/uv data @@ -38,8 +38,8 @@ function init() { @@ -7191,7 +7191,7 @@ index 45361b92..f5d72d3c 100644 if (geometry) { const mesh = new THREE.Mesh(geometry, material); diff --git a/examples-testing/examples/webgl_loader_texture_dds.ts b/examples-testing/examples/webgl_loader_texture_dds.ts -index bc4bd057..0bf94def 100644 +index 0a697e1a..6137631b 100644 --- a/examples-testing/examples/webgl_loader_texture_dds.ts +++ b/examples-testing/examples/webgl_loader_texture_dds.ts @@ -2,8 +2,8 @@ import * as THREE from 'three'; @@ -7205,9 +7205,9 @@ index bc4bd057..0bf94def 100644 init(); -@@ -106,7 +106,7 @@ function init() { - const material11 = new THREE.MeshBasicMaterial({ map: map9 }); +@@ -111,7 +111,7 @@ function init() { const material12 = new THREE.MeshBasicMaterial({ map: map10 }); + const material13 = new THREE.MeshBasicMaterial({ map: map11 }); - let mesh = new THREE.Mesh(new THREE.TorusGeometry(), material1); + let mesh: THREE.Mesh = new THREE.Mesh(new THREE.TorusGeometry(), material1); @@ -11571,7 +11571,7 @@ index 18020f78..3b61996d 100644 init(); render(); diff --git a/examples-testing/examples/webgl_shadow_contact.ts b/examples-testing/examples/webgl_shadow_contact.ts -index 9eda35b8..0c262569 100644 +index f402fa20..8e71282d 100644 --- a/examples-testing/examples/webgl_shadow_contact.ts +++ b/examples-testing/examples/webgl_shadow_contact.ts @@ -5,9 +5,9 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js'; @@ -16338,7 +16338,7 @@ index 535e1c93..ab2e4ee0 100644 canvas.width = tileWidth; context.drawImage(imageObj, tileWidth * i, 0, tileWidth, tileWidth, 0, 0, tileWidth, tileWidth); diff --git a/examples-testing/examples/webxr_vr_panorama_depth.ts b/examples-testing/examples/webxr_vr_panorama_depth.ts -index 66215469..9ad505c4 100644 +index 42ac8332..093dcd93 100644 --- a/examples-testing/examples/webxr_vr_panorama_depth.ts +++ b/examples-testing/examples/webxr_vr_panorama_depth.ts @@ -1,12 +1,16 @@ diff --git a/src-testing/changes.patch b/src-testing/changes.patch index 9990f6449..d791f4fe8 100644 --- a/src-testing/changes.patch +++ b/src-testing/changes.patch @@ -634,7 +634,7 @@ index dd4b5cba..5a997eef 100644 addMethodChaining('context', context); addMethodChaining('label', label); diff --git a/src-testing/src/nodes/core/InputNode.ts b/src-testing/src/nodes/core/InputNode.ts -index 37dff4b1..b70057a9 100644 +index 91d31e90..3f080c9a 100644 --- a/src-testing/src/nodes/core/InputNode.ts +++ b/src-testing/src/nodes/core/InputNode.ts @@ -1,23 +1,29 @@ @@ -708,7 +708,7 @@ index 37dff4b1..b70057a9 100644 export default InputNode; diff --git a/src-testing/src/nodes/core/Node.ts b/src-testing/src/nodes/core/Node.ts -index 5dc5038b..831cc7a6 100644 +index b307586a..f59892ec 100644 --- a/src-testing/src/nodes/core/Node.ts +++ b/src-testing/src/nodes/core/Node.ts @@ -3,25 +3,103 @@ import { getNodeChildren, getCacheKey } from './NodeUtils.js'; @@ -817,7 +817,7 @@ index 5dc5038b..831cc7a6 100644 super(); /** -@@ -106,7 +184,7 @@ class Node extends EventDispatcher { +@@ -121,7 +199,7 @@ class Node extends EventDispatcher { * @type {Boolean} * @default false */ @@ -826,7 +826,7 @@ index 5dc5038b..831cc7a6 100644 if (value === true) { this.version++; } -@@ -119,7 +197,7 @@ class Node extends EventDispatcher { +@@ -134,7 +212,7 @@ class Node extends EventDispatcher { * @readonly */ get type() { @@ -835,7 +835,7 @@ index 5dc5038b..831cc7a6 100644 } /** -@@ -129,7 +207,7 @@ class Node extends EventDispatcher { +@@ -144,7 +222,7 @@ class Node extends EventDispatcher { * @param {String} updateType - The update type. * @return {Node} A reference to this node. */ @@ -844,7 +844,7 @@ index 5dc5038b..831cc7a6 100644 this.updateType = updateType; this.update = callback.bind(this.getSelf()); -@@ -143,7 +221,7 @@ class Node extends EventDispatcher { +@@ -158,7 +236,7 @@ class Node extends EventDispatcher { * @param {Function} callback - The update method. * @return {Node} A reference to this node. */ @@ -853,7 +853,7 @@ index 5dc5038b..831cc7a6 100644 return this.onUpdate(callback, NodeUpdateType.FRAME); } -@@ -154,7 +232,7 @@ class Node extends EventDispatcher { +@@ -169,7 +247,7 @@ class Node extends EventDispatcher { * @param {Function} callback - The update method. * @return {Node} A reference to this node. */ @@ -862,7 +862,7 @@ index 5dc5038b..831cc7a6 100644 return this.onUpdate(callback, NodeUpdateType.RENDER); } -@@ -165,7 +243,7 @@ class Node extends EventDispatcher { +@@ -180,7 +258,7 @@ class Node extends EventDispatcher { * @param {Function} callback - The update method. * @return {Node} A reference to this node. */ @@ -871,7 +871,7 @@ index 5dc5038b..831cc7a6 100644 return this.onUpdate(callback, NodeUpdateType.OBJECT); } -@@ -175,7 +253,7 @@ class Node extends EventDispatcher { +@@ -190,7 +268,7 @@ class Node extends EventDispatcher { * @param {Function} callback - The update method. * @return {Node} A reference to this node. */ @@ -880,7 +880,7 @@ index 5dc5038b..831cc7a6 100644 this.updateReference = callback.bind(this.getSelf()); return this; -@@ -200,7 +278,7 @@ class Node extends EventDispatcher { +@@ -215,7 +293,7 @@ class Node extends EventDispatcher { * @param {Any} state - This method can be invocated in different contexts so `state` can refer to any object type. * @return {Any} The updated reference. */ @@ -889,7 +889,7 @@ index 5dc5038b..831cc7a6 100644 return this; } -@@ -212,7 +290,7 @@ class Node extends EventDispatcher { +@@ -227,7 +305,7 @@ class Node extends EventDispatcher { * @param {NodeBuilder} builder - The current node builder. * @return {Boolean} Whether this node is global or not. */ @@ -898,7 +898,7 @@ index 5dc5038b..831cc7a6 100644 return this.global; } -@@ -247,7 +325,7 @@ class Node extends EventDispatcher { +@@ -263,7 +341,7 @@ class Node extends EventDispatcher { * * @param {traverseCallback} callback - A callback that is executed per node. */ @@ -907,7 +907,7 @@ index 5dc5038b..831cc7a6 100644 callback(this); for (const childNode of this.getChildren()) { -@@ -289,7 +367,7 @@ class Node extends EventDispatcher { +@@ -305,7 +383,7 @@ class Node extends EventDispatcher { * @param {NodeBuilder} builder - The current node builder. * @return {String} The hash. */ @@ -916,7 +916,7 @@ index 5dc5038b..831cc7a6 100644 return this.uuid; } -@@ -328,7 +406,7 @@ class Node extends EventDispatcher { +@@ -344,7 +422,7 @@ class Node extends EventDispatcher { * @param {NodeBuilder} builder - The current node builder. * @return {String} The type of the node. */ @@ -925,7 +925,7 @@ index 5dc5038b..831cc7a6 100644 const type = this.getNodeType(builder); const elementType = builder.getElementType(type); -@@ -341,7 +419,7 @@ class Node extends EventDispatcher { +@@ -357,7 +435,7 @@ class Node extends EventDispatcher { * @param {NodeBuilder} builder - The current node builder. * @return {String} The type of the node. */ @@ -934,7 +934,7 @@ index 5dc5038b..831cc7a6 100644 const nodeProperties = builder.getNodeProperties(this); if (nodeProperties.outputNode) { -@@ -360,7 +438,7 @@ class Node extends EventDispatcher { +@@ -376,7 +454,7 @@ class Node extends EventDispatcher { * @param {NodeBuilder} builder - The current node builder. * @return {Node} The shared node if possible. Otherwise `this` is returned. */ @@ -943,7 +943,7 @@ index 5dc5038b..831cc7a6 100644 const hash = this.getHash(builder); const nodeFromHash = builder.getNodeFromHash(hash); -@@ -375,13 +453,13 @@ class Node extends EventDispatcher { +@@ -391,13 +469,13 @@ class Node extends EventDispatcher { * @param {NodeBuilder} builder - The current node builder. * @return {Node?} The output node. */ @@ -959,7 +959,7 @@ index 5dc5038b..831cc7a6 100644 } // return a outputNode if exists -@@ -394,7 +472,7 @@ class Node extends EventDispatcher { +@@ -410,7 +488,7 @@ class Node extends EventDispatcher { * * @param {NodeBuilder} builder - The current node builder. */ @@ -968,7 +968,7 @@ index 5dc5038b..831cc7a6 100644 const usageCount = builder.increaseUsage(this); if (usageCount === 1) { -@@ -403,8 +481,8 @@ class Node extends EventDispatcher { +@@ -419,8 +497,8 @@ class Node extends EventDispatcher { const nodeProperties = builder.getNodeProperties(this); for (const childNode of Object.values(nodeProperties)) { @@ -979,7 +979,7 @@ index 5dc5038b..831cc7a6 100644 } } } -@@ -418,7 +496,7 @@ class Node extends EventDispatcher { +@@ -434,7 +512,7 @@ class Node extends EventDispatcher { * @param {String?} output - Can be used to define the output type. * @return {String?} The generated shader string. */ @@ -988,7 +988,7 @@ index 5dc5038b..831cc7a6 100644 const { outputNode } = builder.getNodeProperties(this); if (outputNode && outputNode.isNode === true) { -@@ -432,7 +510,7 @@ class Node extends EventDispatcher { +@@ -448,7 +526,7 @@ class Node extends EventDispatcher { * * @param {NodeFrame} frame - A reference to the current node frame. */ @@ -997,7 +997,7 @@ index 5dc5038b..831cc7a6 100644 console.warn('Abstract function.'); } -@@ -442,7 +520,7 @@ class Node extends EventDispatcher { +@@ -458,7 +536,7 @@ class Node extends EventDispatcher { * * @param {NodeFrame} frame - A reference to the current node frame. */ @@ -1006,7 +1006,7 @@ index 5dc5038b..831cc7a6 100644 console.warn('Abstract function.'); } -@@ -452,7 +530,7 @@ class Node extends EventDispatcher { +@@ -468,7 +546,7 @@ class Node extends EventDispatcher { * * @param {NodeFrame} frame - A reference to the current node frame. */ @@ -1015,7 +1015,7 @@ index 5dc5038b..831cc7a6 100644 console.warn('Abstract function.'); } -@@ -464,7 +542,7 @@ class Node extends EventDispatcher { +@@ -480,7 +558,7 @@ class Node extends EventDispatcher { * @param {String?} output - Can be used to define the output type. * @return {String?} When this method is executed in the setup or analyze stage, `null` is returned. In the generate stage, the generated shader string. */ @@ -1024,7 +1024,7 @@ index 5dc5038b..831cc7a6 100644 const refNode = this.getShared(builder); if (this !== refNode) { -@@ -500,8 +578,8 @@ class Node extends EventDispatcher { +@@ -516,8 +594,8 @@ class Node extends EventDispatcher { } for (const childNode of Object.values(properties)) { @@ -1035,7 +1035,7 @@ index 5dc5038b..831cc7a6 100644 } } } -@@ -550,10 +628,10 @@ class Node extends EventDispatcher { +@@ -566,10 +644,10 @@ class Node extends EventDispatcher { * * @param {Object} json - The output JSON object. */ @@ -1048,7 +1048,7 @@ index 5dc5038b..831cc7a6 100644 for (const { property, index, childNode } of nodeChildren) { if (index !== undefined) { -@@ -561,7 +639,9 @@ class Node extends EventDispatcher { +@@ -577,7 +655,9 @@ class Node extends EventDispatcher { inputNodes[property] = Number.isInteger(index) ? [] : {}; } @@ -1059,7 +1059,7 @@ index 5dc5038b..831cc7a6 100644 } else { inputNodes[property] = childNode.toJSON(json.meta).uuid; } -@@ -577,33 +657,33 @@ class Node extends EventDispatcher { +@@ -593,33 +673,33 @@ class Node extends EventDispatcher { * * @param {Object} json - The JSON object. */ @@ -1103,7 +1103,7 @@ index 5dc5038b..831cc7a6 100644 } } } -@@ -615,7 +695,7 @@ class Node extends EventDispatcher { +@@ -631,7 +711,7 @@ class Node extends EventDispatcher { * @param {Object?} meta - An optional JSON object that already holds serialized data from other scene objects. * @return {Object} The serialized node. */ @@ -1112,7 +1112,7 @@ index 5dc5038b..831cc7a6 100644 const { uuid, type } = this; const isRoot = meta === undefined || typeof meta === 'string'; -@@ -624,18 +704,18 @@ class Node extends EventDispatcher { +@@ -640,18 +720,18 @@ class Node extends EventDispatcher { textures: {}, images: {}, nodes: {}, @@ -1134,7 +1134,7 @@ index 5dc5038b..831cc7a6 100644 metadata: { version: 4.6, type: 'Node', -@@ -643,7 +723,7 @@ class Node extends EventDispatcher { +@@ -659,7 +739,7 @@ class Node extends EventDispatcher { }, }; @@ -1143,7 +1143,7 @@ index 5dc5038b..831cc7a6 100644 this.serialize(data); -@@ -652,12 +732,12 @@ class Node extends EventDispatcher { +@@ -668,12 +748,12 @@ class Node extends EventDispatcher { // TODO: Copied from Object3D.toJSON @@ -1158,7 +1158,7 @@ index 5dc5038b..831cc7a6 100644 values.push(data); } -@@ -665,9 +745,9 @@ class Node extends EventDispatcher { +@@ -681,9 +761,9 @@ class Node extends EventDispatcher { } if (isRoot) { @@ -1172,7 +1172,7 @@ index 5dc5038b..831cc7a6 100644 if (textures.length > 0) data.textures = textures; if (images.length > 0) data.images = images; diff --git a/src-testing/src/nodes/core/NodeAttribute.ts b/src-testing/src/nodes/core/NodeAttribute.ts -index 59326d9a..5a9c5570 100644 +index b1a5c99b..df827f78 100644 --- a/src-testing/src/nodes/core/NodeAttribute.ts +++ b/src-testing/src/nodes/core/NodeAttribute.ts @@ -1,3 +1,5 @@ @@ -1196,7 +1196,7 @@ index 59326d9a..5a9c5570 100644 * @@ -12,7 +20,7 @@ class NodeAttribute { * @param {String} type - The type of the attribute. - * @param {Node?} node - An optinal reference to the node. + * @param {Node?} node - An optional reference to the node. */ - constructor(name, type, node = null) { + constructor(name: string, type: string | null, node: Node | null = null) { @@ -1204,10 +1204,10 @@ index 59326d9a..5a9c5570 100644 * This flag can be used for type testing. * diff --git a/src-testing/src/nodes/core/NodeBuilder.ts b/src-testing/src/nodes/core/NodeBuilder.ts -index e29af862..a6704eea 100644 +index 851f26f7..e156ab99 100644 --- a/src-testing/src/nodes/core/NodeBuilder.ts +++ b/src-testing/src/nodes/core/NodeBuilder.ts -@@ -8,7 +8,7 @@ import ParameterNode from './ParameterNode.js'; +@@ -9,7 +9,7 @@ import StructTypeNode from './StructTypeNode.js'; import FunctionNode from '../code/FunctionNode.js'; import NodeMaterial from '../../materials/nodes/NodeMaterial.js'; import { getTypeFromLength } from './NodeUtils.js'; @@ -1216,7 +1216,7 @@ index e29af862..a6704eea 100644 import { NumberNodeUniform, -@@ -20,8 +20,8 @@ import { +@@ -21,8 +21,8 @@ import { Matrix4NodeUniform, } from '../../renderers/common/nodes/NodeUniform.js'; @@ -1227,7 +1227,7 @@ index e29af862..a6704eea 100644 import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js'; import ChainMap from '../../renderers/common/ChainMap.js'; -@@ -39,16 +39,49 @@ import { +@@ -40,16 +40,49 @@ import { NearestMipmapLinearFilter, LinearMipmapLinearFilter, } from '../../constants.js'; @@ -1282,7 +1282,7 @@ index e29af862..a6704eea 100644 [Int8Array, 'int'], [Int16Array, 'int'], [Int32Array, 'int'], -@@ -58,21 +91,99 @@ const typeFromArray = new Map([ +@@ -59,21 +92,99 @@ const typeFromArray = new Map([ [Float32Array, 'float'], ]); @@ -1385,7 +1385,7 @@ index e29af862..a6704eea 100644 /** * Constructs a new node builder. * -@@ -80,7 +191,7 @@ class NodeBuilder { +@@ -81,7 +192,7 @@ class NodeBuilder { * @param {Renderer} renderer - The current renderer. * @param {NodeParser} parser - A reference to a node parser. */ @@ -1394,7 +1394,7 @@ index e29af862..a6704eea 100644 /** * The 3D object. * -@@ -93,14 +204,14 @@ class NodeBuilder { +@@ -94,14 +205,14 @@ class NodeBuilder { * * @type {Material?} */ @@ -1411,33 +1411,37 @@ index e29af862..a6704eea 100644 /** * The current renderer. -@@ -217,7 +328,7 @@ class NodeBuilder { +@@ -225,7 +336,7 @@ class NodeBuilder { this.cache = new NodeCache(); this.globalCache = this.cache; - this.flowsData = new WeakMap(); + this.flowsData = new WeakMap(); - this.shaderStage = null; - this.buildStage = null; -@@ -237,11 +348,11 @@ class NodeBuilder { - return bindGroupsCache; - } - + /** + * The current shader stage. +@@ -270,7 +381,7 @@ class NodeBuilder { + * @param {Object} options - The options of the render target. + * @return {RenderTarget} The render target. + */ - createRenderTarget(width, height, options) { + createRenderTarget(width?: number, height?: number, options?: RenderTargetOptions) { return new RenderTarget(width, height, options); } +@@ -282,7 +393,7 @@ class NodeBuilder { + * @param {Object} options - The options of the cube render target. + * @return {CubeRenderTarget} The cube render target. + */ - createCubeRenderTarget(size, options) { + createCubeRenderTarget(size?: number, options?: RenderTargetOptions) { return new CubeRenderTarget(size, options); } -@@ -251,16 +362,16 @@ class NodeBuilder { - return new PMREMGenerator(this.renderer); - } - +@@ -303,16 +414,16 @@ class NodeBuilder { + * @param {Node} node - The node to test. + * @return {Boolean} Whether the given node is included in the internal array of nodes or not. + */ - includes(node) { + includes(node: Node) { return this.nodes.includes(node); @@ -1454,7 +1458,7 @@ index e29af862..a6704eea 100644 let sharedGroup = true; -@@ -275,26 +386,26 @@ class NodeBuilder { +@@ -327,26 +438,26 @@ class NodeBuilder { let bindGroup; if (sharedGroup) { @@ -1485,7 +1489,7 @@ index e29af862..a6704eea 100644 const bindings = this.bindings[shaderStage]; let bindGroup = bindings[groupName]; -@@ -314,12 +425,12 @@ class NodeBuilder { +@@ -366,12 +477,12 @@ class NodeBuilder { let bindingsGroups = this.bindGroups; if (bindingsGroups === null) { @@ -1500,7 +1504,7 @@ index e29af862..a6704eea 100644 const groupUniforms = groups[groupName] || (groups[groupName] = []); groupUniforms.push(...uniforms); -@@ -329,7 +440,7 @@ class NodeBuilder { +@@ -381,7 +492,7 @@ class NodeBuilder { bindingsGroups = []; for (const groupName in groups) { @@ -1509,7 +1513,7 @@ index e29af862..a6704eea 100644 const bindingsGroup = this._getBindGroup(groupName, group); -@@ -355,11 +466,11 @@ class NodeBuilder { +@@ -407,11 +518,11 @@ class NodeBuilder { } } @@ -1523,7 +1527,7 @@ index e29af862..a6704eea 100644 if (this.nodes.includes(node) === false) { this.nodes.push(node); -@@ -400,7 +511,7 @@ class NodeBuilder { +@@ -452,7 +563,7 @@ class NodeBuilder { return this.chaining[this.chaining.length - 1]; } @@ -1532,7 +1536,7 @@ index e29af862..a6704eea 100644 return ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || -@@ -413,7 +524,7 @@ class NodeBuilder { +@@ -465,7 +576,7 @@ class NodeBuilder { ); } @@ -1541,7 +1545,7 @@ index e29af862..a6704eea 100644 /* if ( this.chaining.indexOf( node ) !== - 1 ) { -@@ -425,7 +536,7 @@ class NodeBuilder { +@@ -477,7 +588,7 @@ class NodeBuilder { this.chaining.push(node); } @@ -1550,7 +1554,7 @@ index e29af862..a6704eea 100644 const lastChain = this.chaining.pop(); if (lastChain !== node) { -@@ -433,21 +544,21 @@ class NodeBuilder { +@@ -485,21 +596,21 @@ class NodeBuilder { } } @@ -1576,7 +1580,7 @@ index e29af862..a6704eea 100644 this.context = context; } -@@ -463,7 +574,7 @@ class NodeBuilder { +@@ -515,7 +626,7 @@ class NodeBuilder { return this.context; } @@ -1585,7 +1589,7 @@ index e29af862..a6704eea 100644 this.cache = cache; } -@@ -471,14 +582,14 @@ class NodeBuilder { +@@ -523,14 +634,14 @@ class NodeBuilder { return this.cache; } @@ -1602,7 +1606,7 @@ index e29af862..a6704eea 100644 return false; } -@@ -513,15 +624,53 @@ class NodeBuilder { +@@ -565,15 +676,53 @@ class NodeBuilder { return nodeData.usageCount; } @@ -1665,7 +1669,7 @@ index e29af862..a6704eea 100644 if (value === null) { if (type === 'float' || type === 'int' || type === 'uint') value = 0; else if (type === 'bool') value = false; -@@ -532,26 +681,26 @@ class NodeBuilder { +@@ -584,26 +733,26 @@ class NodeBuilder { } if (type === 'float') return toFloat(value); @@ -1701,58 +1705,79 @@ index e29af862..a6704eea 100644 } else if (typeLength > 4) { return `${this.getType(type)}()`; } -@@ -559,17 +708,17 @@ class NodeBuilder { - throw new Error(`NodeBuilder: Type '${type}' not found in generate constant attempt.`); - } - +@@ -618,7 +767,7 @@ class NodeBuilder { + * @param {String} type - The type. + * @return {String} The updated type. + */ - getType(type) { + getType(type: string | null) { if (type === 'color') return 'vec3'; return type; - } - +@@ -630,7 +779,7 @@ class NodeBuilder { + * @param {String} name - The attribute name. + * @return {Boolean} Whether the given attribute name is defined in the geometry. + */ - hasGeometryAttribute(name) { + hasGeometryAttribute(name: string) { return this.geometry && this.geometry.getAttribute(name) !== undefined; } +@@ -641,7 +790,7 @@ class NodeBuilder { + * @param {String} type - The attribute's type. + * @return {NodeAttribute} The node attribute. + */ - getAttribute(name, type) { + getAttribute(name: string, type: string | null) { const attributes = this.attributes; // find attribute -@@ -589,19 +738,19 @@ class NodeBuilder { - return attribute; - } - +@@ -668,8 +817,8 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. + * @return {String} The property name. + */ - getPropertyName(node /*, shaderStage*/) { - return node.name; + getPropertyName(node: unknown, shaderStage?: NodeShaderStage) { + return (node as { name?: string }).name; } + /** +@@ -678,8 +827,8 @@ class NodeBuilder { + * @param {String} type - The type to check. + * @return {Boolean} Whether the given type is a vector type or not. + */ - isVector(type) { - return /vec\d/.test(type); + isVector(type: string | null) { + return /vec\d/.test(type!); } + /** +@@ -688,8 +837,8 @@ class NodeBuilder { + * @param {String} type - The type to check. + * @return {Boolean} Whether the given type is a matrix type or not. + */ - isMatrix(type) { - return /mat\d/.test(type); + isMatrix(type: string | null) { + return /mat\d/.test(type!); } + /** +@@ -698,7 +847,7 @@ class NodeBuilder { + * @param {String} type - The type to check. + * @return {Boolean} Whether the given type is a reference type or not. + */ - isReference(type) { + isReference(type: string | null) { return ( type === 'void' || type === 'property' || -@@ -618,10 +767,10 @@ class NodeBuilder { - return false; - } - +@@ -728,10 +877,10 @@ class NodeBuilder { + * @param {Texture} texture - The texture. + * @return {String} The component type. + */ - getComponentTypeFromTexture(texture) { + getComponentTypeFromTexture(texture: Texture) { const type = texture.type; @@ -1762,37 +1787,37 @@ index e29af862..a6704eea 100644 if (type === IntType) return 'int'; if (type === UnsignedIntType) return 'uint'; } -@@ -629,7 +778,7 @@ class NodeBuilder { - return 'float'; - } - +@@ -745,7 +894,7 @@ class NodeBuilder { + * @param {String} type - The type. + * @return {String} The element type. + */ - getElementType(type) { + getElementType(type: string | null) { if (type === 'mat2') return 'vec2'; if (type === 'mat3') return 'vec3'; if (type === 'mat4') return 'vec4'; -@@ -637,7 +786,7 @@ class NodeBuilder { - return this.getComponentType(type); - } - +@@ -759,7 +908,7 @@ class NodeBuilder { + * @param {String} type - The type. + * @return {String} The component type. + */ - getComponentType(type) { + getComponentType(type: string | null) { type = this.getVectorType(type); if (type === 'float' || type === 'bool' || type === 'int' || type === 'uint') return type; -@@ -653,7 +802,7 @@ class NodeBuilder { - return 'float'; - } - +@@ -781,7 +930,7 @@ class NodeBuilder { + * @param {String} type - The type. + * @return {String} The vector type. + */ - getVectorType(type) { + getVectorType(type: string | null) { if (type === 'color') return 'vec3'; if (type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D') return 'vec4'; -@@ -661,23 +810,23 @@ class NodeBuilder { - return type; - } - +@@ -796,11 +945,11 @@ class NodeBuilder { + * @param {String} [componentType='float'] - The component type. + * @return {String} The type. + */ - getTypeFromLength(length, componentType = 'float') { + getTypeFromLength(length: number, componentType: string | null = 'float') { if (length === 1) return componentType; @@ -1803,13 +1828,21 @@ index e29af862..a6704eea 100644 return prefix + baseType; } - +@@ -811,8 +960,8 @@ class NodeBuilder { + * @param {TypedArray} type - The typed array. + * @return {String} The type. + */ - getTypeFromArray(array) { - return typeFromArray.get(array.constructor); + getTypeFromArray(array: TypedArray) { + return typeFromArray.get(array.constructor as TypedArrayConstructor); } + /** +@@ -821,10 +970,10 @@ class NodeBuilder { + * @param {BufferAttribute} attribute - The buffer attribute. + * @return {String} The type. + */ - getTypeFromAttribute(attribute) { - let dataAttribute = attribute; - @@ -1821,10 +1854,10 @@ index e29af862..a6704eea 100644 const array = dataAttribute.array; const itemSize = attribute.itemSize; -@@ -692,28 +841,28 @@ class NodeBuilder { - return this.getTypeFromLength(itemSize, arrayType); - } - +@@ -845,15 +994,15 @@ class NodeBuilder { + * @param {String} type - The data type. + * @return {Number} The length. + */ - getTypeLength(type) { + getTypeLength(type: string | null) { const vecType = this.getVectorType(type); @@ -1842,23 +1875,34 @@ index e29af862..a6704eea 100644 return 0; } - +@@ -864,7 +1013,7 @@ class NodeBuilder { + * @param {String} type - The matrix type. + * @return {String} The vector type. + */ - getVectorFromMatrix(type) { + getVectorFromMatrix(type: string) { return type.replace('mat', 'vec'); } +@@ -877,7 +1026,7 @@ class NodeBuilder { + * @param {String} newComponentType - The new component type. + * @return {String} The new type. + */ - changeComponentType(type, newComponentType) { + changeComponentType(type: string, newComponentType: string) { return this.getTypeFromLength(this.getTypeLength(type), newComponentType); } +@@ -887,7 +1036,7 @@ class NodeBuilder { + * @param {String} type - The type. + * @return {String} The integer type. + */ - getIntegerType(type) { + getIntegerType(type: string) { const componentType = this.getComponentType(type); if (componentType === 'int' || componentType === 'uint') return type; -@@ -739,7 +888,11 @@ class NodeBuilder { +@@ -913,7 +1062,11 @@ class NodeBuilder { return lastStack; } @@ -1871,7 +1915,7 @@ index e29af862..a6704eea 100644 cache = cache === null ? (node.isGlobal(this) ? this.globalCache : this.cache) : cache; let nodeData = cache.getData(node); -@@ -752,16 +905,16 @@ class NodeBuilder { +@@ -926,16 +1079,16 @@ class NodeBuilder { if (nodeData[shaderStage] === undefined) nodeData[shaderStage] = {}; @@ -1891,17 +1935,17 @@ index e29af862..a6704eea 100644 const nodeData = this.getDataFromNode(node); let bufferAttribute = nodeData.bufferAttribute; -@@ -779,7 +932,7 @@ class NodeBuilder { +@@ -953,7 +1106,7 @@ class NodeBuilder { return bufferAttribute; } -- getStructTypeFromNode(node, shaderStage = this.shaderStage) { -+ getStructTypeFromNode(node: StructTypeNode, shaderStage = this.shaderStage!) { +- getStructTypeFromNode(node, types, shaderStage = this.shaderStage) { ++ getStructTypeFromNode(node: StructTypeNode, types, shaderStage = this.shaderStage!) { const nodeData = this.getDataFromNode(node, shaderStage); - if (nodeData.structType === undefined) { -@@ -794,7 +947,12 @@ class NodeBuilder { - return node; + let structType = nodeData.structType; +@@ -971,7 +1124,12 @@ class NodeBuilder { + return structType; } - getUniformFromNode(node, type, shaderStage = this.shaderStage, name = null) { @@ -1914,7 +1958,7 @@ index e29af862..a6704eea 100644 const nodeData = this.getDataFromNode(node, shaderStage, this.globalCache); let nodeUniform = nodeData.uniform; -@@ -812,7 +970,12 @@ class NodeBuilder { +@@ -989,7 +1147,12 @@ class NodeBuilder { return nodeUniform; } @@ -1928,7 +1972,7 @@ index e29af862..a6704eea 100644 const nodeData = this.getDataFromNode(node, shaderStage); let nodeVar = nodeData.variable; -@@ -832,7 +995,7 @@ class NodeBuilder { +@@ -1009,7 +1172,7 @@ class NodeBuilder { return nodeVar; } @@ -1937,7 +1981,7 @@ index e29af862..a6704eea 100644 const nodeData = this.getDataFromNode(node, 'any'); let nodeVarying = nodeData.varying; -@@ -853,7 +1016,7 @@ class NodeBuilder { +@@ -1030,7 +1193,7 @@ class NodeBuilder { return nodeVarying; } @@ -1946,7 +1990,7 @@ index e29af862..a6704eea 100644 const nodeData = this.getDataFromNode(node); let nodeCode = nodeData.code; -@@ -903,7 +1066,7 @@ class NodeBuilder { +@@ -1080,7 +1243,7 @@ class NodeBuilder { codeBlock.set(nodeBlock, true); } @@ -1955,7 +1999,7 @@ index e29af862..a6704eea 100644 if (code === '') return this; if (node !== null && this.context.nodeBlock) { -@@ -921,7 +1084,7 @@ class NodeBuilder { +@@ -1098,7 +1261,7 @@ class NodeBuilder { return this; } @@ -1964,7 +2008,7 @@ index e29af862..a6704eea 100644 this.flow.code += code; return this; -@@ -939,11 +1102,11 @@ class NodeBuilder { +@@ -1116,11 +1279,11 @@ class NodeBuilder { return this; } @@ -1978,7 +2022,7 @@ index e29af862..a6704eea 100644 const output = node.getNodeType(this); const flowData = this.flowChildNode(node, output); -@@ -953,7 +1116,9 @@ class NodeBuilder { +@@ -1130,7 +1293,9 @@ class NodeBuilder { return flowData; } @@ -1989,7 +2033,7 @@ index e29af862..a6704eea 100644 const fn = new FunctionNode(); const previous = this.currentFunctionNode; -@@ -967,7 +1132,7 @@ class NodeBuilder { +@@ -1144,7 +1309,7 @@ class NodeBuilder { return fn; } @@ -1998,7 +2042,7 @@ index e29af862..a6704eea 100644 const layout = shaderNode.layout; const inputs = { -@@ -983,7 +1148,7 @@ class NodeBuilder { +@@ -1160,7 +1325,7 @@ class NodeBuilder { }, }; @@ -2007,7 +2051,7 @@ index e29af862..a6704eea 100644 inputs[input.name] = new ParameterNode(input.type, input.name); } -@@ -999,14 +1164,14 @@ class NodeBuilder { +@@ -1176,14 +1341,14 @@ class NodeBuilder { return flowData; } @@ -2024,7 +2068,7 @@ index e29af862..a6704eea 100644 code: '', }; -@@ -1021,7 +1186,7 @@ class NodeBuilder { +@@ -1198,7 +1363,7 @@ class NodeBuilder { flow.result = node.build(this, output); } @@ -2033,7 +2077,7 @@ index e29af862..a6704eea 100644 this.flow = previousFlow; this.vars = previousVars; -@@ -1037,10 +1202,10 @@ class NodeBuilder { +@@ -1214,10 +1379,10 @@ class NodeBuilder { return null; } @@ -2046,7 +2090,7 @@ index e29af862..a6704eea 100644 code: '', }; -@@ -1053,7 +1218,12 @@ class NodeBuilder { +@@ -1230,7 +1395,12 @@ class NodeBuilder { return flow; } @@ -2060,45 +2104,67 @@ index e29af862..a6704eea 100644 const previousShaderStage = this.shaderStage; this.setShaderStage(shaderStage); -@@ -1075,19 +1245,15 @@ class NodeBuilder { - return this.attributes.concat(this.bufferAttributes); - } - +@@ -1264,9 +1434,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. + * @return {String} The attribute code section. + */ - getAttributes(/*shaderStage*/) { - console.warn('Abstract function.'); - } + abstract getAttributes(shaderStage: NodeShaderStage): string; + /** + * Returns the varying definitions as a shader string for the given shader stage. +@@ -1275,9 +1443,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. + * @return {String} The varying code section. + */ - getVaryings(/*shaderStage*/) { - console.warn('Abstract function.'); - } + abstract getVaryings(shaderStage: NodeShaderStage): string; + /** + * Returns a single variable definition as a shader string for the given variable type and name. +@@ -1286,7 +1452,7 @@ class NodeBuilder { + * @param {String} name - The variable's name. + * @return {String} The shader string. + */ - getVar(type, name) { + getVar(type: string | null, name: string) { return `${this.getType(type)} ${name}`; } +@@ -1296,7 +1462,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. + * @return {String} The variable code section. + */ - getVars(shaderStage) { + getVars(shaderStage: 'vertex' | 'fragment' | 'compute') { let snippet = ''; const vars = this.vars[shaderStage]; -@@ -1101,11 +1267,9 @@ class NodeBuilder { - return snippet; - } - +@@ -1317,9 +1483,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. + * @return {String} The uniform code section. + */ - getUniforms(/*shaderStage*/) { - console.warn('Abstract function.'); - } + abstract getUniforms(shaderStage: NodeShaderStage): string; + /** + * Returns the native code definitions as a shader string for the given shader stage. +@@ -1327,7 +1491,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. + * @return {String} The native code section. + */ - getCodes(shaderStage) { + getCodes(shaderStage: 'vertex' | 'fragment' | 'compute') { const codes = this.codes[shaderStage]; let code = ''; -@@ -1120,10 +1284,10 @@ class NodeBuilder { +@@ -1342,7 +1506,7 @@ class NodeBuilder { } getHash() { @@ -2106,21 +2172,26 @@ index e29af862..a6704eea 100644 + return this.vertexShader! + this.fragmentShader + this.computeShader; } + /** +@@ -1350,7 +1514,7 @@ class NodeBuilder { + * + * @param {('vertex'|'fragment'|'compute')?} shaderStage - The shader stage to set. + */ - setShaderStage(shaderStage) { + setShaderStage(shaderStage: NodeShaderStage | null) { this.shaderStage = shaderStage; } -@@ -1131,7 +1295,7 @@ class NodeBuilder { - return this.shaderStage; - } - +@@ -1368,7 +1532,7 @@ class NodeBuilder { + * + * @param {('setup'|'analyze'|'generate')?} buildStage - The build stage to set. + */ - setBuildStage(buildStage) { + setBuildStage(buildStage: string | null) { this.buildStage = buildStage; } -@@ -1197,7 +1361,7 @@ class NodeBuilder { +@@ -1449,7 +1613,7 @@ class NodeBuilder { return this; } @@ -2129,7 +2200,7 @@ index e29af862..a6704eea 100644 if (type === 'float' || type === 'int' || type === 'uint') return new NumberNodeUniform(uniformNode); if (type === 'vec2' || type === 'ivec2' || type === 'uvec2') return new Vector2NodeUniform(uniformNode); if (type === 'vec3' || type === 'ivec3' || type === 'uvec3') return new Vector3NodeUniform(uniformNode); -@@ -1215,7 +1379,7 @@ class NodeBuilder { +@@ -1467,7 +1631,7 @@ class NodeBuilder { throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${type}() instead.`); } @@ -2259,7 +2330,7 @@ index 76642daa..f58273bc 100644 * The name of the code. * diff --git a/src-testing/src/nodes/core/NodeFrame.ts b/src-testing/src/nodes/core/NodeFrame.ts -index 50ad5076..19ae0b05 100644 +index 4cfd00bd..787e9962 100644 --- a/src-testing/src/nodes/core/NodeFrame.ts +++ b/src-testing/src/nodes/core/NodeFrame.ts @@ -1,4 +1,7 @@ @@ -2374,17 +2445,18 @@ index 2e8a372c..0dd736ec 100644 * This flag can be used for type testing. * diff --git a/src-testing/src/nodes/core/NodeUtils.ts b/src-testing/src/nodes/core/NodeUtils.ts -index 618b1587..d30384cd 100644 +index e5c0bb33..ab0ddc13 100644 --- a/src-testing/src/nodes/core/NodeUtils.ts +++ b/src-testing/src/nodes/core/NodeUtils.ts -@@ -4,13 +4,14 @@ import { Matrix4 } from '../../math/Matrix4.js'; +@@ -4,6 +4,7 @@ import { Matrix4 } from '../../math/Matrix4.js'; import { Vector2 } from '../../math/Vector2.js'; import { Vector3 } from '../../math/Vector3.js'; import { Vector4 } from '../../math/Vector4.js'; +import Node from './Node.js'; - // cyrb53 (c) 2018 bryc (github.com/bryc). License: Public domain. Attribution appreciated. - // A fast and simple 64-bit (or 53-bit) string hash function with decent collision resistance. + /** @module NodeUtils **/ + +@@ -12,7 +13,7 @@ import { Vector4 } from '../../math/Vector4.js'; // Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity. // See https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript/52171480#52171480 // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js @@ -2393,17 +2465,37 @@ index 618b1587..d30384cd 100644 let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed; -@@ -36,16 +37,16 @@ function cyrb53(value, seed = 0) { - return 4294967296 * (2097151 & h2) + (h1 >>> 0); - } - +@@ -45,7 +46,7 @@ function cyrb53(value, seed = 0) { + * @param {String} str - The string to be hashed. + * @return {Number} The hash. + */ -export const hashString = str => cyrb53(str); --export const hashArray = array => cyrb53(array); --export const hash = (...params) => cyrb53(params); +export const hashString = (str: string) => cyrb53(str); + + /** + * Computes a hash for the given array. +@@ -54,7 +55,7 @@ export const hashString = str => cyrb53(str); + * @param {Array} array - The array to be hashed. + * @return {Number} The hash. + */ +-export const hashArray = array => cyrb53(array); +export const hashArray = (array: number[]) => cyrb53(array); + + /** + * Computes a hash for the given list of parameters. +@@ -63,7 +64,7 @@ export const hashArray = array => cyrb53(array); + * @param {...Number} params - A list of parameters. + * @return {Number} The hash. + */ +-export const hash = (...params) => cyrb53(params); +export const hash = (...params: number[]) => cyrb53(params); + /** + * Computes a cache key for the given node. +@@ -73,12 +74,12 @@ export const hash = (...params) => cyrb53(params); + * @param {Boolean} [force=false] - Whether to force a cache key computation or not. + * @return {Number} The hash. + */ -export function getCacheKey(object, force = false) { - const values = []; +export function getCacheKey(object: object, force = false) { @@ -2418,11 +2510,10 @@ index 618b1587..d30384cd 100644 } for (const { property, childNode } of getNodeChildren(object)) { -@@ -55,29 +56,51 @@ export function getCacheKey(object, force = false) { +@@ -87,6 +88,17 @@ export function getCacheKey(object, force = false) { + return cyrb53(values); } - --export function* getNodeChildren(node, toJSON = false) { +export interface NodeChild { + property: string; + index?: number | string; @@ -2434,7 +2525,14 @@ index 618b1587..d30384cd 100644 + index?: number | string; + childNode: Node | { toJSON: () => unknown }; +} -+ + + /** + * This generator function can be used to iterate over the node children +@@ -97,29 +109,39 @@ export function getCacheKey(object, force = false) { + * @param {Boolean} [toJSON=false] - Whether to return JSON or not. + * @yields {Object} A result node holding the property, index (if available) and the child node. + */ +-export function* getNodeChildren(node, toJSON = false) { +export function getNodeChildren(node: object): Generator; +export function getNodeChildren(node: object, toJSON: boolean): Generator; +export function* getNodeChildren(node: object, toJSON = false) { @@ -2482,10 +2580,10 @@ index 618b1587..d30384cd 100644 } } } -@@ -108,7 +131,7 @@ export function getLengthFromType(type) { - console.error('THREE.TSL: Unsupported type:', type); - } - +@@ -171,7 +193,7 @@ export function getLengthFromType(type) { + * @param {Any} value - The value. + * @return {String?} The data type. + */ -export function getValueType(value) { +export function getValueType(value: unknown) { if (value === undefined || value === null) return null; @@ -2612,21 +2710,28 @@ index 79313afa..c06474c2 100644 setCurrentStack(this); diff --git a/src-testing/src/nodes/core/StructTypeNode.ts b/src-testing/src/nodes/core/StructTypeNode.ts -index acadb07e..28f7f19f 100644 +index d698c2fb..90dc52b0 100644 --- a/src-testing/src/nodes/core/StructTypeNode.ts +++ b/src-testing/src/nodes/core/StructTypeNode.ts -@@ -5,7 +5,10 @@ class StructTypeNode extends Node { +@@ -11,13 +11,17 @@ class StructTypeNode extends Node { return 'StructTypeNode'; } -- constructor(types) { ++ name: string; + types: string[]; + readonly isStructTypeNode: true; + -+ constructor(types: string[]) { + /** + * Constructs a new struct type node. + * + * @param {String} name - The name of the struct. + * @param {Array} types - An array of types. + */ +- constructor(name, types) { ++ constructor(name: string, types: string[]) { super(); - this.types = types; + /** diff --git a/src-testing/src/nodes/core/UniformGroupNode.ts b/src-testing/src/nodes/core/UniformGroupNode.ts index 3c7fc425..e6677c50 100644 --- a/src-testing/src/nodes/core/UniformGroupNode.ts diff --git a/three.js b/three.js index 3716f3ea7..b2320be80 160000 --- a/three.js +++ b/three.js @@ -1 +1 @@ -Subproject commit 3716f3ea7ce57c191d42769936da3355ae2c6908 +Subproject commit b2320be805e60f68732ad678b518d6f222d87cd4 diff --git a/types/three/src/nodes/core/Node.d.ts b/types/three/src/nodes/core/Node.d.ts index eb084cd9a..56ae22bb6 100644 --- a/types/three/src/nodes/core/Node.d.ts +++ b/types/three/src/nodes/core/Node.d.ts @@ -154,7 +154,7 @@ declare class Node extends EventDispatcher<{ updateReference(state: NodeBuilder | NodeFrame): unknown; /** * By default this method returns the value of the {@link Node#global} flag. This method - * can be overwritten in dervied classes if an analytical way is required to determine the + * can be overwritten in derived classes if an analytical way is required to determine the * global status. * * @param {NodeBuilder} builder - The current node builder. @@ -162,9 +162,10 @@ declare class Node extends EventDispatcher<{ */ isGlobal(builder: NodeBuilder): boolean; /** - * Returns a generator that can be used to iterate over the child nodes. + * Generator function that can be used to iterate over the child nodes. * - * @return {Generator} The generator. + * @generator + * @yields {Node} A child node. */ getChildren(): Generator; /** @@ -187,7 +188,7 @@ declare class Node extends EventDispatcher<{ /** * Returns the cache key for this node. * - * @param {Boolean} [force=false] - When set to `true`, a recompuatation of the cache key is forced. + * @param {Boolean} [force=false] - When set to `true`, a recomputation of the cache key is forced. * @return {Number} The cache key of the node. */ getCacheKey(force?: boolean): number; @@ -242,7 +243,7 @@ declare class Node extends EventDispatcher<{ getNodeType(builder: NodeBuilder): string | null; /** * This method is used during the build process of a node and ensures - * equal nodes are not built multiple times but just once. For exmaple if + * equal nodes are not built multiple times but just once. For example if * `attribute( 'uv' )` is used multiple times by the user, the build * process makes sure to process just the first node. * @@ -308,7 +309,7 @@ declare class Node extends EventDispatcher<{ /** * Returns the child nodes as a JSON object. * - * @return {Object} The serialiezed child objects as JSON. + * @return {Object} The serialized child objects as JSON. */ getSerializeChildren(): Generator; /** @@ -318,13 +319,13 @@ declare class Node extends EventDispatcher<{ */ serialize(json: NodeJSONIntermediateOutputData): void; /** - * Deerializes the node from the given JSON. + * Deserializes the node from the given JSON. * * @param {Object} json - The JSON object. */ deserialize(json: NodeJSONInputData): void; /** - * Seralizes the node into the three.js JSON Object/Scene format. + * Serializes the node into the three.js JSON Object/Scene format. * * @param {Object?} meta - An optional JSON object that already holds serialized data from other scene objects. * @return {Object} The serialized node. diff --git a/types/three/src/nodes/core/NodeAttribute.d.ts b/types/three/src/nodes/core/NodeAttribute.d.ts index e2accc1c1..61711d049 100644 --- a/types/three/src/nodes/core/NodeAttribute.d.ts +++ b/types/three/src/nodes/core/NodeAttribute.d.ts @@ -15,7 +15,7 @@ declare class NodeAttribute { * * @param {String} name - The name of the attribute. * @param {String} type - The type of the attribute. - * @param {Node?} node - An optinal reference to the node. + * @param {Node?} node - An optional reference to the node. */ constructor(name: string, type: string | null, node?: Node | null); } diff --git a/types/three/src/nodes/core/StructTypeNode.d.ts b/types/three/src/nodes/core/StructTypeNode.d.ts index 44d907e93..c5c6a2626 100644 --- a/types/three/src/nodes/core/StructTypeNode.d.ts +++ b/types/three/src/nodes/core/StructTypeNode.d.ts @@ -1,9 +1,27 @@ import Node from "./Node.js"; +/** + * {@link NodeBuilder} is going to create instances of this class during the build process + * of nodes. They represent the final shader struct data that are going to be generated + * by the builder. A dictionary of struct types is maintained in {@link NodeBuilder#structs} + * for this purpose. + */ declare class StructTypeNode extends Node { static get type(): string; + name: string; types: string[]; readonly isStructTypeNode: true; - constructor(types: string[]); + /** + * Constructs a new struct type node. + * + * @param {String} name - The name of the struct. + * @param {Array} types - An array of types. + */ + constructor(name: string, types: string[]); + /** + * Returns the member types. + * + * @return {Array} The types. + */ getMemberTypes(): string[]; } export default StructTypeNode; diff --git a/types/three/src/objects/ClippingGroup.d.ts b/types/three/src/objects/ClippingGroup.d.ts index a192680f4..2a5c95bab 100644 --- a/types/three/src/objects/ClippingGroup.d.ts +++ b/types/three/src/objects/ClippingGroup.d.ts @@ -2,7 +2,7 @@ import { Plane } from "../math/Plane.js"; import { Group } from "./Group.js"; /** - * A special version of the Group object that defines clipping planes for decendant objects. ClippingGroups can be + * A special version of the Group object that defines clipping planes for descendant objects. ClippingGroups can be * nested, with clipping planes accumulating by type: intersection or union. */ declare class ClippingGroup extends Group {