diff --git a/src-testing/changes.patch b/src-testing/changes.patch index d791f4fe8..c432cdf52 100644 --- a/src-testing/changes.patch +++ b/src-testing/changes.patch @@ -1204,7 +1204,7 @@ index b1a5c99b..df827f78 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 851f26f7..e156ab99 100644 +index 39d7d789..3686f10a 100644 --- a/src-testing/src/nodes/core/NodeBuilder.ts +++ b/src-testing/src/nodes/core/NodeBuilder.ts @@ -9,7 +9,7 @@ import StructTypeNode from './StructTypeNode.js'; @@ -1411,8 +1411,8 @@ index 851f26f7..e156ab99 100644 /** * The current renderer. -@@ -225,7 +336,7 @@ class NodeBuilder { - this.cache = new NodeCache(); +@@ -402,7 +513,7 @@ class NodeBuilder { + */ this.globalCache = this.cache; - this.flowsData = new WeakMap(); @@ -1420,7 +1420,7 @@ index 851f26f7..e156ab99 100644 /** * The current shader stage. -@@ -270,7 +381,7 @@ class NodeBuilder { +@@ -453,7 +564,7 @@ class NodeBuilder { * @param {Object} options - The options of the render target. * @return {RenderTarget} The render target. */ @@ -1429,7 +1429,7 @@ index 851f26f7..e156ab99 100644 return new RenderTarget(width, height, options); } -@@ -282,7 +393,7 @@ class NodeBuilder { +@@ -465,7 +576,7 @@ class NodeBuilder { * @param {Object} options - The options of the cube render target. * @return {CubeRenderTarget} The cube render target. */ @@ -1438,7 +1438,7 @@ index 851f26f7..e156ab99 100644 return new CubeRenderTarget(size, options); } -@@ -303,16 +414,16 @@ class NodeBuilder { +@@ -486,7 +597,7 @@ 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. */ @@ -1447,6 +1447,10 @@ index 851f26f7..e156ab99 100644 return this.nodes.includes(node); } +@@ -498,12 +609,12 @@ class NodeBuilder { + * @param {Array} bindings - List of bindings. + * @return {BindGroup} The bind group + */ - _getBindGroup(groupName, bindings) { + _getBindGroup(groupName: string, bindings: NodeUniformsGroup[]) { const bindGroupsCache = this.getBindGroupsCache(); @@ -1458,7 +1462,7 @@ index 851f26f7..e156ab99 100644 let sharedGroup = true; -@@ -327,26 +438,26 @@ class NodeBuilder { +@@ -518,20 +629,20 @@ class NodeBuilder { let bindGroup; if (sharedGroup) { @@ -1482,14 +1486,16 @@ index 851f26f7..e156ab99 100644 } return bindGroup; - } - +@@ -544,7 +655,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. + * @return {Array} The array of node uniform groups. + */ - getBindGroupArray(groupName, shaderStage) { + getBindGroupArray(groupName: string, shaderStage: NodeShaderStage) { const bindings = this.bindings[shaderStage]; let bindGroup = bindings[groupName]; -@@ -366,12 +477,12 @@ class NodeBuilder { +@@ -571,12 +682,12 @@ class NodeBuilder { let bindingsGroups = this.bindGroups; if (bindingsGroups === null) { @@ -1504,7 +1510,7 @@ index 851f26f7..e156ab99 100644 const groupUniforms = groups[groupName] || (groups[groupName] = []); groupUniforms.push(...uniforms); -@@ -381,7 +492,7 @@ class NodeBuilder { +@@ -586,7 +697,7 @@ class NodeBuilder { bindingsGroups = []; for (const groupName in groups) { @@ -1513,119 +1519,137 @@ index 851f26f7..e156ab99 100644 const bindingsGroup = this._getBindGroup(groupName, group); -@@ -407,11 +518,11 @@ class NodeBuilder { - } - } - +@@ -622,7 +733,7 @@ class NodeBuilder { + * @param {Node} node - The node to add. + * @param {Number} hash - The hash of the node. + */ - setHashNode(node, hash) { + setHashNode(node: Node, hash: string) { this.hashNodes[hash] = node; } +@@ -631,7 +742,7 @@ class NodeBuilder { + * + * @param {Node} node - The node to add. + */ - addNode(node) { + addNode(node: Node) { if (this.nodes.includes(node) === false) { this.nodes.push(node); -@@ -452,7 +563,7 @@ class NodeBuilder { - return this.chaining[this.chaining.length - 1]; - } - +@@ -692,7 +803,7 @@ class NodeBuilder { + * @param {Texture} texture - The texture to check. + * @return {Boolean} Whether the given texture is filtered or not. + */ - isFilteredTexture(texture) { + isFilteredTexture(texture: Texture) { return ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || -@@ -465,7 +576,7 @@ class NodeBuilder { - ); - } - +@@ -712,7 +823,7 @@ class NodeBuilder { + * + * @param {Node} node - The node to add. + */ - addChain(node) { + addChain(node: Node) { /* if ( this.chaining.indexOf( node ) !== - 1 ) { -@@ -477,7 +588,7 @@ class NodeBuilder { - this.chaining.push(node); - } - +@@ -729,7 +840,7 @@ class NodeBuilder { + * + * @param {Node} node - The node to remove. + */ - removeChain(node) { + removeChain(node: Node) { const lastChain = this.chaining.pop(); if (lastChain !== node) { -@@ -485,21 +596,21 @@ class NodeBuilder { - } - } - +@@ -746,7 +857,7 @@ class NodeBuilder { + * @param {String} name - The method name to resolve. + * @return {String} The resolved method name. + */ - getMethod(method) { + getMethod(method: string) { return method; } +@@ -756,7 +867,7 @@ class NodeBuilder { + * @param {Number} hash - The hash of the node. + * @return {Node} The found node. + */ - getNodeFromHash(hash) { + getNodeFromHash(hash: string) { return this.hashNodes[hash]; } +@@ -767,7 +878,7 @@ class NodeBuilder { + * @param {Node} node - The node. + * @return {Node} The node + */ - addFlow(shaderStage, node) { + addFlow(shaderStage: NodeShaderStage, node: Node) { this.flowNodes[shaderStage].push(node); return node; - } - +@@ -778,7 +889,7 @@ class NodeBuilder { + * + * @param {Object} context - The context to set. + */ - setContext(context) { + setContext(context: Context) { this.context = context; } -@@ -515,7 +626,7 @@ class NodeBuilder { - return this.context; - } - +@@ -809,7 +920,7 @@ class NodeBuilder { + * + * @param {NodeCache} cache - The cache to set. + */ - setCache(cache) { + setCache(cache: NodeCache) { this.cache = cache; } -@@ -523,14 +634,14 @@ class NodeBuilder { - return this.cache; - } - +@@ -829,7 +940,7 @@ class NodeBuilder { + * @param {Boolean} [parent=true] - Whether this node refers to a shared parent cache or not. + * @return {NodeCache} The cache. + */ - getCacheFromNode(node, parent = true) { + getCacheFromNode(node: Node, parent = true) { const data = this.getDataFromNode(node); if (data.cache === undefined) data.cache = new NodeCache(parent ? this.getCache() : null); - return data.cache; - } - +@@ -843,7 +954,7 @@ class NodeBuilder { + * @param {String} name - The requested feature. + * @return {Boolean} Whether the requested feature is supported or not. + */ - isAvailable(/*name*/) { + isAvailable(name: string) { return false; } -@@ -565,15 +676,53 @@ class NodeBuilder { - return nodeData.usageCount; - } - +@@ -931,9 +1042,12 @@ class NodeBuilder { + * @param {String} uvSnippet - Snippet defining the texture coordinates. + * @return {String} The generated shader string. + */ - generateTexture(/* texture, textureProperty, uvSnippet */) { - console.warn('Abstract function.'); - } -- -- generateTextureLod(/* texture, textureProperty, uvSnippet, levelSnippet */) { -- console.warn('Abstract function.'); -- } -- -- generateConst(type, value = null) { + abstract generateTexture( + texture: Texture, + textureProperty: string, + uvSnippet: string | null, + depthSnippet: string | null, + ): string; -+ + + /** + * Generates a texture LOD shader string for the given texture data. +@@ -945,9 +1059,29 @@ class NodeBuilder { + * @param {String} levelSnippet - Snippet defining the mip level. + * @return {String} The generated shader string. + */ +- generateTextureLod(/* texture, textureProperty, uvSnippet, levelSnippet */) { +- console.warn('Abstract function.'); +- } + abstract generateTextureLod( + texture: Texture, + textureProperty: string, @@ -1649,27 +1673,19 @@ index 851f26f7..e156ab99 100644 + compareSnippet: string | null, + depthSnippet: string | null, + ): string; -+ -+ abstract generateTextureLoad( -+ texture: Texture, -+ textureProperty: string, -+ uvSnippet: string | null, -+ depthSnippet: string | null, -+ ): string; -+ -+ abstract generateTextureBias( -+ texture: Texture, -+ textureProperty: string, -+ uvSnippet: string | null, -+ biasSnippet: string | null, -+ depthSnippet: string | null, -+ ): string; -+ + + /** + * Generates the shader string for the given type and value. +@@ -956,7 +1090,7 @@ class NodeBuilder { + * @param {Any?} [value=null] - The value. + * @return {String} The generated value as a shader string. + */ +- generateConst(type, value = null) { + generateConst(type: string | null, value: unknown = null): string { if (value === null) { if (type === 'float' || type === 'int' || type === 'uint') value = 0; else if (type === 'bool') value = false; -@@ -584,26 +733,26 @@ class NodeBuilder { +@@ -967,26 +1101,26 @@ class NodeBuilder { } if (type === 'float') return toFloat(value); @@ -1705,7 +1721,7 @@ index 851f26f7..e156ab99 100644 } else if (typeLength > 4) { return `${this.getType(type)}()`; } -@@ -618,7 +767,7 @@ class NodeBuilder { +@@ -1001,7 +1135,7 @@ class NodeBuilder { * @param {String} type - The type. * @return {String} The updated type. */ @@ -1714,7 +1730,7 @@ index 851f26f7..e156ab99 100644 if (type === 'color') return 'vec3'; return type; -@@ -630,7 +779,7 @@ class NodeBuilder { +@@ -1013,7 +1147,7 @@ class NodeBuilder { * @param {String} name - The attribute name. * @return {Boolean} Whether the given attribute name is defined in the geometry. */ @@ -1723,7 +1739,7 @@ index 851f26f7..e156ab99 100644 return this.geometry && this.geometry.getAttribute(name) !== undefined; } -@@ -641,7 +790,7 @@ class NodeBuilder { +@@ -1024,7 +1158,7 @@ class NodeBuilder { * @param {String} type - The attribute's type. * @return {NodeAttribute} The node attribute. */ @@ -1732,8 +1748,8 @@ index 851f26f7..e156ab99 100644 const attributes = this.attributes; // find attribute -@@ -668,8 +817,8 @@ class NodeBuilder { - * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. +@@ -1051,8 +1185,8 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. * @return {String} The property name. */ - getPropertyName(node /*, shaderStage*/) { @@ -1743,7 +1759,7 @@ index 851f26f7..e156ab99 100644 } /** -@@ -678,8 +827,8 @@ class NodeBuilder { +@@ -1061,8 +1195,8 @@ class NodeBuilder { * @param {String} type - The type to check. * @return {Boolean} Whether the given type is a vector type or not. */ @@ -1754,7 +1770,7 @@ index 851f26f7..e156ab99 100644 } /** -@@ -688,8 +837,8 @@ class NodeBuilder { +@@ -1071,8 +1205,8 @@ class NodeBuilder { * @param {String} type - The type to check. * @return {Boolean} Whether the given type is a matrix type or not. */ @@ -1765,7 +1781,7 @@ index 851f26f7..e156ab99 100644 } /** -@@ -698,7 +847,7 @@ class NodeBuilder { +@@ -1081,7 +1215,7 @@ class NodeBuilder { * @param {String} type - The type to check. * @return {Boolean} Whether the given type is a reference type or not. */ @@ -1774,7 +1790,7 @@ index 851f26f7..e156ab99 100644 return ( type === 'void' || type === 'property' || -@@ -728,10 +877,10 @@ class NodeBuilder { +@@ -1111,10 +1245,10 @@ class NodeBuilder { * @param {Texture} texture - The texture. * @return {String} The component type. */ @@ -1787,7 +1803,7 @@ index 851f26f7..e156ab99 100644 if (type === IntType) return 'int'; if (type === UnsignedIntType) return 'uint'; } -@@ -745,7 +894,7 @@ class NodeBuilder { +@@ -1128,7 +1262,7 @@ class NodeBuilder { * @param {String} type - The type. * @return {String} The element type. */ @@ -1796,7 +1812,7 @@ index 851f26f7..e156ab99 100644 if (type === 'mat2') return 'vec2'; if (type === 'mat3') return 'vec3'; if (type === 'mat4') return 'vec4'; -@@ -759,7 +908,7 @@ class NodeBuilder { +@@ -1142,7 +1276,7 @@ class NodeBuilder { * @param {String} type - The type. * @return {String} The component type. */ @@ -1805,7 +1821,7 @@ index 851f26f7..e156ab99 100644 type = this.getVectorType(type); if (type === 'float' || type === 'bool' || type === 'int' || type === 'uint') return type; -@@ -781,7 +930,7 @@ class NodeBuilder { +@@ -1164,7 +1298,7 @@ class NodeBuilder { * @param {String} type - The type. * @return {String} The vector type. */ @@ -1814,7 +1830,7 @@ index 851f26f7..e156ab99 100644 if (type === 'color') return 'vec3'; if (type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D') return 'vec4'; -@@ -796,11 +945,11 @@ class NodeBuilder { +@@ -1179,11 +1313,11 @@ class NodeBuilder { * @param {String} [componentType='float'] - The component type. * @return {String} The type. */ @@ -1828,7 +1844,7 @@ index 851f26f7..e156ab99 100644 return prefix + baseType; } -@@ -811,8 +960,8 @@ class NodeBuilder { +@@ -1194,8 +1328,8 @@ class NodeBuilder { * @param {TypedArray} type - The typed array. * @return {String} The type. */ @@ -1839,7 +1855,7 @@ index 851f26f7..e156ab99 100644 } /** -@@ -821,10 +970,10 @@ class NodeBuilder { +@@ -1204,10 +1338,10 @@ class NodeBuilder { * @param {BufferAttribute} attribute - The buffer attribute. * @return {String} The type. */ @@ -1854,7 +1870,7 @@ index 851f26f7..e156ab99 100644 const array = dataAttribute.array; const itemSize = attribute.itemSize; -@@ -845,15 +994,15 @@ class NodeBuilder { +@@ -1228,15 +1362,15 @@ class NodeBuilder { * @param {String} type - The data type. * @return {Number} The length. */ @@ -1875,7 +1891,7 @@ index 851f26f7..e156ab99 100644 return 0; } -@@ -864,7 +1013,7 @@ class NodeBuilder { +@@ -1247,7 +1381,7 @@ class NodeBuilder { * @param {String} type - The matrix type. * @return {String} The vector type. */ @@ -1884,7 +1900,7 @@ index 851f26f7..e156ab99 100644 return type.replace('mat', 'vec'); } -@@ -877,7 +1026,7 @@ class NodeBuilder { +@@ -1260,7 +1394,7 @@ class NodeBuilder { * @param {String} newComponentType - The new component type. * @return {String} The new type. */ @@ -1893,7 +1909,7 @@ index 851f26f7..e156ab99 100644 return this.getTypeFromLength(this.getTypeLength(type), newComponentType); } -@@ -887,7 +1036,7 @@ class NodeBuilder { +@@ -1270,7 +1404,7 @@ class NodeBuilder { * @param {String} type - The type. * @return {String} The integer type. */ @@ -1902,10 +1918,10 @@ index 851f26f7..e156ab99 100644 const componentType = this.getComponentType(type); if (componentType === 'int' || componentType === 'uint') return type; -@@ -913,7 +1062,11 @@ class NodeBuilder { - return lastStack; - } - +@@ -1315,7 +1449,11 @@ class NodeBuilder { + * @param {NodeCache?} cache - An optional cache. + * @return {Object} The node data. + */ - getDataFromNode(node, shaderStage = this.shaderStage, cache = null) { + getDataFromNode( + node: Node, @@ -1915,7 +1931,7 @@ index 851f26f7..e156ab99 100644 cache = cache === null ? (node.isGlobal(this) ? this.globalCache : this.cache) : cache; let nodeData = cache.getData(node); -@@ -926,16 +1079,16 @@ class NodeBuilder { +@@ -1328,7 +1466,7 @@ class NodeBuilder { if (nodeData[shaderStage] === undefined) nodeData[shaderStage] = {}; @@ -1923,31 +1939,38 @@ index 851f26f7..e156ab99 100644 + return nodeData[shaderStage]!; } + /** +@@ -1338,7 +1476,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage='any'] - The shader stage. + * @return {Object} The node properties. + */ - getNodeProperties(node, shaderStage = 'any') { + getNodeProperties(node: Node, shaderStage: NodeShaderStage | 'any' = 'any') { const nodeData = this.getDataFromNode(node, shaderStage); return nodeData.properties || (nodeData.properties = { outputNode: null }); - } - +@@ -1351,7 +1489,7 @@ class NodeBuilder { + * @param {String} type - The node type. + * @return {NodeAttribute} The node attribute. + */ - getBufferAttributeFromNode(node, type) { + getBufferAttributeFromNode(node: Node, type: string | null) { const nodeData = this.getDataFromNode(node); let bufferAttribute = nodeData.bufferAttribute; -@@ -953,7 +1106,7 @@ class NodeBuilder { - return bufferAttribute; - } - +@@ -1377,7 +1515,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage. + * @return {StructTypeNode} The struct type attribute. + */ - getStructTypeFromNode(node, types, shaderStage = this.shaderStage) { + getStructTypeFromNode(node: StructTypeNode, types, shaderStage = this.shaderStage!) { const nodeData = this.getDataFromNode(node, shaderStage); let structType = nodeData.structType; -@@ -971,7 +1124,12 @@ class NodeBuilder { - return structType; - } - +@@ -1404,7 +1542,12 @@ class NodeBuilder { + * @param {String?} name - The name of the uniform. + * @return {NodeUniform} The node uniform. + */ - getUniformFromNode(node, type, shaderStage = this.shaderStage, name = null) { + getUniformFromNode( + node: UniformNode, @@ -1958,10 +1981,10 @@ index 851f26f7..e156ab99 100644 const nodeData = this.getDataFromNode(node, shaderStage, this.globalCache); let nodeUniform = nodeData.uniform; -@@ -989,7 +1147,12 @@ class NodeBuilder { - return nodeUniform; - } - +@@ -1431,7 +1574,12 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage. + * @return {NodeVar} The node variable. + */ - getVarFromNode(node, name = null, type = node.getNodeType(this), shaderStage = this.shaderStage) { + getVarFromNode( + node: Node, @@ -1972,77 +1995,88 @@ index 851f26f7..e156ab99 100644 const nodeData = this.getDataFromNode(node, shaderStage); let nodeVar = nodeData.variable; -@@ -1009,7 +1172,7 @@ class NodeBuilder { - return nodeVar; - } - +@@ -1459,7 +1607,7 @@ class NodeBuilder { + * @param {String} [type=node.getNodeType( this )] - The varying's type. + * @return {NodeVar} The node varying. + */ - getVaryingFromNode(node, name = null, type = node.getNodeType(this)) { + getVaryingFromNode(node: Node, name: string | null = null, type = node.getNodeType(this)) { const nodeData = this.getDataFromNode(node, 'any'); let nodeVarying = nodeData.varying; -@@ -1030,7 +1193,7 @@ class NodeBuilder { - return nodeVarying; - } - +@@ -1488,7 +1636,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage. + * @return {NodeCode} The node code. + */ - getCodeFromNode(node, type, shaderStage = this.shaderStage) { + getCodeFromNode(node: Node, type: string | null, shaderStage = this.shaderStage!) { const nodeData = this.getDataFromNode(node); let nodeCode = nodeData.code; -@@ -1080,7 +1243,7 @@ class NodeBuilder { - codeBlock.set(nodeBlock, true); - } - +@@ -1558,7 +1706,7 @@ class NodeBuilder { + * @param {Node?} [node= null] - TODO. + * @return {NodeBuilder} A reference to this node builder. + */ - addLineFlowCode(code, node = null) { + addLineFlowCode(code: string, node = null) { if (code === '') return this; if (node !== null && this.context.nodeBlock) { -@@ -1098,7 +1261,7 @@ class NodeBuilder { - return this; - } - +@@ -1582,7 +1730,7 @@ class NodeBuilder { + * @param {String} code - TODO. + * @return {NodeBuilder} A reference to this node builder. + */ - addFlowCode(code) { + addFlowCode(code: string) { this.flow.code += code; return this; -@@ -1116,11 +1279,11 @@ class NodeBuilder { - return this; - } - +@@ -1617,7 +1765,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. + * @return {Object} + */ - getFlowData(node /*, shaderStage*/) { + getFlowData(node: Node /*, shaderStage*/) { return this.flowsData.get(node); } +@@ -1627,7 +1775,7 @@ class NodeBuilder { + * @param {Node} node - TODO. + * @return {Object} + */ - flowNode(node) { + flowNode(node: Node) { const output = node.getNodeType(this); const flowData = this.flowChildNode(node, output); -@@ -1130,7 +1293,9 @@ class NodeBuilder { +@@ -1637,6 +1785,8 @@ class NodeBuilder { return flowData; } -- buildFunctionNode(shaderNode) { + abstract buildFunctionCode(shaderNode: ShaderNodeInternal): string; + + /** + * Returns the native shader operator name for a given generic name. + * It is a similar type of method like {@link NodeBuilder#getMethod}. +@@ -1644,7 +1794,7 @@ class NodeBuilder { + * @param {ShaderNodeInternal} shaderNode - The shader node to build the function node with. + * @return {FunctionNode} The build function node. + */ +- buildFunctionNode(shaderNode) { + buildFunctionNode(shaderNode: ShaderNodeInternal) { const fn = new FunctionNode(); const previous = this.currentFunctionNode; -@@ -1144,7 +1309,7 @@ class NodeBuilder { - return fn; - } - +@@ -1664,7 +1814,7 @@ class NodeBuilder { + * @param {ShaderNodeInternal} node - TODO. + * @return {Object} + */ - flowShaderNode(shaderNode) { + flowShaderNode(shaderNode: ShaderNodeInternal) { const layout = shaderNode.layout; const inputs = { -@@ -1160,7 +1325,7 @@ class NodeBuilder { +@@ -1680,7 +1830,7 @@ class NodeBuilder { }, }; @@ -2051,10 +2085,10 @@ index 851f26f7..e156ab99 100644 inputs[input.name] = new ParameterNode(input.type, input.name); } -@@ -1176,14 +1341,14 @@ class NodeBuilder { - return flowData; - } - +@@ -1703,14 +1853,14 @@ class NodeBuilder { + * @param {String?} output - TODO. + * @return {Object} + */ - flowStagesNode(node, output = null) { + flowStagesNode(node: Node, output: string | null = null) { const previousFlow = this.flow; @@ -2068,7 +2102,7 @@ index 851f26f7..e156ab99 100644 code: '', }; -@@ -1198,7 +1363,7 @@ class NodeBuilder { +@@ -1725,7 +1875,7 @@ class NodeBuilder { flow.result = node.build(this, output); } @@ -2077,10 +2111,10 @@ index 851f26f7..e156ab99 100644 this.flow = previousFlow; this.vars = previousVars; -@@ -1214,10 +1379,10 @@ class NodeBuilder { - return null; - } - +@@ -1756,10 +1906,10 @@ class NodeBuilder { + * @param {String?} output - TODO. + * @return {Object} + */ - flowChildNode(node, output = null) { + flowChildNode(node: Node, output: string | null = null) { const previousFlow = this.flow; @@ -2090,10 +2124,10 @@ index 851f26f7..e156ab99 100644 code: '', }; -@@ -1230,7 +1395,12 @@ class NodeBuilder { - return flow; - } - +@@ -1781,7 +1931,12 @@ class NodeBuilder { + * @param {String?} propertyName - TODO. + * @return {Object} + */ - flowNodeFromShaderStage(shaderStage, node, output = null, propertyName = null) { + flowNodeFromShaderStage( + shaderStage: 'vertex' | 'fragment' | 'compute', @@ -2104,8 +2138,8 @@ index 851f26f7..e156ab99 100644 const previousShaderStage = this.shaderStage; this.setShaderStage(shaderStage); -@@ -1264,9 +1434,7 @@ class NodeBuilder { - * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. +@@ -1815,9 +1970,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. * @return {String} The attribute code section. */ - getAttributes(/*shaderStage*/) { @@ -2115,8 +2149,8 @@ index 851f26f7..e156ab99 100644 /** * 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. +@@ -1826,9 +1979,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. * @return {String} The varying code section. */ - getVaryings(/*shaderStage*/) { @@ -2126,7 +2160,7 @@ index 851f26f7..e156ab99 100644 /** * Returns a single variable definition as a shader string for the given variable type and name. -@@ -1286,7 +1452,7 @@ class NodeBuilder { +@@ -1837,7 +1988,7 @@ class NodeBuilder { * @param {String} name - The variable's name. * @return {String} The shader string. */ @@ -2135,8 +2169,8 @@ index 851f26f7..e156ab99 100644 return `${this.getType(type)} ${name}`; } -@@ -1296,7 +1462,7 @@ class NodeBuilder { - * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. +@@ -1847,7 +1998,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. * @return {String} The variable code section. */ - getVars(shaderStage) { @@ -2144,8 +2178,8 @@ index 851f26f7..e156ab99 100644 let snippet = ''; const vars = this.vars[shaderStage]; -@@ -1317,9 +1483,7 @@ class NodeBuilder { - * @param {('vertex'|'fragment'|'compute')?} shaderStage - The current shader stage. +@@ -1868,9 +2019,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. * @return {String} The uniform code section. */ - getUniforms(/*shaderStage*/) { @@ -2155,8 +2189,8 @@ index 851f26f7..e156ab99 100644 /** * 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. +@@ -1878,7 +2027,7 @@ class NodeBuilder { + * @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage. * @return {String} The native code section. */ - getCodes(shaderStage) { @@ -2164,25 +2198,25 @@ index 851f26f7..e156ab99 100644 const codes = this.codes[shaderStage]; let code = ''; -@@ -1342,7 +1506,7 @@ class NodeBuilder { - } - +@@ -1898,7 +2047,7 @@ class NodeBuilder { + * @return {String} The hash. + */ getHash() { - return this.vertexShader + this.fragmentShader + this.computeShader; + return this.vertexShader! + this.fragmentShader + this.computeShader; } /** -@@ -1350,7 +1514,7 @@ class NodeBuilder { +@@ -1906,7 +2055,7 @@ class NodeBuilder { * - * @param {('vertex'|'fragment'|'compute')?} shaderStage - The shader stage to set. + * @param {('vertex'|'fragment'|'compute'|'any')?} shaderStage - The shader stage to set. */ - setShaderStage(shaderStage) { + setShaderStage(shaderStage: NodeShaderStage | null) { this.shaderStage = shaderStage; } -@@ -1368,7 +1532,7 @@ class NodeBuilder { +@@ -1924,7 +2073,7 @@ class NodeBuilder { * * @param {('setup'|'analyze'|'generate')?} buildStage - The build stage to set. */ @@ -2191,19 +2225,19 @@ index 851f26f7..e156ab99 100644 this.buildStage = buildStage; } -@@ -1449,7 +1613,7 @@ class NodeBuilder { - return this; - } - +@@ -2012,7 +2161,7 @@ class NodeBuilder { + * @param {String} type - The requested type. + * @return {Uniform} The uniform. + */ - getNodeUniform(uniformNode, type) { + getNodeUniform(uniformNode: NodeUniform, type: string | null) { 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); -@@ -1467,7 +1631,7 @@ class NodeBuilder { - throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${type}() instead.`); - } - +@@ -2034,7 +2183,7 @@ class NodeBuilder { + * @param {String} toType - The target type. + * @return {String} The updated shader string. + */ - format(snippet, fromType, toType) { + format(snippet: string, fromType: string | null, toType: string | null): string { fromType = this.getVectorType(fromType); @@ -2637,18 +2671,19 @@ index 8a291b92..39c864a4 100644 /** diff --git a/src-testing/src/nodes/core/StackNode.ts b/src-testing/src/nodes/core/StackNode.ts -index 79313afa..c06474c2 100644 +index 11c95ee6..2fd57262 100644 --- a/src-testing/src/nodes/core/StackNode.ts +++ b/src-testing/src/nodes/core/StackNode.ts -@@ -1,12 +1,22 @@ +@@ -1,6 +1,7 @@ import Node from './Node.js'; import { select } from '../math/ConditionalNode.js'; -import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack } from '../tsl/TSLBase.js'; +import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack, ShaderNodeObject } from '../tsl/TSLBase.js'; +import NodeBuilder from './NodeBuilder.js'; - class StackNode extends Node { - static get type() { + /** + * TODO +@@ -12,6 +13,15 @@ class StackNode extends Node { return 'StackNode'; } @@ -2661,10 +2696,10 @@ index 79313afa..c06474c2 100644 + + readonly isStackNode: true; + - constructor(parent = null) { - super(); - -@@ -20,24 +30,24 @@ class StackNode extends Node { + /** + * Constructs a new stack node. + * +@@ -62,7 +72,7 @@ class StackNode extends Node { this.isStackNode = true; } @@ -2673,30 +2708,37 @@ index 79313afa..c06474c2 100644 return this.outputNode ? this.outputNode.getNodeType(builder) : 'void'; } +@@ -72,7 +82,7 @@ class StackNode extends Node { + * @param {Node} node - The node to add. + * @return {StackNode} A reference to this stack node. + */ - add(node) { + add(node: Node) { this.nodes.push(node); return this; - } - +@@ -85,7 +95,7 @@ class StackNode extends Node { + * @param {Function} method - TSL code which is executed if the condition evaluates to `true`. + * @return {StackNode} A reference to this stack node. + */ - If(boolNode, method) { + If(boolNode: Node, method: () => void) { const methodNode = new ShaderNode(method); this._currentCond = select(boolNode, methodNode); - return this.add(this._currentCond); - } - +@@ -99,7 +109,7 @@ class StackNode extends Node { + * @param {Function} method - TSL code which is executed if the condition evaluates to `true`. + * @return {StackNode} A reference to this stack node. + */ - ElseIf(boolNode, method) { + ElseIf(boolNode: Node, method: () => void) { const methodNode = new ShaderNode(method); const ifNode = select(boolNode, methodNode); -@@ -47,13 +57,13 @@ class StackNode extends Node { - return this; - } - +@@ -115,13 +125,13 @@ class StackNode extends Node { + * @param {Function} method - TSL code which is executed in the `else` case. + * @return {StackNode} A reference to this stack node. + */ - Else(method) { + Else(method: () => void) { this._currentCond.elseNode = new ShaderNode(method); @@ -2934,7 +2976,7 @@ index 1fe2dbbd..a431897f 100644 +export const shaderStages: NodeShaderStage[] = [...defaultShaderStages, 'compute']; export const vectorComponents = ['x', 'y', 'z', 'w']; diff --git a/src-testing/src/nodes/fog/FogNode.ts b/src-testing/src/nodes/fog/FogNode.ts -index f08efb70..fdb3f470 100644 +index a5e53e34..53e2abcd 100644 --- a/src-testing/src/nodes/fog/FogNode.ts +++ b/src-testing/src/nodes/fog/FogNode.ts @@ -1,6 +1,7 @@ @@ -2943,12 +2985,12 @@ index f08efb70..fdb3f470 100644 import { nodeProxy } from '../tsl/TSLBase.js'; +import NodeBuilder from '../core/NodeBuilder.js'; - class FogNode extends Node { - static get type() { -@@ -16,7 +17,7 @@ class FogNode extends Node { - this.factorNode = factorNode; - } - + /** + * This class can be used to configure a fog for the scene. +@@ -57,7 +58,7 @@ class FogNode extends Node { + * @param {NodeBuilder} builder - The current node builder. + * @return {Node} The viewZ node. + */ - getViewZNode(builder) { + getViewZNode(builder: NodeBuilder) { let viewZ; diff --git a/three.js b/three.js index b2320be80..ae2791a85 160000 --- a/three.js +++ b/three.js @@ -1 +1 @@ -Subproject commit b2320be805e60f68732ad678b518d6f222d87cd4 +Subproject commit ae2791a85ed47eff59dd3ff83d1adc88950f858e diff --git a/types/three/src/core/RenderTarget.d.ts b/types/three/src/core/RenderTarget.d.ts index 2f20cabb5..4dca48477 100644 --- a/types/three/src/core/RenderTarget.d.ts +++ b/types/three/src/core/RenderTarget.d.ts @@ -72,11 +72,6 @@ export class RenderTarget extend */ resolveStencilBuffer: boolean; - /** - * @default null - */ - depthTexture: DepthTexture | null; - /** * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. * @default 0 @@ -88,6 +83,9 @@ export class RenderTarget extend get texture(): TTexture; set texture(value: TTexture); + set depthTexture(current: DepthTexture | null); + get depthTexture(): DepthTexture | null; + setSize(width: number, height: number, depth?: number): void; clone(): this; copy(source: RenderTarget): this; diff --git a/types/three/src/textures/Texture.d.ts b/types/three/src/textures/Texture.d.ts index 2dc33c5d1..a8d7460ca 100644 --- a/types/three/src/textures/Texture.d.ts +++ b/types/three/src/textures/Texture.d.ts @@ -10,6 +10,7 @@ import { Wrapping, } from "../constants.js"; import { EventDispatcher } from "../core/EventDispatcher.js"; +import { RenderTarget } from "../core/RenderTarget.js"; import { Matrix3 } from "../math/Matrix3.js"; import { Vector2 } from "../math/Vector2.js"; import { CompressedTextureMipmap } from "./CompressedTexture.js"; @@ -426,6 +427,8 @@ export class Texture extends EventDispatcher<{ dispose: {} }> { */ static DEFAULT_MAPPING: Mapping; + renderTarget: RenderTarget | null; + /** * A callback function, called when the texture is updated _(e.g., when needsUpdate has been set to true and then the texture is used)_. */