diff --git a/.dprint.jsonc b/.dprint.jsonc index 168ee7032..51524e916 100644 --- a/.dprint.jsonc +++ b/.dprint.jsonc @@ -3,6 +3,7 @@ "./examples-testing", "./jsdoc-testing", "./src-testing", + "./tsl-testing", "./three.js", "pnpm-lock.yaml" ], diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 28207c815..1abdb6b8a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -127,3 +127,21 @@ jobs: working-directory: jsdoc-testing - run: pnpm run check-declarations working-directory: jsdoc-testing + test-tsl: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + submodules: true + - uses: pnpm/action-setup@v2 + with: + version: 10.20.0 + - uses: actions/setup-node@v6 + with: + node-version: 'lts/*' + cache: 'pnpm' + - run: pnpm install + - run: pnpm run type-check + working-directory: tsl-testing + - run: pnpm run format-check + working-directory: tsl-testing diff --git a/examples-testing/changes.patch b/examples-testing/changes.patch index 5271cfa14..29009bfca 100644 --- a/examples-testing/changes.patch +++ b/examples-testing/changes.patch @@ -13789,7 +13789,7 @@ index 91bc961d..374525a2 100644 const clock = new THREE.Clock(); -export const lightSpeed = /*#__PURE__*/ Fn(([suv_immutable]) => { -+export const lightSpeed = /*#__PURE__*/ Fn<[THREE.Node]>(([suv_immutable]) => { ++export const lightSpeed = /*#__PURE__*/ Fn<[THREE.Node], THREE.Node<'vec3'>>(([suv_immutable]) => { // forked from https://www.shadertoy.com/view/7ly3D1 const suv = vec2(suv_immutable); @@ -13975,11 +13975,11 @@ index 1b780ce9..5d7ada58 100644 const waterPosY = positionWorld.y.sub(water.position.y); - let transition = waterPosY.add(0.1).saturate().oneMinus(); -+ let transition: THREE.Node = waterPosY.add(0.1).saturate().oneMinus(); ++ let transition: THREE.Node<'float'> = waterPosY.add(0.1).saturate().oneMinus(); transition = waterPosY.lessThan(0).select(transition, normalWorld.y.mix(transition, 0)).toVar(); - const colorNode = transition.mix(material.colorNode, material.colorNode.add(waterLayer0)); -+ const colorNode = transition.mix(material.colorNode!, material.colorNode!.add(waterLayer0)); ++ const colorNode = transition.mix(material.colorNode as THREE.Node<'vec4'>, material.colorNode!.add(waterLayer0)); //material.colorNode = colorNode; floor.material.colorNode = colorNode; @@ -14421,7 +14421,7 @@ index 229033d7..b7bd1fde 100644 +let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer; +let computeNode: THREE.ComputeNode; +let waveBuffer: Float32Array, sampleRate: number; -+let waveArray: THREE.StorageBufferNode; ++let waveArray: THREE.StorageBufferNode<'float'>; +let currentAudio: AudioBufferSourceNode, currentAnalyser: AnalyserNode; const analyserBuffer = new Uint8Array(1024); -let analyserTexture; @@ -14446,7 +14446,7 @@ index 229033d7..b7bd1fde 100644 const time = index.mul(pitch); - let wave = originalWave.element(time); -+ let wave: THREE.Node = originalWave.element(time); ++ let wave: THREE.Node<'float'> = originalWave.element(time); // delay @@ -14480,14 +14480,14 @@ index c602920e..266f691e 100644 +let computeVelocity: THREE.ComputeNode, + computePosition: THREE.ComputeNode, + effectController: { -+ separation: THREE.UniformNode; -+ alignment: THREE.UniformNode; -+ cohesion: THREE.UniformNode; -+ freedom: THREE.UniformNode; -+ now: THREE.UniformNode; -+ deltaTime: THREE.UniformNode; -+ rayOrigin: THREE.UniformNode; -+ rayDirection: THREE.UniformNode; ++ separation: THREE.UniformNode<'float', number>; ++ alignment: THREE.UniformNode<'float', number>; ++ cohesion: THREE.UniformNode<'float', number>; ++ freedom: THREE.UniformNode<'float', number>; ++ now: THREE.UniformNode<'float', number>; ++ deltaTime: THREE.UniformNode<'float', number>; ++ rayOrigin: THREE.UniformNode<'vec3', THREE.Vector3>; ++ rayDirection: THREE.UniformNode<'vec3', THREE.Vector3>; + }; const BIRDS = 16384; @@ -14543,19 +14543,19 @@ index b5f7c5df..a95c1efd 100644 -let dampeningUniform, spherePositionUniform, stiffnessUniform, sphereUniform, windUniform; -let vertexWireframeObject, springWireframeObject; -let clothMesh, clothMaterial, sphere; -+let vertexPositionBuffer: THREE.StorageBufferNode, -+ vertexForceBuffer: THREE.StorageBufferNode, -+ vertexParamsBuffer: THREE.StorageBufferNode; -+let springVertexIdBuffer: THREE.StorageBufferNode, -+ springRestLengthBuffer: THREE.StorageBufferNode, -+ springForceBuffer: THREE.StorageBufferNode; -+let springListBuffer: THREE.StorageBufferNode; ++let vertexPositionBuffer: THREE.StorageBufferNode<'vec3'>, ++ vertexForceBuffer: THREE.StorageBufferNode<'vec3'>, ++ vertexParamsBuffer: THREE.StorageBufferNode<'uvec3'>; ++let springVertexIdBuffer: THREE.StorageBufferNode<'uvec2'>, ++ springRestLengthBuffer: THREE.StorageBufferNode<'float'>, ++ springForceBuffer: THREE.StorageBufferNode<'vec3'>; ++let springListBuffer: THREE.StorageBufferNode<'uint'>; +let computeSpringForces: THREE.ComputeNode, computeVertexForces: THREE.ComputeNode; -+let dampeningUniform: THREE.UniformNode, -+ spherePositionUniform: THREE.UniformNode, -+ stiffnessUniform: THREE.UniformNode, -+ sphereUniform: THREE.UniformNode, -+ windUniform: THREE.UniformNode; ++let dampeningUniform: THREE.UniformNode<'float', number>, ++ spherePositionUniform: THREE.UniformNode<'vec3', THREE.Vector3>, ++ stiffnessUniform: THREE.UniformNode<'float', number>, ++ sphereUniform: THREE.UniformNode<'float', number>, ++ windUniform: THREE.UniformNode<'float', number>; +let vertexWireframeObject: THREE.Mesh, springWireframeObject: THREE.Line; +let clothMesh: THREE.Mesh, clothMaterial: THREE.MeshPhysicalNodeMaterial, sphere: THREE.Mesh; let timeSinceLastStep = 0; @@ -14611,6 +14611,15 @@ index b5f7c5df..a95c1efd 100644 const id = verletSprings.length; const spring = { id, +@@ -349,7 +372,7 @@ function setupWireframe() { + const springWireframeMaterial = new THREE.LineBasicNodeMaterial(); + springWireframeMaterial.positionNode = Fn(() => { + const vertexIds = springVertexIdBuffer.element(instanceIndex); +- const vertexId = select(attribute('vertexIndex').equal(0), vertexIds.x, vertexIds.y); ++ const vertexId = select(attribute<'uint'>('vertexIndex').equal(0), vertexIds.x, vertexIds.y); + return vertexPositionBuffer.element(vertexId); + })(); + @@ -382,7 +405,7 @@ function setupClothMesh() { const verletVertexIdArray = new Uint32Array(vertexCount * 4); const indices = []; @@ -14620,6 +14629,15 @@ index b5f7c5df..a95c1efd 100644 return y * clothNumSegmentsX + x; }; +@@ -419,7 +442,7 @@ function setupClothMesh() { + + clothMaterial.positionNode = Fn(({ material }) => { + // gather the position of the 4 verlet vertices and calculate the center position and normal from that +- const vertexIds = attribute('vertexIds'); ++ const vertexIds = attribute<'uvec4'>('vertexIds'); + const v0 = vertexPositionBuffer.element(vertexIds.x).toVar(); + const v1 = vertexPositionBuffer.element(vertexIds.y).toVar(); + const v2 = vertexPositionBuffer.element(vertexIds.z).toVar(); @@ -436,7 +459,7 @@ function setupClothMesh() { const normal = cross(tangent, bitangent); @@ -14658,7 +14676,7 @@ index 1f76c981..f12346d8 100644 const computeUpdate = Fn(() => { - const getCoord = pos => pos.add(50).div(100); -+ const getCoord = (pos: THREE.Node) => pos.add(50).div(100); ++ const getCoord = (pos: THREE.Node<'vec2'>) => pos.add(50).div(100); const position = positionBuffer.element(instanceIndex); const scale = scaleBuffer.element(instanceIndex); @@ -14676,7 +14694,7 @@ index 1f76c981..f12346d8 100644 // compose - let totalPass = scenePass.toInspector('Scene'); -+ let totalPass: THREE.Node = scenePass.toInspector('Scene'); ++ let totalPass: THREE.Node<'vec4'> = scenePass.toInspector('Scene'); totalPass = totalPass.add(scenePassColorBlurred.mul(0.1)); totalPass = totalPass.mul(vignette); totalPass = totalPass.add(teapotTreePass.mul(10).add(teapotTreePassBlurred).toInspector('Teapot Blur')); @@ -14733,7 +14751,7 @@ index 9a37a9ec..b277be89 100644 // Display utilities -const getElementIndex = Fn( -+const getElementIndex = Fn( ++const getElementIndex = Fn, THREE.Node<'uint'>, THREE.Node<'uint'>], THREE.Node<'uint'>>( ([uvNode, gridWidth, gridHeight]) => { const newUV = uvNode.mul(vec2(gridWidth, gridHeight)); const pixel = uvec2(uint(floor(newUV.x)), uint(floor(newUV.y))); @@ -14742,7 +14760,7 @@ index 9a37a9ec..b277be89 100644 ); -const getColor = Fn( -+const getColor = Fn( ++const getColor = Fn, THREE.Node<'float'>, THREE.Node<'float'>], THREE.Node<'vec3'>>( ([colorChanger, gridWidth, gridHeight]) => { const subtracter = colorChanger.div(gridWidth.mul(gridHeight)); return vec3(subtracter.oneMinus()).toVar(); @@ -14779,23 +14797,26 @@ index 9a37a9ec..b277be89 100644 -const createDisplayMesh = (elementsStorage, algoStorage = null, blockHeightStorage = null) => { +const createDisplayMesh = ( -+ elementsStorage: THREE.StorageBufferNode, -+ algoStorage: THREE.StorageBufferNode | null = null, -+ blockHeightStorage: THREE.StorageBufferNode | null = null, ++ elementsStorage: THREE.StorageBufferNode<'uint'>, ++ algoStorage: THREE.StorageBufferNode<'uint'> | null = null, ++ blockHeightStorage: THREE.StorageBufferNode<'uint'> | null = null, +) => { const material = new THREE.MeshBasicNodeMaterial({ color: 0x00ff00 }); const display = Fn(() => { -@@ -151,7 +155,7 @@ const createDisplayMesh = (elementsStorage, algoStorage = null, blockHeightStora +@@ -151,7 +155,10 @@ const createDisplayMesh = (elementsStorage, algoStorage = null, blockHeightStora return plane; }; -const createDisplayMesh2 = (elementsStorage, infoStorage) => { -+const createDisplayMesh2 = (elementsStorage: THREE.StorageBufferNode, infoStorage: THREE.StorageBufferNode) => { ++const createDisplayMesh2 = ( ++ elementsStorage: THREE.StorageBufferNode<'uint'>, ++ infoStorage: THREE.StorageBufferNode<'uint'>, ++) => { const material = new THREE.MeshBasicNodeMaterial({ color: 0x00ff00 }); const display = Fn(() => { -@@ -175,7 +179,7 @@ const createDisplayMesh2 = (elementsStorage, infoStorage) => { +@@ -175,7 +182,7 @@ const createDisplayMesh2 = (elementsStorage, infoStorage) => { return plane; }; @@ -14804,7 +14825,7 @@ index 9a37a9ec..b277be89 100644 document.body.appendChild(renderer.domElement); renderer.domElement.style.position = 'absolute'; renderer.domElement.style.top = '0'; -@@ -319,7 +323,7 @@ async function initGlobalSwapOnly() { +@@ -319,7 +326,7 @@ async function initGlobalSwapOnly() { .setName('RandomizedElements'); // Swap the elements in local storage @@ -14831,7 +14852,7 @@ index 43d162ab..99033e0e 100644 // create function - const computeTexture = Fn(({ storageTexture }) => { -+ const computeTexture = Fn<{ storageTexture: THREE.Texture }>(({ storageTexture }) => { ++ const computeTexture = Fn<{ storageTexture: THREE.Texture }, void>(({ storageTexture }) => { const posX = instanceIndex.mod(width); const posY = instanceIndex.div(width); const indexUV = uvec2(posX, posY); @@ -14866,24 +14887,27 @@ index ccdfba0b..eb764390 100644 const size = 200; - const computeCloud = Fn(({ storageTexture }) => { -+ const computeCloud = Fn<{ storageTexture: THREE.Storage3DTexture }>(({ storageTexture }) => { ++ const computeCloud = Fn<{ storageTexture: THREE.Storage3DTexture }, void>(({ storageTexture }) => { const scale = float(0.05); const id = instanceIndex; -@@ -110,33 +110,37 @@ async function init() { +@@ -110,33 +110,40 @@ async function init() { // Shader - const transparentRaymarchingTexture = Fn( - ({ texture, range = float(0.14), threshold = float(0.08), opacity = float(0.18), steps = float(100) }) => { - const finalColor = vec4(0).toVar(); -+ const transparentRaymarchingTexture = Fn<{ -+ texture: THREE.Texture3DNode; -+ range?: THREE.UniformNode; -+ threshold?: THREE.UniformNode; -+ opacity?: THREE.UniformNode; -+ steps?: THREE.UniformNode; -+ }>(({ texture, range = float(0.14), threshold = float(0.08), opacity = float(0.18), steps = float(100) }) => { ++ const transparentRaymarchingTexture = Fn< ++ { ++ texture: THREE.Texture3DNode; ++ range?: THREE.UniformNode<'float', number>; ++ threshold?: THREE.UniformNode<'float', number>; ++ opacity?: THREE.UniformNode<'float', number>; ++ steps?: THREE.UniformNode<'float', number>; ++ }, ++ THREE.Node<'vec4'> ++ >(({ texture, range = float(0.14), threshold = float(0.08), opacity = float(0.18), steps = float(100) }) => { + const finalColor = vec4(0).toVar(); - RaymarchingBox(steps, ({ positionRay }) => { @@ -14926,7 +14950,7 @@ index ccdfba0b..eb764390 100644 // Material -@@ -171,7 +175,7 @@ async function init() { +@@ -171,7 +178,7 @@ async function init() { renderer.compute(computeNode); @@ -14967,12 +14991,26 @@ index 429d2ff4..e6ffdb5b 100644 init(); -@@ -68,7 +68,7 @@ async function init() { +@@ -59,16 +59,16 @@ async function init() { + saturation: 1, + }; + +- const mixNode = reference('mix', 'float', adjustments); +- const proceduralNode = reference('procedural', 'float', adjustments); +- const intensityNode = reference('intensity', 'float', adjustments); +- const hueNode = reference('hue', 'float', adjustments); +- const saturationNode = reference('saturation', 'float', adjustments); ++ const mixNode = reference<'float', typeof adjustments>('mix', 'float', adjustments); ++ const proceduralNode = reference<'float', typeof adjustments>('procedural', 'float', adjustments); ++ const intensityNode = reference<'float', typeof adjustments>('intensity', 'float', adjustments); ++ const hueNode = reference<'float', typeof adjustments>('hue', 'float', adjustments); ++ const saturationNode = reference<'float', typeof adjustments>('saturation', 'float', adjustments); + const rotateY1Matrix = new THREE.Matrix4(); const rotateY2Matrix = new THREE.Matrix4(); - const getEnvironmentNode = (reflectNode, positionNode) => { -+ const getEnvironmentNode = (reflectNode: THREE.Node, positionNode: THREE.Node) => { ++ const getEnvironmentNode = (reflectNode: THREE.Node<'vec3'>, positionNode: THREE.Node<'vec3'>) => { const custom1UV = reflectNode.xyz.mul(uniform(rotateY1Matrix)); const custom2UV = reflectNode.xyz.mul(uniform(rotateY2Matrix)); const mixCubeMaps = mix( @@ -15248,6 +15286,21 @@ index a5bce322..d542dc64 100644 v.x += 0.5 - Math.random(); v.y += 0.5 - Math.random(); +@@ -92,10 +92,10 @@ async function init() { + + // TSL + +- const instancePosition = instancedBufferAttribute(positionAttribute); +- const instanceColor = instancedBufferAttribute(colorAttribute); +- const instanceSeed = instancedBufferAttribute(seedAttribute); +- const instanceTime = instancedBufferAttribute(timeAttribute); ++ const instancePosition = instancedBufferAttribute<'vec3'>(positionAttribute); ++ const instanceColor = instancedBufferAttribute<'vec3'>(colorAttribute); ++ const instanceSeed = instancedBufferAttribute<'float'>(seedAttribute); ++ const instanceTime = instancedBufferAttribute<'float'>(timeAttribute); + + const localTime = instanceTime.add(time); + const modTime = mod(time.mul(0.4), 1); diff --git a/examples-testing/examples/webgpu_instance_points.ts b/examples-testing/examples/webgpu_instance_points.ts index 40912937..e43bcee2 100644 --- a/examples-testing/examples/webgpu_instance_points.ts @@ -15264,12 +15317,12 @@ index 40912937..e43bcee2 100644 + camera: THREE.PerspectiveCamera, + camera2: THREE.PerspectiveCamera, + controls: OrbitControls, -+ backgroundNode: THREE.Node; ++ backgroundNode: THREE.Node<'color'>; +let material: THREE.PointsNodeMaterial; +let effectController: { -+ pulseSpeed: THREE.UniformNode; -+ minWidth: THREE.UniformNode; -+ maxWidth: THREE.UniformNode; ++ pulseSpeed: THREE.UniformNode<'float', number>; ++ minWidth: THREE.UniformNode<'float', number>; ++ maxWidth: THREE.UniformNode<'float', number>; +}; // viewport @@ -15284,6 +15337,19 @@ index 40912937..e43bcee2 100644 init(); +@@ -94,10 +103,10 @@ async function init() { + + // Material / Sprites + +- const attributeRange = instancedBufferAttribute(instanceSizeBufferAttribute); ++ const attributeRange = instancedBufferAttribute<'float'>(instanceSizeBufferAttribute); + const pointColors = mix( + vec3(0.0), +- instancedBufferAttribute(colorsAttribute), ++ instancedBufferAttribute<'vec3'>(colorsAttribute), + attributeRange.div(float(effectController.maxWidth)), + ); + @@ -136,7 +145,7 @@ async function init() { // GUI @@ -15360,6 +15426,22 @@ index c1db7d60..15b6851c 100644 // instance data const positions = []; +@@ -117,11 +117,11 @@ function getMaterial(count, color, sprite) { + + // TSL + +- const instancePosition = instancedBufferAttribute(positionAttribute); +- const instanceDirection = instancedBufferAttribute(directionAttribute); +- const instanceRotation = instancedBufferAttribute(rotationAttribute); ++ const instancePosition = instancedBufferAttribute<'vec3'>(positionAttribute); ++ const instanceDirection = instancedBufferAttribute<'vec3'>(directionAttribute); ++ const instanceRotation = instancedBufferAttribute<'vec3'>(rotationAttribute); + +- const localTime = instancedBufferAttribute(timeAttribute).add(time.mul(0.02)); ++ const localTime = instancedBufferAttribute<'float'>(timeAttribute).add(time.mul(0.02)); + const modTime = mod(localTime, 1.0); + + const rotatedPosition = rotate(positionLocal, instanceRotation.mul(modTime.mul(20))); diff --git a/examples-testing/examples/webgpu_lensflares.ts b/examples-testing/examples/webgpu_lensflares.ts index cfd67fde..90af446b 100644 --- a/examples-testing/examples/webgpu_lensflares.ts @@ -15628,6 +15710,20 @@ index e00d75b2..ee12bb56 100644 mesh.geometry = createGeometry(mesh.geometry); mesh.material = createMaterial(); +@@ -102,10 +106,10 @@ function animate() { + function createMaterial() { + const material = new THREE.MeshPhongNodeMaterial(); + +- const seedAttribute = attribute('seed'); +- const displaceNormalAttribute = attribute('displaceNormal'); ++ const seedAttribute = attribute<'float'>('seed'); ++ const displaceNormalAttribute = attribute<'vec3'>('displaceNormal'); + +- const localTime = attribute('time').add(time); ++ const localTime = attribute<'float'>('time').add(time); + + const effector1 = uniform(light1.position).toVar(); + const effector2 = uniform(light2.position).toVar(); @@ -125,7 +129,7 @@ function createMaterial() { return material; } @@ -15776,8 +15872,8 @@ index c30e0bb5..25c53f3a 100644 + lights: THREE.Group, + lightDummy: THREE.InstancedMesh, + controls: OrbitControls, -+ compose: THREE.Node, -+ tileInfluence: THREE.UniformNode, ++ compose: THREE.Node<'vec4'>, ++ tileInfluence: THREE.UniformNode<'float', number>, + lighting: TiledLighting, + count: number, + postProcessing: THREE.PostProcessing; @@ -15830,7 +15926,7 @@ index 96417888..2ec8e8b1 100644 + camera: THREE.PerspectiveCamera, + camera2: THREE.PerspectiveCamera, + controls: OrbitControls, -+ backgroundNode: THREE.Node; ++ backgroundNode: THREE.Node<'color'>; +let line1: THREE.Line; +let matLine: THREE.Line2NodeMaterial, + matLineBasic: THREE.LineBasicNodeMaterial, @@ -15979,7 +16075,7 @@ index 9ab5c44c..dee04a5a 100644 + camera: THREE.PerspectiveCamera, + camera2: THREE.PerspectiveCamera, + controls: OrbitControls, -+ backgroundNode: THREE.Node; ++ backgroundNode: THREE.Node<'color'>; +let wireframe1: THREE.LineSegments; +let matLine: THREE.Line2NodeMaterial, matLineBasic: THREE.LineBasicMaterial, matLineDashed: THREE.LineDashedMaterial; +let gui: ParametersGroup; @@ -16191,14 +16287,14 @@ index 4dde3561..6777cd37 100644 init(); -@@ -90,27 +90,29 @@ function init() { +@@ -90,29 +90,33 @@ function init() { const material = new THREE.MeshBasicNodeMaterial(); - const gridXZ = Fn(([gridSize = float(1.0), dotWidth = float(0.1), lineWidth = float(0.02)]) => { - const coord = positionWorld.xz.div(gridSize); - const grid = fract(coord); -+ const gridXZ = Fn<[THREE.Node, THREE.Node, THREE.Node]>( ++ const gridXZ = Fn<[THREE.Node<'float'>, THREE.Node<'float'>, THREE.Node<'float'>], THREE.Node<'float'>>( + ([gridSize = float(1.0), dotWidth = float(0.1), lineWidth = float(0.02)]) => { + const coord = positionWorld.xz.div(gridSize); + const grid = fract(coord); @@ -16233,11 +16329,17 @@ index 4dde3561..6777cd37 100644 + ); - const radialGradient = Fn(([radius = float(10.0), falloff = float(1.0)]) => { -+ const radialGradient = Fn<[THREE.Node, THREE.Node]>(([radius = float(10.0), falloff = float(1.0)]) => { - return smoothstep(radius, radius.sub(falloff), length(positionWorld)); - }); +- return smoothstep(radius, radius.sub(falloff), length(positionWorld)); +- }); ++ const radialGradient = Fn<[THREE.Node<'float'>, THREE.Node<'float'>], THREE.Node<'float'>>( ++ ([radius = float(10.0), falloff = float(1.0)]) => { ++ return smoothstep(radius, radius.sub(falloff), length(positionWorld)); ++ }, ++ ); -@@ -177,7 +179,7 @@ function updateModelsAlign() { + // Create grid pattern + const gridPattern = gridXZ(1.0, 0.03, 0.005); +@@ -177,7 +181,7 @@ function updateModelsAlign() { } } @@ -16246,7 +16348,7 @@ index 4dde3561..6777cd37 100644 const model = prefab.clone(); models.push(model); -@@ -191,12 +193,12 @@ async function addSample(sample, path) { +@@ -191,12 +195,12 @@ async function addSample(sample, path) { const material = await new MaterialXLoader() .setPath(path) .loadAsync(sample) @@ -16262,7 +16364,7 @@ index 4dde3561..6777cd37 100644 previewMesh.material = material; if (material.transparent) { -@@ -206,7 +208,7 @@ async function addSample(sample, path) { +@@ -206,7 +210,7 @@ async function addSample(sample, path) { } function addGUI() { @@ -16271,7 +16373,7 @@ index 4dde3561..6777cd37 100644 const API = { showCalibrationMesh: true, -@@ -226,9 +228,9 @@ function addGUI() { +@@ -226,9 +230,9 @@ function addGUI() { }); } @@ -16762,7 +16864,7 @@ index c76df99d..9c9fb02d 100644 model.position.set(0, 0, 10); model.scale.setScalar(1); model.material = material; -@@ -103,16 +103,24 @@ function initMaterial() { +@@ -103,37 +103,45 @@ function initMaterial() { initGUI(material); } @@ -16787,16 +16889,42 @@ index c76df99d..9c9fb02d 100644 + scale: number; + + constructor() { -+ this.distortion = material.thicknessDistortionNode.value; -+ this.ambient = material.thicknessAmbientNode.value; -+ this.attenuation = material.thicknessAttenuationNode.value; -+ this.power = material.thicknessPowerNode.value; -+ this.scale = material.thicknessScaleNode.value; ++ this.distortion = (material.thicknessDistortionNode as THREE.UniformNode<'float', number>).value; ++ this.ambient = (material.thicknessAmbientNode as THREE.UniformNode<'float', number>).value; ++ this.attenuation = (material.thicknessAttenuationNode as THREE.UniformNode<'float', number>).value; ++ this.power = (material.thicknessPowerNode as THREE.UniformNode<'float', number>).value; ++ this.scale = (material.thicknessScaleNode as THREE.UniformNode<'float', number>).value; + } + } const thicknessControls = new ThicknessControls(); + gui.add(thicknessControls, 'distortion', 0.01, 1, 0.01).onChange(function () { +- material.thicknessDistortionNode.value = thicknessControls.distortion; ++ (material.thicknessDistortionNode as THREE.UniformNode<'float', number>).value = thicknessControls.distortion; + }); + + gui.add(thicknessControls, 'ambient', 0.01, 5.0, 0.05).onChange(function () { +- material.thicknessAmbientNode.value = thicknessControls.ambient; ++ (material.thicknessAmbientNode as THREE.UniformNode<'float', number>).value = thicknessControls.ambient; + }); + + gui.add(thicknessControls, 'attenuation', 0.01, 5.0, 0.05).onChange(function () { +- material.thicknessAttenuationNode.value = thicknessControls.attenuation; ++ (material.thicknessAttenuationNode as THREE.UniformNode<'float', number>).value = thicknessControls.attenuation; + }); + + gui.add(thicknessControls, 'power', 0.01, 16.0, 0.1).onChange(function () { +- material.thicknessPowerNode.value = thicknessControls.power; ++ (material.thicknessPowerNode as THREE.UniformNode<'float', number>).value = thicknessControls.power; + }); + + gui.add(thicknessControls, 'scale', 0.01, 50.0, 0.1).onChange(function () { +- material.thicknessScaleNode.value = thicknessControls.scale; ++ (material.thicknessScaleNode as THREE.UniformNode<'float', number>).value = thicknessControls.scale; + }); + } + diff --git a/examples-testing/examples/webgpu_materials_texture_manualmipmap.ts b/examples-testing/examples/webgpu_materials_texture_manualmipmap.ts index 09037272..2456b295 100644 --- a/examples-testing/examples/webgpu_materials_texture_manualmipmap.ts @@ -17562,9 +17690,10 @@ index e49f98ce..148171a6 100644 -let camera, scene, renderer, controls; +let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer, controls: OrbitControls; - class OcclusionNode extends THREE.Node { +-class OcclusionNode extends THREE.Node { - constructor(testObject, normalColor, occludedColor) { -+ uniformNode: THREE.UniformNode; ++class OcclusionNode extends THREE.Node<'vec3'> { ++ uniformNode: THREE.UniformNode<'color', THREE.Color>; + + testObject: THREE.Mesh; + normalColor: THREE.Color; @@ -17903,7 +18032,7 @@ index 3dc3ceb4..aad91a01 100644 const loader = new GLTFLoader(); loader.load('models/gltf/Xbot.glb', function (gltf) { - const createModel = (colorNode = null) => { -+ const createModel = (colorNode: THREE.Node | null = null) => { ++ const createModel = (colorNode: THREE.Node<'vec3'> | null = null) => { let object; if (mixers.length === 0) { @@ -18057,8 +18186,12 @@ index f23b09c1..166d3b92 100644 gui.add(params, 'intensity', 0, 1); window.addEventListener('resize', onWindowResize); -@@ -219,7 +240,7 @@ async function animate() { - lutPass.intensityNode.value = params.intensity; +@@ -216,10 +237,10 @@ function onWindowResize() { + async function animate() { + controls.update(); + +- lutPass.intensityNode.value = params.intensity; ++ (lutPass.intensityNode as THREE.UniformNode<'float', number>).value = params.intensity; if (lutMap[params.lut]) { - const lut = lutMap[params.lut]; @@ -18086,6 +18219,22 @@ index 88a0c635..286b58cf 100644 const params = { damp: uniform(0.8, 'float').setName('damp'), +@@ -72,13 +72,13 @@ function init() { + + const material = new THREE.SpriteNodeMaterial({ blending: THREE.AdditiveBlending, depthWrite: false }); + +- const localTime = instancedBufferAttribute(timeAttribute).add(time.mul(0.1)); ++ const localTime = instancedBufferAttribute<'float'>(timeAttribute).add(time.mul(0.1)); + const modTime = mod(localTime, 1.0); + const accTime = modTime.mul(modTime); + + const angle = accTime.mul(40.0); + const pulse = vec2(sin(angle).mul(20.0), cos(angle).mul(20.0)); +- const pos = instancedBufferAttribute(positionAttribute); ++ const pos = instancedBufferAttribute<'vec3'>(positionAttribute); + + const animated = vec3( + pos.x.mul(accTime).add(pulse.x), @@ -107,8 +107,8 @@ function init() { // @@ -18093,7 +18242,7 @@ index 88a0c635..286b58cf 100644 - const gui = renderer.inspector.createParameters('Settings'); - gui.add(afterImagePass.damp, 'value', 0.25, 1); + const gui = (renderer.inspector as Inspector).createParameters('Settings'); -+ gui.add(afterImagePass.damp as THREE.UniformNode, 'value', 0.25, 1); ++ gui.add(afterImagePass.damp as THREE.UniformNode<'float', number>, 'value', 0.25, 1); gui.add(params, 'enabled').onChange(updatePassChain); window.addEventListener('resize', onWindowResize); @@ -18245,7 +18394,7 @@ index 48ea482e..4ec44893 100644 + .material; - const bloomIntensity = material.mrtNode.get('bloomIntensity'); -+ const bloomIntensity = material.mrtNode!.get('bloomIntensity') as THREE.UniformNode; ++ const bloomIntensity = material.mrtNode!.get('bloomIntensity') as THREE.UniformNode<'float', number>; bloomIntensity.value = bloomIntensity.value === 0 ? 1 : 0; } }); @@ -18472,7 +18621,7 @@ index 160be467..e21c6cd2 100644 const sceneMask2 = pass(maskScene2, camera).a; - let compose = base; -+ let compose: THREE.Node = base; ++ let compose: THREE.Node<'vec4'> = base; compose = sceneMask1.mix(compose, texture(texture1)); compose = sceneMask2.mix(compose, texture(texture2)); @@ -18582,9 +18731,9 @@ index 01d72fce..3684c180 100644 + crystalMesh: THREE.Mesh, + clock: THREE.Clock; +let effectController: { -+ pixelSize: THREE.UniformNode; -+ normalEdgeStrength: THREE.UniformNode; -+ depthEdgeStrength: THREE.UniformNode; ++ pixelSize: THREE.UniformNode<'float', number>; ++ normalEdgeStrength: THREE.UniformNode<'float', number>; ++ depthEdgeStrength: THREE.UniformNode<'float', number>; + pixelAlignedPanning: boolean; +}; @@ -18971,12 +19120,12 @@ index c4c88665..fc7976ff 100644 + animateScene: boolean; + animateTransition: boolean; + transition: number; -+ _transition: THREE.UniformNode; ++ _transition: THREE.UniformNode<'float', number>; + useTexture: boolean; -+ _useTexture: THREE.UniformNode; ++ _useTexture: THREE.UniformNode<'float', number>; + texture: number; + cycle: boolean; -+ threshold: THREE.UniformNode; ++ threshold: THREE.UniformNode<'float', number>; +} + +const effectController: EffectController = { @@ -19163,12 +19312,27 @@ index 76592b8c..53dbdbba 100644 if (count < maxSteps) { const newLength = length * lengthMult; const newX = x + Math.cos(angle) * length; +@@ -288,10 +287,10 @@ function createTreeMesh() { + + // TSL + +- const instancePosition = instancedBufferAttribute(attributePosition); +- const instanceNormal = instancedBufferAttribute(attributeNormal); +- const instanceColor = instancedBufferAttribute(attributeColor); +- const instanceData = instancedBufferAttribute(attributeData); ++ const instancePosition = instancedBufferAttribute<'vec3'>(attributePosition); ++ const instanceNormal = instancedBufferAttribute<'vec3'>(attributeNormal); ++ const instanceColor = instancedBufferAttribute<'vec3'>(attributeColor); ++ const instanceData = instancedBufferAttribute<'vec3'>(attributeData); + + material.positionNode = Fn(() => { + const instanceSize = instanceData.x; @@ -308,7 +307,7 @@ function createTreeMesh() { // accumulate different vertex animations - let animated = positionLocal.add(instancePosition).toVar(); -+ let animated: THREE.Node = positionLocal.add(instancePosition).toVar(); ++ let animated: THREE.Node<'vec3'> = positionLocal.add(instancePosition).toVar(); const direction = positionGeometry.normalize().toConst(); animated = animated.add(direction.mul(effect.add(instanceSize))); @@ -19256,6 +19420,24 @@ index 627fd6b1..ededdfd5 100644 const map3D = new THREE.Data3DTexture(array, size.width, size.height, size.depth); map3D.name = 'Data3DTexture'; +@@ -109,7 +120,7 @@ async function init() { + // 3D + const helper3D = new TextureHelper(map3D, 10, 10, depth); + helper3D.material.outputNode = vec4( +- vec3(diffuseColor.r.mul(attribute('uvw').z.mul(diffuseColor.r))), ++ vec3(diffuseColor.r.mul(attribute<'vec3'>('uvw').z.mul(diffuseColor.r))), + diffuseColor.r.mul(diffuseColor.a), + ); + views[1].scene.add(helper3D); +@@ -135,7 +146,7 @@ async function init() { + + const helperArray = new TextureHelper(mapArray, 10, 10, depth); + helperArray.material.outputNode = vec4( +- vec3(diffuseColor.r.mul(attribute('uvw').z.div(size.depth).mul(diffuseColor.r))), ++ vec3(diffuseColor.r.mul(attribute<'vec3'>('uvw').z.div(size.depth).mul(diffuseColor.r))), + diffuseColor.r.mul(diffuseColor.a), + ); + views[0].scene.add(helperArray); @@ -159,7 +170,7 @@ async function init() { const quadMesh = new THREE.QuadMesh(materialQuad); @@ -19753,10 +19935,63 @@ index 1b4461d3..440b4ac3 100644 const type = ['float', 'vec2', 'vec3', 'vec4']; - const arrayBufferNodes = []; -+ const arrayBufferNodes: THREE.StorageBufferNode[] = []; ++ const arrayBufferNodes: THREE.StorageBufferNode[] = []; for (let i = 0; i < type.length; i++) { const typeSize = i + 1; +@@ -34,7 +34,7 @@ async function init(forceWebGL = false) { + + const arrayBuffer = new THREE.StorageInstancedBufferAttribute(new Float32Array(array), typeSize); + +- arrayBufferNodes.push(storage(arrayBuffer, type[i], size).setPBO(true)); ++ arrayBufferNodes.push(storage(arrayBuffer, type[i] as 'float', size).setPBO(true)); + } + + const computeInitOrder = Fn(() => { +@@ -45,7 +45,9 @@ async function init(forceWebGL = false) { + + const computeInvertOrder = Fn(() => { + for (let i = 0; i < type.length; i++) { +- const invertIndex = arrayBufferNodes[i].element(uint(size - 1).sub(instanceIndex)).toVar(); ++ const invertIndex = ( ++ arrayBufferNodes[i].element(uint(size - 1).sub(instanceIndex)) as THREE.StorageArrayElementNode<'float'> ++ ).toVar(); + workgroupBarrier(); + arrayBufferNodes[i].element(instanceIndex).assign(invertIndex); + } +@@ -69,28 +71,28 @@ async function init(forceWebGL = false) { + const color = vec3(0, 0, 0).toVar(); + + If(uv().y.greaterThan(0.0), () => { +- const indexValue = arrayBufferNodes[0].element(index).toVar(); ++ const indexValue = (arrayBufferNodes[0].element(index) as THREE.StorageArrayElementNode<'float'>).toVar(); + const value = float(indexValue).div(float(size)).mul(barCount).floor().div(barCount); + + color.assign(vec3(value, 0, 0)); + }); + + If(uv().y.greaterThan(0.25), () => { +- const indexValue = arrayBufferNodes[1].element(index).toVar(); ++ const indexValue = (arrayBufferNodes[1].element(index) as THREE.StorageArrayElementNode<'vec2'>).toVar(); + const value = float(indexValue).div(float(size)).mul(barCount).floor().div(barCount); + + color.assign(vec3(0, value, 0)); + }); + + If(uv().y.greaterThan(0.5), () => { +- const indexValue = arrayBufferNodes[2].element(index).toVar(); ++ const indexValue = (arrayBufferNodes[2].element(index) as THREE.StorageArrayElementNode<'vec3'>).toVar(); + const value = float(indexValue).div(float(size)).mul(barCount).floor().div(barCount); + + color.assign(vec3(0, 0, value)); + }); + + If(uv().y.greaterThan(0.75), () => { +- const indexValue = arrayBufferNodes[3].element(index).toVar(); ++ const indexValue = (arrayBufferNodes[3].element(index) as THREE.StorageArrayElementNode<'vec4'>).toVar(); + const value = float(indexValue).div(float(size)).mul(barCount).floor().div(barCount); + + color.assign(vec3(value, value, value)); diff --git a/examples-testing/examples/webgpu_struct_drawindirect.ts b/examples-testing/examples/webgpu_struct_drawindirect.ts index b0d1139d..e61beb33 100644 --- a/examples-testing/examples/webgpu_struct_drawindirect.ts @@ -19770,6 +20005,29 @@ index b0d1139d..e61beb33 100644 init(); +@@ -139,15 +139,15 @@ async function init() { + drawInfo.get('offset').assign(0); + })().compute(1); + +- const vPosition = varyingProperty('vec3', 'vPosition'); +- const vColor = varyingProperty('vec4', 'vColor'); ++ const vPosition = varyingProperty<'vec3'>('vec3', 'vPosition'); ++ const vColor = varyingProperty<'vec4'>('vec4', 'vColor'); + + const positionShaderParams = { +- position: attribute('position'), +- offset: attribute('offset'), +- color: attribute('color'), +- orientationStart: attribute('orientationStart'), +- orientationEnd: attribute('orientationEnd'), ++ position: attribute<'vec3'>('position'), ++ offset: attribute<'vec3'>('offset'), ++ color: attribute<'vec4'>('color'), ++ orientationStart: attribute<'vec4'>('orientationStart'), ++ orientationEnd: attribute<'vec4'>('orientationEnd'), + time: time, + }; + diff --git a/examples-testing/examples/webgpu_textures_2d-array.ts b/examples-testing/examples/webgpu_textures_2d-array.ts index a1a354ff..26d952ce 100644 --- a/examples-testing/examples/webgpu_textures_2d-array.ts @@ -19800,7 +20058,7 @@ index a1a354ff..26d952ce 100644 map.needsUpdate = true; - let coord = uv(); -+ let coord: THREE.Node = uv(); ++ let coord: THREE.Node<'vec2'> = uv(); coord = coord.setY(coord.y.oneMinus()); // flip y let oscLayers = oscTriangle(time.mul(0.5)); // [ /\/ ] triangle osc animation @@ -19959,16 +20217,24 @@ index 646c5893..bab3f6f2 100644 init(); -@@ -45,7 +45,7 @@ function init() { +@@ -45,10 +45,12 @@ function init() { // TSL functions - const inAngle = Fn(([position, angleStart, angleArc]) => { -+ const inAngle = Fn<[THREE.Node, THREE.Node, THREE.Node]>(([position, angleStart, angleArc]) => { - const angle = atan(position.y, position.x).sub(angleStart).mod(TWO_PI).toVar(); - return angle.greaterThan(0).and(angle.lessThan(angleArc)); - }); -@@ -112,9 +112,9 @@ function init() { +- const angle = atan(position.y, position.x).sub(angleStart).mod(TWO_PI).toVar(); +- return angle.greaterThan(0).and(angle.lessThan(angleArc)); +- }); ++ const inAngle = Fn<[THREE.Node<'vec2'>, THREE.Node<'float'>, THREE.Node<'float'>], THREE.Node<'bool'>>( ++ ([position, angleStart, angleArc]) => { ++ const angle = atan(position.y, position.x).sub(angleStart).mod(TWO_PI).toVar(); ++ return angle.greaterThan(0).and(angle.lessThan(angleArc)); ++ }, ++ ); + + // materials + +@@ -112,9 +114,9 @@ function init() { const model = gltf.scene; model.traverse(child => { @@ -19981,7 +20247,7 @@ index 646c5893..bab3f6f2 100644 child.castShadow = true; child.receiveShadow = true; -@@ -160,7 +160,7 @@ function init() { +@@ -160,7 +162,7 @@ function init() { // debug @@ -20008,15 +20274,6 @@ index 14c14890..6d022baa 100644 init(); -@@ -106,7 +111,7 @@ function init() { - // atmosphere - - const atmosphereMaterial = new THREE.MeshBasicNodeMaterial({ side: THREE.BackSide, transparent: true }); -- let alpha = fresnel.remap(0.73, 1, 1, 0).pow(3); -+ let alpha: THREE.Node = fresnel.remap(0.73, 1, 1, 0).pow(3); - alpha = alpha.mul(sunOrientation.smoothstep(-0.5, 1)); - atmosphereMaterial.outputNode = vec4(atmosphereColor, alpha); - @@ -136,7 +141,7 @@ function init() { // debug @@ -20071,14 +20328,14 @@ index 143d577f..dc289242 100644 +} + +interface Uniforms { -+ count: THREE.UniformNode; -+ color: THREE.UniformNode; -+ direction: THREE.UniformNode; -+ start: THREE.UniformNode; -+ end: THREE.UniformNode; -+ mixLow: THREE.UniformNode; -+ mixHigh: THREE.UniformNode; -+ radius: THREE.UniformNode; ++ count: THREE.UniformNode<'float', number>; ++ color: THREE.UniformNode<'color', THREE.Color>; ++ direction: THREE.UniformNode<'vec3', THREE.Vector3>; ++ start: THREE.UniformNode<'float', number>; ++ end: THREE.UniformNode<'float', number>; ++ mixLow: THREE.UniformNode<'float', number>; ++ mixHigh: THREE.UniformNode<'float', number>; ++ radius: THREE.UniformNode<'float', number>; +} + +let camera: THREE.PerspectiveCamera, @@ -20108,23 +20365,33 @@ index 143d577f..dc289242 100644 uniforms.count = uniform(settings.count); uniforms.color = uniform(color(settings.color)); -@@ -112,7 +141,9 @@ function init() { +@@ -112,7 +141,19 @@ function init() { // halftone functions - const halftone = Fn(([count, color, direction, start, end, radius, mixLow, mixHigh]) => { + const halftone = Fn< -+ [THREE.Node, THREE.Node, THREE.Node, THREE.Node, THREE.Node, THREE.Node, THREE.Node, THREE.Node] ++ [ ++ THREE.UniformNode<'float', number>, ++ THREE.UniformNode<'vec3', THREE.Node<'vec3'>>, ++ THREE.UniformNode<'vec3', THREE.Vector3>, ++ THREE.UniformNode<'float', number>, ++ THREE.UniformNode<'float', number>, ++ THREE.UniformNode<'float', number>, ++ THREE.UniformNode<'float', number>, ++ THREE.UniformNode<'float', number>, ++ ], ++ THREE.Node<'vec4'> + >(([count, color, direction, start, end, radius, mixLow, mixHigh]) => { // grid pattern let gridUv = screenCoordinate.xy.div(screenSize.yy).mul(count); -@@ -133,19 +164,19 @@ function init() { +@@ -133,19 +174,19 @@ function init() { return vec4(color, mask); }); - const halftones = Fn(([input]) => { -+ const halftones = Fn<[THREE.Node]>(([input]) => { ++ const halftones = Fn<[THREE.PropertyNode<'vec4'>], THREE.PropertyNode<'vec4'>>(([input]) => { const halftonesOutput = input; for (const settings of halftoneSettings) { @@ -20148,7 +20415,7 @@ index 143d577f..dc289242 100644 ); halftonesOutput.rgb.assign(mix(halftonesOutput.rgb, halfToneOutput.rgb, halfToneOutput.a)); } -@@ -177,7 +208,9 @@ function init() { +@@ -177,7 +218,9 @@ function init() { model.position.y = -2; model.scale.setScalar(2.5); model.traverse(child => { @@ -20159,7 +20426,7 @@ index 143d577f..dc289242 100644 }); scene.add(model); -@@ -204,8 +237,8 @@ async function animate() { +@@ -204,8 +247,8 @@ async function animate() { controls.update(); const time = clock.getElapsedTime(); @@ -20190,24 +20457,24 @@ index e57c66ee..31838ac1 100644 function onWindowResize() { renderer.setSize(window.innerWidth, window.innerHeight); +@@ -46,7 +46,7 @@ function init() { + throw new Error('No WebGPU support'); + } + +- const vUv = varyingProperty('vec2', 'vUv'); ++ const vUv = varyingProperty<'vec2'>('vec2', 'vUv'); + + // In WGSL, access varying properties from the varying struct + const wgslVertexShader = wgslFn( @@ -195,7 +195,7 @@ function init() { samplePoint.x = samplePoint.x.add(fract(scaledTime.div(20))); samplePoint.y = samplePoint.y.sub(1.5); - let color = texture(planetTexture, samplePoint); -+ let color: THREE.Node = texture(planetTexture, samplePoint); ++ let color: THREE.Node<'vec4'> = texture(planetTexture, samplePoint); const ind = floor(subCoord.x).mod(3); -@@ -215,7 +215,7 @@ function init() { - color = color.mul(maskColor); - - const pixelDampen = pixel.y.div(pulseWidthUniform); -- let pulse = sin(pixelDampen.add(time.mul(pulseRateUniform))); -+ let pulse: THREE.Node = sin(pixelDampen.add(time.mul(pulseRateUniform))); - pulse = pulse.mul(pulseIntensityUniform); - color = color.mul(float(1.0).add(pulse)); - @@ -249,7 +249,7 @@ function init() { window.addEventListener('resize', onWindowResize); @@ -20254,7 +20521,7 @@ index ef87d67b..2e495a08 100644 const vPosition = varying(vec3()); - const terrainElevation = Fn(([position]) => { -+ const terrainElevation = Fn<[THREE.Node]>(([position]) => { ++ const terrainElevation = Fn<[THREE.Node<'vec2'>], THREE.Node<'float'>>(([position]) => { const warpedPosition = position.add(offset).toVar(); warpedPosition.addAssign( mx_noise_float(warpedPosition.mul(positionFrequency).mul(warpFrequency), 1, 0).mul(warpStrength), @@ -20321,7 +20588,7 @@ index cb513d07..9b867d08 100644 // TSL functions - const wavesElevation = Fn(([position]) => { -+ const wavesElevation = Fn<[THREE.Node]>(([position]) => { ++ const wavesElevation = Fn<[THREE.Node<'vec3'>], THREE.Node<'float'>>(([position]) => { // large waves const elevation = mul( @@ -20389,7 +20656,7 @@ index 4c4ee68e..6dcc8e26 100644 -let updateParticles, spawnParticles; // TSL compute nodes -let getInstanceColor; // TSL function +let updateParticles: THREE.ComputeNode, spawnParticles: THREE.ComputeNode; // TSL compute nodes -+let getInstanceColor: THREE.TSL.ShaderNodeFn<[THREE.Node]>; // TSL function ++let getInstanceColor: THREE.TSL.FnNode<[THREE.Node<'uint'>], THREE.Node<'vec3'>>; // TSL function const screenPointer = new THREE.Vector2(); const scenePointer = new THREE.Vector3(); @@ -20398,7 +20665,7 @@ index 4c4ee68e..6dcc8e26 100644 // TSL function // current color from index - getInstanceColor = Fn(([i]) => { -+ getInstanceColor = Fn<[THREE.Node]>(([i]) => { ++ getInstanceColor = Fn<[THREE.IndexNode], THREE.Node<'vec3'>>(([i]) => { return hue( color(0x0000ff), colorOffset.add(mx_fractal_noise_float(i.toFloat().mul(0.1), 2, 2.0, 0.5, colorVariance)), @@ -20437,54 +20704,36 @@ index 571b7ea0..78c200d0 100644 init(); -@@ -44,7 +48,7 @@ function init() { +@@ -44,7 +48,10 @@ function init() { // TSL functions - const toRadialUv = Fn(([uv, multiplier, rotation, offset]) => { -+ const toRadialUv = Fn<[THREE.Node, THREE.Node, THREE.Node, THREE.Node]>(([uv, multiplier, rotation, offset]) => { ++ const toRadialUv = Fn< ++ [THREE.Node<'vec2'>, THREE.Node<'vec2'>, THREE.Node<'float'>, THREE.Node<'float'>], ++ THREE.Node<'vec2'> ++ >(([uv, multiplier, rotation, offset]) => { const centeredUv = uv.sub(0.5).toVar(); const distanceToCenter = centeredUv.length(); const angle = atan(centeredUv.y, centeredUv.x); -@@ -56,24 +60,26 @@ function init() { +@@ -56,11 +63,14 @@ function init() { return radialUv; }); - const toSkewedUv = Fn(([uv, skew]) => { -+ const toSkewedUv = Fn<[THREE.Node, THREE.Node]>(([uv, skew]) => { ++ const toSkewedUv = Fn<[THREE.Node<'vec2'>, THREE.Node<'vec2'>], THREE.Node<'vec2'>>(([uv, skew]) => { return vec2(uv.x.add(uv.y.mul(skew.x)), uv.y.add(uv.x.mul(skew.y))); }); - const twistedCylinder = Fn(([position, parabolStrength, parabolOffset, parabolAmplitude, time]) => { -- const angle = atan(position.z, position.x).toVar(); -- const elevation = position.y; -+ const twistedCylinder = Fn<[THREE.Node, THREE.Node, THREE.Node, THREE.Node, THREE.Node]>( -+ ([position, parabolStrength, parabolOffset, parabolAmplitude, time]) => { -+ const angle = atan(position.z, position.x).toVar(); -+ const elevation = position.y; - -- // parabol -- const radius = parabolStrength.mul(position.y.sub(parabolOffset)).pow(2).add(parabolAmplitude).toVar(); -+ // parabol -+ const radius = parabolStrength.mul(position.y.sub(parabolOffset)).pow(2).add(parabolAmplitude).toVar(); - -- // turbulences -- radius.addAssign(sin(elevation.sub(time).mul(20).add(angle.mul(2))).mul(0.05)); -+ // turbulences -+ radius.addAssign(sin(elevation.sub(time).mul(20).add(angle.mul(2))).mul(0.05)); - -- const twistedPosition = vec3(cos(angle).mul(radius), elevation, sin(angle).mul(radius)); -+ const twistedPosition = vec3(cos(angle).mul(radius), elevation, sin(angle).mul(radius)); - -- return twistedPosition; -- }); -+ return twistedPosition; -+ }, -+ ); - - // uniforms ++ const twistedCylinder = Fn< ++ [THREE.Node<'vec3'>, THREE.Node<'float'>, THREE.Node<'float'>, THREE.Node<'float'>, THREE.Node<'float'>], ++ THREE.Node<'vec3'> ++ >(([position, parabolStrength, parabolOffset, parabolAmplitude, time]) => { + const angle = atan(position.z, position.x).toVar(); + const elevation = position.y; -@@ -260,7 +266,7 @@ function init() { +@@ -260,7 +270,7 @@ function init() { // debug @@ -20532,14 +20781,14 @@ index 5a4e0650..21088360 100644 return { x: 0, y: (finishIndex - Finishes.length / 2) * 1.0, -@@ -28,29 +36,33 @@ function getGridPosition(woodIndex, finishIndex) { +@@ -28,27 +36,32 @@ function getGridPosition(woodIndex, finishIndex) { function createGridPlane() { const material = new THREE.MeshBasicNodeMaterial(); - const gridXZ = TSL.Fn(([gridSize = TSL.float(1.0), dotWidth = TSL.float(0.1), lineWidth = TSL.float(0.02)]) => { - const coord = TSL.positionWorld.xz.div(gridSize); - const grid = TSL.fract(coord); -+ const gridXZ = TSL.Fn<[THREE.Node, THREE.Node, THREE.Node]>( ++ const gridXZ = TSL.Fn<[THREE.Node<'float'>, THREE.Node<'float'>, THREE.Node<'float'>], THREE.Node<'float'>>( + ([gridSize = TSL.float(1.0), dotWidth = TSL.float(0.1), lineWidth = TSL.float(0.02)]) => { + const coord = TSL.positionWorld.xz.div(gridSize); + const grid = TSL.fract(coord); @@ -20574,17 +20823,14 @@ index 5a4e0650..21088360 100644 + ); - const radialGradient = TSL.Fn(([radius = TSL.float(10.0), falloff = TSL.float(1.0)]) => { -- return TSL.smoothstep(radius, radius.sub(falloff), TSL.length(TSL.positionWorld)); -- }); -+ const radialGradient = TSL.Fn<[THREE.Node, THREE.Node, THREE.Node] | [THREE.Node, THREE.Node]>( -+ ([radius = TSL.float(10.0), falloff = TSL.float(1.0)]) => { -+ return TSL.smoothstep(radius, radius.sub(falloff), TSL.length(TSL.positionWorld)); -+ }, -+ ); ++ const radialGradient = TSL.Fn< ++ [THREE.Node<'float'>, THREE.Node<'float'>, THREE.Node<'float'>] | [THREE.Node<'float'>, THREE.Node<'float'>], ++ THREE.Node<'float'> ++ >(([radius = TSL.float(10.0), falloff = TSL.float(1.0)]) => { + return TSL.smoothstep(radius, radius.sub(falloff), TSL.length(TSL.positionWorld)); + }); - // Create grid pattern - const gridPattern = gridXZ(1.0, 0.03, 0.005); -@@ -69,7 +81,12 @@ function createGridPlane() { +@@ -69,7 +82,12 @@ function createGridPlane() { } // Helper function to create and position labels @@ -20598,7 +20844,7 @@ index 5a4e0650..21088360 100644 const txt_geo = new TextGeometry(text, { font: font, size: 0.1, -@@ -79,9 +96,9 @@ function createLabel(text, font, material, position) { +@@ -79,9 +97,9 @@ function createLabel(text, font, material, position) { }); txt_geo.computeBoundingBox(); @@ -20611,7 +20857,7 @@ index 5a4e0650..21088360 100644 txt_geo.translate(offx, offy, offz); const label = new THREE.Group(); -@@ -91,7 +108,7 @@ function createLabel(text, font, material, position) { +@@ -91,7 +109,7 @@ function createLabel(text, font, material, position) { // Apply default rotation for labels label.rotateY(-Math.PI / 2); @@ -20620,7 +20866,7 @@ index 5a4e0650..21088360 100644 label.position.copy(position); base.add(label); } -@@ -115,7 +132,7 @@ async function init() { +@@ -115,7 +133,7 @@ async function init() { controls = new OrbitControls(camera, renderer.domElement); controls.target.set(0, 0, 0.548); @@ -20629,7 +20875,7 @@ index 5a4e0650..21088360 100644 font = await new FontLoader().loadAsync('./fonts/helvetiker_regular.typeface.json'); -@@ -189,7 +206,7 @@ if (WebGPU.isAvailable()) { +@@ -189,7 +207,7 @@ if (WebGPU.isAvailable()) { document.body.appendChild(WebGPU.getErrorMessage()); } @@ -20721,21 +20967,39 @@ index 5250dc91..affe0602 100644 gui.add(causticOcclusion, 'value', 0, 20).name('caustic occlusion'); gui.addColor(duck.material, 'color').name('material color'); -@@ -224,12 +224,12 @@ async function init() { +@@ -224,20 +224,22 @@ async function init() { const volumetricMaterial = new THREE.VolumeNodeMaterial(); volumetricMaterial.steps = 20; volumetricMaterial.offsetNode = bayer16(screenCoordinate.add(frameId)); // Add dithering to reduce banding - volumetricMaterial.scatteringNode = Fn(({ positionRay }) => { -+ volumetricMaterial.scatteringNode = Fn<{ positionRay: THREE.Node }>(({ positionRay }) => { - // Return the amount of fog based on the noise texture +- // Return the amount of fog based on the noise texture ++ volumetricMaterial.scatteringNode = Fn<{ positionRay: THREE.Node<'vec3'> }, THREE.Node<'float'>>( ++ ({ positionRay }) => { ++ // Return the amount of fog based on the noise texture - const timeScaled = vec3(time.mul(0.01), 0, time.mul(0.03)); +- const timeScaled = vec3(time.mul(0.01), 0, time.mul(0.03)); ++ const timeScaled = vec3(time.mul(0.01), 0, time.mul(0.03)); - const sampleGrain = (scale, timeScale = 1) => -+ const sampleGrain = (scale: number, timeScale = 1) => - texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); +- texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); ++ const sampleGrain = (scale: number, timeScale = 1) => ++ texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); + +- let density = sampleGrain(1); +- density = density.mul(sampleGrain(0.5, 1)); +- density = density.mul(sampleGrain(0.2, 2)); ++ let density = sampleGrain(1); ++ density = density.mul(sampleGrain(0.5, 1)); ++ density = density.mul(sampleGrain(0.2, 2)); + +- return smokeAmount.mix(1, density); +- }); ++ return smokeAmount.mix(1, density); ++ }, ++ ); - let density = sampleGrain(1); + const volumetricMesh = new THREE.Mesh(new THREE.BoxGeometry(1.5, 0.5, 1.5), volumetricMaterial); + volumetricMesh.receiveShadow = true; diff --git a/examples-testing/examples/webgpu_volume_cloud.ts b/examples-testing/examples/webgpu_volume_cloud.ts index 1d46c354..0b4d8513 100644 --- a/examples-testing/examples/webgpu_volume_cloud.ts @@ -20760,20 +21024,23 @@ index 1d46c354..0b4d8513 100644 const gradient = context.createLinearGradient(0, 0, 0, 32); gradient.addColorStop(0.0, '#014a84'); gradient.addColorStop(0.5, '#0561a0'); -@@ -86,33 +86,37 @@ function init() { +@@ -86,33 +86,40 @@ function init() { // Shader - const transparentRaymarchingTexture = Fn( - ({ texture, range = float(0.1), threshold = float(0.25), opacity = float(0.25), steps = float(100) }) => { - const finalColor = vec4(0).toVar(); -+ const transparentRaymarchingTexture = Fn<{ -+ texture: THREE.TextureNode; -+ range: THREE.UniformNode; -+ threshold: THREE.UniformNode; -+ opacity: THREE.UniformNode; -+ steps: THREE.UniformNode; -+ }>(({ texture, range = float(0.1), threshold = float(0.25), opacity = float(0.25), steps = float(100) }) => { ++ const transparentRaymarchingTexture = Fn< ++ { ++ texture: THREE.TextureNode; ++ range: THREE.UniformNode<'float', number>; ++ threshold: THREE.UniformNode<'float', number>; ++ opacity: THREE.UniformNode<'float', number>; ++ steps: THREE.UniformNode<'float', number>; ++ }, ++ THREE.Node<'vec4'> ++ >(({ texture, range = float(0.1), threshold = float(0.25), opacity = float(0.25), steps = float(100) }) => { + const finalColor = vec4(0).toVar(); - RaymarchingBox(steps, ({ positionRay }) => { @@ -20816,7 +21083,7 @@ index 1d46c354..0b4d8513 100644 // Material -@@ -142,7 +146,7 @@ function init() { +@@ -142,7 +149,7 @@ function init() { // @@ -20842,22 +21109,40 @@ index 3edecb90..ef458d0a 100644 init(); -@@ -86,12 +86,12 @@ function init() { +@@ -86,20 +86,22 @@ function init() { const volumetricMaterial = new THREE.VolumeNodeMaterial(); volumetricMaterial.steps = 12; volumetricMaterial.offsetNode = bayer16(screenCoordinate); // Add dithering to reduce banding - volumetricMaterial.scatteringNode = Fn(({ positionRay }) => { -+ volumetricMaterial.scatteringNode = Fn(({ positionRay }: { positionRay: THREE.Node }) => { - // Return the amount of fog based on the noise texture +- // Return the amount of fog based on the noise texture ++ volumetricMaterial.scatteringNode = Fn( ++ ({ positionRay }: { positionRay: THREE.Node<'vec3'> }): THREE.Node<'float'> => { ++ // Return the amount of fog based on the noise texture - const timeScaled = vec3(time, 0, time.mul(0.3)); +- const timeScaled = vec3(time, 0, time.mul(0.3)); ++ const timeScaled = vec3(time, 0, time.mul(0.3)); - const sampleGrain = (scale, timeScale = 1) => -+ const sampleGrain = (scale: number, timeScale = 1) => - texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); +- texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); ++ const sampleGrain = (scale: number, timeScale = 1) => ++ texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); + +- let density = sampleGrain(0.1); +- density = density.mul(sampleGrain(0.05, 1)); +- density = density.mul(sampleGrain(0.02, 2)); ++ let density = sampleGrain(0.1); ++ density = density.mul(sampleGrain(0.05, 1)); ++ density = density.mul(sampleGrain(0.02, 2)); + +- return smokeAmount.mix(1, density); +- }); ++ return smokeAmount.mix(1, density); ++ }, ++ ); - let density = sampleGrain(0.1); -@@ -199,7 +199,7 @@ function init() { + volumetricMesh = new THREE.Mesh(new THREE.BoxGeometry(20, 10, 20), volumetricMaterial); + volumetricMesh.receiveShadow = true; +@@ -199,7 +201,7 @@ function init() { denoise: true, }; @@ -20887,22 +21172,40 @@ index 4089b3f7..da8ee7b5 100644 init(); -@@ -88,12 +88,12 @@ function init() { +@@ -88,20 +88,22 @@ function init() { const volumetricMaterial = new THREE.VolumeNodeMaterial(); volumetricMaterial.steps = 12; volumetricMaterial.offsetNode = bayer16(screenCoordinate); // Add dithering to reduce banding - volumetricMaterial.scatteringNode = Fn(({ positionRay }) => { -+ volumetricMaterial.scatteringNode = Fn(({ positionRay }: { positionRay: THREE.Node }) => { - // Return the amount of fog based on the noise texture +- // Return the amount of fog based on the noise texture ++ volumetricMaterial.scatteringNode = Fn( ++ ({ positionRay }: { positionRay: THREE.Node<'vec3'> }): THREE.Node<'float'> => { ++ // Return the amount of fog based on the noise texture - const timeScaled = vec3(time, 0, time.mul(0.3)); +- const timeScaled = vec3(time, 0, time.mul(0.3)); ++ const timeScaled = vec3(time, 0, time.mul(0.3)); - const sampleGrain = (scale, timeScale = 1) => -+ const sampleGrain = (scale: number, timeScale = 1) => - texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); +- texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); ++ const sampleGrain = (scale: number, timeScale = 1) => ++ texture3D(noiseTexture3D, positionRay.add(timeScaled.mul(timeScale)).mul(scale).mod(1), 0).r.add(0.5); + +- let density = sampleGrain(0.1); +- density = density.mul(sampleGrain(0.05, 1)); +- density = density.mul(sampleGrain(0.02, 2)); ++ let density = sampleGrain(0.1); ++ density = density.mul(sampleGrain(0.05, 1)); ++ density = density.mul(sampleGrain(0.02, 2)); + +- return smokeAmount.mix(1, density); +- }); ++ return smokeAmount.mix(1, density); ++ }, ++ ); - let density = sampleGrain(0.1); -@@ -129,7 +129,7 @@ function init() { + volumetricMesh = new THREE.Mesh(new THREE.BoxGeometry(50, 40, 50), volumetricMaterial); + volumetricMesh.receiveShadow = true; +@@ -129,7 +131,7 @@ function init() { // @@ -20911,7 +21214,7 @@ index 4089b3f7..da8ee7b5 100644 const geometry = new THREE.PlaneGeometry(4, 10); const frontMaterial = new THREE.MeshBasicMaterial({ color: rectLight.color, side: THREE.BackSide }); const backMaterial = new THREE.MeshStandardMaterial({ color: 0x111111 }); -@@ -211,7 +211,7 @@ function init() { +@@ -211,7 +213,7 @@ function init() { denoise: true, }; @@ -20935,20 +21238,23 @@ index fb6f2bbd..5705090e 100644 init(); -@@ -58,7 +58,11 @@ function init() { +@@ -58,7 +58,14 @@ function init() { // Shader - const opaqueRaymarchingTexture = Fn(({ texture, steps, threshold }) => { -+ const opaqueRaymarchingTexture = Fn<{ -+ texture: THREE.Texture3DNode; -+ steps: THREE.Node; -+ threshold: THREE.Node; -+ }>(({ texture, steps, threshold }) => { ++ const opaqueRaymarchingTexture = Fn< ++ { ++ texture: THREE.Texture3DNode; ++ steps: THREE.Node<'float'>; ++ threshold: THREE.Node<'float'>; ++ }, ++ THREE.Node<'vec4'> ++ >(({ texture, steps, threshold }) => { const finalColor = vec4(0).toVar(); RaymarchingBox(steps, ({ positionRay }) => { -@@ -95,7 +99,7 @@ function init() { +@@ -95,7 +102,7 @@ function init() { // @@ -21828,3 +22134,33 @@ index 2cd50ba4..b97f3eee 100644 isDepthSupplied = false; }); +diff --git a/types/three/src/nodes/fog/Fog.d.ts b/types/three/src/nodes/fog/Fog.d.ts +index 2387be67e..39ff8ca23 100644 +--- a/types/three/src/nodes/fog/Fog.d.ts ++++ b/types/three/src/nodes/fog/Fog.d.ts +@@ -4,7 +4,7 @@ export const rangeFogFactor: (near: Node<"float"> | number, far: Node<"float"> | + + export const densityFogFactor: (density: Node) => Node; + +-export const fog: (color: Node, factor: Node) => Node; ++export const fog: (color: Node, factor: Node) => Node<"vec4">; + + /** + * @deprecated +diff --git a/types/three/src/renderers/common/nodes/Nodes.d.ts b/types/three/src/renderers/common/nodes/Nodes.d.ts +index d2a1b20d6..e34da57a3 100644 +--- a/types/three/src/renderers/common/nodes/Nodes.d.ts ++++ b/types/three/src/renderers/common/nodes/Nodes.d.ts +@@ -44,9 +44,9 @@ interface CacheKeyData { + } + declare module "../../../scenes/Scene.js" { + interface Scene { +- environmentNode?: Node | null | undefined; +- backgroundNode?: Node | null | undefined; +- fogNode?: Node | null | undefined; ++ environmentNode?: Node<"vec3"> | null | undefined; ++ backgroundNode?: Node<"vec3"> | Node<"vec4"> | Node<"color"> | null | undefined; ++ fogNode?: Node<"vec4"> | null | undefined; + } + } + /** diff --git a/jsdoc-testing/changes.patch b/jsdoc-testing/changes.patch index 91ba55b08..84a94275a 100644 --- a/jsdoc-testing/changes.patch +++ b/jsdoc-testing/changes.patch @@ -6236,10 +6236,10 @@ index 0545af43c..e2d866f57 100644 + +export default MeshPhysicalNodeMaterial; diff --git a/jsdoc-testing/jsdoc/materials/nodes/MeshSSSNodeMaterial.d.ts b/jsdoc-testing/jsdoc/materials/nodes/MeshSSSNodeMaterial.d.ts -index ca33d8128..d0626a6cf 100644 +index ca33d8128..3fc2c7687 100644 --- a/jsdoc-testing/jsdoc/materials/nodes/MeshSSSNodeMaterial.d.ts +++ b/jsdoc-testing/jsdoc/materials/nodes/MeshSSSNodeMaterial.d.ts -@@ -1,52 +1,89 @@ +@@ -1,52 +1,88 @@ -export default MeshSSSNodeMaterial; +import MeshPhysicalNodeMaterial, { MeshPhysicalNodeMaterialNodeProperties } from './MeshPhysicalNodeMaterial.js'; +import PhysicalLightingModel from '../../nodes/functions/PhysicalLightingModel.js'; @@ -6248,7 +6248,6 @@ index ca33d8128..d0626a6cf 100644 +import { MapColorPropertiesToColorRepresentations } from '../Material.js'; +import { MeshPhysicalMaterialParameters, MeshPhysicalMaterialProperties } from '../MeshPhysicalMaterial.js'; +import Node from "../../nodes/core/Node.js"; -+import InputNode from "../../nodes/core/InputNode.js"; + /** - * This node material is an experimental extension of {@link MeshPhysicalNodeMaterial} @@ -6303,35 +6302,35 @@ index ca33d8128..d0626a6cf 100644 - * @type {?Node} */ - thicknessDistortionNode: Node | null; -+ thicknessDistortionNode: InputNode; ++ thicknessDistortionNode: Node<'float'>; /** * Represents the thickness ambient factor. - * - * @type {?Node} */ - thicknessAmbientNode: Node | null; -+ thicknessAmbientNode: InputNode; ++ thicknessAmbientNode: Node<'float'>; /** * Represents the thickness attenuation. - * - * @type {?Node} */ - thicknessAttenuationNode: Node | null; -+ thicknessAttenuationNode: InputNode; ++ thicknessAttenuationNode: Node<'float'>; /** * Represents the thickness power. - * - * @type {?Node} */ - thicknessPowerNode: Node | null; -+ thicknessPowerNode: InputNode; ++ thicknessPowerNode: Node<'float'>; /** * Represents the thickness scale. - * - * @type {?Node} */ - thicknessScaleNode: Node | null; -+ thicknessScaleNode: InputNode; ++ thicknessScaleNode: Node<'float'>; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -6353,7 +6352,7 @@ index ca33d8128..d0626a6cf 100644 * @default true */ get useSSS(): boolean; -@@ -57,40 +94,8 @@ declare class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial { +@@ -57,40 +93,8 @@ declare class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial { */ setupLightingModel(): SSSLightingModel; } @@ -6568,7 +6567,7 @@ index 1ffe1bd1b..94d4efb05 100644 + +export default MeshToonNodeMaterial; diff --git a/jsdoc-testing/jsdoc/materials/nodes/NodeMaterial.d.ts b/jsdoc-testing/jsdoc/materials/nodes/NodeMaterial.d.ts -index 03097be43..abd419b15 100644 +index 03097be43..8f8a0997f 100644 --- a/jsdoc-testing/jsdoc/materials/nodes/NodeMaterial.d.ts +++ b/jsdoc-testing/jsdoc/materials/nodes/NodeMaterial.d.ts @@ -1,37 +1,23 @@ @@ -6668,7 +6667,7 @@ index 03097be43..abd419b15 100644 * @default null */ - colorNode: Node | null; -+ colorNode: Node | null; ++ colorNode: Node<'float'> | Node<'vec2'> | Node<'vec3'> | Node<'vec4'> | Node<'color'> | null; /** * The normals of node materials are by default inferred from the `normalMap`/`normalScale` * or `bumpMap`/`bumpScale` properties. This node property allows to overwrite the default @@ -6853,7 +6852,8 @@ index 03097be43..abd419b15 100644 - * @type {?ContextNode} * @default null */ - contextNode: ContextNode | null; +- contextNode: ContextNode | null; ++ contextNode: ContextNode | null; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 668a2da1a..62ae3070c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,6 +102,18 @@ importers: specifier: latest version: 5.9.3 + tsl-testing: + dependencies: + '@types/three': + specifier: file:../types/three + version: link:../types/three + prettier: + specifier: ^3.6.2 + version: 3.6.2 + typescript: + specifier: latest + version: 5.9.3 + types/three: dependencies: '@dimforge/rapier3d-compat': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d68da080c..14c297a1d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,6 +2,7 @@ packages: - examples-testing - jsdoc-testing - src-testing + - tsl-testing - types/three onlyBuiltDependencies: - dprint diff --git a/src-testing/changes.patch b/src-testing/changes.patch index 16f9c265c..0b63ab56d 100644 --- a/src-testing/changes.patch +++ b/src-testing/changes.patch @@ -194,7 +194,7 @@ index 4c5e4c7d..4f710ccc 100644 this.hasNode || this.hasAnimation || diff --git a/src-testing/src/nodes/accessors/BufferAttributeNode.ts b/src-testing/src/nodes/accessors/BufferAttributeNode.ts -index 5b4d8aa0..f7931662 100644 +index 5b4d8aa0..de10cc60 100644 --- a/src-testing/src/nodes/accessors/BufferAttributeNode.ts +++ b/src-testing/src/nodes/accessors/BufferAttributeNode.ts @@ -4,7 +4,12 @@ import { varying } from '../core/VaryingNode.js'; @@ -234,7 +234,7 @@ index 5b4d8aa0..f7931662 100644 * @augments InputNode */ -class BufferAttributeNode extends InputNode { -+class BufferAttributeNode extends InputNode { ++class BufferAttributeNodeClass extends InputNode { static get type() { return 'BufferAttributeNode'; } @@ -287,7 +287,7 @@ index 5b4d8aa0..f7931662 100644 * @return {string} The hash. */ - getHash(builder) { -+ getHash(builder: NodeBuilder) { ++ getHash(builder: NodeBuilder): string { if (this.bufferStride === 0 && this.bufferOffset === 0) { let bufferData = builder.globalCache.getData(this.value); @@ -361,7 +361,7 @@ index 5b4d8aa0..f7931662 100644 } return this; -@@ -280,7 +301,7 @@ class BufferAttributeNode extends InputNode { +@@ -280,12 +301,31 @@ class BufferAttributeNode extends InputNode { * @param {boolean} value - The value to set. * @return {BufferAttributeNode} A reference to this node. */ @@ -370,68 +370,92 @@ index 5b4d8aa0..f7931662 100644 this.instanced = value; return this; -@@ -301,7 +322,14 @@ export default BufferAttributeNode; + } + } ++declare const BufferAttributeNode: { ++ /** ++ * Constructs a new buffer attribute node. ++ * ++ * @param {BufferAttribute|InterleavedBuffer|TypedArray} value - The attribute data. ++ * @param {?string} [bufferType=null] - The buffer type (e.g. `'vec3'`). ++ * @param {number} [bufferStride=0] - The buffer stride. ++ * @param {number} [bufferOffset=0] - The buffer offset. ++ */ ++ new ( ++ value: TypedArray | InterleavedBuffer | BufferAttribute, ++ bufferType?: string | null, ++ bufferStride?: number, ++ bufferOffset?: number, ++ ): BufferAttributeNode; ++}; ++ ++type BufferAttributeNode = InputNode & ++ BufferAttributeNodeClass; + + export default BufferAttributeNode; + +@@ -301,7 +341,14 @@ export default BufferAttributeNode; * @param {boolean} [instanced=false] - Whether the buffer is instanced. * @returns {BufferAttributeNode|Node} The buffer attribute node. */ -function createBufferAttribute(array, type = null, stride = 0, offset = 0, usage = StaticDrawUsage, instanced = false) { -+function createBufferAttribute( ++function createBufferAttribute( + array: BufferAttribute | InterleavedBuffer | TypedArray, + type: string | null = null, + stride: number = 0, + offset: number = 0, + usage: Usage = StaticDrawUsage, + instanced = false, -+): Node { ++): Node { if (type === 'mat3' || (type === null && array.itemSize === 9)) { return mat3( new BufferAttributeNode(array, 'vec3', 9, 0).setUsage(usage).setInstanced(instanced), -@@ -331,8 +359,12 @@ function createBufferAttribute(array, type = null, stride = 0, offset = 0, usage +@@ -331,8 +378,12 @@ function createBufferAttribute(array, type = null, stride = 0, offset = 0, usage * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export const bufferAttribute = (array, type = null, stride = 0, offset = 0) => - createBufferAttribute(array, type, stride, offset); -+export const bufferAttribute = ( ++export const bufferAttribute = ( + array: BufferAttribute | InterleavedBuffer | TypedArray, + type: string | null = null, + stride: number = 0, + offset: number = 0, -+) => createBufferAttribute(array, type, stride, offset); ++): Node => createBufferAttribute(array, type, stride, offset); /** * TSL function for creating a buffer attribute node but with dynamic draw usage. -@@ -346,8 +378,12 @@ export const bufferAttribute = (array, type = null, stride = 0, offset = 0) => +@@ -346,8 +397,12 @@ export const bufferAttribute = (array, type = null, stride = 0, offset = 0) => * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export const dynamicBufferAttribute = (array, type = null, stride = 0, offset = 0) => - createBufferAttribute(array, type, stride, offset, DynamicDrawUsage); -+export const dynamicBufferAttribute = ( ++export const dynamicBufferAttribute = ( + array: BufferAttribute | InterleavedBuffer | TypedArray, + type: string | null = null, + stride: number = 0, + offset: number = 0, -+) => createBufferAttribute(array, type, stride, offset, DynamicDrawUsage); ++): Node => createBufferAttribute(array, type, stride, offset, DynamicDrawUsage); /** * TSL function for creating a buffer attribute node but with enabled instancing -@@ -360,8 +396,12 @@ export const dynamicBufferAttribute = (array, type = null, stride = 0, offset = +@@ -360,8 +415,12 @@ export const dynamicBufferAttribute = (array, type = null, stride = 0, offset = * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export const instancedBufferAttribute = (array, type = null, stride = 0, offset = 0) => - createBufferAttribute(array, type, stride, offset, StaticDrawUsage, true); -+export const instancedBufferAttribute = ( ++export const instancedBufferAttribute = ( + array: BufferAttribute | InterleavedBuffer | TypedArray, + type: string | null = null, + stride: number = 0, + offset: number = 0, -+) => createBufferAttribute(array, type, stride, offset, StaticDrawUsage, true); ++): Node => createBufferAttribute(array, type, stride, offset, StaticDrawUsage, true); /** * TSL function for creating a buffer attribute node but with dynamic draw usage and enabled instancing -@@ -374,7 +414,18 @@ export const instancedBufferAttribute = (array, type = null, stride = 0, offset +@@ -374,7 +433,19 @@ export const instancedBufferAttribute = (array, type = null, stride = 0, offset * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ @@ -439,19 +463,20 @@ index 5b4d8aa0..f7931662 100644 - createBufferAttribute(array, type, stride, offset, DynamicDrawUsage, true); - -addMethodChaining('toAttribute', bufferNode => bufferAttribute(bufferNode.value)); -+export const instancedDynamicBufferAttribute = ( ++export const instancedDynamicBufferAttribute = ( + array: BufferAttribute | InterleavedBuffer | TypedArray, + type: string | null = null, + stride: number = 0, + offset: number = 0, -+) => createBufferAttribute(array, type, stride, offset, DynamicDrawUsage, true); ++): Node => createBufferAttribute(array, type, stride, offset, DynamicDrawUsage, true); + -+addMethodChaining('toAttribute', (bufferNode: BufferNode) => bufferAttribute(bufferNode.value)); ++addMethodChaining('toAttribute', (bufferNode: BufferNode) => ++ bufferAttribute(bufferNode.value), ++); + -+declare module '../Nodes.js' { -+ interface BufferNode { -+ toAttribute: () => BufferAttributeNode; -+ toAttributeAssign: () => this; ++declare module './BufferNode.js' { ++ interface BufferNodeExtensions { ++ toAttribute: () => BufferAttributeNode; + } +} diff --git a/src-testing/src/nodes/accessors/TextureNode.ts b/src-testing/src/nodes/accessors/TextureNode.ts @@ -822,7 +847,7 @@ index f2cedcd3..ea2c2c89 100644 return setName(node, name); diff --git a/src-testing/src/nodes/core/InputNode.ts b/src-testing/src/nodes/core/InputNode.ts -index ffb7734e..d71c6d24 100644 +index ffb7734e..2dc76d1c 100644 --- a/src-testing/src/nodes/core/InputNode.ts +++ b/src-testing/src/nodes/core/InputNode.ts @@ -1,24 +1,30 @@ @@ -837,7 +862,7 @@ index ffb7734e..d71c6d24 100644 * @augments Node */ -class InputNode extends Node { -+class InputNode extends Node { ++class InputNodeClass extends Node { static get type() { return 'InputNode'; } @@ -885,7 +910,7 @@ index ffb7734e..d71c6d24 100644 this.precision = precision; return this; -@@ -107,10 +113,6 @@ class InputNode extends Node { +@@ -107,10 +113,12 @@ class InputNode extends Node { if (this.value && this.value.fromArray) this.value = this.value.fromArray(data.value); } @@ -895,9 +920,15 @@ index ffb7734e..d71c6d24 100644 - } } ++declare const InputNode: { ++ new (value: TValue, nodeType?: string | null): InputNode; ++}; ++ ++type InputNode = Node & InputNodeClass; ++ export default InputNode; diff --git a/src-testing/src/nodes/core/Node.ts b/src-testing/src/nodes/core/Node.ts -index 335f0bf3..6ec8d35a 100644 +index 335f0bf3..ddb745db 100644 --- a/src-testing/src/nodes/core/Node.ts +++ b/src-testing/src/nodes/core/Node.ts @@ -4,6 +4,8 @@ import { hash, hashArray, hashString } from './NodeUtils.js'; @@ -917,13 +948,13 @@ index 335f0bf3..6ec8d35a 100644 + type?: string; +} + -+interface NodeJSONMeta { ++export interface NodeJSONMeta { + textures: { [key: string]: unknown }; + images: { [key: string]: unknown }; + nodes: { [key: string]: NodeJSONIntermediateOutputData }; +} + -+interface NodeJSONMetadata { ++export interface NodeJSONMetadata { + version: number; + type: 'Node'; + generator: 'Node.toJSON'; @@ -980,7 +1011,7 @@ index 335f0bf3..6ec8d35a 100644 * @augments EventDispatcher */ -class Node extends EventDispatcher { -+class Node extends EventDispatcher<{ dispose: {} }> { ++class NodeClass extends EventDispatcher<{ dispose: {} }> { static get type() { return 'Node'; } @@ -1423,6 +1454,143 @@ index 335f0bf3..6ec8d35a 100644 if (textures.length > 0) data.textures = textures; if (images.length > 0) data.images = images; +@@ -890,4 +980,136 @@ class Node extends EventDispatcher { + } + } + ++declare const Node: { ++ /** ++ * Constructs a new node. ++ * ++ * @param {?string} nodeType - The node type. ++ */ ++ new (nodeType?: string | null): Node; ++ new (nodeType?: string | null): Node; ++ get type(): string; ++}; ++ ++export interface NodeElements {} ++ ++export type NumberType = 'float' | 'int' | 'uint'; ++export type IntegerType = 'int' | 'uint'; ++export type NumOrBoolType = NumberType | 'bool'; ++export type FloatVectorType = 'vec2' | 'vec3' | 'vec4'; ++export type MatrixType = 'mat2' | 'mat3' | 'mat4'; ++export interface NodeExtensions {} ++export interface FloatExtensions {} ++export interface IntExtensions {} ++export interface UintExtensions {} ++export interface NumberExtensions {} ++export interface IntegerExtensions {} ++export interface NumOrBoolExtensions {} ++export interface BoolExtensions {} ++export interface Vec2Extensions {} ++export interface Ivec2Extensions {} ++export interface Uvec2Extensions {} ++export interface NumberVec2Extensions {} ++export interface NumOrBoolVec2Extensions {} ++export interface Vec3Extensions {} ++export interface Ivec3Extensions {} ++export interface Uvec3Extensions {} ++export interface NumberVec3Extensions {} ++export interface NumOrBoolVec3Extensions {} ++export interface Vec4Extensions {} ++export interface Ivec4Extensions {} ++export interface Uvec4Extensions {} ++export interface NumberVec4Extensions {} ++export interface NumOrBoolVec4Extensions {} ++export interface FloatVectorExtensions {} ++export interface BvecExtensions {} ++export interface Matrix2Extensions {} ++export interface Matrix3Extensions {} ++export interface Matrix4Extensions {} ++export interface MatrixExtensions {} ++export interface ColorExtensions {} ++type Node = NodeClass & ++ NodeElements & ++ (TValue extends 'float' ++ ? FloatExtensions & NumberExtensions<'float'> & NumOrBoolExtensions<'float'> & NodeExtensions<'float'> ++ : TValue extends 'int' ++ ? IntExtensions & ++ NumberExtensions<'int'> & ++ IntegerExtensions<'int'> & ++ NumOrBoolExtensions<'int'> & ++ NodeExtensions<'int'> ++ : TValue extends 'uint' ++ ? UintExtensions & ++ NumberExtensions<'uint'> & ++ IntegerExtensions<'uint'> & ++ NumOrBoolExtensions<'uint'> & ++ NodeExtensions<'uint'> ++ : TValue extends 'bool' ++ ? BoolExtensions & NumOrBoolExtensions<'bool'> & NodeExtensions<'bool'> ++ : TValue extends 'vec2' ++ ? Vec2Extensions & ++ NumberVec2Extensions<'float'> & ++ NumOrBoolVec2Extensions<'float'> & ++ FloatVectorExtensions<'vec2'> & ++ NodeExtensions<'vec2'> ++ : TValue extends 'ivec2' ++ ? Ivec2Extensions & ++ NumberVec2Extensions<'int'> & ++ NumOrBoolVec2Extensions<'int'> & ++ NodeExtensions<'ivec2'> ++ : TValue extends 'uvec2' ++ ? Uvec2Extensions & ++ NumberVec2Extensions<'uint'> & ++ NumOrBoolVec2Extensions<'uint'> & ++ NodeExtensions<'uvec2'> ++ : TValue extends 'bvec2' ++ ? BvecExtensions & NumOrBoolVec2Extensions<'bool'> & NodeExtensions<'bvec2'> ++ : TValue extends 'vec3' ++ ? Vec3Extensions & ++ NumberVec3Extensions<'float'> & ++ NumOrBoolVec3Extensions<'float'> & ++ FloatVectorExtensions<'vec3'> & ++ NodeExtensions<'vec3'> ++ : TValue extends 'ivec3' ++ ? Ivec3Extensions & ++ NumberVec3Extensions<'int'> & ++ NumOrBoolVec3Extensions<'int'> & ++ NodeExtensions<'ivec3'> ++ : TValue extends 'uvec3' ++ ? Uvec3Extensions & ++ NumberVec3Extensions<'uint'> & ++ NumOrBoolVec3Extensions<'uint'> & ++ NodeExtensions<'uvec3'> ++ : TValue extends 'bvec3' ++ ? BvecExtensions & NumOrBoolVec3Extensions<'bool'> & NodeExtensions<'bvec3'> ++ : TValue extends 'vec4' ++ ? Vec4Extensions & ++ NumberVec4Extensions<'float'> & ++ NumOrBoolVec4Extensions<'float'> & ++ FloatVectorExtensions<'vec4'> & ++ NodeExtensions<'vec4'> ++ : TValue extends 'ivec4' ++ ? Ivec4Extensions & ++ NumberVec4Extensions<'int'> & ++ NumOrBoolVec4Extensions<'int'> & ++ NodeExtensions<'ivec4'> ++ : TValue extends 'uvec4' ++ ? Uvec4Extensions & ++ NumberVec4Extensions<'uint'> & ++ NumOrBoolVec4Extensions<'uint'> & ++ NodeExtensions<'uvec4'> ++ : TValue extends 'bvec4' ++ ? BvecExtensions & NumOrBoolVec4Extensions<'bool'> & NodeExtensions<'bvec4'> ++ : TValue extends 'mat2' ++ ? Matrix2Extensions & MatrixExtensions<'mat2'> & NodeExtensions<'mat2'> ++ : TValue extends 'mat3' ++ ? Matrix3Extensions & MatrixExtensions<'mat3'> & NodeExtensions<'mat3'> ++ : TValue extends 'mat4' ++ ? Matrix4Extensions & MatrixExtensions<'mat4'> & NodeExtensions<'mat4'> ++ : TValue extends 'color' ++ ? ColorExtensions & NodeExtensions<'color'> ++ : {}) & { ++ __TypeScript_VALUE__: TValue; ++ }; ++ + export default Node; diff --git a/src-testing/src/nodes/core/NodeAttribute.ts b/src-testing/src/nodes/core/NodeAttribute.ts index 393325c3..5daf1095 100644 --- a/src-testing/src/nodes/core/NodeAttribute.ts @@ -2511,7 +2679,7 @@ index 15a27827..4bee878c 100644 toType = this.getVectorType(toType); diff --git a/src-testing/src/nodes/core/NodeCache.ts b/src-testing/src/nodes/core/NodeCache.ts -index 60ca0039..180c7e3b 100644 +index 60ca0039..cbbfb7c8 100644 --- a/src-testing/src/nodes/core/NodeCache.ts +++ b/src-testing/src/nodes/core/NodeCache.ts @@ -1,16 +1,64 @@ @@ -2539,7 +2707,7 @@ index 60ca0039..180c7e3b 100644 + | undefined; + bufferAttribute?: NodeAttribute | undefined; + structType?: StructType | undefined; -+ uniform?: NodeUniform | undefined; ++ uniform?: NodeUniform | undefined; + variable?: NodeVar | undefined; + varying?: NodeVarying | undefined; + code?: NodeCode | undefined; @@ -2557,7 +2725,7 @@ index 60ca0039..180c7e3b 100644 +} + +interface BufferAttributeData { -+ node: BufferAttributeNode; ++ node: BufferAttributeNode; +} + /** @@ -2714,7 +2882,7 @@ index ae664a23..65e57edd 100644 export default NodeParser; diff --git a/src-testing/src/nodes/core/NodeUniform.ts b/src-testing/src/nodes/core/NodeUniform.ts -index 09ff8b51..9a5b8384 100644 +index 09ff8b51..f862f04f 100644 --- a/src-testing/src/nodes/core/NodeUniform.ts +++ b/src-testing/src/nodes/core/NodeUniform.ts @@ -1,10 +1,19 @@ @@ -2727,12 +2895,12 @@ index 09ff8b51..9a5b8384 100644 * for this purpose. */ -class NodeUniform { -+class NodeUniform { ++class NodeUniform { + readonly isNodeUniform: true; + + name: string; + type: string | null; -+ node: UniformNode; ++ node: UniformNode; + needsUpdate: boolean | undefined; + /** @@ -2743,7 +2911,7 @@ index 09ff8b51..9a5b8384 100644 * @param {UniformNode} node - An reference to the node. */ - constructor(name, type, node) { -+ constructor(name: string, type: string | null, node: UniformNode) { ++ constructor(name: string, type: string | null, node: UniformNode) { /** * This flag can be used for type testing. * @@ -3102,10 +3270,10 @@ index 94299fca..125e9ad4 100644 this.name = data.name; diff --git a/src-testing/src/nodes/core/UniformNode.ts b/src-testing/src/nodes/core/UniformNode.ts -index 19e6487a..b674b9df 100644 +index 19e6487a..9feba57c 100644 --- a/src-testing/src/nodes/core/UniformNode.ts +++ b/src-testing/src/nodes/core/UniformNode.ts -@@ -1,26 +1,36 @@ +@@ -1,26 +1,43 @@ import InputNode from './InputNode.js'; -import { objectGroup } from './UniformGroupNode.js'; +import UniformGroupNode, { objectGroup } from './UniformGroupNode.js'; @@ -3117,6 +3285,13 @@ index 19e6487a..b674b9df 100644 +import NodeFrame from './NodeFrame.js'; +import { NodeUpdateType } from './constants.js'; +import ConstNode from './ConstNode.js'; ++import { Vector2 } from '../../math/Vector2.js'; ++import { Vector3 } from '../../math/Vector3.js'; ++import { Vector4 } from '../../math/Vector4.js'; ++import { Matrix2 } from '../../math/Matrix2.js'; ++import { Matrix3 } from '../../math/Matrix3.js'; ++import { Matrix4 } from '../../math/Matrix4.js'; ++import { Color } from '../../math/Color.js'; /** * Class for representing a uniform. @@ -3124,7 +3299,7 @@ index 19e6487a..b674b9df 100644 * @augments InputNode */ -class UniformNode extends InputNode { -+class UniformNode extends InputNode { ++class UniformNodeClass extends InputNode { static get type() { return 'UniformNode'; } @@ -3145,7 +3320,7 @@ index 19e6487a..b674b9df 100644 super(value, nodeType); /** -@@ -56,11 +66,11 @@ class UniformNode extends InputNode { +@@ -56,11 +73,11 @@ class UniformNode extends InputNode { * @param {string} name - The name of the uniform. * @return {UniformNode} A reference to this node. */ @@ -3159,7 +3334,7 @@ index 19e6487a..b674b9df 100644 /** * Sets the {@link UniformNode#name} property. -@@ -69,11 +79,11 @@ class UniformNode extends InputNode { +@@ -69,11 +86,11 @@ class UniformNode extends InputNode { * @param {string} name - The name of the uniform. * @return {UniformNode} A reference to this node. */ @@ -3173,7 +3348,7 @@ index 19e6487a..b674b9df 100644 /** * Sets the {@link UniformNode#groupNode} property. -@@ -81,7 +91,7 @@ class UniformNode extends InputNode { +@@ -81,7 +98,7 @@ class UniformNode extends InputNode { * @param {UniformGroupNode} group - The uniform group. * @return {UniformNode} A reference to this node. */ @@ -3182,7 +3357,7 @@ index 19e6487a..b674b9df 100644 this.groupNode = group; return this; -@@ -103,11 +113,11 @@ class UniformNode extends InputNode { +@@ -103,11 +120,11 @@ class UniformNode extends InputNode { * @param {NodeBuilder} builder - The current node builder. * @return {string} The uniform hash. */ @@ -3196,7 +3371,7 @@ index 19e6487a..b674b9df 100644 callback = callback.bind(this); return super.onUpdate(frame => { -@@ -119,7 +129,7 @@ class UniformNode extends InputNode { +@@ -119,7 +136,7 @@ class UniformNode extends InputNode { }, updateType); } @@ -3205,7 +3380,7 @@ index 19e6487a..b674b9df 100644 let type = super.getInputType(builder); if (type === 'bool') { -@@ -129,12 +139,12 @@ class UniformNode extends InputNode { +@@ -129,12 +146,12 @@ class UniformNode extends InputNode { return type; } @@ -3220,7 +3395,7 @@ index 19e6487a..b674b9df 100644 if (sharedNode === undefined) { builder.setHashNode(this, hash); -@@ -147,7 +157,7 @@ class UniformNode extends InputNode { +@@ -147,7 +164,7 @@ class UniformNode extends InputNode { const nodeUniform = builder.getUniformFromNode( sharedNode, sharedNodeType, @@ -3229,16 +3404,53 @@ index 19e6487a..b674b9df 100644 this.name || builder.context.nodeName, ); const uniformName = builder.getPropertyName(nodeUniform); -@@ -194,7 +204,7 @@ export default UniformNode; +@@ -183,8 +200,33 @@ class UniformNode extends InputNode { + } + } + ++declare const UniformNode: { ++ /** ++ * Constructs a new uniform node. ++ * ++ * @param {any} value - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture). ++ * @param {?string} nodeType - The node type. If no explicit type is defined, the node tries to derive the type from its value. ++ */ ++ new (value: TValue, nodeType?: string | null): UniformNode; ++ get type(): string; ++}; ++type UniformNode = UniformNodeClass & InputNode; ++ + export default UniformNode; + ++interface Uniform { ++ (value: number, type?: 'float'): UniformNode<'float', number>; ++ (value: boolean): UniformNode<'bool', boolean>; ++ (value: Vector2): UniformNode<'vec2', Vector2>; ++ (value: Vector3): UniformNode<'vec3', Vector3>; ++ (value: Vector4): UniformNode<'vec4', Vector4>; ++ (value: Matrix2): UniformNode<'mat2', Matrix2>; ++ (value: Matrix3): UniformNode<'mat3', Matrix3>; ++ (value: Matrix4): UniformNode<'mat4', Matrix4>; ++ (value: Color): UniformNode<'color', Color>; ++ (value: InputNode): UniformNode; ++} ++ + /** + * TSL function for creating a uniform node. + * +@@ -194,7 +236,10 @@ export default UniformNode; * @param {string} [type] - The node type. If no explicit type is defined, the node tries to derive the type from its value. * @returns {UniformNode} */ -export const uniform = (value, type) => { -+export const uniform = (value: InputNode | TValue, type?: Node | string): UniformNode => { ++export const uniform: Uniform = ( ++ value: InputNode | TValue, ++ type?: Node | string, ++): UniformNode => { const nodeType = getConstNodeType(type || value); if (nodeType === value) { -@@ -203,17 +213,17 @@ export const uniform = (value, type) => { +@@ -203,17 +248,17 @@ export const uniform = (value, type) => { value = getValueFromType(nodeType); } @@ -3391,6 +3603,56 @@ index ee5cf92a..7240bb88 100644 this.value = this._value || (this._value = this.getContext()); this.value.lightingModel = this.lightingModel || builder.context.lightingModel; +diff --git a/src-testing/src/nodes/math/OperatorNode.d.ts b/src-testing/src/nodes/math/OperatorNode.d.ts +index eece6633..91711e70 100644 +--- a/src-testing/src/nodes/math/OperatorNode.d.ts ++++ b/src-testing/src/nodes/math/OperatorNode.d.ts +@@ -270,7 +270,7 @@ declare module "../core/Node.js" { + div: (b: Number<"float">) => Node<"vec3">; + } + +- interface NumberVec2Extensions { ++ interface NumVec2Extensions { + add: AddSubMulDivNumberVecVec2Extensions; + sub: AddSubMulDivNumberVecVec2Extensions; + mul: MulVec2Extensions; +@@ -282,7 +282,7 @@ declare module "../core/Node.js" { + divAssign: AddSubMulDivNumberVecVec2AssignExtensions; + } + +- interface NumberVec3Extensions { ++ interface NumVec3Extensions { + add: AddSubMulDivNumberVecVec3Extensions; + sub: AddSubMulDivNumberVecVec3Extensions; + mul: MulVec3Extensions; +@@ -294,7 +294,7 @@ declare module "../core/Node.js" { + divAssign: AddSubMulDivNumberVecVec3AssignExtensions; + } + +- interface NumberVec4Extensions { ++ interface NumVec4Extensions { + add: AddSubMulDivNumberVecVec4Extensions; + sub: AddSubMulDivNumberVecVec4Extensions; + mul: MulVec4Extensions; +@@ -363,15 +363,15 @@ declare module "../core/Node.js" { + mod: (b: Vec4OrLessOrNumber) => Node; + modAssign: (b: Vec4OrLessOrNumber) => this; + } +- interface NumberVec2Extensions { ++ interface NumVec2Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } +- interface NumberVec3Extensions { ++ interface NumVec3Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } +- interface NumberVec4Extensions { ++ interface NumVec4Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } diff --git a/src-testing/src/nodes/tsl/TSLCore.ts b/src-testing/src/nodes/tsl/TSLCore.ts index 614df3fa..9c8bd09c 100644 --- a/src-testing/src/nodes/tsl/TSLCore.ts @@ -6275,7 +6537,7 @@ index d12ad583..ef6e14ec 100644 } diff --git a/src-testing/src/renderers/common/RenderObject.ts b/src-testing/src/renderers/common/RenderObject.ts -index b76afd62..fd427e42 100644 +index cbe4e919..2264205f 100644 --- a/src-testing/src/renderers/common/RenderObject.ts +++ b/src-testing/src/renderers/common/RenderObject.ts @@ -1,8 +1,27 @@ @@ -8442,7 +8704,7 @@ index 93c9419f..aa5b6b4b 100644 /** diff --git a/src-testing/src/renderers/common/UniformsGroup.ts b/src-testing/src/renderers/common/UniformsGroup.ts -index e5354d6c..4871cd0b 100644 +index e5354d6c..b3842486 100644 --- a/src-testing/src/renderers/common/UniformsGroup.ts +++ b/src-testing/src/renderers/common/UniformsGroup.ts @@ -1,6 +1,16 @@ @@ -8509,7 +8771,7 @@ index e5354d6c..4871cd0b 100644 let buffer = this._buffer; if (buffer === null) { -@@ -170,14 +186,14 @@ class UniformsGroup extends UniformBuffer { +@@ -170,14 +186,21 @@ class UniformsGroup extends UniformBuffer { * @param {Uniform} uniform - The uniform to update. * @return {boolean} Whether the uniform has been updated or not. */ @@ -8522,80 +8784,87 @@ index e5354d6c..4871cd0b 100644 - if (uniform.isMatrix3Uniform) return this.updateMatrix3(uniform); - if (uniform.isMatrix4Uniform) return this.updateMatrix4(uniform); + updateByType(uniform: NodeUniformGPU) { -+ if ((uniform as NumberNodeUniform).isNumberUniform) return this.updateNumber(uniform as NumberNodeUniform); -+ if ((uniform as Vector2NodeUniform).isVector2Uniform) return this.updateVector2(uniform as Vector2NodeUniform); -+ if ((uniform as Vector3NodeUniform).isVector3Uniform) return this.updateVector3(uniform as Vector3NodeUniform); -+ if ((uniform as Vector4NodeUniform).isVector4Uniform) return this.updateVector4(uniform as Vector4NodeUniform); -+ if ((uniform as ColorNodeUniform).isColorUniform) return this.updateColor(uniform as ColorNodeUniform); -+ if ((uniform as Matrix3NodeUniform).isMatrix3Uniform) return this.updateMatrix3(uniform as Matrix3NodeUniform); -+ if ((uniform as Matrix4NodeUniform).isMatrix4Uniform) return this.updateMatrix4(uniform as Matrix4NodeUniform); ++ if ((uniform as NumberNodeUniform).isNumberUniform) ++ return this.updateNumber(uniform as NumberNodeUniform); ++ if ((uniform as Vector2NodeUniform).isVector2Uniform) ++ return this.updateVector2(uniform as Vector2NodeUniform); ++ if ((uniform as Vector3NodeUniform).isVector3Uniform) ++ return this.updateVector3(uniform as Vector3NodeUniform); ++ if ((uniform as Vector4NodeUniform).isVector4Uniform) ++ return this.updateVector4(uniform as Vector4NodeUniform); ++ if ((uniform as ColorNodeUniform).isColorUniform) ++ return this.updateColor(uniform as ColorNodeUniform); ++ if ((uniform as Matrix3NodeUniform).isMatrix3Uniform) ++ return this.updateMatrix3(uniform as Matrix3NodeUniform); ++ if ((uniform as Matrix4NodeUniform).isMatrix4Uniform) ++ return this.updateMatrix4(uniform as Matrix4NodeUniform); error('WebGPUUniformsGroup: Unsupported uniform type.', uniform); } -@@ -188,7 +204,7 @@ class UniformsGroup extends UniformBuffer { +@@ -188,7 +211,7 @@ class UniformsGroup extends UniformBuffer { * @param {NumberUniform} uniform - The Number uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateNumber(uniform) { -+ updateNumber(uniform: NumberNodeUniform) { ++ updateNumber(uniform: NumberNodeUniform) { let updated = false; const a = this.values; -@@ -212,7 +228,7 @@ class UniformsGroup extends UniformBuffer { +@@ -212,7 +235,7 @@ class UniformsGroup extends UniformBuffer { * @param {Vector2Uniform} uniform - The Vector2 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector2(uniform) { -+ updateVector2(uniform: Vector2NodeUniform) { ++ updateVector2(uniform: Vector2NodeUniform) { let updated = false; const a = this.values; -@@ -238,7 +254,7 @@ class UniformsGroup extends UniformBuffer { +@@ -238,7 +261,7 @@ class UniformsGroup extends UniformBuffer { * @param {Vector3Uniform} uniform - The Vector3 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector3(uniform) { -+ updateVector3(uniform: Vector3NodeUniform) { ++ updateVector3(uniform: Vector3NodeUniform) { let updated = false; const a = this.values; -@@ -265,7 +281,7 @@ class UniformsGroup extends UniformBuffer { +@@ -265,7 +288,7 @@ class UniformsGroup extends UniformBuffer { * @param {Vector4Uniform} uniform - The Vector4 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector4(uniform) { -+ updateVector4(uniform: Vector4NodeUniform) { ++ updateVector4(uniform: Vector4NodeUniform) { let updated = false; const a = this.values; -@@ -293,7 +309,7 @@ class UniformsGroup extends UniformBuffer { +@@ -293,7 +316,7 @@ class UniformsGroup extends UniformBuffer { * @param {ColorUniform} uniform - The Color uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateColor(uniform) { -+ updateColor(uniform: ColorNodeUniform) { ++ updateColor(uniform: ColorNodeUniform) { let updated = false; const a = this.values; -@@ -319,7 +335,7 @@ class UniformsGroup extends UniformBuffer { +@@ -319,7 +342,7 @@ class UniformsGroup extends UniformBuffer { * @param {Matrix3Uniform} uniform - The Matrix3 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateMatrix3(uniform) { -+ updateMatrix3(uniform: Matrix3NodeUniform) { ++ updateMatrix3(uniform: Matrix3NodeUniform) { let updated = false; const a = this.values; -@@ -361,7 +377,7 @@ class UniformsGroup extends UniformBuffer { +@@ -361,7 +384,7 @@ class UniformsGroup extends UniformBuffer { * @param {Matrix4Uniform} uniform - The Matrix4 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateMatrix4(uniform) { -+ updateMatrix4(uniform: Matrix4NodeUniform) { ++ updateMatrix4(uniform: Matrix4NodeUniform) { let updated = false; const a = this.values; -@@ -385,7 +401,7 @@ class UniformsGroup extends UniformBuffer { +@@ -385,7 +408,7 @@ class UniformsGroup extends UniformBuffer { * @param {string} type - The data type. * @return {TypedArray} The typed array. */ @@ -8604,7 +8873,7 @@ index e5354d6c..4871cd0b 100644 if (type === 'int' || type === 'ivec2' || type === 'ivec3' || type === 'ivec4') return new Int32Array(this.buffer.buffer); if (type === 'uint' || type === 'uvec2' || type === 'uvec3' || type === 'uvec4') -@@ -402,7 +418,7 @@ class UniformsGroup extends UniformBuffer { +@@ -402,7 +425,7 @@ class UniformsGroup extends UniformBuffer { * @param {TypedArray} b - The second array. * @param {number} offset - An index offset for the first array. */ @@ -8613,7 +8882,7 @@ index e5354d6c..4871cd0b 100644 for (let i = 0, l = b.length; i < l; i++) { a[offset + i] = b[i]; } -@@ -417,7 +433,7 @@ function setArray(a, b, offset) { +@@ -417,7 +440,7 @@ function setArray(a, b, offset) { * @param {number} offset - An index offset for the first array. * @return {boolean} Whether the given arrays are equal or not. */ @@ -9451,7 +9720,7 @@ index 7c61c35c..04e6eb0d 100644 warn(`Redefinition of node ${baseClass.name}`); return; diff --git a/src-testing/src/renderers/common/nodes/NodeUniform.ts b/src-testing/src/renderers/common/nodes/NodeUniform.ts -index 81d9f2ce..f4c0431c 100644 +index 81d9f2ce..7a6a0b9c 100644 --- a/src-testing/src/renderers/common/nodes/NodeUniform.ts +++ b/src-testing/src/renderers/common/nodes/NodeUniform.ts @@ -8,6 +8,14 @@ import { @@ -9469,11 +9738,13 @@ index 81d9f2ce..f4c0431c 100644 /** * A special form of Number uniform binding type. -@@ -17,12 +25,14 @@ import { +@@ -16,13 +24,15 @@ import { + * @private * @augments NumberUniform */ - class NumberNodeUniform extends NumberUniform { -+ nodeUniform: NodeUniform; +-class NumberNodeUniform extends NumberUniform { ++class NumberNodeUniform extends NumberUniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Number uniform. @@ -9481,15 +9752,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -60,12 +70,14 @@ class NumberNodeUniform extends NumberUniform { +@@ -59,13 +69,15 @@ class NumberNodeUniform extends NumberUniform { + * @private * @augments Vector2Uniform */ - class Vector2NodeUniform extends Vector2Uniform { -+ nodeUniform: NodeUniform; +-class Vector2NodeUniform extends Vector2Uniform { ++class Vector2NodeUniform extends Vector2Uniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Vector2 uniform. @@ -9497,15 +9770,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -103,12 +115,14 @@ class Vector2NodeUniform extends Vector2Uniform { +@@ -102,13 +114,15 @@ class Vector2NodeUniform extends Vector2Uniform { + * @private * @augments Vector3Uniform */ - class Vector3NodeUniform extends Vector3Uniform { -+ nodeUniform: NodeUniform; +-class Vector3NodeUniform extends Vector3Uniform { ++class Vector3NodeUniform extends Vector3Uniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Vector3 uniform. @@ -9513,15 +9788,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -146,12 +160,14 @@ class Vector3NodeUniform extends Vector3Uniform { +@@ -145,13 +159,15 @@ class Vector3NodeUniform extends Vector3Uniform { + * @private * @augments Vector4Uniform */ - class Vector4NodeUniform extends Vector4Uniform { -+ nodeUniform: NodeUniform; +-class Vector4NodeUniform extends Vector4Uniform { ++class Vector4NodeUniform extends Vector4Uniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Vector4 uniform. @@ -9529,15 +9806,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -189,12 +205,14 @@ class Vector4NodeUniform extends Vector4Uniform { +@@ -188,13 +204,15 @@ class Vector4NodeUniform extends Vector4Uniform { + * @private * @augments ColorUniform */ - class ColorNodeUniform extends ColorUniform { -+ nodeUniform: NodeUniform; +-class ColorNodeUniform extends ColorUniform { ++class ColorNodeUniform extends ColorUniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Color uniform. @@ -9545,15 +9824,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -232,12 +250,14 @@ class ColorNodeUniform extends ColorUniform { +@@ -231,13 +249,15 @@ class ColorNodeUniform extends ColorUniform { + * @private * @augments Matrix2Uniform */ - class Matrix2NodeUniform extends Matrix2Uniform { -+ nodeUniform: NodeUniform; +-class Matrix2NodeUniform extends Matrix2Uniform { ++class Matrix2NodeUniform extends Matrix2Uniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Matrix2 uniform. @@ -9561,15 +9842,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -275,12 +295,14 @@ class Matrix2NodeUniform extends Matrix2Uniform { +@@ -274,13 +294,15 @@ class Matrix2NodeUniform extends Matrix2Uniform { + * @private * @augments Matrix3Uniform */ - class Matrix3NodeUniform extends Matrix3Uniform { -+ nodeUniform: NodeUniform; +-class Matrix3NodeUniform extends Matrix3Uniform { ++class Matrix3NodeUniform extends Matrix3Uniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Matrix3 uniform. @@ -9577,15 +9860,17 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** -@@ -318,12 +340,14 @@ class Matrix3NodeUniform extends Matrix3Uniform { +@@ -317,13 +339,15 @@ class Matrix3NodeUniform extends Matrix3Uniform { + * @private * @augments Matrix4Uniform */ - class Matrix4NodeUniform extends Matrix4Uniform { -+ nodeUniform: NodeUniform; +-class Matrix4NodeUniform extends Matrix4Uniform { ++class Matrix4NodeUniform extends Matrix4Uniform { ++ nodeUniform: NodeUniform; + /** * Constructs a new node-based Matrix4 uniform. @@ -9593,7 +9878,7 @@ index 81d9f2ce..f4c0431c 100644 * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform) { -+ constructor(nodeUniform: NodeUniform) { ++ constructor(nodeUniform: NodeUniform) { super(nodeUniform.name, nodeUniform.value); /** @@ -9602,13 +9887,13 @@ index 81d9f2ce..f4c0431c 100644 Matrix4NodeUniform, }; +export type NodeUniformGPU = -+ | NumberNodeUniform -+ | Vector2NodeUniform -+ | Vector3NodeUniform -+ | Vector4NodeUniform -+ | ColorNodeUniform -+ | Matrix3NodeUniform -+ | Matrix4NodeUniform; ++ | NumberNodeUniform ++ | Vector2NodeUniform ++ | Vector3NodeUniform ++ | Vector4NodeUniform ++ | ColorNodeUniform ++ | Matrix3NodeUniform ++ | Matrix4NodeUniform; diff --git a/src-testing/src/renderers/common/nodes/NodeUniformsGroup.ts b/src-testing/src/renderers/common/nodes/NodeUniformsGroup.ts index 19a8dd2a..26f39bf2 100644 --- a/src-testing/src/renderers/common/nodes/NodeUniformsGroup.ts @@ -9640,7 +9925,7 @@ index 19a8dd2a..26f39bf2 100644 /** diff --git a/src-testing/src/renderers/common/nodes/Nodes.ts b/src-testing/src/renderers/common/nodes/Nodes.ts -index 34f4121f..0c7b983e 100644 +index 34f4121f..8c444be0 100644 --- a/src-testing/src/renderers/common/nodes/Nodes.ts +++ b/src-testing/src/renderers/common/nodes/Nodes.ts @@ -28,10 +28,63 @@ import { @@ -9695,9 +9980,9 @@ index 34f4121f..0c7b983e 100644 + +declare module '../../../scenes/Scene.js' { + interface Scene { -+ environmentNode?: Node | null | undefined; -+ backgroundNode?: Node | null | undefined; -+ fogNode?: Node | null | undefined; ++ environmentNode?: Node<'vec3'> | null | undefined; ++ backgroundNode?: Node<'vec3'> | Node<'vec4'> | Node<'color'> | null | undefined; ++ fogNode?: Node<'vec4'> | null | undefined; + } +} @@ -10543,10 +10828,10 @@ index df211906..e7db9d47 100644 const nodeData = this.getDataFromNode(node, shaderStage, this.globalCache); diff --git a/src-testing/src/renderers/webgpu/WebGPUBackend.ts b/src-testing/src/renderers/webgpu/WebGPUBackend.ts -index 6462ea5e..4984e3a3 100644 +index b56a69e4..f88e3333 100644 --- a/src-testing/src/renderers/webgpu/WebGPUBackend.ts +++ b/src-testing/src/renderers/webgpu/WebGPUBackend.ts -@@ -1672,7 +1672,14 @@ class WebGPUBackend extends Backend { +@@ -1678,7 +1678,14 @@ class WebGPUBackend extends Backend { * @param {number} faceIndex - The face index. * @return {Promise} A Promise that resolves with a typed array when the copy operation has finished. */ diff --git a/swizzle-generator.js b/swizzle-generator.js new file mode 100644 index 000000000..7a7f372b1 --- /dev/null +++ b/swizzle-generator.js @@ -0,0 +1,153 @@ +const swizzleA = ["x", "y", "z", "w"]; +const swizzleB = ["r", "g", "b", "a"]; +const swizzleC = ["s", "t", "p", "q"]; + +let swizzleOptions = []; +for (let i = 0; i < 4; i++) { + swizzleOptions[i] = []; + for (let j = 0; j < 4; j++) { + swizzleOptions[i][j] = []; + } +} + +let swizzleOptionsNoRepetition = []; +for (let i = 0; i < 4; i++) { + swizzleOptionsNoRepetition[i] = []; + for (let j = 0; j < 4; j++) { + swizzleOptionsNoRepetition[i][j] = []; + } +} + +let swizzleOptionsNoRepetitionOrdered = []; +for (let i = 0; i < 4; i++) { + swizzleOptionsNoRepetitionOrdered[i] = []; + for (let j = 0; j < 4; j++) { + swizzleOptionsNoRepetitionOrdered[i][j] = []; + } +} + +function setProtoSwizzle(a, b, c, d) { + let prop = swizzleA[a]; + let altA = swizzleB[a]; + let altB = swizzleC[a]; + + if (b != null) { + prop += swizzleA[b]; + altA += swizzleB[b]; + altB += swizzleC[b]; + } + + if (c != null) { + prop += swizzleA[c]; + altA += swizzleB[c]; + altB += swizzleC[c]; + } + + if (d != null) { + prop += swizzleA[d]; + altA += swizzleB[d]; + altB += swizzleC[d]; + } + + const validChars = [a, b, c, d].filter(x => x != null); + const numChars = validChars.length; + const maxCharNum = Math.max(...validChars); + + swizzleOptions[numChars - 1][maxCharNum].push(prop); + swizzleOptions[numChars - 1][maxCharNum].push(altA); + swizzleOptions[numChars - 1][maxCharNum].push(altB); + + if (b == null || b !== a) { + if (c == null || c !== a && c !== b) { + if (d == null || d !== c && d !== b && d !== a) { + swizzleOptionsNoRepetition[numChars - 1][maxCharNum].push(prop); + swizzleOptionsNoRepetition[numChars - 1][maxCharNum].push(altA); + swizzleOptionsNoRepetition[numChars - 1][maxCharNum].push(altB); + } + } + } + + if (b == null || a < b) { + if (c == null || a < c && b < c) { + if (d == null || c < d && b < d && a < d) { + swizzleOptionsNoRepetitionOrdered[numChars - 1][maxCharNum].push(prop); + swizzleOptionsNoRepetitionOrdered[numChars - 1][maxCharNum].push(altA); + swizzleOptionsNoRepetitionOrdered[numChars - 1][maxCharNum].push(altB); + } + } + } +} + +for (let a = 0; a < 4; a++) { + setProtoSwizzle(a, null, null, null); + for (let b = 0; b < 4; b++) { + setProtoSwizzle(a, b, null, null); + for (let c = 0; c < 4; c++) { + setProtoSwizzle(a, b, c, null); + for (let d = 0; d < 4; d++) { + setProtoSwizzle(a, b, c, d); + } + } + } +} + +const accessType = [ + "Node", + "Node>", + "Node>", + "Node>", +]; + +const assignType = [ + "NumOrBool", + "Node> | NumOrBool", + "Node> | NumOrBool", + "Node> | NumOrBool", +]; + +for (let i = 0; i < 4; i++) { + for (let j = 0; j < 4; j++) { + let interfaceLine = `interface Swizzle${i + 1}From${j + 1}`; + if (j > 0) interfaceLine += ` extends Swizzle${i + 1}From${j}`; + interfaceLine += " {"; + console.log(interfaceLine); + const arr = swizzleOptions[i][j]; + const arrNoRepetition = swizzleOptionsNoRepetition[i][j]; + for (const val of arr) { + console.log(` get ${val}(): ${accessType[i]};`); + if (arrNoRepetition.includes(val)) { + console.log(` set ${val}(value: ${assignType[i]});`); + } + } + console.log("}"); + console.log(); + } +} + +for (let i = 0; i < 4; i++) { + console.log(`interface SetSwizzle${i + 1} {`); + for (let j = 0; j <= i; j++) { + for (let k = 0; k <= i; k++) { + const arr = swizzleOptionsNoRepetition[j][k]; + for (const val of arr) { + console.log(` set${val.toUpperCase()}(value: ${assignType[j]}): ${accessType[i]};`); + } + } + } + console.log("}"); + console.log(); +} + +for (let i = 0; i < 4; i++) { + console.log(`interface FlipSwizzle${i + 1} {`); + for (let j = 0; j <= i; j++) { + for (let k = 0; k <= i; k++) { + const arr = swizzleOptionsNoRepetitionOrdered[j][k]; + for (const val of arr) { + console.log(` flip${val.toUpperCase()}(): ${accessType[i]};`); + } + } + } + console.log("}"); + console.log(); +} diff --git a/tsl-testing/TSLCore.ts b/tsl-testing/TSLCore.ts new file mode 100644 index 000000000..1263672ab --- /dev/null +++ b/tsl-testing/TSLCore.ts @@ -0,0 +1,65 @@ +import { vec2, vec3 } from "three/tsl"; +import * as THREE from "three/webgpu"; + +/** + * Setup + */ + +const testVec2 = vec2(2, 3); +const testVec3 = vec3(1, 0, 2); + +/** + * Access swizzle properties + */ + +const testVec2Swizzle: THREE.Node<"vec2"> = testVec3.xy; + +// @ts-expect-error +testVec2.xz; + +/** + * Assign swizzle properties + */ + +testVec3.x = 5; +testVec3.xy = testVec2; +testVec3.xy = 6; + +// @ts-expect-error +testVec3.xy = testVec3; + +// @ts-expect-error +testVec3.xx = 5; + +/** + * Set swizzle methods + */ + +testVec3.setXY(5); +testVec3.setXY(testVec2); +testVec3.setXZ(3); + +// @ts-expect-error +testVec2.setXZ(testVec2); + +// @ts-expect-error +testVec3.setXY(testVec3); + +// @ts-expect-error +testVec3.setXX(5); + +/** + * Flip swizzle methods + */ + +testVec3.flipX(); +testVec3.flipXZ(); + +// @ts-expect-error +testVec2.flipXZ(); + +// @ts-expect-error +testVec3.flipZX(); + +// @ts-expect-error +testVec3.flipXX(); diff --git a/tsl-testing/package.json b/tsl-testing/package.json new file mode 100644 index 000000000..ddfecb9df --- /dev/null +++ b/tsl-testing/package.json @@ -0,0 +1,19 @@ +{ + "name": "tsl-testing", + "version": "1.0.0", + "description": "", + "main": "", + "scripts": { + "type-check": "tsc", + "format": "prettier --write .", + "format-check": "prettier --check ." + }, + "type": "module", + "author": "", + "license": "ISC", + "dependencies": { + "@types/three": "file:../types/three", + "prettier": "^3.6.2", + "typescript": "latest" + } +} diff --git a/tsl-testing/tsconfig.json b/tsl-testing/tsconfig.json new file mode 100644 index 000000000..48e743d91 --- /dev/null +++ b/tsl-testing/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es2017", + "module": "NodeNext", + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strict": true + } +} diff --git a/types/three/examples/jsm/gpgpu/BitonicSort.d.ts b/types/three/examples/jsm/gpgpu/BitonicSort.d.ts index d6a04a21c..b4ef06ae4 100644 --- a/types/three/examples/jsm/gpgpu/BitonicSort.d.ts +++ b/types/three/examples/jsm/gpgpu/BitonicSort.d.ts @@ -1,20 +1,20 @@ import { Node, Renderer, StorageBufferNode } from "three/webgpu"; -export const getBitonicFlipIndices: (index: Node, blockHeight: Node) => Node; +export const getBitonicFlipIndices: (index: Node<"uint">, blockHeight: Node<"uint">) => Node<"uvec2">; -export const getBitonicDisperseIndices: (index: Node, swapSpan: Node) => Node; +export const getBitonicDisperseIndices: (index: Node<"uint">, swapSpan: Node<"uint">) => Node<"uvec2">; export interface BitonicSortOptions { workgroupSize?: number | undefined; } -export class BitonicSort { - infoStorage: StorageBufferNode; +export class BitonicSort { + infoStorage: StorageBufferNode; swapOpCount: number; stepCount: number; - constructor(renderer: Renderer, dataBuffer: StorageBufferNode, options?: BitonicSortOptions); + constructor(renderer: Renderer, dataBuffer: StorageBufferNode, options?: BitonicSortOptions); computeStep(renderer: Renderer): Promise; compute(renderer: Renderer): Promise; diff --git a/types/three/examples/jsm/objects/SkyMesh.d.ts b/types/three/examples/jsm/objects/SkyMesh.d.ts index be7f71535..933285a82 100644 --- a/types/three/examples/jsm/objects/SkyMesh.d.ts +++ b/types/three/examples/jsm/objects/SkyMesh.d.ts @@ -1,12 +1,12 @@ import { BoxGeometry, Mesh, NodeMaterial, UniformNode, Vector3 } from "three/webgpu"; declare class SkyMesh extends Mesh { - turbidity: UniformNode; - rayleigh: UniformNode; - mieCoefficient: UniformNode; - mieDirectionalG: UniformNode; - sunPosition: UniformNode; - upUniform: UniformNode; + turbidity: UniformNode<"float", number>; + rayleigh: UniformNode<"float", number>; + mieCoefficient: UniformNode<"float", number>; + mieDirectionalG: UniformNode<"float", number>; + sunPosition: UniformNode<"vec3", Vector3>; + upUniform: UniformNode<"vec3", Vector3>; /** * @deprecated diff --git a/types/three/examples/jsm/objects/Water2Mesh.d.ts b/types/three/examples/jsm/objects/Water2Mesh.d.ts index 5ed9cf400..ca39102ee 100644 --- a/types/three/examples/jsm/objects/Water2Mesh.d.ts +++ b/types/three/examples/jsm/objects/Water2Mesh.d.ts @@ -30,19 +30,19 @@ declare class WaterMesh extends Mesh { constructor(geometry: BufferGeometry, options: WaterMeshOptions); } -declare class WaterNode extends TempNode { +declare class WaterNode extends TempNode<"vec4"> { waterBody: WaterMesh; normalMap0: TextureNode; normalMap1: TextureNode; flowMap: TextureNode; - color: UniformNode; - flowDirection: UniformNode; - flowSpeed: UniformNode; - reflectivity: UniformNode; - scale: UniformNode; - flowConfig: UniformNode; + color: UniformNode<"color", Color>; + flowDirection: UniformNode<"vec2", Vector2>; + flowSpeed: UniformNode<"float", number>; + reflectivity: UniformNode<"float", number>; + scale: UniformNode<"float", number>; + flowConfig: UniformNode<"vec3", Vector3>; constructor(options: WaterMeshOptions, waterBody: WaterMesh); diff --git a/types/three/examples/jsm/objects/WaterMesh.d.ts b/types/three/examples/jsm/objects/WaterMesh.d.ts index fe90d3700..196b9fb62 100644 --- a/types/three/examples/jsm/objects/WaterMesh.d.ts +++ b/types/three/examples/jsm/objects/WaterMesh.d.ts @@ -27,12 +27,12 @@ declare class WaterMesh extends Mesh { resolutionScale: number; waterNormals: TextureNode; - alpha: UniformNode; - size: UniformNode; - sunColor: UniformNode; - sunDirection: UniformNode; - waterColor: UniformNode; - distortionScale: UniformNode; + alpha: UniformNode<"float", number>; + size: UniformNode<"float", number>; + sunColor: UniformNode<"color", Color>; + sunDirection: UniformNode<"vec3", Vector3>; + waterColor: UniformNode<"color", Color>; + distortionScale: UniformNode<"float", number>; constructor(geometry: BufferGeometry, options: WaterMeshOptions); } diff --git a/types/three/examples/jsm/tsl/display/AfterImageNode.d.ts b/types/three/examples/jsm/tsl/display/AfterImageNode.d.ts index 7fdf4eb48..972ae221b 100644 --- a/types/three/examples/jsm/tsl/display/AfterImageNode.d.ts +++ b/types/three/examples/jsm/tsl/display/AfterImageNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, TextureNode } from "three/webgpu"; -export default class AfterImageNode extends TempNode { +export default class AfterImageNode extends TempNode<"vec4"> { textureNode: TextureNode; textureNodeOld: Node; damp: Node; diff --git a/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts b/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts index 6f4598898..38f2fae2f 100644 --- a/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts +++ b/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, Vector2 } from "three/webgpu"; -export default class AnamorphicNode extends TempNode { +export default class AnamorphicNode extends TempNode<"vec4"> { textureNode: Node; thresholdNode: Node; scaleNode: Node; diff --git a/types/three/examples/jsm/tsl/display/BloomNode.d.ts b/types/three/examples/jsm/tsl/display/BloomNode.d.ts index b2bd8135d..291e697a3 100644 --- a/types/three/examples/jsm/tsl/display/BloomNode.d.ts +++ b/types/three/examples/jsm/tsl/display/BloomNode.d.ts @@ -1,12 +1,12 @@ import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class BloomNode extends TempNode { +declare class BloomNode extends TempNode<"vec4"> { inputNode: Node; - strength: UniformNode; - radius: UniformNode; - threshold: UniformNode; + strength: UniformNode<"float", number>; + radius: UniformNode<"float", number>; + threshold: UniformNode<"float", number>; - smoothWidth: UniformNode; + smoothWidth: UniformNode<"float", number>; constructor(inputNode: Node, strength?: number, radius?: number, threshold?: number); diff --git a/types/three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts b/types/three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts index 133767bf5..7d34617b8 100644 --- a/types/three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts +++ b/types/three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, Vector2 } from "three/webgpu"; -declare class ChromaticAberrationNode extends TempNode { +declare class ChromaticAberrationNode extends TempNode<"vec4"> { textureNode: Node; strengthNode: Node; centerNode: Node; diff --git a/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts b/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts index b2689fad2..322a7d06e 100644 --- a/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts +++ b/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts @@ -1,17 +1,17 @@ import { Camera, Node, TempNode, UniformNode } from "three/webgpu"; -declare class DenoiseNode extends TempNode { +declare class DenoiseNode extends TempNode<"vec4"> { textureNode: Node; depthNode: Node; normalNode: Node; noiseNode: Node; - lumaPhi: UniformNode; - depthPhi: UniformNode; - normalPhi: UniformNode; - radius: UniformNode; - index: UniformNode; + lumaPhi: UniformNode<"float", number>; + depthPhi: UniformNode<"float", number>; + normalPhi: UniformNode<"float", number>; + radius: UniformNode<"float", number>; + index: UniformNode<"float", number>; constructor(textureNode: Node, depthNode: Node, normalNode: Node, noiseNode: Node, camera: Camera); } diff --git a/types/three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts b/types/three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts index 9e104e615..c927f619b 100644 --- a/types/three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts +++ b/types/three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, TextureNode } from "three/webgpu"; -declare class DepthOfFieldNode extends TempNode { +declare class DepthOfFieldNode extends TempNode<"vec4"> { textureNode: TextureNode; viewZNode: Node; diff --git a/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts b/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts index 26f43564e..559e75d79 100644 --- a/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts +++ b/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts @@ -1,19 +1,17 @@ -import { Node, TempNode, UniformNode, Vector2 } from "three/webgpu"; +import { Node, TempNode, UniformNode } from "three/webgpu"; -declare class DotScreenNode extends TempNode { +declare class DotScreenNode extends TempNode<"vec4"> { inputNode: Node; - center: UniformNode; - angle: UniformNode; - scale: UniformNode; + angle: UniformNode<"float", number>; + scale: UniformNode<"float", number>; - constructor(inputNode: Node, center?: Vector2, angle?: number, scale?: number); + constructor(inputNode: Node, angle?: number, scale?: number); } export default DotScreenNode; export const dotScreen: ( node: Node, - center?: Vector2, angle?: number, scale?: number, ) => DotScreenNode; diff --git a/types/three/examples/jsm/tsl/display/FXAANode.d.ts b/types/three/examples/jsm/tsl/display/FXAANode.d.ts index cb34101ca..3883a70f5 100644 --- a/types/three/examples/jsm/tsl/display/FXAANode.d.ts +++ b/types/three/examples/jsm/tsl/display/FXAANode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, TextureNode } from "three/webgpu"; -declare class FXAANode extends TempNode { +declare class FXAANode extends TempNode<"vec4"> { textureNode: TextureNode; constructor(textureNode: TextureNode); diff --git a/types/three/examples/jsm/tsl/display/FilmNode.d.ts b/types/three/examples/jsm/tsl/display/FilmNode.d.ts index beacaa2bf..29749ea39 100644 --- a/types/three/examples/jsm/tsl/display/FilmNode.d.ts +++ b/types/three/examples/jsm/tsl/display/FilmNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode } from "three/webgpu"; -declare class FilmNode extends TempNode { +declare class FilmNode extends TempNode<"vec4"> { inputNode: Node; intensityNode: Node | null; uvNode: Node | null; diff --git a/types/three/examples/jsm/tsl/display/GTAONode.d.ts b/types/three/examples/jsm/tsl/display/GTAONode.d.ts index 8fd6fad03..2ec5689b8 100644 --- a/types/three/examples/jsm/tsl/display/GTAONode.d.ts +++ b/types/three/examples/jsm/tsl/display/GTAONode.d.ts @@ -1,18 +1,18 @@ import { Camera, Node, TempNode, TextureNode, UniformNode, Vector2 } from "three/webgpu"; -declare class GTAONode extends TempNode { +declare class GTAONode extends TempNode<"float"> { depthNode: Node; normalNode: Node; resolutionScale: number; - radius: UniformNode; - resolution: UniformNode; - thickness: UniformNode; - distanceExponent: UniformNode; - distanceFallOff: UniformNode; - scale: UniformNode; - samples: UniformNode; + radius: UniformNode<"float", number>; + resolution: UniformNode<"vec2", Vector2>; + thickness: UniformNode<"float", number>; + distanceExponent: UniformNode<"float", number>; + distanceFallOff: UniformNode<"float", number>; + scale: UniformNode<"float", number>; + samples: UniformNode<"float", number>; useTemporalFiltering: boolean; diff --git a/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts b/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts index 88493f2c5..52face1b5 100644 --- a/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts +++ b/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts @@ -5,7 +5,7 @@ export interface GaussianBlurNodeOptions { resolution?: Vector2 | undefined; } -declare class GaussianBlurNode extends TempNode { +declare class GaussianBlurNode extends TempNode<"vec4"> { textureNode: TextureNode; directionNode: Node | null; sigma: number; diff --git a/types/three/examples/jsm/tsl/display/LensflareNode.d.ts b/types/three/examples/jsm/tsl/display/LensflareNode.d.ts index b2bd8018c..f23ec6208 100644 --- a/types/three/examples/jsm/tsl/display/LensflareNode.d.ts +++ b/types/three/examples/jsm/tsl/display/LensflareNode.d.ts @@ -9,14 +9,14 @@ interface LensflareNodeParams { downSampleRatio?: number | undefined; } -declare class LensflareNode extends TempNode { +declare class LensflareNode extends TempNode<"vec4"> { textureNode: TextureNode; - ghostTintNode: UniformNode; - thresholdNode: UniformNode; - ghostSamplesNode: UniformNode; - ghostSpacingNode: UniformNode; - ghostAttenuationFactorNode: UniformNode; + ghostTintNode: UniformNode<"vec3", Vector3>; + thresholdNode: UniformNode<"float", number>; + ghostSamplesNode: UniformNode<"float", number>; + ghostSpacingNode: UniformNode<"float", number>; + ghostAttenuationFactorNode: UniformNode<"float", number>; downSampleRatio: number; constructor(textureNode: TextureNode, params?: LensflareNodeParams); diff --git a/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts b/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts index 3b292e764..7fb5b5f57 100644 --- a/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts +++ b/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts @@ -1,12 +1,12 @@ -import { Data3DTexture, Node, TempNode, Texture3DNode, UniformNode } from "three/webgpu"; +import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class Lut3DNode extends TempNode { +declare class Lut3DNode extends TempNode<"vec4"> { inputNode: Node; - lutNode: Texture3DNode; - size: UniformNode; - intensityNode: UniformNode; + lutNode: TextureNode; + size: UniformNode<"float", number>; + intensityNode: Node<"float">; - constructor(inputNode: Node, lutNode: UniformNode, size: number, intensityNode: UniformNode); + constructor(inputNode: Node, lutNode: TextureNode, size: number, intensityNode: Node<"float">); } export default Lut3DNode; diff --git a/types/three/examples/jsm/tsl/display/MotionBlur.d.ts b/types/three/examples/jsm/tsl/display/MotionBlur.d.ts index e2c720ad8..2883f115c 100644 --- a/types/three/examples/jsm/tsl/display/MotionBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/MotionBlur.d.ts @@ -1,7 +1,16 @@ import { Node } from "three/webgpu"; -export const motionBlur: ( - inputNode: Node, - velocity: Node, - numSamples?: Node, -) => Node; +interface MotionBlur { + ( + inputNode: Node<"vec3">, + velocity: Node<"vec2"> | Node<"vec3"> | Node<"vec4">, + numSamples?: Node<"int">, + ): Node<"vec3">; + ( + inputNode: Node<"vec4">, + velocity: Node<"vec2"> | Node<"vec3"> | Node<"vec4">, + numSamples?: Node<"int">, + ): Node<"vec4">; +} + +export const motionBlur: MotionBlur; diff --git a/types/three/examples/jsm/tsl/display/OutlineNode.d.ts b/types/three/examples/jsm/tsl/display/OutlineNode.d.ts index 479bc345e..68a40d90a 100644 --- a/types/three/examples/jsm/tsl/display/OutlineNode.d.ts +++ b/types/three/examples/jsm/tsl/display/OutlineNode.d.ts @@ -1,4 +1,4 @@ -import { Camera, Node, Object3D, Scene, TempNode, TextureNode, UniformNode } from "three/webgpu"; +import { Camera, Node, Object3D, Scene, TempNode, TextureNode } from "three/webgpu"; export interface OutlineNodeParams { selectedObjects?: Object3D[] | undefined; @@ -7,19 +7,19 @@ export interface OutlineNodeParams { downSampleRatio?: number | undefined; } -declare class OutlineNode extends TempNode { +declare class OutlineNode extends TempNode<"vec4"> { scene: Scene; camera: Camera; selectedObjects: Object3D[]; - edgeThicknessNode: UniformNode; - edgeGlowNode: UniformNode; + edgeThicknessNode: Node<"float">; + edgeGlowNode: Node<"float">; downSampleRatio: number; constructor(scene: Scene, camera: Camera, params?: OutlineNodeParams); - get visibleEdge(): Node; + get visibleEdge(): Node<"vec3">; - get hiddenEdge(): Node; + get hiddenEdge(): Node<"vec3">; getTextureNode(): TextureNode; diff --git a/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts b/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts index 6c4223e47..b18106e9e 100644 --- a/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts +++ b/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts @@ -1,9 +1,9 @@ -import { Camera, PassNode, Scene, UniformNode } from "three/webgpu"; +import { Camera, Node, PassNode, Scene } from "three/webgpu"; declare class PixelationPassNode extends PassNode { - pixelSize: UniformNode; - normalEdgeStrength: UniformNode; - depthEdgeStrength: UniformNode; + pixelSize: Node<"float">; + normalEdgeStrength: Node<"float">; + depthEdgeStrength: Node<"float">; readonly isPixelationPassNode: true; @@ -19,9 +19,9 @@ declare class PixelationPassNode extends PassNode { export const pixelationPass: ( scene: Scene, camera: Camera, - pixelSize: UniformNode, - normalEdgeStrength: UniformNode, - depthEdgeStrength: UniformNode, + pixelSize: Node<"float">, + normalEdgeStrength: Node<"float">, + depthEdgeStrength: Node<"float">, ) => PixelationPassNode; export default PixelationPassNode; diff --git a/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts b/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts index e36889828..c9aeb9121 100644 --- a/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts +++ b/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts @@ -1,9 +1,9 @@ import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -export default class RGBShiftNode extends TempNode { +export default class RGBShiftNode extends TempNode<"vec4"> { textureNode: TextureNode; - amount: UniformNode; - angle: UniformNode; + amount: UniformNode<"float", number>; + angle: UniformNode<"float", number>; constructor(textureNode: TextureNode, amount?: number, angle?: number); diff --git a/types/three/examples/jsm/tsl/display/SMAANode.d.ts b/types/three/examples/jsm/tsl/display/SMAANode.d.ts index e6a5b71ab..0f1c26cfe 100644 --- a/types/three/examples/jsm/tsl/display/SMAANode.d.ts +++ b/types/three/examples/jsm/tsl/display/SMAANode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, TextureNode } from "three/webgpu"; -declare class SMAANode extends TempNode { +declare class SMAANode extends TempNode<"vec4"> { textureNode: TextureNode; constructor(textureNode: TextureNode); diff --git a/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts b/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts index 3a0760f17..4f53e31ab 100644 --- a/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts @@ -8,7 +8,7 @@ declare class SSAAPassNode extends PassNode { clearColor: Color; clearAlpha: number; - sampleWeight: UniformNode; + sampleWeight: UniformNode<"float", number>; sampleRenderTarget: RenderTarget | null; diff --git a/types/three/examples/jsm/tsl/display/SSGINode.d.ts b/types/three/examples/jsm/tsl/display/SSGINode.d.ts index f2479fa8d..6a3df43df 100644 --- a/types/three/examples/jsm/tsl/display/SSGINode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSGINode.d.ts @@ -1,20 +1,20 @@ import { Node, PerspectiveCamera, TempNode, UniformNode } from "three/webgpu"; -declare class SSGINode extends TempNode { +declare class SSGINode extends TempNode<"vec4"> { beautyNode: Node; depthNode: Node; normalNode: Node; - sliceCount: UniformNode; - stepCount: UniformNode; - aoIntensity: UniformNode; - giIntensity: UniformNode; - radius: UniformNode; - useScreenSpaceSampling: UniformNode; - expFactor: UniformNode; - thickness: UniformNode; - useLinearThickness: UniformNode; - backfaceLighting: UniformNode; + sliceCount: UniformNode<"uint", number>; + stepCount: UniformNode<"uint", number>; + aoIntensity: UniformNode<"float", number>; + giIntensity: UniformNode<"float", number>; + radius: UniformNode<"float", number>; + useScreenSpaceSampling: UniformNode<"bool", boolean>; + expFactor: UniformNode<"float", number>; + thickness: UniformNode<"float", number>; + useLinearThickness: UniformNode<"bool", boolean>; + backfaceLighting: UniformNode<"float", number>; useTemporalFiltering: boolean; constructor(beautyNode: Node, depthNode: Node, normalNode: Node, camera: PerspectiveCamera); diff --git a/types/three/examples/jsm/tsl/display/SSRNode.d.ts b/types/three/examples/jsm/tsl/display/SSRNode.d.ts index 4cad8929a..e84b60f68 100644 --- a/types/three/examples/jsm/tsl/display/SSRNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSRNode.d.ts @@ -1,6 +1,6 @@ import { Camera, Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class SSRNode extends TempNode { +declare class SSRNode extends TempNode<"vec4"> { colorNode: Node; depthNode: Node; normalNode: Node; @@ -10,11 +10,11 @@ declare class SSRNode extends TempNode { resolutionScale: number; - maxDistance: UniformNode; - thickness: UniformNode; - opacity: UniformNode; - quality: UniformNode; - blurQuality: UniformNode; + maxDistance: UniformNode<"float", number>; + thickness: UniformNode<"float", number>; + opacity: UniformNode<"float", number>; + quality: UniformNode<"float", number>; + blurQuality: UniformNode<"int", number>; constructor( colorNode: Node, diff --git a/types/three/examples/jsm/tsl/display/SSSNode.d.ts b/types/three/examples/jsm/tsl/display/SSSNode.d.ts index 089445358..16653990e 100644 --- a/types/three/examples/jsm/tsl/display/SSSNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSSNode.d.ts @@ -1,12 +1,12 @@ import { Camera, DirectionalLight, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class SSSNode extends TempNode { +declare class SSSNode extends TempNode<"float"> { depthNode: TextureNode; - maxDistance: UniformNode; - thickness: UniformNode; - shadowIntensity: UniformNode; - quality: UniformNode; + maxDistance: UniformNode<"float", number>; + thickness: UniformNode<"float", number>; + shadowIntensity: UniformNode<"float", number>; + quality: UniformNode<"float", number>; resolutionScale: number; useTemporalFiltering: boolean; diff --git a/types/three/examples/jsm/tsl/display/SobelOperatorNode.d.ts b/types/three/examples/jsm/tsl/display/SobelOperatorNode.d.ts index 0467ca321..f724422e0 100644 --- a/types/three/examples/jsm/tsl/display/SobelOperatorNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SobelOperatorNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, TextureNode } from "three/webgpu"; -declare class SobelOperatorNode extends TempNode { +declare class SobelOperatorNode extends TempNode<"vec4"> { textureNode: TextureNode; constructor(textureNode: TextureNode); diff --git a/types/three/examples/jsm/tsl/display/TRAANode.d.ts b/types/three/examples/jsm/tsl/display/TRAANode.d.ts index 2939b4daf..5af865cfc 100644 --- a/types/three/examples/jsm/tsl/display/TRAANode.d.ts +++ b/types/three/examples/jsm/tsl/display/TRAANode.d.ts @@ -1,6 +1,6 @@ import { Camera, Node, TempNode, TextureNode } from "three/webgpu"; -declare class TRAANode extends TempNode { +declare class TRAANode extends TempNode<"vec4"> { readonly isTRAANode: true; beautyNode: TextureNode; diff --git a/types/three/examples/jsm/tsl/display/TransitionNode.d.ts b/types/three/examples/jsm/tsl/display/TransitionNode.d.ts index 2a0b55e2d..a9c785a95 100644 --- a/types/three/examples/jsm/tsl/display/TransitionNode.d.ts +++ b/types/three/examples/jsm/tsl/display/TransitionNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class TransitionNode extends TempNode { +declare class TransitionNode extends TempNode<"vec4"> { textureNodeA: TextureNode; textureNodeB: TextureNode; mixTextureNode: TextureNode; @@ -25,7 +25,7 @@ export const transition: ( node: Node, nodeB: Node, mixTexture: Node, - mixRatio: UniformNode, - threshold: UniformNode, - useTexture: UniformNode, + mixRatio: UniformNode<"float", number>, + threshold: UniformNode<"float", number>, + useTexture: UniformNode<"float", number>, ) => TransitionNode; diff --git a/types/three/examples/jsm/tsl/display/boxBlur.d.ts b/types/three/examples/jsm/tsl/display/boxBlur.d.ts index a42f9720c..167eed073 100644 --- a/types/three/examples/jsm/tsl/display/boxBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/boxBlur.d.ts @@ -1,10 +1,9 @@ import { Node } from "three/webgpu"; export interface BoxBlurOptions { - size?: Node | undefined; - separation?: Node | undefined; - mask?: Node | null | undefined; + size?: Node<"int"> | Node<"float"> | undefined; + separation?: Node<"int"> | Node<"float"> | undefined; premultipliedAlpha?: boolean | undefined; } -export const boxBlur: (textureNode: Node, options?: BoxBlurOptions) => Node; +export const boxBlur: (textureNode: Node<"vec4">, options?: BoxBlurOptions) => Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/display/hashBlur.d.ts b/types/three/examples/jsm/tsl/display/hashBlur.d.ts index e591cbcd1..177281105 100644 --- a/types/three/examples/jsm/tsl/display/hashBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/hashBlur.d.ts @@ -1,13 +1,12 @@ import { Node } from "three/webgpu"; interface HashBlurOptions { - size?: Node | undefined; - mask?: Node | null | undefined; + repeats?: Node<"float"> | number | undefined; premultipliedAlpha?: boolean | undefined; } export const hashBlur: ( - textureNode: Node, - bluramount?: Node | number, + textureNode: Node<"vec4">, + bluramount?: Node<"float"> | number, options?: HashBlurOptions, -) => Node; +) => Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/utils/Raymarching.d.ts b/types/three/examples/jsm/tsl/utils/Raymarching.d.ts index f42fdc164..664df29d6 100644 --- a/types/three/examples/jsm/tsl/utils/Raymarching.d.ts +++ b/types/three/examples/jsm/tsl/utils/Raymarching.d.ts @@ -3,6 +3,6 @@ import { FunctionNode, Node } from "three/webgpu"; export const RaymarchingBox: ( steps: number | Node, callback: - | ((params: { positionRay: Node }) => void) - | FunctionNode<{ positionRay: Node }>, + | ((params: { positionRay: Node<"vec3"> }) => void) + | FunctionNode<{ positionRay: Node<"vec3"> }>, ) => void; diff --git a/types/three/src/Three.TSL.d.ts b/types/three/src/Three.TSL.d.ts index 73d3d34b8..5907ee366 100644 --- a/types/three/src/Three.TSL.d.ts +++ b/types/three/src/Three.TSL.d.ts @@ -630,4 +630,4 @@ export const workgroupId: typeof TSL.workgroupId; export const workingToColorSpace: typeof TSL.workingToColorSpace; export const xor: typeof TSL.xor; -export type { ProxiedObject, Swizzable } from "./nodes/TSL.js"; +export type { ProxiedObject } from "./nodes/TSL.js"; diff --git a/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts index 0fd2fe66b..36f785dbe 100644 --- a/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts @@ -1,4 +1,3 @@ -import InputNode from "../../nodes/core/InputNode.js"; import { LightingModelDirectInput } from "../../nodes/core/LightingModel.js"; import Node from "../../nodes/core/Node.js"; import NodeBuilder from "../../nodes/core/NodeBuilder.js"; @@ -58,23 +57,23 @@ export interface MeshSSSNodeMaterialNodeProperties extends MeshPhysicalNodeMater /** * Represents the distortion factor. */ - thicknessDistortionNode: InputNode; + thicknessDistortionNode: Node<"float">; /** * Represents the thickness ambient factor. */ - thicknessAmbientNode: InputNode; + thicknessAmbientNode: Node<"float">; /** * Represents the thickness attenuation. */ - thicknessAttenuationNode: InputNode; + thicknessAttenuationNode: Node<"float">; /** * Represents the thickness power. */ - thicknessPowerNode: InputNode; + thicknessPowerNode: Node<"float">; /** * Represents the thickness scale. */ - thicknessScaleNode: InputNode; + thicknessScaleNode: Node<"float">; } // eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/types/three/src/materials/nodes/NodeMaterial.d.ts b/types/three/src/materials/nodes/NodeMaterial.d.ts index b941010e7..cb94e0a6b 100644 --- a/types/three/src/materials/nodes/NodeMaterial.d.ts +++ b/types/three/src/materials/nodes/NodeMaterial.d.ts @@ -88,7 +88,7 @@ export interface NodeMaterialNodeProperties { * * @default null */ - colorNode: Node | null; + colorNode: Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4"> | Node<"color"> | null; /** * The normals of node materials are by default inferred from the `normalMap`/`normalScale` * or `bumpMap`/`bumpScale` properties. This node property allows to overwrite the default @@ -278,7 +278,7 @@ export interface NodeMaterialNodeProperties { * * @default null */ - contextNode: ContextNode | null; + contextNode: ContextNode | null; } // eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/types/three/src/nodes/accessors/Arrays.d.ts b/types/three/src/nodes/accessors/Arrays.d.ts index df0a81a7b..e8060aa58 100644 --- a/types/three/src/nodes/accessors/Arrays.d.ts +++ b/types/three/src/nodes/accessors/Arrays.d.ts @@ -1,13 +1,20 @@ -import { TypedArray } from "../../core/BufferAttribute.js"; -import { Struct } from "../core/StructNode.js"; import StorageBufferNode from "./StorageBufferNode.js"; -export const attributeArray: ( - count: TypedArray | number, - type?: string | Struct, -) => StorageBufferNode; +interface ArrayFunction { + (count: number | Float32Array, type?: "float"): StorageBufferNode<"float">; + (count: number | Int32Array, type: "int"): StorageBufferNode<"int">; + (count: number | Uint32Array, type: "uint"): StorageBufferNode<"uint">; + (count: number | Float32Array, type: "vec2"): StorageBufferNode<"vec2">; + (count: number | Int32Array, type: "ivec2"): StorageBufferNode<"ivec2">; + (count: number | Uint32Array, type: "uvec2"): StorageBufferNode<"uvec2">; + (count: number | Float32Array, type: "vec3"): StorageBufferNode<"vec3">; + (count: number | Int32Array, type: "ivec3"): StorageBufferNode<"ivec3">; + (count: number | Uint32Array, type: "uvec3"): StorageBufferNode<"uvec3">; + (count: number | Float32Array, type: "vec4"): StorageBufferNode<"vec4">; + (count: number | Int32Array, type: "ivec4"): StorageBufferNode<"ivec4">; + (count: number | Uint32Array, type: "uvec4"): StorageBufferNode<"uvec4">; +} -export const instancedArray: ( - count: TypedArray | number, - type?: string | Struct, -) => StorageBufferNode; +export const attributeArray: ArrayFunction; + +export const instancedArray: ArrayFunction; diff --git a/types/three/src/nodes/accessors/BufferAttributeNode.d.ts b/types/three/src/nodes/accessors/BufferAttributeNode.d.ts index 97912d987..49093bcaf 100644 --- a/types/three/src/nodes/accessors/BufferAttributeNode.d.ts +++ b/types/three/src/nodes/accessors/BufferAttributeNode.d.ts @@ -27,7 +27,7 @@ import NodeBuilder from "../core/NodeBuilder.js"; * ``` * @augments InputNode */ -declare class BufferAttributeNode extends InputNode { +declare class BufferAttributeNodeClass extends InputNode { static get type(): string; readonly isBufferNode: true; bufferType: string | null; @@ -103,6 +103,25 @@ declare class BufferAttributeNode extends InputNode( + value: TypedArray | InterleavedBuffer | BufferAttribute, + bufferType?: string | null, + bufferStride?: number, + bufferOffset?: number, + ): BufferAttributeNode; +}; +type BufferAttributeNode = + & InputNode + & BufferAttributeNodeClass; export default BufferAttributeNode; /** * TSL function for creating a buffer attribute node. @@ -115,12 +134,12 @@ export default BufferAttributeNode; * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const bufferAttribute: ( +export declare const bufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, type?: string | null, stride?: number, offset?: number, -) => Node; +) => Node; /** * TSL function for creating a buffer attribute node but with dynamic draw usage. * Use this function if attribute data are updated per frame. @@ -133,12 +152,12 @@ export declare const bufferAttribute: ( * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const dynamicBufferAttribute: ( +export declare const dynamicBufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, type?: string | null, stride?: number, offset?: number, -) => Node; +) => Node; /** * TSL function for creating a buffer attribute node but with enabled instancing * @@ -150,12 +169,12 @@ export declare const dynamicBufferAttribute: ( * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const instancedBufferAttribute: ( +export declare const instancedBufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, type?: string | null, stride?: number, offset?: number, -) => Node; +) => Node; /** * TSL function for creating a buffer attribute node but with dynamic draw usage and enabled instancing * @@ -167,15 +186,14 @@ export declare const instancedBufferAttribute: ( * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const instancedDynamicBufferAttribute: ( +export declare const instancedDynamicBufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, type?: string | null, stride?: number, offset?: number, -) => Node; -declare module "../Nodes.js" { - interface BufferNode { - toAttribute: () => BufferAttributeNode; - toAttributeAssign: () => this; +) => Node; +declare module "./BufferNode.js" { + interface BufferNodeExtensions { + toAttribute: () => BufferAttributeNode; } } diff --git a/types/three/src/nodes/accessors/BufferNode.d.ts b/types/three/src/nodes/accessors/BufferNode.d.ts index 586468951..73ff7a12c 100644 --- a/types/three/src/nodes/accessors/BufferNode.d.ts +++ b/types/three/src/nodes/accessors/BufferNode.d.ts @@ -1,17 +1,29 @@ import UniformNode from "../core/UniformNode.js"; import { NodeOrType } from "../tsl/TSLCore.js"; -export default class BufferNode extends UniformNode { +interface BufferNodeInterface { isBufferNode: true; bufferType: string; bufferCount: number; +} + +declare const BufferNode: { + new(value: TValue, bufferType: string, bufferCount?: number): BufferNode; +}; - constructor(value: TValue, bufferType: string, bufferCount?: number); +export interface BufferNodeExtensions { } -export const buffer: ( - value: unknown, +type BufferNode = + & UniformNode + & BufferNodeInterface + & BufferNodeExtensions; + +export default BufferNode; + +export const buffer: ( + value: TValue, nodeOrType: NodeOrType, count: number, -) => BufferNode; +) => BufferNode; diff --git a/types/three/src/nodes/accessors/Camera.d.ts b/types/three/src/nodes/accessors/Camera.d.ts index a37ce5a11..0eb189f07 100644 --- a/types/three/src/nodes/accessors/Camera.d.ts +++ b/types/three/src/nodes/accessors/Camera.d.ts @@ -4,13 +4,13 @@ import { Vector3 } from "../../math/Vector3.js"; import { Vector4 } from "../../math/Vector4.js"; import UniformNode from "../core/UniformNode.js"; -export const cameraIndex: UniformNode; -export const cameraNear: UniformNode; -export const cameraFar: UniformNode; -export const cameraProjectionMatrix: UniformNode; -export const cameraProjectionMatrixInverse: UniformNode; -export const cameraViewMatrix: UniformNode; -export const cameraWorldMatrix: UniformNode; -export const cameraNormalMatrix: UniformNode; -export const cameraPosition: UniformNode; -export const cameraViewport: UniformNode; +export const cameraIndex: UniformNode<"uint", number>; +export const cameraNear: UniformNode<"float", number>; +export const cameraFar: UniformNode<"float", number>; +export const cameraProjectionMatrix: UniformNode<"mat4", Matrix4>; +export const cameraProjectionMatrixInverse: UniformNode<"mat4", Matrix4>; +export const cameraViewMatrix: UniformNode<"mat4", Matrix4>; +export const cameraWorldMatrix: UniformNode<"mat4", Matrix4>; +export const cameraNormalMatrix: UniformNode<"mat3", Matrix3>; +export const cameraPosition: UniformNode<"vec3", Vector3>; +export const cameraViewport: UniformNode<"vec4", Vector4>; diff --git a/types/three/src/nodes/accessors/CubeTextureNode.d.ts b/types/three/src/nodes/accessors/CubeTextureNode.d.ts index 4f40b452d..bd78c830b 100644 --- a/types/three/src/nodes/accessors/CubeTextureNode.d.ts +++ b/types/three/src/nodes/accessors/CubeTextureNode.d.ts @@ -4,12 +4,12 @@ import TextureNode from "./TextureNode.js"; declare class CubeTextureNode extends TextureNode { isCubeTextureNode: boolean; - uvNode: Node | null; + uvNode: Node<"vec3"> | null; levelNode: Node | null; constructor( value: CubeTexture, - uvNode?: Node | null, + uvNode?: Node<"vec3"> | null, levelNode?: Node | null, biasNode?: Node | null, ); diff --git a/types/three/src/nodes/accessors/Lights.d.ts b/types/three/src/nodes/accessors/Lights.d.ts index 862422913..4185cff79 100644 --- a/types/three/src/nodes/accessors/Lights.d.ts +++ b/types/three/src/nodes/accessors/Lights.d.ts @@ -1,14 +1,14 @@ import { Light } from "../../lights/Light.js"; import Node from "../core/Node.js"; -export function lightShadowMatrix(light: Light): Node; +export function lightShadowMatrix(light: Light): Node<"mat4">; -export function lightProjectionUV(light: Light, position?: Node): Node; +export function lightProjectionUV(light: Light, position?: Node<"vec3">): Node<"vec3">; -export function lightPosition(light: Light): Node; +export function lightPosition(light: Light): Node<"vec3">; -export function lightTargetPosition(light: Light): Node; +export function lightTargetPosition(light: Light): Node<"vec3">; -export function lightViewPosition(light: Light): Node; +export function lightViewPosition(light: Light): Node<"vec3">; -export const lightTargetDirection: (light: Light) => Node; +export const lightTargetDirection: (light: Light) => Node<"vec3">; diff --git a/types/three/src/nodes/accessors/MaterialNode.d.ts b/types/three/src/nodes/accessors/MaterialNode.d.ts index 2a2aa75ce..bdfe4a174 100644 --- a/types/three/src/nodes/accessors/MaterialNode.d.ts +++ b/types/three/src/nodes/accessors/MaterialNode.d.ts @@ -1,6 +1,4 @@ -import { Vector2 } from "../../math/Vector2.js"; import Node from "../core/Node.js"; -import UniformNode from "../core/UniformNode.js"; export type MaterialNodeScope = | typeof MaterialNode.ALPHA_TEST @@ -86,43 +84,43 @@ export default class MaterialNode extends Node { constructor(scope?: MaterialNodeScope); } -export const materialAlphaTest: MaterialNode; -export const materialColor: MaterialNode; -export const materialShininess: MaterialNode; -export const materialEmissive: MaterialNode; -export const materialOpacity: MaterialNode; -export const materialSpecular: MaterialNode; +export const materialAlphaTest: Node<"float">; +export const materialColor: Node<"vec3">; +export const materialShininess: Node<"float">; +export const materialEmissive: Node<"vec3">; +export const materialOpacity: Node<"float">; +export const materialSpecular: Node<"vec3">; -export const materialSpecularIntensity: MaterialNode; -export const materialSpecularColor: MaterialNode; +export const materialSpecularIntensity: Node<"float">; +export const materialSpecularColor: Node<"vec3">; -export const materialSpecularStrength: MaterialNode; -export const materialReflectivity: MaterialNode; -export const materialRoughness: MaterialNode; -export const materialMetalness: MaterialNode; -export const materialNormal: Node; -export const materialClearcoat: MaterialNode; -export const materialClearcoatRoughness: MaterialNode; -export const materialClearcoatNormal: Node; -export const materialRotation: MaterialNode; -export const materialSheen: MaterialNode; -export const materialSheenRoughness: MaterialNode; -export const materialAnisotropy: MaterialNode; -export const materialIridescence: MaterialNode; -export const materialIridescenceIOR: MaterialNode; -export const materialIridescenceThickness: MaterialNode; -export const materialTransmission: MaterialNode; -export const materialThickness: MaterialNode; -export const materialIOR: MaterialNode; -export const materialAttenuationDistance: MaterialNode; -export const materialAttenuationColor: MaterialNode; -export const materialLineScale: MaterialNode; -export const materialLineDashSize: MaterialNode; -export const materialLineGapSize: MaterialNode; -export const materialLineWidth: MaterialNode; -export const materialLineDashOffset: MaterialNode; -export const materialPointSize: MaterialNode; -export const materialDispersion: MaterialNode; -export const materialLightMap: MaterialNode; -export const materialAO: MaterialNode; -export const materialAnisotropyVector: UniformNode; +export const materialSpecularStrength: Node<"float">; +export const materialReflectivity: Node<"float">; +export const materialRoughness: Node<"float">; +export const materialMetalness: Node<"float">; +export const materialNormal: Node<"vec3">; +export const materialClearcoat: Node<"float">; +export const materialClearcoatRoughness: Node<"float">; +export const materialClearcoatNormal: Node<"vec3">; +export const materialRotation: Node<"float">; +export const materialSheen: Node<"vec3">; +export const materialSheenRoughness: Node<"float">; +export const materialAnisotropy: Node<"vec2">; +export const materialIridescence: Node<"float">; +export const materialIridescenceIOR: Node<"float">; +export const materialIridescenceThickness: Node<"float">; +export const materialTransmission: Node<"float">; +export const materialThickness: Node<"float">; +export const materialIOR: Node<"float">; +export const materialAttenuationDistance: Node<"float">; +export const materialAttenuationColor: Node<"vec3">; +export const materialLineScale: Node<"float">; +export const materialLineDashSize: Node<"float">; +export const materialLineGapSize: Node<"float">; +export const materialLineWidth: Node<"float">; +export const materialLineDashOffset: Node<"float">; +export const materialPointSize: Node<"float">; +export const materialDispersion: Node<"float">; +export const materialLightMap: Node<"vec3">; +export const materialAO: Node<"float">; +export const materialAnisotropyVector: Node<"vec2">; diff --git a/types/three/src/nodes/accessors/MaterialProperties.d.ts b/types/three/src/nodes/accessors/MaterialProperties.d.ts index b97bf137a..45f700237 100644 --- a/types/three/src/nodes/accessors/MaterialProperties.d.ts +++ b/types/three/src/nodes/accessors/MaterialProperties.d.ts @@ -1,8 +1,8 @@ -import { Matrix4 } from "../../math/Matrix4.js"; +import Node from "../core/Node.js"; import UniformNode from "../core/UniformNode.js"; -export const materialRefractionRatio: UniformNode; +export const materialRefractionRatio: UniformNode<"float", number>; -export const materialEnvIntensity: UniformNode; +export const materialEnvIntensity: Node<"float">; -export const materialEnvRotation: UniformNode; +export const materialEnvRotation: Node<"mat4">; diff --git a/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts b/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts index 34fd8550d..cdcd6aa51 100644 --- a/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts +++ b/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts @@ -2,7 +2,7 @@ import { Material } from "../../materials/Material.js"; import { NodeOrType } from "../tsl/TSLCore.js"; import ReferenceNode from "./ReferenceNode.js"; -export default class MaterialReferenceNode extends ReferenceNode { +export default class MaterialReferenceNode extends ReferenceNode { readonly isMaterialReferenceNode: true; constructor(property: string, inputType: string, material?: Material | null); diff --git a/types/three/src/nodes/accessors/ModelNode.d.ts b/types/three/src/nodes/accessors/ModelNode.d.ts index 3545af20c..c2eba2448 100644 --- a/types/three/src/nodes/accessors/ModelNode.d.ts +++ b/types/three/src/nodes/accessors/ModelNode.d.ts @@ -1,3 +1,4 @@ +import { Matrix3 } from "../../math/Matrix3.js"; import { Matrix4 } from "../../math/Matrix4.js"; import Node from "../core/Node.js"; import { UniformNode } from "../Nodes.js"; @@ -6,27 +7,43 @@ import Object3DNode from "./Object3DNode.js"; /** * Similar to {@link Object3DNode} but the object comes from {@link NodeFrame} */ -export default class ModelNode extends Object3DNode { - constructor(scope: string); -} - -export const modelDirection: ModelNode; -export const modelWorldMatrix: ModelNode; -export const modelPosition: ModelNode; -export const modelScale: ModelNode; -export const modelViewPosition: ModelNode; -export const modelRadius: ModelNode; -export const modelNormalMatrix: Node; -export const modelWorldMatrixInverse: UniformNode; - -export const modelViewMatrix: ModelNode; +declare const ModelNode: { + new(scope: typeof ModelNode.WORLD_MATRIX): ModelNode<"mat4">; + new(scope: typeof ModelNode.POSITION): ModelNode<"vec3">; + new(scope: typeof ModelNode.SCALE): ModelNode<"vec3">; + new(scope: typeof ModelNode.VIEW_POSITION): ModelNode<"vec3">; + new(scope: typeof ModelNode.DIRECTION): ModelNode<"vec3">; + new(scope: typeof ModelNode.RADIUS): ModelNode<"float">; + + WORLD_MATRIX: "worldMatrix"; + POSITION: "position"; + SCALE: "scale"; + VIEW_POSITION: "viewPosition"; + DIRECTION: "direction"; + RADIUS: "radius"; +}; + +type ModelNode = Object3DNode; + +export default Object3DNode; + +export const modelDirection: ModelNode<"vec3">; +export const modelWorldMatrix: ModelNode<"mat4">; +export const modelPosition: ModelNode<"vec3">; +export const modelScale: ModelNode<"vec3">; +export const modelViewPosition: ModelNode<"vec3">; +export const modelRadius: ModelNode<"float">; +export const modelNormalMatrix: UniformNode<"mat3", Matrix3>; +export const modelWorldMatrixInverse: UniformNode<"mat4", Matrix4>; + +export const modelViewMatrix: Node<"mat4">; // GPU Precision -export const mediumpModelViewMatrix: Node; +export const mediumpModelViewMatrix: Node<"mat4">; // CPU Precision -export const highpModelViewMatrix: Node; +export const highpModelViewMatrix: Node<"mat4">; -export const highpModelNormalViewMatrix: Node; +export const highpModelNormalViewMatrix: Node<"mat3">; diff --git a/types/three/src/nodes/accessors/MorphNode.d.ts b/types/three/src/nodes/accessors/MorphNode.d.ts index 32f8f53b2..7fcf9729d 100644 --- a/types/three/src/nodes/accessors/MorphNode.d.ts +++ b/types/three/src/nodes/accessors/MorphNode.d.ts @@ -4,7 +4,7 @@ import UniformNode from "../core/UniformNode.js"; declare class MorphNode extends Node { mesh: Mesh; - morphBaseInfluence: UniformNode; + morphBaseInfluence: UniformNode<"float", number>; constructor(mesh: Mesh); } diff --git a/types/three/src/nodes/accessors/Normal.d.ts b/types/three/src/nodes/accessors/Normal.d.ts index bdc76a815..5937460b7 100644 --- a/types/three/src/nodes/accessors/Normal.d.ts +++ b/types/three/src/nodes/accessors/Normal.d.ts @@ -1,38 +1,36 @@ -import AttributeNode from "../core/AttributeNode.js"; import Node from "../core/Node.js"; -import VarNode from "../core/VarNode.js"; -export const normalGeometry: AttributeNode; +export const normalGeometry: Node<"vec3">; -export const normalLocal: VarNode; +export const normalLocal: Node<"vec3">; -export const normalFlat: VarNode; +export const normalFlat: Node<"vec3">; -export const normalViewGeometry: VarNode; +export const normalViewGeometry: Node<"vec3">; -export const normalWorldGeometry: VarNode; +export const normalWorldGeometry: Node<"vec3">; -export const normalView: VarNode; +export const normalView: Node<"vec3">; -export const normalWorld: VarNode; +export const normalWorld: Node<"vec3">; -export const clearcoatNormalView: VarNode; +export const clearcoatNormalView: Node<"vec3">; -export const transformNormal: (normal: Node, matrix?: Node) => Node; +export const transformNormal: (normal: Node, matrix?: Node) => Node<"vec3">; -export const transformNormalToView: (normal: Node) => Node; +export const transformNormalToView: (normal: Node) => Node<"vec3">; /** * @deprecated since r178. Use `normalView` instead. */ -export const transformedNormalView: VarNode; +export const transformedNormalView: Node<"vec3">; /** * @deprecated since r178. Use `normalWorld` instead. */ -export const transformedNormalWorld: VarNode; +export const transformedNormalWorld: Node<"vec3">; /** * @deprecated since r178. Use `clearcoatNormalView` instead. */ -export const transformedClearcoatNormalView: VarNode; +export const transformedClearcoatNormalView: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/Object3DNode.d.ts b/types/three/src/nodes/accessors/Object3DNode.d.ts index 568869585..edeab21c2 100644 --- a/types/three/src/nodes/accessors/Object3DNode.d.ts +++ b/types/three/src/nodes/accessors/Object3DNode.d.ts @@ -1,23 +1,42 @@ import { Object3D } from "../../core/Object3D.js"; import Node from "../core/Node.js"; -export default class Object3DNode extends Node { - scope: string; +export type Object3DNodeScope = + | typeof Object3DNode.WORLD_MATRIX + | typeof Object3DNode.POSITION + | typeof Object3DNode.SCALE + | typeof Object3DNode.VIEW_POSITION + | typeof Object3DNode.DIRECTION + | typeof Object3DNode.RADIUS; + +interface Object3DNodeInterface { + scope: Object3DNodeScope; object3d: Object3D | null; +} - constructor(scope: string, object3d?: Object3D | null); +declare const Object3DNode: { + new(scope: typeof Object3DNode.WORLD_MATRIX, object3d?: Object3D | null): Object3DNode<"mat4">; + new(scope: typeof Object3DNode.POSITION, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.SCALE, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.VIEW_POSITION, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.DIRECTION, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.RADIUS, object3d?: Object3D | null): Object3DNode<"float">; - static WORLD_MATRIX: "worldMatrix"; - static POSITION: "position"; - static SCALE: "scale"; - static VIEW_POSITION: "viewPosition"; - static DIRECTION: "direction"; - static RADIUS: "radius"; -} + WORLD_MATRIX: "worldMatrix"; + POSITION: "position"; + SCALE: "scale"; + VIEW_POSITION: "viewPosition"; + DIRECTION: "direction"; + RADIUS: "radius"; +}; + +type Object3DNode = Node & Object3DNodeInterface; + +export default Object3DNode; -export const objectDirection: (object3d: Object3D | null) => Object3DNode; -export const objectWorldMatrix: (object3d: Object3D | null) => Object3DNode; -export const objectPosition: (object3d: Object3D | null) => Object3DNode; -export const objectScale: (object3d: Object3D | null) => Object3DNode; -export const objectViewPosition: (object3d: Object3D | null) => Object3DNode; -export const objectRadius: (object3d: Object3D | null) => Object3DNode; +export const objectDirection: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectWorldMatrix: (object3d: Object3D | null) => Object3DNode<"mat4">; +export const objectPosition: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectScale: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectViewPosition: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectRadius: (object3d: Object3D | null) => Object3DNode<"float">; diff --git a/types/three/src/nodes/accessors/Position.d.ts b/types/three/src/nodes/accessors/Position.d.ts index cbe99d876..5380dbdf2 100644 --- a/types/three/src/nodes/accessors/Position.d.ts +++ b/types/three/src/nodes/accessors/Position.d.ts @@ -1,9 +1,9 @@ import Node from "../core/Node.js"; -export const positionGeometry: Node; -export const positionLocal: Node; -export const positionPrevious: Node; -export const positionWorld: Node; -export const positionWorldDirection: Node; -export const positionView: Node; -export const positionViewDirection: Node; +export const positionGeometry: Node<"vec3">; +export const positionLocal: Node<"vec3">; +export const positionPrevious: Node<"vec3">; +export const positionWorld: Node<"vec3">; +export const positionWorldDirection: Node<"vec3">; +export const positionView: Node<"vec3">; +export const positionViewDirection: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/ReferenceNode.d.ts b/types/three/src/nodes/accessors/ReferenceNode.d.ts index f5e72dbc2..073d3ba4f 100644 --- a/types/three/src/nodes/accessors/ReferenceNode.d.ts +++ b/types/three/src/nodes/accessors/ReferenceNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -declare class ReferenceNode extends Node { +interface ReferenceNodeInterface extends Node { property: string; uniformType: string; @@ -12,17 +12,26 @@ declare class ReferenceNode extends Node { reference: T | null; node: Node | null; - constructor(property: string, uniformType: string, object?: T | null, count?: number | null); - setNodeType(uniformType: string): void; } +declare const ReferenceNode: { + new( + property: string, + uniformType: string, + object?: T | null, + count?: number | null, + ): ReferenceNode; +}; + +type ReferenceNode = ReferenceNodeInterface & Node; + export default ReferenceNode; -export const reference: (name: string, type: string, object: T) => ReferenceNode; -export const referenceBuffer: ( +export const reference: (name: string, type: string, object: T) => ReferenceNode; +export const referenceBuffer: ( name: string, type: string, count: number, object: T, -) => ReferenceNode; +) => ReferenceNode; diff --git a/types/three/src/nodes/accessors/ReflectVector.d.ts b/types/three/src/nodes/accessors/ReflectVector.d.ts index 32f149bf3..53db54bbf 100644 --- a/types/three/src/nodes/accessors/ReflectVector.d.ts +++ b/types/three/src/nodes/accessors/ReflectVector.d.ts @@ -1,8 +1,7 @@ import Node from "../core/Node.js"; -import VarNode from "../core/VarNode.js"; -export const reflectView: Node; -export const refractView: Node; +export const reflectView: Node<"vec3">; +export const refractView: Node<"vec3">; -export const reflectVector: VarNode; -export const refractVector: VarNode; +export const reflectVector: Node<"vec3">; +export const refractVector: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/RendererReferenceNode.d.ts b/types/three/src/nodes/accessors/RendererReferenceNode.d.ts index 7bf48604c..c3bc488ec 100644 --- a/types/three/src/nodes/accessors/RendererReferenceNode.d.ts +++ b/types/three/src/nodes/accessors/RendererReferenceNode.d.ts @@ -1,7 +1,7 @@ import Renderer from "../../renderers/common/Renderer.js"; import ReferenceNode from "./ReferenceNode.js"; -export default class RendererReferenceNode extends ReferenceNode { +export default class RendererReferenceNode extends ReferenceNode { renderer: Renderer | null; constructor(property: string, inputType: string, renderer?: Renderer | null); diff --git a/types/three/src/nodes/accessors/StorageBufferNode.d.ts b/types/three/src/nodes/accessors/StorageBufferNode.d.ts index 7045ca722..179a751e6 100644 --- a/types/three/src/nodes/accessors/StorageBufferNode.d.ts +++ b/types/three/src/nodes/accessors/StorageBufferNode.d.ts @@ -8,7 +8,7 @@ import StructTypeNode from "../core/StructTypeNode.js"; import StorageArrayElementNode from "../utils/StorageArrayElementNode.js"; import BufferNode from "./BufferNode.js"; -export default class StorageBufferNode extends BufferNode { +interface StorageBufferNodeInterface { readonly isStorageBufferNode: true; structTypeNode: StructTypeNode | null; @@ -19,13 +19,7 @@ export default class StorageBufferNode extends BufferNode StorageArrayElementNode; + element: (indexNode: Node | number) => StorageArrayElementNode; setPBO(value: boolean): this; @@ -40,17 +34,56 @@ export default class StorageBufferNode extends BufferNode StorageBufferNode; +declare const StorageBufferNode: { + new( + value: StorageBufferAttribute | StorageInstancedBufferAttribute, + bufferType?: string | Struct | null, + bufferCount?: number, + ): StorageBufferNode; +}; + +type StorageBufferNode = + & StorageBufferNodeInterface + & BufferNode; + +export default StorageBufferNode; + +interface Storage { + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "float", + count: number, + ): StorageBufferNode<"float">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "uint", + count: number, + ): StorageBufferNode<"uint">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "vec2", + count: number, + ): StorageBufferNode<"vec2">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "vec3", + count: number, + ): StorageBufferNode<"vec3">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "vec4", + count: number, + ): StorageBufferNode<"vec4">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: Struct, + count: number, + ): StorageBufferNode<"struct">; +} + +export const storage: Storage; /** * @deprecated */ -export const storageObject: ( - value: StorageBufferAttribute | StorageInstancedBufferAttribute, - type?: string | Struct | null, - count?: number, -) => StorageBufferNode; +export const storageObject: Storage; diff --git a/types/three/src/nodes/accessors/Tangent.d.ts b/types/three/src/nodes/accessors/Tangent.d.ts index bad61533a..5832d8ae0 100644 --- a/types/three/src/nodes/accessors/Tangent.d.ts +++ b/types/three/src/nodes/accessors/Tangent.d.ts @@ -1,8 +1,6 @@ -import AttributeNode from "../core/AttributeNode.js"; -import VaryingNode from "../core/VaryingNode.js"; -import MathNode from "../math/MathNode.js"; +import Node from "../core/Node.js"; -export const tangentGeometry: AttributeNode; -export const tangentLocal: VaryingNode; -export const tangentView: MathNode; -export const tangentWorld: MathNode; +export const tangentGeometry: Node<"vec4">; +export const tangentLocal: Node<"vec3">; +export const tangentView: Node<"vec3">; +export const tangentWorld: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/Texture3DNode.d.ts b/types/three/src/nodes/accessors/Texture3DNode.d.ts index d984915b5..1133160a0 100644 --- a/types/three/src/nodes/accessors/Texture3DNode.d.ts +++ b/types/three/src/nodes/accessors/Texture3DNode.d.ts @@ -7,7 +7,7 @@ export default class Texture3DNode extends TextureNode { constructor(value: Texture, uvNode?: Node | null, levelNode?: Node | null); - normal(uvNode: Node): Node; + normal(uvNode: Node<"vec3">): Node<"vec3">; } export const texture3D: ( diff --git a/types/three/src/nodes/accessors/TextureBicubic.d.ts b/types/three/src/nodes/accessors/TextureBicubic.d.ts index 4d0740e5e..c0bc791d5 100644 --- a/types/three/src/nodes/accessors/TextureBicubic.d.ts +++ b/types/three/src/nodes/accessors/TextureBicubic.d.ts @@ -1,5 +1,6 @@ import Node from "../core/Node.js"; +import TextureNode from "./TextureNode.js"; -export const textureBicubicLevel: (textureNode: Node, lodNode: Node) => Node; +export const textureBicubicLevel: (textureNode: TextureNode, lodNode: Node<"float">) => TextureNode; -export const textureBicubic: (textureNode: Node, strength: Node) => Node; +export const textureBicubic: (textureNode: TextureNode, strength: Node<"float">) => TextureNode; diff --git a/types/three/src/nodes/accessors/TextureNode.d.ts b/types/three/src/nodes/accessors/TextureNode.d.ts index e619bf699..eb3aa8f36 100644 --- a/types/three/src/nodes/accessors/TextureNode.d.ts +++ b/types/three/src/nodes/accessors/TextureNode.d.ts @@ -2,10 +2,10 @@ import { Texture } from "../../textures/Texture.js"; import Node from "../core/Node.js"; import UniformNode from "../core/UniformNode.js"; -export default class TextureNode extends UniformNode { +interface TextureNodeInterface { readonly isTextureNode: true; - uvNode: Node | null; + uvNode: Node<"vec2"> | Node<"vec3"> | null; levelNode: Node | null; biasNode: Node | null; compareNode: Node | null; @@ -17,13 +17,6 @@ export default class TextureNode extends UniformNode { referenceNode: Node | null; - constructor( - value?: Texture, - uvNode?: Node | null, - levelNode?: Node | null, - biasNode?: Node | null, - ); - getDefaultUV(): Node; setSampler(value: boolean): this; @@ -35,7 +28,7 @@ export default class TextureNode extends UniformNode { */ uv(uvNode: Node): Node; - sample(uvNode: Node): Node; + sample(uvNode: Node): Node; load(uvNode: Node): Node; @@ -51,13 +44,26 @@ export default class TextureNode extends UniformNode { compare(compareNode: Node): Node; - grad(gradeNodeX: Node, gradeNodeY: Node): Node; + grad(gradeNodeX: Node, gradeNodeY: Node): TextureNode; - depth(depthNode: Node): Node; + depth(depthNode: Node): TextureNode; clone(): this; } +declare const TextureNode: { + new( + value?: Texture, + uvNode?: Node | null, + levelNode?: Node | null, + biasNode?: Node | null, + ): TextureNode; +}; + +type TextureNode = TextureNodeInterface & UniformNode; + +export default TextureNode; + export const texture: ( value?: Texture | TextureNode, uvNode?: Node | null, diff --git a/types/three/src/nodes/accessors/UV.d.ts b/types/three/src/nodes/accessors/UV.d.ts index e5e8f0a99..aa5beb5de 100644 --- a/types/three/src/nodes/accessors/UV.d.ts +++ b/types/three/src/nodes/accessors/UV.d.ts @@ -1,3 +1,3 @@ import AttributeNode from "../core/AttributeNode.js"; -export const uv: (index?: number) => AttributeNode; +export const uv: (index?: number) => AttributeNode<"vec2">; diff --git a/types/three/src/nodes/accessors/UniformArrayNode.d.ts b/types/three/src/nodes/accessors/UniformArrayNode.d.ts index 1f3e6dd92..fb5f95aef 100644 --- a/types/three/src/nodes/accessors/UniformArrayNode.d.ts +++ b/types/three/src/nodes/accessors/UniformArrayNode.d.ts @@ -2,24 +2,26 @@ import Node from "../core/Node.js"; import ArrayElementNode from "../utils/ArrayElementNode.js"; import BufferNode from "./BufferNode.js"; -declare class UniformArrayElementNode extends ArrayElementNode { - constructor(arrayBuffer: Node, indexNode: Node); -} +type UniformArrayElementNode = ArrayElementNode; -declare class UniformArrayNode extends BufferNode { +declare class UniformArrayNodeInterface { array: unknown[]; elementType: string | null; paddedType: string; readonly isArrayBufferNode: true; - constructor(value: unknown[], elementType?: string | null); - getPaddedType(): string; - element: (indexNode: Node) => UniformArrayElementNode; + element: (indexNode: Node) => UniformArrayElementNode; } +declare const UniformArrayNode: { + new(value: unknown[], elementType?: string | null): UniformArrayNode; +}; + +type UniformArrayNode = UniformArrayNodeInterface & BufferNode; + export default UniformArrayNode; -export const uniformArray: (values: unknown[], nodeType?: string | null) => UniformArrayNode; +export const uniformArray: (values: unknown[], nodeType?: string | null) => UniformArrayNode; diff --git a/types/three/src/nodes/accessors/UserDataNode.d.ts b/types/three/src/nodes/accessors/UserDataNode.d.ts index 0daa1d748..f57886700 100644 --- a/types/three/src/nodes/accessors/UserDataNode.d.ts +++ b/types/three/src/nodes/accessors/UserDataNode.d.ts @@ -2,7 +2,7 @@ import ReferenceNode from "./ReferenceNode.js"; export type NodeUserData = Record; -export default class UserDataNode extends ReferenceNode { +export default class UserDataNode extends ReferenceNode { userData: NodeUserData | null; constructor(property: string, inputType: string, userData?: NodeUserData | null); } diff --git a/types/three/src/nodes/accessors/VelocityNode.d.ts b/types/three/src/nodes/accessors/VelocityNode.d.ts index 4719cc7bf..78b9cc6d6 100644 --- a/types/three/src/nodes/accessors/VelocityNode.d.ts +++ b/types/three/src/nodes/accessors/VelocityNode.d.ts @@ -2,12 +2,12 @@ import { Matrix4 } from "../../math/Matrix4.js"; import TempNode from "../core/TempNode.js"; import UniformNode from "../core/UniformNode.js"; -declare class VelocityNode extends TempNode { +declare class VelocityNode extends TempNode<"vec2"> { projectionMatrix: Matrix4 | null; - previousModelWorldMatrix: UniformNode; - previousProjectionMatrix: UniformNode; - previousCameraViewMatrix: UniformNode; + previousModelWorldMatrix: UniformNode<"mat4", Matrix4>; + previousProjectionMatrix: UniformNode<"mat4", Matrix4>; + previousCameraViewMatrix: UniformNode<"mat4", Matrix4>; constructor(); diff --git a/types/three/src/nodes/accessors/VertexColorNode.d.ts b/types/three/src/nodes/accessors/VertexColorNode.d.ts index e880b7b6d..5487be407 100644 --- a/types/three/src/nodes/accessors/VertexColorNode.d.ts +++ b/types/three/src/nodes/accessors/VertexColorNode.d.ts @@ -1,6 +1,6 @@ import AttributeNode from "../core/AttributeNode.js"; -export default class VertexColorNode extends AttributeNode { +export default class VertexColorNode extends AttributeNode<"vec4"> { readonly isVertexColorNode: true; index: number; diff --git a/types/three/src/nodes/code/ExpressionNode.d.ts b/types/three/src/nodes/code/ExpressionNode.d.ts index bad5c0dc9..d88d59d2d 100644 --- a/types/three/src/nodes/code/ExpressionNode.d.ts +++ b/types/three/src/nodes/code/ExpressionNode.d.ts @@ -1,9 +1,7 @@ -import TempNode from "../core/TempNode.js"; +export default class ExpressionNode extends Node { + snippet: string; -export default class ExpressionNode extends TempNode { - snipped: string; - - constructor(snipped?: string, nodeType?: string); + constructor(snippet?: string, nodeType?: string); } -export const expression: (snipped: string, nodeType?: string) => ExpressionNode; +export const expression: (snippet: string, nodeType?: string) => ExpressionNode; diff --git a/types/three/src/nodes/code/FunctionCallNode.d.ts b/types/three/src/nodes/code/FunctionCallNode.d.ts index d746ead23..3a71dfe2a 100644 --- a/types/three/src/nodes/code/FunctionCallNode.d.ts +++ b/types/three/src/nodes/code/FunctionCallNode.d.ts @@ -3,26 +3,35 @@ import TempNode from "../core/TempNode.js"; import { ProxiedObject } from "../tsl/TSLCore.js"; import FunctionNode, { FunctionNodeArguments } from "./FunctionNode.js"; -export default class FunctionCallNode

| { [name: string]: Node | number }> - extends TempNode -{ +interface FunctionCallNodeInterface

| { [name: string]: Node | number }> { functionNode: FunctionNode

; parameters: { [name: string]: Node }; - constructor(functionNode?: FunctionNode

, parameters?: P); - setParameters(parameters: P): this; getParameters(): P; } -export const call:

( +declare const FunctionCallNode: { + new | { [name: string]: Node | number }>( + functionNode?: FunctionNode

, + parameters?: P, + ): FunctionCallNode; +}; + +type FunctionCallNode | { [name: string]: Node | number }> = + & TempNode + & FunctionCallNodeInterface

; + +export default FunctionCallNode; + +export const call: ( functionNode?: FunctionNode

, parameters?: ProxiedObject

, -) => FunctionCallNode

; +) => FunctionCallNode; declare module "../Nodes.js" { interface FunctionNode

{ - call: (parameters?: ProxiedObject

) => FunctionCallNode

; + call: (parameters?: ProxiedObject

) => FunctionCallNode; callAssign: (parameters?: ProxiedObject

) => this; } } diff --git a/types/three/src/nodes/core/ArrayNode.d.ts b/types/three/src/nodes/core/ArrayNode.d.ts index 327ac90cd..5dfc82d05 100644 --- a/types/three/src/nodes/core/ArrayNode.d.ts +++ b/types/three/src/nodes/core/ArrayNode.d.ts @@ -1,26 +1,29 @@ import Node from "./Node.js"; import TempNode from "./TempNode.js"; -declare class ArrayNode extends TempNode { +interface ArrayNodeInterface { count: number; values: Node[]; readonly isArrayNode: true; - - constructor(nodeType: string, count: number, values: Node[]); } +declare const ArrayNode: { + new(nodeType: string, count: number, values: Node[]): ArrayNode; +}; + +type ArrayNode = TempNode & ArrayNodeInterface; + export default ArrayNode; interface ArrayFunction { - (values: Node[]): ArrayNode; - (nodeType: string, count: number): ArrayNode; + (values: Node[]): ArrayNode; + (nodeType: string, count: number): ArrayNode; } export const array: ArrayFunction; -declare module "../Nodes.js" { - interface Node { - toArray: (count: number) => ArrayNode; - toArrayAssign: (count: number) => this; +declare module "./Node.js" { + interface NodeElements { + toArray: (count: number) => ArrayNode; } } diff --git a/types/three/src/nodes/core/AssignNode.d.ts b/types/three/src/nodes/core/AssignNode.d.ts index 85ee70b3c..990e39672 100644 --- a/types/three/src/nodes/core/AssignNode.d.ts +++ b/types/three/src/nodes/core/AssignNode.d.ts @@ -2,14 +2,18 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; import TempNode from "./TempNode.js"; -declare class AssignNode extends TempNode { +interface AssignNodeInterface { readonly isAssignNode: true; - constructor(targetNode: Node, sourceNode: Node); - needsSplitAssign(builder: NodeBuilder): boolean; } +declare const AssignNode: { + new(targetNode: Node, sourceNode: Node): AssignNode; +}; + +type AssignNode = TempNode & AssignNodeInterface; + export default AssignNode; -export const assign: (targetNode: Node, sourceNode: Node | number) => AssignNode; +export const assign: (targetNode: Node, sourceNode: Node | number) => AssignNode; diff --git a/types/three/src/nodes/core/AttributeNode.d.ts b/types/three/src/nodes/core/AttributeNode.d.ts index c9e762a3f..a5d552442 100644 --- a/types/three/src/nodes/core/AttributeNode.d.ts +++ b/types/three/src/nodes/core/AttributeNode.d.ts @@ -1,15 +1,21 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; -export default class AttributeNode extends Node { - constructor(attributeName: string, nodeType?: string | null); - +interface AttributeNodeInterface { setAttributeName(attributeName: string): this; getAttributeName(builder: NodeBuilder): string; } -export const attribute: ( +declare const AttributeNode: { + new(attributeName: string, nodeType?: string | null): AttributeNode; +}; + +type AttributeNode = Node & AttributeNodeInterface; + +export default AttributeNode; + +export const attribute: ( name: string, nodeType?: string | null, -) => AttributeNode; +) => AttributeNode; diff --git a/types/three/src/nodes/core/BypassNode.d.ts b/types/three/src/nodes/core/BypassNode.d.ts index f39e08c2d..85c126116 100644 --- a/types/three/src/nodes/core/BypassNode.d.ts +++ b/types/three/src/nodes/core/BypassNode.d.ts @@ -10,9 +10,8 @@ export default class BypassNode extends Node { export const bypass: (returnNode: Node, callNode: Node) => BypassNode; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { bypass: (callNode: Node) => BypassNode; - bypassAssign: (callNode: Node) => this; } } diff --git a/types/three/src/nodes/core/ConstNode.d.ts b/types/three/src/nodes/core/ConstNode.d.ts index f866b0c0c..92f163e5e 100644 --- a/types/three/src/nodes/core/ConstNode.d.ts +++ b/types/three/src/nodes/core/ConstNode.d.ts @@ -1,9 +1,16 @@ import InputNode from "./InputNode.js"; import NodeBuilder from "./NodeBuilder.js"; -export default class ConstNode extends InputNode { +interface ConstNodeInterface { isConstNode: true; - constructor(value: Value, nodeType?: string | null); generateConst(builder: NodeBuilder): string; } + +declare const ConstNode: { + new(value: TValue, nodeType?: string | null): ConstNode; +}; + +type ConstNode = InputNode & ConstNodeInterface; + +export default ConstNode; diff --git a/types/three/src/nodes/core/ContextNode.d.ts b/types/three/src/nodes/core/ContextNode.d.ts index 2dab710d9..51b58543f 100644 --- a/types/three/src/nodes/core/ContextNode.d.ts +++ b/types/three/src/nodes/core/ContextNode.d.ts @@ -2,61 +2,62 @@ import { Light } from "../../lights/Light.js"; import Node from "./Node.js"; import { NodeBuilderContext } from "./NodeBuilder.js"; -declare class ContextNode extends Node { +declare class ContextNodeInterface extends Node { readonly isContextNode: true; - node: Node | null; + node: Node | null; value: NodeBuilderContext; - - constructor(node?: Node | null, value?: NodeBuilderContext); } +declare const ContextNode: { + new(node?: Node | null, value?: NodeBuilderContext): ContextNode; +}; + +type ContextNode = ContextNodeInterface & Node; + export default ContextNode; interface ContextFunction { - (value?: NodeBuilderContext): ContextNode; - (node: Node, value?: NodeBuilderContext): ContextNode; + (value?: NodeBuilderContext): ContextNode; + (node: Node, value?: NodeBuilderContext): ContextNode; } export const context: ContextFunction; -export const uniformFlow: (node: Node) => ContextNode; +export const uniformFlow: (node: Node) => ContextNode; export const setName: (node: Node, label: string) => Node; -export function builtinShadowContext(shadowNode: Node, light: Light, node?: Node | null): ContextNode; +export function builtinShadowContext( + shadowNode: Node, + light: Light, + node?: Node | null, +): ContextNode; -export function builtinAOContext(aoNode: Node, node?: Node | null): ContextNode; +export function builtinAOContext(aoNode: Node, node?: Node | null): ContextNode; /** * @deprecated "label()" has been deprecated. Use "setName()" instead. */ export function label(node: Node, label: string): Node; -declare module "../Nodes.js" { - interface Node { - context: (context?: NodeBuilderContext) => ContextNode; - contextAssign: (context?: NodeBuilderContext) => this; - +declare module "./Node.js" { + interface NodeElements { /** * @deprecated "label()" has been deprecated. Use "setName()" instead. */ label: (label: string) => Node; - /** - * @deprecated "label()" has been deprecated. Use "setName()" instead. - */ - labelAssign: (label: string) => this; + } + + interface NodeExtensions { + context: (context?: NodeBuilderContext) => ContextNode; - uniformFlow: () => ContextNode; - uniformFlowAssign: () => this; + uniformFlow: () => ContextNode; - setName: (label: string) => Node; - setNameAssign: (label: string) => this; + setName: (label: string) => Node; - builtinShadowContext: (shadowNode: Node, light: Light) => ContextNode; - builtinShadowContextAssign: (shadowNode: Node, light: Light) => this; + builtinShadowContext: (shadowNode: Node, light: Light) => ContextNode; - builtinAOContext: (aoValue: Node) => ContextNode; - builtinAOContextAssign: (aoValue: Node) => this; + builtinAOContext: (aoValue: Node) => ContextNode; } } diff --git a/types/three/src/nodes/core/IndexNode.d.ts b/types/three/src/nodes/core/IndexNode.d.ts index c60fd7bbc..c491ec22a 100644 --- a/types/three/src/nodes/core/IndexNode.d.ts +++ b/types/three/src/nodes/core/IndexNode.d.ts @@ -8,7 +8,7 @@ export type IndexNodeScope = | typeof IndexNode.INVOCATION_SUBGROUP | typeof IndexNode.DRAW; -declare class IndexNode extends Node { +declare class IndexNode extends Node<"uint"> { scope: IndexNodeScope; readonly isInstanceNode: true; diff --git a/types/three/src/nodes/core/InputNode.d.ts b/types/three/src/nodes/core/InputNode.d.ts index e5b3ca1b2..74ed6dbd2 100644 --- a/types/three/src/nodes/core/InputNode.d.ts +++ b/types/three/src/nodes/core/InputNode.d.ts @@ -3,13 +3,19 @@ import NodeBuilder from "./NodeBuilder.js"; export type Precision = "low" | "medium" | "high"; -export default abstract class InputNode extends Node { +interface InputNodeInterface { isInputNode: true; - value: Value; + value: TValue; precision: Precision | null; - constructor(value: Value, nodeType?: string | null); - getInputType(builder: NodeBuilder): string | null; setPrecision(precision: Precision): this; } + +declare const InputNode: { + new(value: TValue, nodeType?: string | null): InputNode; +}; + +type InputNode = Node & InputNodeInterface; + +export default InputNode; diff --git a/types/three/src/nodes/core/InspectorNode.d.ts b/types/three/src/nodes/core/InspectorNode.d.ts index 93ec3d69f..f6b380844 100644 --- a/types/three/src/nodes/core/InspectorNode.d.ts +++ b/types/three/src/nodes/core/InspectorNode.d.ts @@ -8,9 +8,8 @@ export default InspectorNode; export function inspector(node: T, name?: string, callback?: (node: T) => Node): T; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { toInspector: (name?: string, callback?: (node: this) => Node) => this; - toInspectorAssign: (name?: string, callback?: (node: this) => Node) => this; } } diff --git a/types/three/src/nodes/core/IsolateNode.d.ts b/types/three/src/nodes/core/IsolateNode.d.ts index d466d2a8b..3d921bdb9 100644 --- a/types/three/src/nodes/core/IsolateNode.d.ts +++ b/types/three/src/nodes/core/IsolateNode.d.ts @@ -19,18 +19,13 @@ export const isolate: (node: Node) => IsolateNode; */ export const cache: (node: Node, cache?: NodeCache) => IsolateNode; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { /** * @deprecated "cache()" has been deprecated. Use "isolate()" instead. */ cache: (cache?: NodeCache) => IsolateNode; - /** - * @deprecated "cache()" has been deprecated. Use "isolate()" instead. - */ - cacheAssign: (cache?: NodeCache) => this; isolate: () => IsolateNode; - isolateAssign: () => this; } } diff --git a/types/three/src/nodes/core/Node.d.ts b/types/three/src/nodes/core/Node.d.ts index ab64d6332..4188da7a3 100644 --- a/types/three/src/nodes/core/Node.d.ts +++ b/types/three/src/nodes/core/Node.d.ts @@ -2,7 +2,7 @@ import { EventDispatcher } from "../../core/EventDispatcher.js"; import { NodeUpdateType } from "./constants.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeFrame from "./NodeFrame.js"; -interface NodeJSONMeta { +export interface NodeJSONMeta { textures: { [key: string]: unknown; }; @@ -13,7 +13,7 @@ interface NodeJSONMeta { [key: string]: NodeJSONIntermediateOutputData; }; } -interface NodeJSONMetadata { +export interface NodeJSONMetadata { version: number; type: "Node"; generator: "Node.toJSON"; @@ -67,7 +67,7 @@ export interface NodeChild { * * @augments EventDispatcher */ -declare class Node extends EventDispatcher<{ +declare class NodeClass extends EventDispatcher<{ dispose: {}; }> { static get type(): string; @@ -168,7 +168,7 @@ declare class Node extends EventDispatcher<{ * @generator * @yields {Node} A child node. */ - getChildren(): Generator; + getChildren(): Generator, void, unknown>; /** * Calling this method dispatches the `dispose` event. This event can be used * to register event listeners for clean up tasks. @@ -249,7 +249,7 @@ declare class Node extends EventDispatcher<{ * @param {NodeBuilder} builder - The current node builder. * @return {string} The type of the node. */ - getElementType(builder: NodeBuilder): "bool" | "int" | "float" | "vec2" | "vec3" | "vec4" | "uint" | null; + getElementType(builder: NodeBuilder): "float" | "int" | "uint" | "bool" | "vec2" | "vec3" | "vec4" | null; /** * Returns the node member type for the given name. * @@ -373,4 +373,140 @@ declare class Node extends EventDispatcher<{ */ toJSON(meta?: NodeJSONMeta | string): NodeJSONOutputData; } +declare const Node: { + /** + * Constructs a new node. + * + * @param {?string} nodeType - The node type. + */ + new(nodeType?: string | null): Node; + new(nodeType?: string | null): Node; + get type(): string; +}; +export interface NodeElements { +} +export type NumberType = "float" | "int" | "uint"; +export type IntegerType = "int" | "uint"; +export type NumOrBoolType = NumberType | "bool"; +export type FloatVectorType = "vec2" | "vec3" | "vec4"; +export type MatrixType = "mat2" | "mat3" | "mat4"; +export interface NodeExtensions { +} +export interface FloatExtensions { +} +export interface IntExtensions { +} +export interface UintExtensions { +} +export interface NumberExtensions { +} +export interface IntegerExtensions { +} +export interface NumOrBoolExtensions { +} +export interface BoolExtensions { +} +export interface Vec2Extensions { +} +export interface Ivec2Extensions { +} +export interface Uvec2Extensions { +} +export interface NumberVec2Extensions { +} +export interface NumOrBoolVec2Extensions { +} +export interface Vec3Extensions { +} +export interface Ivec3Extensions { +} +export interface Uvec3Extensions { +} +export interface NumberVec3Extensions { +} +export interface NumOrBoolVec3Extensions { +} +export interface Vec4Extensions { +} +export interface Ivec4Extensions { +} +export interface Uvec4Extensions { +} +export interface NumberVec4Extensions { +} +export interface NumOrBoolVec4Extensions { +} +export interface FloatVectorExtensions { +} +export interface BvecExtensions { +} +export interface Matrix2Extensions { +} +export interface Matrix3Extensions { +} +export interface Matrix4Extensions { +} +export interface MatrixExtensions { +} +export interface ColorExtensions { +} +type Node = + & NodeClass + & NodeElements + & (TValue extends "float" + ? FloatExtensions & NumberExtensions<"float"> & NumOrBoolExtensions<"float"> & NodeExtensions<"float"> + : TValue extends "int" ? + & IntExtensions + & NumberExtensions<"int"> + & IntegerExtensions<"int"> + & NumOrBoolExtensions<"int"> + & NodeExtensions<"int"> + : TValue extends "uint" ? + & UintExtensions + & NumberExtensions<"uint"> + & IntegerExtensions<"uint"> + & NumOrBoolExtensions<"uint"> + & NodeExtensions<"uint"> + : TValue extends "bool" ? BoolExtensions & NumOrBoolExtensions<"bool"> & NodeExtensions<"bool"> + : TValue extends "vec2" ? + & Vec2Extensions + & NumberVec2Extensions<"float"> + & NumOrBoolVec2Extensions<"float"> + & FloatVectorExtensions<"vec2"> + & NodeExtensions<"vec2"> + : TValue extends "ivec2" + ? Ivec2Extensions & NumberVec2Extensions<"int"> & NumOrBoolVec2Extensions<"int"> & NodeExtensions<"ivec2"> + : TValue extends "uvec2" + ? Uvec2Extensions & NumberVec2Extensions<"uint"> & NumOrBoolVec2Extensions<"uint"> & NodeExtensions<"uvec2"> + : TValue extends "bvec2" ? BvecExtensions & NumOrBoolVec2Extensions<"bool"> & NodeExtensions<"bvec2"> + : TValue extends "vec3" ? + & Vec3Extensions + & NumberVec3Extensions<"float"> + & NumOrBoolVec3Extensions<"float"> + & FloatVectorExtensions<"vec3"> + & NodeExtensions<"vec3"> + : TValue extends "ivec3" + ? Ivec3Extensions & NumberVec3Extensions<"int"> & NumOrBoolVec3Extensions<"int"> & NodeExtensions<"ivec3"> + : TValue extends "uvec3" + ? Uvec3Extensions & NumberVec3Extensions<"uint"> & NumOrBoolVec3Extensions<"uint"> & NodeExtensions<"uvec3"> + : TValue extends "bvec3" ? BvecExtensions & NumOrBoolVec3Extensions<"bool"> & NodeExtensions<"bvec3"> + : TValue extends "vec4" ? + & Vec4Extensions + & NumberVec4Extensions<"float"> + & NumOrBoolVec4Extensions<"float"> + & FloatVectorExtensions<"vec4"> + & NodeExtensions<"vec4"> + : TValue extends "ivec4" + ? Ivec4Extensions & NumberVec4Extensions<"int"> & NumOrBoolVec4Extensions<"int"> & NodeExtensions<"ivec4"> + : TValue extends "uvec4" + ? Uvec4Extensions & NumberVec4Extensions<"uint"> & NumOrBoolVec4Extensions<"uint"> & NodeExtensions<"uvec4"> + : TValue extends "bvec4" ? BvecExtensions & NumOrBoolVec4Extensions<"bool"> & NodeExtensions<"bvec4"> + : TValue extends "mat2" ? Matrix2Extensions & MatrixExtensions<"mat2"> & NodeExtensions<"mat2"> + : TValue extends "mat3" ? Matrix3Extensions & MatrixExtensions<"mat3"> & NodeExtensions<"mat3"> + : TValue extends "mat4" ? Matrix4Extensions & MatrixExtensions<"mat4"> & NodeExtensions<"mat4"> + : TValue extends "color" ? ColorExtensions & NodeExtensions<"color"> + : {}) + & { + __TypeScript_VALUE__: TValue; + }; export default Node; diff --git a/types/three/src/nodes/core/NodeBuilder.d.ts b/types/three/src/nodes/core/NodeBuilder.d.ts index eb477e39e..09dc9e08e 100644 --- a/types/three/src/nodes/core/NodeBuilder.d.ts +++ b/types/three/src/nodes/core/NodeBuilder.d.ts @@ -92,7 +92,10 @@ export default abstract class NodeBuilder { getAttribute(name: string, type: string): NodeAttribute; - getPropertyName(node: NodeVar | NodeUniform, shaderStage: NodeShaderStage): string; + getPropertyName( + node: NodeVar | NodeUniform, + shaderStage: NodeShaderStage, + ): string; isVector(type: string): boolean; isMatrix(type: string): boolean; @@ -110,7 +113,7 @@ export default abstract class NodeBuilder { type: string, shaderStage?: NodeShaderStage, name?: string | null, - ): NodeUniform; + ): NodeUniform; getVarFromNode(node: Node, type: string, shaderStage?: NodeShaderStage): NodeVar; getVaryFromNode(node: Node, type: string): NodeVarying; getCodeFromNode(node: Node, type: string, shaderStage?: NodeShaderStage): string; diff --git a/types/three/src/nodes/core/NodeCache.d.ts b/types/three/src/nodes/core/NodeCache.d.ts index a9272f47b..ea07aaa26 100644 --- a/types/three/src/nodes/core/NodeCache.d.ts +++ b/types/three/src/nodes/core/NodeCache.d.ts @@ -22,7 +22,7 @@ export interface ShaderStageNodeData { | undefined; bufferAttribute?: NodeAttribute | undefined; structType?: StructType | undefined; - uniform?: NodeUniform | undefined; + uniform?: NodeUniform | undefined; variable?: NodeVar | undefined; varying?: NodeVarying | undefined; code?: NodeCode | undefined; @@ -38,7 +38,7 @@ interface NodeData { any?: ShaderStageNodeData | undefined; } interface BufferAttributeData { - node: BufferAttributeNode; + node: BufferAttributeNode; } /** * This utility class is used in {@link NodeBuilder} as an internal diff --git a/types/three/src/nodes/core/NodeUniform.d.ts b/types/three/src/nodes/core/NodeUniform.d.ts index 81804abef..4e0712e24 100644 --- a/types/three/src/nodes/core/NodeUniform.d.ts +++ b/types/three/src/nodes/core/NodeUniform.d.ts @@ -5,11 +5,11 @@ import UniformNode from "./UniformNode.js"; * by the builder. A dictionary of node uniforms is maintained in {@link NodeBuilder#uniforms} * for this purpose. */ -declare class NodeUniform { +declare class NodeUniform { readonly isNodeUniform: true; name: string; type: string | null; - node: UniformNode; + node: UniformNode; needsUpdate: boolean | undefined; /** * Constructs a new node uniform. @@ -18,7 +18,7 @@ declare class NodeUniform { * @param {string} type - The type of the uniform. * @param {UniformNode} node - An reference to the node. */ - constructor(name: string, type: string | null, node: UniformNode); + constructor(name: string, type: string | null, node: UniformNode); /** * The value of the uniform node. * diff --git a/types/three/src/nodes/core/PropertyNode.d.ts b/types/three/src/nodes/core/PropertyNode.d.ts index de00f157a..a624d619c 100644 --- a/types/three/src/nodes/core/PropertyNode.d.ts +++ b/types/three/src/nodes/core/PropertyNode.d.ts @@ -1,44 +1,54 @@ import Node from "./Node.js"; -export default class PropertyNode extends Node { +interface PropertyNodeInterface extends Node { name: string | null; varying: boolean; readonly isPropertyNode: true; - - constructor(nodeType?: string | null, name?: string | null, varying?: boolean); } -export const property: (type?: string | null, name?: string | null) => PropertyNode; -export const varyingProperty: (type?: string | null, name?: string | null) => PropertyNode; +declare const PropertyNode: { + new( + nodeType?: string | null, + name?: string | null, + varying?: boolean, + ): PropertyNode; +}; + +type PropertyNode = Node & PropertyNodeInterface; + +export default PropertyNode; + +export const property: (type?: string | null, name?: string | null) => PropertyNode; +export const varyingProperty: (type?: string | null, name?: string | null) => PropertyNode; -export const diffuseColor: PropertyNode; -export const diffuseContribution: PropertyNode; -export const emissive: PropertyNode; -export const roughness: PropertyNode; -export const metalness: PropertyNode; -export const clearcoat: PropertyNode; -export const clearcoatRoughness: PropertyNode; -export const sheen: PropertyNode; -export const sheenRoughness: PropertyNode; -export const iridescence: PropertyNode; -export const iridescenceIOR: PropertyNode; -export const iridescenceThickness: PropertyNode; -export const alphaT: PropertyNode; -export const anisotropy: PropertyNode; -export const anisotropyT: PropertyNode; -export const anisotropyB: PropertyNode; -export const specularColor: PropertyNode; -export const specularColorBlended: PropertyNode; -export const specularF90: PropertyNode; -export const shininess: PropertyNode; -export const output: PropertyNode; -export const dashSize: PropertyNode; -export const gapSize: PropertyNode; -export const pointWidth: PropertyNode; -export const ior: PropertyNode; -export const transmission: PropertyNode; -export const thickness: PropertyNode; -export const attenuationDistance: PropertyNode; -export const attenuationColor: PropertyNode; -export const dispersion: PropertyNode; +export const diffuseColor: PropertyNode<"vec4">; +export const diffuseContribution: PropertyNode<"vec3">; +export const emissive: PropertyNode<"vec3">; +export const roughness: PropertyNode<"float">; +export const metalness: PropertyNode<"float">; +export const clearcoat: PropertyNode<"float">; +export const clearcoatRoughness: PropertyNode<"float">; +export const sheen: PropertyNode<"vec3">; +export const sheenRoughness: PropertyNode<"float">; +export const iridescence: PropertyNode<"float">; +export const iridescenceIOR: PropertyNode<"float">; +export const iridescenceThickness: PropertyNode<"float">; +export const alphaT: PropertyNode<"float">; +export const anisotropy: PropertyNode<"float">; +export const anisotropyT: PropertyNode<"vec3">; +export const anisotropyB: PropertyNode<"vec3">; +export const specularColor: PropertyNode<"color">; +export const specularColorBlended: PropertyNode<"color">; +export const specularF90: PropertyNode<"float">; +export const shininess: PropertyNode<"float">; +export const output: PropertyNode<"vec4">; +export const dashSize: PropertyNode<"float">; +export const gapSize: PropertyNode<"float">; +export const pointWidth: PropertyNode<"float">; +export const ior: PropertyNode<"float">; +export const transmission: PropertyNode<"float">; +export const thickness: PropertyNode<"float">; +export const attenuationDistance: PropertyNode<"float">; +export const attenuationColor: PropertyNode<"color">; +export const dispersion: PropertyNode<"float">; diff --git a/types/three/src/nodes/core/TempNode.d.ts b/types/three/src/nodes/core/TempNode.d.ts index 367f5ade1..c5274444a 100644 --- a/types/three/src/nodes/core/TempNode.d.ts +++ b/types/three/src/nodes/core/TempNode.d.ts @@ -1,10 +1,16 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; -export default class TempNode extends Node { +interface TempNodeInterface { isTempNode: true; - constructor(type: string | null); - hasDependencies(builder: NodeBuilder): boolean; } + +declare const TempNode: { + new(type: string | null): TempNode; +}; + +type TempNode = Node & TempNodeInterface; + +export default TempNode; diff --git a/types/three/src/nodes/core/UniformNode.d.ts b/types/three/src/nodes/core/UniformNode.d.ts index 4d6a41738..e54867c40 100644 --- a/types/three/src/nodes/core/UniformNode.d.ts +++ b/types/three/src/nodes/core/UniformNode.d.ts @@ -1,6 +1,12 @@ +import { Color } from "../../math/Color.js"; +import { Matrix2 } from "../../math/Matrix2.js"; +import { Matrix3 } from "../../math/Matrix3.js"; +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 { NodeUpdateType } from "./constants.js"; import InputNode from "./InputNode.js"; -import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeFrame from "./NodeFrame.js"; import UniformGroupNode from "./UniformGroupNode.js"; @@ -9,7 +15,7 @@ import UniformGroupNode from "./UniformGroupNode.js"; * * @augments InputNode */ -declare class UniformNode extends InputNode { +declare class UniformNodeClass extends InputNode { static get type(): string; readonly isUniformNode: true; name: string; @@ -61,7 +67,30 @@ declare class UniformNode extends InputNode { getInputType(builder: NodeBuilder): string | null; generate(builder: NodeBuilder, output: string | null): string; } +declare const UniformNode: { + /** + * Constructs a new uniform node. + * + * @param {any} value - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture). + * @param {?string} nodeType - The node type. If no explicit type is defined, the node tries to derive the type from its value. + */ + new(value: TValue, nodeType?: string | null): UniformNode; + get type(): string; +}; +type UniformNode = UniformNodeClass & InputNode; export default UniformNode; +interface Uniform { + (value: number, type?: "float"): UniformNode<"float", number>; + (value: boolean): UniformNode<"bool", boolean>; + (value: Vector2): UniformNode<"vec2", Vector2>; + (value: Vector3): UniformNode<"vec3", Vector3>; + (value: Vector4): UniformNode<"vec4", Vector4>; + (value: Matrix2): UniformNode<"mat2", Matrix2>; + (value: Matrix3): UniformNode<"mat3", Matrix3>; + (value: Matrix4): UniformNode<"mat4", Matrix4>; + (value: Color): UniformNode<"color", Color>; + (value: InputNode): UniformNode; +} /** * TSL function for creating a uniform node. * @@ -71,4 +100,4 @@ export default UniformNode; * @param {string} [type] - The node type. If no explicit type is defined, the node tries to derive the type from its value. * @returns {UniformNode} */ -export declare const uniform: (value: InputNode | TValue, type?: Node | string) => UniformNode; +export declare const uniform: Uniform; diff --git a/types/three/src/nodes/core/VarNode.d.ts b/types/three/src/nodes/core/VarNode.d.ts index 55fe3c46b..e4a315012 100644 --- a/types/three/src/nodes/core/VarNode.d.ts +++ b/types/three/src/nodes/core/VarNode.d.ts @@ -1,6 +1,6 @@ import Node from "./Node.js"; -declare class VarNode extends Node { +interface VarNodeInterface { node: Node; name: string | null; @@ -10,29 +10,30 @@ declare class VarNode extends Node { intent: boolean; - constructor(node: Node, name?: string | null, readOnly?: boolean); - setIntent(value: boolean): this; getIntent(): boolean; } +declare const VarNode: { + new(node: Node, name?: string | null, readOnly?: boolean): VarNode; +}; + +type VarNode = Node & VarNodeInterface; + export default VarNode; -export const Var: (node: Node, name?: string | null) => VarNode; +export const Var: (node: Node, name?: string | null) => VarNode; -export const Const: (node: Node, name?: string | null) => VarNode; +export const Const: (node: Node, name?: string | null) => VarNode; -export const VarIntent: (node: Node) => Node; +export const VarIntent: (node: Node) => Node; -declare module "../Nodes.js" { - interface Node { - toVar: (name?: string | null) => VarNode; - toVarAssign: (name?: string | null) => this; +declare module "./Node.js" { + interface NodeExtensions { + toVar: (name?: string | null) => VarNode; - toConst: (name?: string | null) => VarNode; - toConstAssign: (name?: string | null) => this; + toConst: (name?: string | null) => VarNode; - toVarIntent: () => Node; - toVarIntentAssign: () => this; + toVarIntent: () => VarNode; } } diff --git a/types/three/src/nodes/core/VaryingNode.d.ts b/types/three/src/nodes/core/VaryingNode.d.ts index 218cfcedd..e41d42316 100644 --- a/types/three/src/nodes/core/VaryingNode.d.ts +++ b/types/three/src/nodes/core/VaryingNode.d.ts @@ -3,39 +3,39 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeVarying from "./NodeVarying.js"; -export default class VaryingNode extends Node { +interface VaryingNodeInterface { node: Node; name: string | null; readonly isVaryingNode: true; interpolationType: InterpolationSamplingType | null; interpolationSampling: InterpolationSamplingMode | null; - constructor(node: Node, name?: string | null); - setInterpolation(type: InterpolationSamplingType | null, sampling?: InterpolationSamplingMode | null): this; setupVarying(builder: NodeBuilder): NodeVarying; } -export const varying: (node: Node, name?: string) => VaryingNode; +declare const VaryingNode: { + new(node: Node, name?: string | null): VaryingNode; +}; -export const vertexStage: (node: Node) => VaryingNode; +type VaryingNode = VaryingNodeInterface & Node; -declare module "../Nodes.js" { - interface Node { - toVarying: (name?: string) => VaryingNode; - toVaryingAssign: (name?: string) => this; +export default VaryingNode; - toVertexStage: () => VaryingNode; - toVertexStageAssign: () => this; +export const varying: (node: Node, name?: string) => VaryingNode; + +export const vertexStage: (node: Node) => VaryingNode; + +declare module "./Node.js" { + interface NodeExtensions { + toVarying: (name?: string) => VaryingNode; + + toVertexStage: () => VaryingNode; /** * @deprecated .vertexStage() has been renamed to .toVertexStage(). */ - vertexStage: () => VaryingNode; - /** - * @deprecated .vertexStage() has been renamed to .toVertexStage(). - */ - vertexStageAssign: () => this; + vertexStage: () => VaryingNode; } } diff --git a/types/three/src/nodes/display/BlendModes.d.ts b/types/three/src/nodes/display/BlendModes.d.ts index e0a56b78a..0e46b1e26 100644 --- a/types/three/src/nodes/display/BlendModes.d.ts +++ b/types/three/src/nodes/display/BlendModes.d.ts @@ -1,35 +1,47 @@ import Node from "../core/Node.js"; -export const blendBurn: (base: Node, blend: Node) => Node; +export const blendBurn: ( + base: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, + blend: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, +) => Node<"vec3">; -export const blendDodge: (base: Node, blend: Node) => Node; +export const blendDodge: ( + base: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, + blend: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, +) => Node<"vec3">; -export const blendScreen: (base: Node, blend: Node) => Node; +export const blendScreen: ( + base: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, + blend: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, +) => Node<"vec3">; -export const blendOverlay: (base: Node, blend: Node) => Node; +export const blendOverlay: ( + base: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, + blend: number | Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4">, +) => Node<"vec3">; -export const blendColor: (base: Node, blend: Node) => Node; +export const blendColor: (base: Node<"vec4">, blend: Node<"vec4">) => Node<"vec4">; -export const premultiplyAlpha: (color: Node) => Node; +export const premultiplyAlpha: (color: Node<"vec4">) => Node<"vec4">; -export const unpremultiplyAlpha: (color: Node) => Node; +export const unpremultiplyAlpha: (color: Node<"vec4">) => Node<"vec4">; /** * @deprecated */ -export const burn: (base: Node, blend: Node) => Node; +export const burn: (base: Node<"vec3">, blend: Node<"vec3">) => Node<"vec3">; /** * @deprecated */ -export const dodge: (base: Node, blend: Node) => Node; +export const dodge: (base: Node<"vec3">, blend: Node<"vec3">) => Node<"vec3">; /** * @deprecated */ -export const screen: (base: Node, blend: Node) => Node; +export const screen: (base: Node<"vec3">, blend: Node<"vec3">) => Node<"vec3">; /** * @deprecated */ -export const overlay: (base: Node, blend: Node) => Node; +export const overlay: (base: Node<"vec3">, blend: Node<"vec3">) => Node<"vec3">; diff --git a/types/three/src/nodes/display/BumpMapNode.d.ts b/types/three/src/nodes/display/BumpMapNode.d.ts index 376d541c6..702cb2652 100644 --- a/types/three/src/nodes/display/BumpMapNode.d.ts +++ b/types/three/src/nodes/display/BumpMapNode.d.ts @@ -1,7 +1,7 @@ import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class BumpMapNode extends TempNode { +declare class BumpMapNode extends TempNode<"vec3"> { textureNode: Node; scaleNode: Node | null; diff --git a/types/three/src/nodes/display/ColorAdjustment.d.ts b/types/three/src/nodes/display/ColorAdjustment.d.ts index 612ffb0c2..b7b1c15ab 100644 --- a/types/three/src/nodes/display/ColorAdjustment.d.ts +++ b/types/three/src/nodes/display/ColorAdjustment.d.ts @@ -1,29 +1,27 @@ import Node from "../core/Node.js"; import MathNode from "../math/MathNode.js"; -export const grayscale: (color: Node) => Node; +export const grayscale: (color: Node) => Node<"vec3">; export const saturation: ( color: Node, adjustment?: Node | number, -) => Node; +) => Node<"vec3">; export const vibrance: ( color: Node, adjustment?: Node | number, -) => Node; +) => Node<"vec3">; export const hue: ( color: Node, adjustment?: Node | number, -) => Node; +) => Node<"vec3">; export const luminance: ( color: Node, luminanceCoefficients?: Node, -) => MathNode; - -export const threshold: (color: Node, thershold: Node) => MathNode; +) => Node<"float">; /** * Color Decision List (CDL) v1.2 @@ -52,4 +50,4 @@ export const cdl: ( power?: Node, saturation?: Node, luminanceCoefficients?: Node, -) => Node; +) => Node<"vec4">; diff --git a/types/three/src/nodes/display/ColorSpaceNode.d.ts b/types/three/src/nodes/display/ColorSpaceNode.d.ts index b19315561..975dedd7e 100644 --- a/types/three/src/nodes/display/ColorSpaceNode.d.ts +++ b/types/three/src/nodes/display/ColorSpaceNode.d.ts @@ -12,7 +12,7 @@ export function getColorSpaceMethod( target: typeof LinearSRGBColorSpace | typeof SRGBColorSpace, ): ColorSpaceMethod; -export default class ColorSpaceNode extends TempNode { +export default class ColorSpaceNode extends TempNode<"vec4"> { colorNode: Node; source: string; target: string; @@ -41,20 +41,14 @@ export const convertColorSpace: ( targetColorSpace: string, ) => ColorSpaceNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { workingToColorSpace: ( targetColorSpace: string, ) => ColorSpaceNode; - workingToColorSpaceAssign: ( - targetColorSpace: string, - ) => this; colorSpaceToWorking: ( sourceColorSpace: string, ) => ColorSpaceNode; - colorSpaceToWorkingAssign: ( - sourceColorSpace: string, - ) => this; } } diff --git a/types/three/src/nodes/display/FrontFacingNode.d.ts b/types/three/src/nodes/display/FrontFacingNode.d.ts index b4398515e..39238ce68 100644 --- a/types/three/src/nodes/display/FrontFacingNode.d.ts +++ b/types/three/src/nodes/display/FrontFacingNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -declare class FrontFacingNode extends Node { +declare class FrontFacingNode extends Node<"bool"> { isFrontFacingNode: true; constructor(); } diff --git a/types/three/src/nodes/display/NormalMapNode.d.ts b/types/three/src/nodes/display/NormalMapNode.d.ts index ceb116165..bf8ce1f97 100644 --- a/types/three/src/nodes/display/NormalMapNode.d.ts +++ b/types/three/src/nodes/display/NormalMapNode.d.ts @@ -2,7 +2,7 @@ import { NormalMapTypes, NormalPacking } from "../../constants.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class NormalMapNode extends TempNode { +declare class NormalMapNode extends TempNode<"vec3"> { node: Node; scaleNode: Node | null; diff --git a/types/three/src/nodes/display/PassNode.d.ts b/types/three/src/nodes/display/PassNode.d.ts index 370bdbf3e..23023619d 100644 --- a/types/three/src/nodes/display/PassNode.d.ts +++ b/types/three/src/nodes/display/PassNode.d.ts @@ -27,7 +27,7 @@ declare class PassMultipleTextureNode extends PassTextureNode { updateTexture(): void; } -declare class PassNode extends TempNode { +declare class PassNode extends TempNode<"vec4"> { scope: PassNodeScope; scene: Object3D; camera: Camera; @@ -38,7 +38,7 @@ declare class PassNode extends TempNode { transparent: boolean; opaque: boolean; - contextNode: ContextNode | null; + contextNode: ContextNode | null; readonly isPassNode: true; @@ -74,11 +74,11 @@ declare class PassNode extends TempNode { getTextureNode(name?: string): TextureNode; - getPreviousTextureNode(name?: string): Node; + getPreviousTextureNode(name?: string): TextureNode; - getViewZNode(name?: string): Node; + getViewZNode(name?: string): Node<"float">; - getLinearDepthNode(name?: string): Node; + getLinearDepthNode(name?: string): Node<"float">; compileAsync(renderer: Renderer): Promise; diff --git a/types/three/src/nodes/display/PosterizeNode.d.ts b/types/three/src/nodes/display/PosterizeNode.d.ts index 9c3dd1bce..e464bfe65 100644 --- a/types/three/src/nodes/display/PosterizeNode.d.ts +++ b/types/three/src/nodes/display/PosterizeNode.d.ts @@ -1,13 +1,13 @@ import Node from "../core/Node.js"; -export default class PosterizeNode extends Node { - sourceNode: Node; - stepsNode: Node; +export default class PosterizeNode extends Node<"vec4"> { + sourceNode: Node<"vec4">; + stepsNode: Node<"float">; - constructor(sourceNode: Node, stepsNode: Node); + constructor(sourceNode: Node<"vec4">, stepsNode: Node<"float">); } export const posterize: ( - sourceNode: Node, - stepsNode: Node | number, + sourceNode: Node<"vec4">, + stepsNode: Node<"float"> | number, ) => PosterizeNode; diff --git a/types/three/src/nodes/display/RenderOutputNode.d.ts b/types/three/src/nodes/display/RenderOutputNode.d.ts index 5762c657d..100a8a394 100644 --- a/types/three/src/nodes/display/RenderOutputNode.d.ts +++ b/types/three/src/nodes/display/RenderOutputNode.d.ts @@ -2,7 +2,7 @@ import { ToneMapping } from "../../constants.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class RenderOutputNode extends TempNode { +declare class RenderOutputNode extends TempNode<"vec4"> { colorNode: Node; outputColorSpace: string | null; @@ -19,15 +19,11 @@ export const renderOutput: ( outputColorSpace?: string | null, ) => RenderOutputNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { renderOutput: ( toneMapping?: ToneMapping | null, outputColorSpace?: string | null, ) => RenderOutputNode; - renderOutputAssign: ( - toneMapping?: ToneMapping | null, - outputColorSpace?: string | null, - ) => this; } } diff --git a/types/three/src/nodes/display/ScreenNode.d.ts b/types/three/src/nodes/display/ScreenNode.d.ts index 4bd121ea2..a457b1c2c 100644 --- a/types/three/src/nodes/display/ScreenNode.d.ts +++ b/types/three/src/nodes/display/ScreenNode.d.ts @@ -7,39 +7,47 @@ export type ScreenNodeScope = | typeof ScreenNode.UV | typeof ScreenNode.DPR; -declare class ScreenNode extends Node { +interface ScreenNodeInterface { scope: ScreenNodeScope; readonly isViewportNode: true; +} - constructor(scope: ScreenNodeScope); +declare const ScreenNode: { + new(scope: typeof ScreenNode.COORDINATE): ScreenNode<"vec2">; + new(scope: typeof ScreenNode.VIEWPORT): ScreenNode<"vec4">; + new(scope: typeof ScreenNode.SIZE): ScreenNode<"vec2">; + new(scope: typeof ScreenNode.UV): ScreenNode<"vec2">; + new(scope: typeof ScreenNode.DPR): ScreenNode<"float">; - static COORDINATE: "coordinate"; - static VIEWPORT: "viewport"; - static SIZE: "size"; - static UV: "uv"; - static DPR: "dpr"; -} + COORDINATE: "coordinate"; + VIEWPORT: "viewport"; + SIZE: "size"; + UV: "uv"; + DPR: "dpr"; +}; + +type ScreenNode = Node & ScreenNodeInterface; export default ScreenNode; // Screen -export const screenDPR: ScreenNode; -export const screenUV: ScreenNode; -export const screenSize: ScreenNode; -export const screenCoordinate: ScreenNode; +export const screenDPR: ScreenNode<"float">; +export const screenUV: ScreenNode<"vec2">; +export const screenSize: ScreenNode<"vec2">; +export const screenCoordinate: ScreenNode<"vec2">; // Viewport -export const viewport: ScreenNode; -export const viewportSize: Node; -export const viewportCoordinate: Node; -export const viewportUV: Node; +export const viewport: ScreenNode<"vec4">; +export const viewportSize: Node<"vec2">; +export const viewportCoordinate: Node<"vec2">; +export const viewportUV: Node<"vec2">; // Deprecated /** * @deprecated "viewportResolution" is deprecated. Use "screenSize" instead. */ -export const viewportResolution: ScreenNode; +export const viewportResolution: ScreenNode<"vec2">; diff --git a/types/three/src/nodes/display/ToneMappingNode.d.ts b/types/three/src/nodes/display/ToneMappingNode.d.ts index d8ae7fda3..0da32f5eb 100644 --- a/types/three/src/nodes/display/ToneMappingNode.d.ts +++ b/types/three/src/nodes/display/ToneMappingNode.d.ts @@ -3,7 +3,7 @@ import RendererReferenceNode from "../accessors/RendererReferenceNode.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class ToneMappingNode extends TempNode { +declare class ToneMappingNode extends TempNode<"vec3"> { exposureNode: Node; colorNode: Node | null; @@ -19,15 +19,11 @@ export const toneMapping: ( ) => ToneMappingNode; export const toneMappingExposure: RendererReferenceNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { toneMapping: ( mapping?: ToneMapping, exposure?: Node | number, ) => ToneMappingNode; - toneMappingAssign: ( - mapping?: ToneMapping, - exposure?: Node | number, - ) => this; } } diff --git a/types/three/src/nodes/display/ViewportDepthNode.d.ts b/types/three/src/nodes/display/ViewportDepthNode.d.ts index fe601cd5a..a201cb729 100644 --- a/types/three/src/nodes/display/ViewportDepthNode.d.ts +++ b/types/three/src/nodes/display/ViewportDepthNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -declare class ViewportDepthNode extends Node { +declare class ViewportDepthNode extends Node<"float"> { scope: ViewportDepthNodeScope; valueNode: Node; @@ -20,17 +20,17 @@ export type ViewportDepthNodeScope = export default ViewportDepthNode; -export const viewZToOrthographicDepth: (viewZ: Node, near: Node, far: Node) => Node; +export const viewZToOrthographicDepth: (viewZ: Node<"float">, near: Node<"float">, far: Node<"float">) => Node<"float">; -export const orthographicDepthToViewZ: (depth: Node, near: Node, far: Node) => Node; +export const orthographicDepthToViewZ: (depth: Node<"float">, near: Node<"float">, far: Node<"float">) => Node<"float">; -export const viewZToPerspectiveDepth: (viewZ: Node, near: Node, far: Node) => Node; +export const viewZToPerspectiveDepth: (viewZ: Node<"float">, near: Node<"float">, far: Node<"float">) => Node<"float">; -export const perspectiveDepthToViewZ: (depth: Node, near: Node, far: Node) => Node; +export const perspectiveDepthToViewZ: (depth: Node<"float">, near: Node<"float">, far: Node<"float">) => Node<"float">; -export const viewZToLogarithmicDepth: (viewZ: Node, near: Node, far: Node) => Node; +export const viewZToLogarithmicDepth: (viewZ: Node<"float">, near: Node<"float">, far: Node<"float">) => Node<"float">; -export const logarithmicDepthToViewZ: (depth: Node, near: Node, far: Node) => Node; +export const logarithmicDepthToViewZ: (depth: Node<"float">, near: Node<"float">, far: Node<"float">) => Node<"float">; export const depth: ViewportDepthNode; export const linearDepth: (valueNode?: Node | null) => ViewportDepthNode; diff --git a/types/three/src/nodes/fog/Fog.d.ts b/types/three/src/nodes/fog/Fog.d.ts index 4424e72b4..39ff8ca23 100644 --- a/types/three/src/nodes/fog/Fog.d.ts +++ b/types/three/src/nodes/fog/Fog.d.ts @@ -1,10 +1,10 @@ import Node from "../core/Node.js"; -export const rangeFogFactor: (near: Node | number, far: Node | number) => Node; +export const rangeFogFactor: (near: Node<"float"> | number, far: Node<"float"> | number) => Node<"float">; export const densityFogFactor: (density: Node) => Node; -export const fog: (color: Node, factor: Node) => Node; +export const fog: (color: Node, factor: Node) => Node<"vec4">; /** * @deprecated diff --git a/types/three/src/nodes/functions/ShadowMaskModel.d.ts b/types/three/src/nodes/functions/ShadowMaskModel.d.ts index 80440ad8a..762176cf1 100644 --- a/types/three/src/nodes/functions/ShadowMaskModel.d.ts +++ b/types/three/src/nodes/functions/ShadowMaskModel.d.ts @@ -1,8 +1,8 @@ import LightingModel from "../core/LightingModel.js"; -import VarNode from "../core/VarNode.js"; +import Node from "../core/Node.js"; export default class ShadowMaskModel extends LightingModel { - shadowNode: VarNode; + shadowNode: Node; constructor(); } diff --git a/types/three/src/nodes/geometry/RangeNode.d.ts b/types/three/src/nodes/geometry/RangeNode.d.ts index 61a91b014..54352eabd 100644 --- a/types/three/src/nodes/geometry/RangeNode.d.ts +++ b/types/three/src/nodes/geometry/RangeNode.d.ts @@ -5,16 +5,58 @@ import { Vector4 } from "../../math/Vector4.js"; import Node from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; -export default class RangeNode extends Node { - minNode: Node; - maxNode: Node; - - constructor(minNode: Node, maxNode: Node); +interface RangeNodeInterface { + minNode: Node; + maxNode: Node; getVectorLength(builder: NodeBuilder): number; } -export const range: ( - minNode: Node | number | Color | Vector2 | Vector3 | Vector4, - maxNode: Node | number | Color | Vector2 | Vector3 | Vector4, -) => RangeNode; +declare const RangeNode: { + new(minNode: Node, maxNode: Node): RangeNode; +}; + +type RangeNode = RangeNodeInterface & Node; + +export default RangeNode; + +interface Range { + ( + minNode: number, + maxNode: number, + ): RangeNode<"float">; + ( + minNode: Vector2, + maxNode: Vector2, + ): RangeNode<"vec2">; + ( + minNode: Vector3, + maxNode: Vector3, + ): RangeNode<"vec3">; + ( + minNode: Vector4, + maxNode: Vector4, + ): RangeNode<"vec4">; + ( + minNode: Color, + maxNode: Color, + ): RangeNode<"vec3">; + ( + minNode: Node<"float">, + maxNode: Node<"float">, + ): RangeNode<"float">; + ( + minNode: Node<"vec2">, + maxNode: Node<"vec2">, + ): RangeNode<"vec2">; + ( + minNode: Node<"vec3">, + maxNode: Node<"vec3">, + ): RangeNode<"vec3">; + ( + minNode: Node<"vec4">, + maxNode: Node<"vec4">, + ): RangeNode<"vec4">; +} + +export const range: Range; diff --git a/types/three/src/nodes/gpgpu/ComputeNode.d.ts b/types/three/src/nodes/gpgpu/ComputeNode.d.ts index aa1f483e6..c3a6507f3 100644 --- a/types/three/src/nodes/gpgpu/ComputeNode.d.ts +++ b/types/three/src/nodes/gpgpu/ComputeNode.d.ts @@ -34,18 +34,13 @@ export const compute: ( workgroupSize?: number[], ) => ComputeNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { compute: ( count: number, workgroupSize?: number[], ) => ComputeNode; - computeAssign: ( - count: number, - workgroupSize?: number[], - ) => this; computeKernel: (workgroupSize?: number[]) => ComputeNode; - computeKernelAssign: (workgroupSize?: number[]) => this; } } diff --git a/types/three/src/nodes/lighting/HemisphereLightNode.d.ts b/types/three/src/nodes/lighting/HemisphereLightNode.d.ts index 7cf38dd79..0b4158fa1 100644 --- a/types/three/src/nodes/lighting/HemisphereLightNode.d.ts +++ b/types/three/src/nodes/lighting/HemisphereLightNode.d.ts @@ -1,13 +1,15 @@ import { HemisphereLight } from "../../lights/HemisphereLight.js"; +import { Vector3 } from "../../math/Vector3.js"; import Object3DNode from "../accessors/Object3DNode.js"; import Node from "../core/Node.js"; +import UniformNode from "../core/UniformNode.js"; import AnalyticLightNode from "./AnalyticLightNode.js"; export default class HemisphereLightNode extends AnalyticLightNode { - lightPositionNode: Object3DNode; - lightDirectionNode: Node; + lightPositionNode: UniformNode<"vec3", Vector3>; + lightDirectionNode: Node<"vec3">; - groundColorNode: Node; + groundColorNode: UniformNode<"vec3", Vector3>; constructor(light?: HemisphereLight | null); } diff --git a/types/three/src/nodes/lighting/LightProbeNode.d.ts b/types/three/src/nodes/lighting/LightProbeNode.d.ts index 3a5b12963..441a774ce 100644 --- a/types/three/src/nodes/lighting/LightProbeNode.d.ts +++ b/types/three/src/nodes/lighting/LightProbeNode.d.ts @@ -3,7 +3,7 @@ import UniformArrayNode from "../accessors/UniformArrayNode.js"; import AnalyticLightNode from "./AnalyticLightNode.js"; declare class LightProbeNode extends AnalyticLightNode { - lightProbe: UniformArrayNode; + lightProbe: UniformArrayNode<"vec3[]">; constructor(light?: LightProbe | null); } diff --git a/types/three/src/nodes/lighting/LightUtils.d.ts b/types/three/src/nodes/lighting/LightUtils.d.ts index 7f10cdf64..7ed187cf2 100644 --- a/types/three/src/nodes/lighting/LightUtils.d.ts +++ b/types/three/src/nodes/lighting/LightUtils.d.ts @@ -1,8 +1,7 @@ import Node from "../core/Node.js"; -import ConditionalNode from "../math/ConditionalNode.js"; export const getDistanceAttenuation: (args: { - lightDistance: Node; - cutoffDistance: Node; - decayExponent: Node; -}) => ConditionalNode; + lightDistance: Node<"float">; + cutoffDistance: Node<"float">; + decayExponent: Node<"float">; +}) => Node<"float">; diff --git a/types/three/src/nodes/lighting/LightingContextNode.d.ts b/types/three/src/nodes/lighting/LightingContextNode.d.ts index bb7079b6c..ce2d027ad 100644 --- a/types/three/src/nodes/lighting/LightingContextNode.d.ts +++ b/types/three/src/nodes/lighting/LightingContextNode.d.ts @@ -13,7 +13,7 @@ export interface LightingContext { backdropAlpha: Node; } -export default class LightingContextNode extends ContextNode { +export default class LightingContextNode extends ContextNode { lightingModelNode: LightingModel | null; backdropNode: Node | null; backdropAlphaNode: Node | null; diff --git a/types/three/src/nodes/lighting/LightingNode.d.ts b/types/three/src/nodes/lighting/LightingNode.d.ts index 3e8dd5424..bcc825a3f 100644 --- a/types/three/src/nodes/lighting/LightingNode.d.ts +++ b/types/three/src/nodes/lighting/LightingNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -export default abstract class LightingNode extends Node { +export default abstract class LightingNode extends Node<"vec3"> { readonly isLightingNode: true; constructor(); diff --git a/types/three/src/nodes/materialx/MaterialXNodes.d.ts b/types/three/src/nodes/materialx/MaterialXNodes.d.ts index 9297660c2..a55c8f043 100644 --- a/types/three/src/nodes/materialx/MaterialXNodes.d.ts +++ b/types/three/src/nodes/materialx/MaterialXNodes.d.ts @@ -55,17 +55,17 @@ export const mx_noise_float: ( texcoord?: Node, amplitude?: Node | number, pivot?: Node | number, -) => Node; +) => Node<"float">; export const mx_noise_vec3: ( texcoord?: Node, amplitude?: Node | number, pivot?: Node | number, -) => Node; +) => Node<"vec3">; export const mx_noise_vec4: ( texcoord?: Node, amplitude?: Node | number, pivot?: Node | number, -) => Node; +) => Node<"vec4">; export const mx_unifiednoise2d: ( noiseType: Node, @@ -97,17 +97,17 @@ export const mx_unifiednoise3d: ( export function mx_worley_noise_float( texcoord?: Node, jitter?: Node | number, -): Node; +): Node<"float">; export function mx_worley_noise_vec2( texcoord?: Node, jitter?: Node | number, -): Node; +): Node<"vec2">; export function mx_worley_noise_vec3( texcoord?: Node, jitter?: Node | number, -): Node; +): Node<"vec3">; -export function mx_cell_noise_float(texcoord?: Node): Node; +export function mx_cell_noise_float(texcoord?: Node): Node<"float">; export function mx_fractal_noise_float( position?: Node, @@ -115,28 +115,28 @@ export function mx_fractal_noise_float( lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"float">; export function mx_fractal_noise_vec2( position?: Node, octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"vec2">; export function mx_fractal_noise_vec3( position?: Node, octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"vec3">; export function mx_fractal_noise_vec4( position?: Node, octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"vec4">; export { mx_hsvtorgb, mx_rgbtohsv, mx_srgb_texture_to_lin_rec709 }; diff --git a/types/three/src/nodes/materialx/lib/mx_noise.d.ts b/types/three/src/nodes/materialx/lib/mx_noise.d.ts index 735aec32f..016c192ec 100644 --- a/types/three/src/nodes/materialx/lib/mx_noise.d.ts +++ b/types/three/src/nodes/materialx/lib/mx_noise.d.ts @@ -14,7 +14,7 @@ export const mx_negate_if: ( export const mx_floor: (x_immutable: Node | number) => Node; -export const mx_floorfrac: (x_immutable: Node | number, i: VarNode) => Node; +export const mx_floorfrac: (x_immutable: Node | number, i: Node) => Node; export const mx_bilerp_0: ( v0_immutable: Node | number, @@ -140,9 +140,9 @@ export const mx_gradient_scale3d: (v_immutable: Node | number) => Node; export const mx_rotl32: (x_immutable: Node | number, k_immutable: Node | number) => Node; export const mx_bjmix: ( - a: VarNode, - b: VarNode, - c: VarNode, + a: Node, + b: Node, + c: Node, ) => Node; export const mx_bjfinal: ( diff --git a/types/three/src/nodes/math/ConditionalNode.d.ts b/types/three/src/nodes/math/ConditionalNode.d.ts index 77e83a046..6c2345fec 100644 --- a/types/three/src/nodes/math/ConditionalNode.d.ts +++ b/types/three/src/nodes/math/ConditionalNode.d.ts @@ -1,30 +1,55 @@ import Node from "../core/Node.js"; -declare class ConditionalNode extends Node { +interface ConditionalNodeInterface { condNode: Node; ifNode: Node; elseNode: Node | null; - - constructor(condNode: Node, ifNode: Node, elseNode?: Node | null); } +declare const ConditionalNode: { + new( + condNode: Node<"bool">, + ifNode: Node, + elseNode?: Node | null, + ): ConditionalNode; +}; + +type ConditionalNode = Node & ConditionalNodeInterface; + export default ConditionalNode; -export const select: ( - condNode: Node, - ifNode: Node | number, - elseNode?: Node | number | null, -) => Node; - -declare module "../Nodes.js" { - interface Node { - select: ( - ifNode: Node | number, - elseNode?: Node | number | null, - ) => Node; - selectAssign: ( - ifNode: Node | number, - elseNode?: Node | number | null, +interface Select { + ( + condNode: Node<"bool">, + ifNode: Node<"float"> | number, + elseNode?: Node<"float"> | number | null, + ): Node<"float">; + ( + condNode: Node<"bool">, + ifNode: Node, + elseNode?: Node | null, + ): Node; +} + +export const select: Select; + +interface SelectExtension { + ( + ifNode: Node<"float"> | number, + elseNode?: Node<"float"> | number | null, + ): Node<"float">; + ( + ifNode: Node, + elseNode?: Node | null, + ): Node; +} + +declare module "../core/Node.js" { + interface BoolExtensions { + select: SelectExtension; + selectAssign: ( + ifNode: Node, + elseNode?: Node | null, ) => this; } } diff --git a/types/three/src/nodes/math/Hash.d.ts b/types/three/src/nodes/math/Hash.d.ts index 57620ad34..bc30544ec 100644 --- a/types/three/src/nodes/math/Hash.d.ts +++ b/types/three/src/nodes/math/Hash.d.ts @@ -1,3 +1,3 @@ import Node from "../core/Node.js"; -export const hash: (seed: Node) => Node; +export const hash: (seed: Node<"int"> | Node<"uint">) => Node<"float">; diff --git a/types/three/src/nodes/math/MathNode.d.ts b/types/three/src/nodes/math/MathNode.d.ts index 2d718b4a8..9d8a446d2 100644 --- a/types/three/src/nodes/math/MathNode.d.ts +++ b/types/three/src/nodes/math/MathNode.d.ts @@ -1,7 +1,8 @@ +import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; +import { Vector4 } from "../../math/Vector4.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -import OperatorNode from "./OperatorNode.js"; export type MathNodeMethod1 = | typeof MathNode.RADIANS @@ -129,319 +130,672 @@ export default class MathNode extends TempNode { constructor(method: MathNodeMethod3, aNode: Node, bNode: Node, cNode: Node); } -export const EPSILON: Node; -export const INFINITY: Node; -export const PI: Node; +type FloatOrNumber = Node<"float"> | number; +type IntOrNumber = Node<"int"> | number; +type FloatVector = Node<"vec2"> | Node<"vec3"> | Node<"vec4">; +type FloatVectorOrNumber = FloatOrNumber | Node<"vec2"> | Node<"vec3"> | Node<"vec4">; -/** - * @deprecated Please use the non-deprecated version `TWO_PI`. - */ -export const PI2: Node; - -export const TWO_PI: Node; +type BoolVector = Node<"bvec2"> | Node<"bvec3"> | Node<"bvec4">; -export const HALF_PI: Node; +type Matrix = Node<"mat2"> | Node<"mat3"> | Node<"mat4">; -type MathNodeParameter = Node | number; +type Vec2OrLessOrFloat = FloatOrNumber | Node<"vec2">; +type Vec3OrLessOrFloat = Vec2OrLessOrFloat | Node<"vec3">; +type Vec4OrLessOrFloat = Vec3OrLessOrFloat | Node<"vec4">; -type Unary = (a: MathNodeParameter) => MathNode; - -export const all: Unary; -export const any: Unary; +export const EPSILON: Node<"float">; +export const INFINITY: Node<"float">; +export const PI: Node<"float">; /** - * @deprecated "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )" - */ -export const equals: Unary; - -export const radians: Unary; -export const degrees: Unary; -export const exp: Unary; -export const exp2: Unary; -export const log: Unary; -export const log2: Unary; -export const sqrt: Unary; -export const inverseSqrt: Unary; -export const floor: Unary; -export const ceil: Unary; -export const normalize: (a: Node | Vector3) => MathNode; -export const fract: Unary; -export const sin: Unary; -export const cos: Unary; -export const tan: Unary; -export const asin: Unary; -export const acos: Unary; -export const atan: (a: MathNodeParameter, b?: MathNodeParameter) => MathNode; -export const abs: Unary; -export const sign: Unary; -export const length: Unary; -export const negate: Unary; -export const oneMinus: Unary; -export const dFdx: Unary; -export const dFdy: Unary; -export const round: Unary; -export const reciprocal: Unary; -export const trunc: Unary; -export const fwidth: Unary; -export const transpose: Unary; -export const determinant: (x: Node) => MathNode; -export const inverse: (x: Node) => MathNode; - -type Binary = (a: MathNodeParameter, b: MathNodeParameter) => MathNode; - -export const min: ( - x: MathNodeParameter, - y: MathNodeParameter, - ...values: MathNodeParameter[] -) => MathNode; -export const max: ( - x: MathNodeParameter, - y: MathNodeParameter, - ...values: MathNodeParameter[] -) => MathNode; -export const step: Binary; -export const reflect: Binary; -export const distance: Binary; -export const difference: Binary; -export const dot: Binary; -export const cross: (x: Node, y: Node) => MathNode; -export const pow: Binary; -export const pow2: Unary; -export const pow3: Unary; -export const pow4: Unary; -export const transformDirection: Binary; -export const cbrt: Unary; -export const lengthSq: Unary; - -type Ternary = (a: MathNodeParameter, b: MathNodeParameter, c: MathNodeParameter) => MathNode; - -export const mix: Ternary; -export const clamp: ( - a: MathNodeParameter, - b?: MathNodeParameter, - c?: MathNodeParameter, -) => MathNode; -export const saturate: Unary; -export const refract: Ternary; -export const smoothstep: Ternary; -export const faceForward: Ternary; - -export const rand: (uv: MathNodeParameter) => OperatorNode; - -export const mixElement: Ternary; -export const smoothstepElement: Ternary; -export const stepElement: Binary; - -/** - * @deprecated + * @deprecated Please use the non-deprecated version `TWO_PI`. */ -export const atan2: Binary; - -// GLSL alias function - -export const faceforward: typeof faceForward; -export const inversesqrt: typeof inverseSqrt; - -// Method chaining - -declare module "../Nodes.js" { - interface Node { - all: () => MathNode; - allAssign: () => this; - - any: () => MathNode; - anyAssign: () => this; - - /** - * @deprecated "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )" - */ - equals: () => MathNode; - /** - * @deprecated "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )" - */ - equalsAssign: () => this; - - radians: () => MathNode; - radiansAssign: () => this; - - degrees: () => MathNode; - degreesAssign: () => this; - - exp: () => MathNode; - expAssign: () => this; +export const PI2: Node<"float">; - exp2: () => MathNode; - exp2Assign: () => this; +export const TWO_PI: Node<"float">; - log: () => MathNode; - logAssign: () => this; +export const HALF_PI: Node<"float">; - log2: () => MathNode; - log2Assign: () => this; - - sqrt: () => MathNode; - sqrtAssign: () => this; - - inverseSqrt: () => MathNode; - inverseSqrtAssign: () => this; - - floor: () => MathNode; - floorAssign: () => this; - - ceil: () => MathNode; - ceilAssign: () => this; - - normalize: () => MathNode; - normalizeAssign: () => this; - - fract: () => MathNode; - fractAssign: () => this; - - sin: () => MathNode; - sinAssign: () => this; - - cos: () => MathNode; - cosAssign: () => this; - - tan: () => MathNode; - tanAssign: () => this; +export const all: (x: BoolVector) => Node<"bool">; +export const any: (x: BoolVector) => Node<"bool">; +declare module "../core/Node.js" { + interface BvecExtensions { + all: () => Node<"bool">; + any: () => Node<"bool">; + } +} - asin: () => MathNode; - asinAssign: () => this; +interface UnaryFunction { + (x: FloatOrNumber): Node<"float">; +} +export const radians: UnaryFunction; +export const degrees: UnaryFunction; +export const exp: UnaryFunction; +export const exp2: UnaryFunction; +export const log: UnaryFunction; +export const log2: UnaryFunction; +export const sqrt: UnaryFunction; +export const inverseSqrt: UnaryFunction; +declare module "../core/Node.js" { + interface FloatExtensions { + radians: () => Node<"float">; + degrees: () => Node<"float">; + exp: () => Node<"float">; + exp2: () => Node<"float">; + log: () => Node<"float">; + log2: () => Node<"float">; + sqrt: () => Node<"float">; + inverseSqrt: () => Node<"float">; + } +} - acos: () => MathNode; - acosAssign: () => this; +interface FloorCeil { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const floor: FloorCeil; +export const ceil: FloorCeil; +declare module "../core/Node.js" { + interface FloatExtensions { + floor: () => Node<"float">; + ceil: () => Node<"float">; + } + interface FloatVectorExtensions { + floor: () => Node; + ceil: () => Node; + } +} - atan: (b?: MathNodeParameter) => MathNode; - atanAssign: (b?: MathNodeParameter) => this; +interface Normalize { + (x: Node<"vec2"> | Vector2): Node<"vec2">; + (x: Node<"vec3"> | Vector3): Node<"vec3">; + (x: Node<"vec4"> | Vector4): Node<"vec4">; +} +export const normalize: Normalize; +declare module "../core/Node.js" { + interface FloatVectorExtensions { + normalize: () => Node; + } +} - abs: () => MathNode; - absAssign: () => this; +interface Fract { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const fract: Fract; +declare module "../core/Node.js" { + interface FloatExtensions { + fract: () => Node<"float">; + } + interface FloatVectorExtensions { + fract: () => Node; + } +} - sign: () => MathNode; - signAssign: () => this; +export const sin: (x: FloatOrNumber) => Node<"float">; +export const cos: (x: FloatOrNumber) => Node<"float">; +export const tan: (x: FloatOrNumber) => Node<"float">; +export const asin: (x: FloatOrNumber) => Node<"float">; +export const acos: (x: FloatOrNumber) => Node<"float">; +export const atan: (y: FloatOrNumber, x?: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + sin: () => Node<"float">; + cos: () => Node<"float">; + tan: () => Node<"float">; + asin: () => Node<"float">; + acos: () => Node<"float">; + atan: (x?: FloatOrNumber) => Node<"float">; + } +} - length: () => MathNode; - lengthAssign: () => this; +interface Abs { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; + (x: IntOrNumber): Node<"int">; +} +export const abs: Abs; +declare module "../core/Node.js" { + interface FloatExtensions { + abs: () => Node<"float">; + } + interface IntExtensions { + abs: () => Node<"int">; + } + interface FloatVectorExtensions { + abs: () => Node; + } +} - lengthSq: () => MathNode; - lengthSqAssign: () => this; +interface Sign { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const sign: Sign; +declare module "../core/Node.js" { + interface FloatExtensions { + sign: () => Node<"float">; + } + interface FloatVectorExtensions { + sign: () => Node; + } +} - negate: () => MathNode; - negateAssign: () => this; +export const length: (x: FloatVector) => Node<"float">; +declare module "../core/Node.js" { + interface FloatVectorExtensions { + length: () => Node<"float">; + } +} - oneMinus: () => MathNode; - oneMinusAssign: () => this; +interface Negate { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const negate: Negate; +declare module "../core/Node.js" { + interface FloatExtensions { + negate: () => Node<"float">; + } + interface FloatVectorExtensions { + negate: () => Node; + } +} - dFdx: () => MathNode; - dFdxAssign: () => this; +interface OneMinus { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const oneMinus: OneMinus; +declare module "../core/Node.js" { + interface FloatExtensions { + oneMinus: () => Node<"float">; + } + interface FloatVectorExtensions { + oneMinus: () => Node; + } +} - dFdy: () => MathNode; - dFdyAssign: () => this; +interface Derivative { + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const dFdx: Derivative; +export const dFdy: Derivative; +declare module "../core/Node.js" { + interface FloatVectorExtensions { + dFdx: () => Node; + dFdy: () => Node; + } +} - round: () => MathNode; - roundAssign: () => this; +export const round: (x: FloatOrNumber) => Node<"float">; +export const reciprocal: (x: FloatOrNumber) => Node<"float">; +export const trunc: (x: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + round: () => Node<"float">; + reciprocal: () => Node<"float">; + trunc: () => Node<"float">; + } +} - reciprocal: () => MathNode; - reciprocalAssign: () => this; +interface Fwidth { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const fwidth: Fwidth; +declare module "../core/Node.js" { + interface FloatExtensions { + fwidth: () => Node<"float">; + } + interface FloatVectorExtensions { + fwidth: () => Node; + } +} - trunc: () => MathNode; - truncAssign: () => this; +interface Transpose { + (x: Node<"mat2">): Node<"mat2">; + (x: Node<"mat3">): Node<"mat3">; + (x: Node<"mat4">): Node<"mat4">; +} +export const transpose: Transpose; +declare module "../core/Node.js" { + interface MatrixExtensions { + transpose: () => Node; + } +} - fwidth: () => MathNode; - fwidthAssign: () => this; +export const determinant: (x: Matrix) => Node<"float">; +declare module "../core/Node.js" { + interface MatrixExtensions { + determinant: () => Node<"float">; + } +} - /** - * @deprecated - */ - atan2: (b: MathNodeParameter) => MathNode; - /** - * @deprecated - */ - atan2Assign: (b: MathNodeParameter) => this; +interface Inverse { + (x: Node<"mat2">): Node<"mat2">; + (x: Node<"mat3">): Node<"mat3">; + (x: Node<"mat4">): Node<"mat4">; +} +export const inverse: Inverse; +declare module "../core/Node.js" { + interface MatrixExtensions { + inverse: () => Node; + } +} - min: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => MathNode; - minAssign: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => this; +export const equals: (x: FloatOrNumber, y: FloatOrNumber) => Node<"bool">; +declare module "../core/Node.js" { + interface FloatExtensions { + equals: (y: FloatOrNumber) => Node<"bool">; + } +} - max: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => MathNode; - maxAssign: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => this; +interface MinMax { + (x: FloatOrNumber, y: FloatOrNumber, ...params: FloatOrNumber[]): Node<"float">; + (x: Vec2OrLessOrFloat, y: Vec2OrLessOrFloat, ...params: Vec2OrLessOrFloat[]): Node<"vec2">; + (x: Vec3OrLessOrFloat, y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (x: Vec4OrLessOrFloat, y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +export const min: MinMax; +export const max: MinMax; +interface MinMaxFloatExtension { + (y: FloatOrNumber, ...params: FloatOrNumber[]): Node<"float">; + (y: Vec2OrLessOrFloat, ...params: Vec2OrLessOrFloat[]): Node<"vec2">; + (y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +interface MinMaxVec2Extension { + (y: Vec2OrLessOrFloat, ...params: Vec2OrLessOrFloat[]): Node<"vec2">; + (y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +interface MinMaxVec3Extension { + (y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +interface MinMaxVec4Extension { + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + min: MinMaxFloatExtension; + max: MinMaxFloatExtension; + } + interface Vec2Extensions { + min: MinMaxVec2Extension; + max: MinMaxVec2Extension; + } + interface Vec3Extensions { + min: MinMaxVec3Extension; + max: MinMaxVec3Extension; + } + interface Vec4Extensions { + min: MinMaxVec4Extension; + max: MinMaxVec4Extension; + } +} - step: (b: MathNodeParameter) => MathNode; - stepAssign: (b: MathNodeParameter) => this; +export const step: (x: FloatOrNumber, y: FloatOrNumber) => Node<"float">; - reflect: (b: MathNodeParameter) => MathNode; - reflectAssign: (b: MathNodeParameter) => this; +interface Reflect { + (I: Vec2OrLessOrFloat, N: Vec2OrLessOrFloat): Node<"vec2">; + (I: Vec3OrLessOrFloat, N: Vec3OrLessOrFloat): Node<"vec3">; + (I: Vec4OrLessOrFloat, N: Vec4OrLessOrFloat): Node<"vec4">; +} +export const reflect: Reflect; +interface ReflectVec2Extension { + (N: Vec2OrLessOrFloat): Node<"vec2">; + (N: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ReflectVec3Extension { + (N: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ReflectVec4Extension { + (N: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface Vec2Extensions { + reflect: ReflectVec2Extension; + } + interface Vec3Extensions { + reflect: ReflectVec3Extension; + } + interface Vec4Extensions { + reflect: ReflectVec4Extension; + } +} - distance: (b: MathNodeParameter) => MathNode; - distanceAssign: (b: MathNodeParameter) => this; +export const distance: (x: FloatVectorOrNumber, y: FloatVectorOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + distance: (y: FloatVectorOrNumber) => Node<"float">; + } + interface FloatVectorExtensions { + distance: (y: FloatVectorOrNumber) => Node<"float">; + } +} - dot: (b: MathNodeParameter) => MathNode; - dotAssign: (b: MathNodeParameter) => this; +interface Difference { + (x: FloatOrNumber, y: FloatOrNumber): Node<"float">; + (x: Vec2OrLessOrFloat, y: Vec2OrLessOrFloat): Node<"vec2">; + (x: Vec3OrLessOrFloat, y: Vec3OrLessOrFloat): Node<"vec3">; + (x: Vec4OrLessOrFloat, y: Vec4OrLessOrFloat): Node<"vec4">; +} +export const difference: Difference; +interface DifferenceFloatExtension { + (y: FloatOrNumber): Node<"float">; + (y: Vec2OrLessOrFloat): Node<"vec2">; + (y: Vec3OrLessOrFloat): Node<"vec3">; + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +interface DifferenceVec2Extension { + (y: Vec2OrLessOrFloat): Node<"vec2">; + (y: Vec3OrLessOrFloat): Node<"vec3">; + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +interface DifferenceVec3Extension { + (y: Vec3OrLessOrFloat): Node<"vec3">; + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +interface DifferenceVec4Extension { + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + difference: DifferenceFloatExtension; + } + interface Vec2Extensions { + difference: DifferenceVec2Extension; + } + interface Vec3Extensions { + difference: DifferenceVec3Extension; + } + interface Vec4Extensions { + difference: DifferenceVec4Extension; + } +} - cross: (y: Node) => MathNode; - crossAssign: (y: Node) => this; +export const dot: (x: FloatVector, y: FloatVector) => Node<"float">; +declare module "../core/Node.js" { + interface FloatVectorExtensions { + dot: (y: FloatVector) => Node<"float">; + } +} - pow: (b: MathNodeParameter) => MathNode; - powAssign: (b: MathNodeParameter) => this; +export const cross: (x: Node<"vec3">, y: Node<"vec3">) => Node<"vec3">; +declare module "../core/Node.js" { + interface Vec3Extensions { + cross: (y: Node<"vec3">) => Node<"vec3">; + } +} - pow2: () => MathNode; - pow2Assign: () => this; +interface Pow { + (x: FloatOrNumber, y: FloatOrNumber): Node<"float">; + (x: Node<"vec2">, y: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">, y: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">, y: Node<"vec4">): Node<"vec4">; +} +export const pow: (x: FloatOrNumber, y: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + pow: (y: FloatOrNumber) => Node<"float">; + } + interface FloatVectorExtensions { + pow: (y: Node) => Node; + } +} - pow3: () => MathNode; - pow3Assign: () => this; +interface PowConstant { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const pow2: PowConstant; +export const pow3: PowConstant; +export const pow4: PowConstant; +declare module "../core/Node.js" { + interface FloatExtensions { + pow2: () => Node<"float">; + pow3: () => Node<"float">; + pow4: () => Node<"float">; + } + interface FloatVectorExtensions { + pow2: () => Node; + pow3: () => Node; + pow4: () => Node; + } +} - pow4: () => MathNode; - pow4Assign: () => this; +export const transformDirection: (direction: Node<"vec3">, matrix: Node<"mat3"> | Node<"mat4">) => Node<"vec3">; +declare module "../core/Node.js" { + interface Vec3Extensions { + transformDirection: (matrix: Node<"mat3"> | Node<"mat4">) => Node<"vec3">; + } +} - transformDirection: (b: MathNodeParameter) => MathNode; - transformDirectionAssign: (b: MathNodeParameter) => this; +export const cbrt: (a: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + cbrt: () => Node<"float">; + } +} - mix: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - mixAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +export const lengthSq: (a: FloatVector) => Node<"float">; +declare module "../core/Node.js" { + interface FloatVectorExtensions { + lengthSq: () => Node<"float">; + } +} - clamp: (b?: MathNodeParameter, c?: MathNodeParameter) => MathNode; - clampAssign: (b?: MathNodeParameter, c?: MathNodeParameter) => this; +interface Mix { + (a: FloatOrNumber, b: FloatOrNumber, t: FloatOrNumber): Node<"float">; + (a: Vec2OrLessOrFloat, b: Vec2OrLessOrFloat, t: FloatOrNumber): Node<"vec2">; + (a: Vec3OrLessOrFloat | Node<"color">, b: Vec3OrLessOrFloat | Node<"color">, t: FloatOrNumber): Node<"vec3">; + (a: Vec4OrLessOrFloat, b: Vec4OrLessOrFloat, t: FloatOrNumber): Node<"vec4">; +} +export const mix: Mix; - refract: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - refractAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface Clamp { + (value: FloatOrNumber, low?: FloatOrNumber, high?: FloatOrNumber): Node<"float">; + (value: Vec2OrLessOrFloat, low?: Vec2OrLessOrFloat, high?: Vec2OrLessOrFloat): Node<"vec2">; + (value: Vec3OrLessOrFloat, low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (value: Vec4OrLessOrFloat, low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +export const clamp: Clamp; +interface ClampFloatExtension { + (low?: FloatOrNumber, high?: FloatOrNumber): Node<"float">; + (low?: Vec2OrLessOrFloat, high?: Vec2OrLessOrFloat): Node<"vec2">; + (low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ClampVec2Extension { + (low?: Vec2OrLessOrFloat, high?: Vec2OrLessOrFloat): Node<"vec2">; + (low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ClampVec3Extension { + (low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ClampVec4Extension { + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + clamp: ClampFloatExtension; + } + interface Vec2Extensions { + clamp: ClampVec2Extension; + } + interface Vec3Extensions { + clamp: ClampVec3Extension; + } + interface Vec4Extensions { + clamp: ClampVec4Extension; + } +} - smoothstep: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - smoothstepAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface Saturate { + (value: FloatOrNumber): Node<"float">; + (value: Node<"vec2">): Node<"vec2">; + (value: Node<"vec3">): Node<"vec3">; + (value: Node<"vec4">): Node<"vec4">; +} +export const saturate: Saturate; +declare module "../core/Node.js" { + interface FloatExtensions { + saturate: () => Node<"float">; + } + interface FloatVectorExtensions { + saturate: () => Node; + } +} - faceForward: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - faceForwardAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface Refract { + (I: Vec2OrLessOrFloat, N: Vec2OrLessOrFloat, ratio: FloatOrNumber): Node<"vec2">; + (I: Vec3OrLessOrFloat, N: Vec3OrLessOrFloat, ratio: FloatOrNumber): Node<"vec3">; + (I: Vec4OrLessOrFloat, N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +export const refract: Refract; +interface RefractVec2Extension { + (N: Vec2OrLessOrFloat, ratio: FloatOrNumber): Node<"vec2">; + (N: Vec3OrLessOrFloat, ratio: FloatOrNumber): Node<"vec3">; + (N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +interface RefractVec3Extension { + (N: Vec3OrLessOrFloat, ratio: FloatOrNumber): Node<"vec3">; + (N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +interface RefractVec4Extension { + (N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +declare module "../core/Node.js" { + interface Vec2Extensions { + refract: RefractVec2Extension; + } + interface Vec3Extensions { + refract: RefractVec3Extension; + } + interface Vec4Extensions { + refract: RefractVec4Extension; + } +} - difference: (b: MathNodeParameter) => MathNode; - differenceAssign: (b: MathNodeParameter) => this; +interface Smoothstep { + (low: FloatOrNumber, high: FloatOrNumber, x: FloatOrNumber): Node<"float">; +} +export const smoothstep: Smoothstep; - saturate: () => MathNode; - saturateAssign: () => this; +interface FaceForward { + (N: Vec2OrLessOrFloat, I: Vec2OrLessOrFloat, Nref: Vec2OrLessOrFloat): Node<"vec2">; + (N: Vec3OrLessOrFloat, I: Vec3OrLessOrFloat, Nref: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat, I: Vec4OrLessOrFloat, Nref: Vec4OrLessOrFloat): Node<"vec4">; +} +export const faceForward: FaceForward; +interface FaceForwardVec2Extension { + (I: Vec2OrLessOrFloat, Nref: Vec2OrLessOrFloat): Node<"vec2">; + (I: Vec3OrLessOrFloat, Nref: Vec3OrLessOrFloat): Node<"vec3">; + (I: Vec4OrLessOrFloat, Nref: Vec4OrLessOrFloat): Node<"vec4">; +} +interface FaceForwardVec3Extension { + (N: Vec3OrLessOrFloat, ratio: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat, ratio: Vec4OrLessOrFloat): Node<"vec4">; +} +interface FaceForwardVec4Extension { + (N: Vec4OrLessOrFloat, ratio: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface Vec2Extensions { + faceForward: FaceForwardVec2Extension; + } + interface Vec3Extensions { + faceForward: FaceForwardVec3Extension; + } + interface Vec4Extensions { + faceForward: FaceForwardVec4Extension; + } +} - cbrt: () => MathNode; - cbrtAssign: () => this; +export const rand: (uv: Node<"vec2">) => Node<"float">; +declare module "../core/Node.js" { + interface Vec2Extensions { + rand: () => Node<"float">; + } +} - transpose: () => MathNode; - transposeAssign: () => this; +interface MixElement { + (t: FloatOrNumber, e1: FloatOrNumber, e2: FloatOrNumber): Node<"float">; + (t: FloatOrNumber, e1: Vec2OrLessOrFloat, e2: Vec2OrLessOrFloat): Node<"vec2">; + (t: FloatOrNumber, e1: Vec3OrLessOrFloat | Node<"color">, e2: Vec3OrLessOrFloat | Node<"color">): Node<"vec3">; + (t: FloatOrNumber, e1: Vec4OrLessOrFloat, e2: Vec4OrLessOrFloat): Node<"vec4">; +} +export const mixElement: MixElement; +interface MixExtension { + (e1: FloatOrNumber, e2: FloatOrNumber): Node<"float">; + (e1: Vec2OrLessOrFloat, e2: Vec2OrLessOrFloat): Node<"vec2">; + (e1: Vec3OrLessOrFloat | Node<"color">, e2: Vec3OrLessOrFloat | Node<"color">): Node<"vec3">; + (e1: Vec4OrLessOrFloat | Node<"color">, e2: Vec4OrLessOrFloat | Node<"color">): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + mix: MixExtension; + } +} - determinant: () => MathNode; - determinantAssign: () => this; +interface SmoothstepElement { + (x: FloatOrNumber, low: FloatOrNumber, high: FloatOrNumber): Node<"float">; +} +export const smoothstepElement: SmoothstepElement; +interface SmoothstepExtension { + (low: FloatOrNumber, high: FloatOrNumber): Node<"float">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + smoothstep: SmoothstepExtension; + } +} - inverse: () => MathNode; - inverseAssign: () => this; +export const stepElement: (x: FloatOrNumber, edge: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + step: (edge: FloatOrNumber) => Node<"float">; + } +} - rand: () => OperatorNode; - randAssign: () => this; +/** + * @deprecated + */ +export const atan2: typeof atan; +declare module "../core/Node.js" { + interface FloatExtensions { + /** + * @deprecated + */ + atan2: (x?: FloatOrNumber) => Node<"float">; } } + +// GLSL alias function + +export const faceforward: typeof faceForward; +export const inversesqrt: typeof inverseSqrt; diff --git a/types/three/src/nodes/math/MathUtils.d.ts b/types/three/src/nodes/math/MathUtils.d.ts index 572d9eef5..5261fafac 100644 --- a/types/three/src/nodes/math/MathUtils.d.ts +++ b/types/three/src/nodes/math/MathUtils.d.ts @@ -1,6 +1,10 @@ -import { Binary, Ternary } from "./MathNode.js"; +import Node from "../core/Node.js"; -export const parabola: Binary; -export const gain: Binary; -export const pcurve: Ternary; -export const sinc: Binary; +type FloatOrNumber = Node<"float"> | number; + +export const parabola: (x: FloatOrNumber, k: FloatOrNumber) => Node<"float">; +export const gain: (x: FloatOrNumber, k: FloatOrNumber) => Node<"float">; +export const pcurve: (x: FloatOrNumber, a: FloatOrNumber, b: FloatOrNumber) => Node<"float">; +export const sinc: (x: FloatOrNumber, k: FloatOrNumber) => Node<"float">; + +export {}; diff --git a/types/three/src/nodes/math/OperatorNode.d.ts b/types/three/src/nodes/math/OperatorNode.d.ts index fc9fdde0d..eece6633b 100644 --- a/types/three/src/nodes/math/OperatorNode.d.ts +++ b/types/three/src/nodes/math/OperatorNode.d.ts @@ -1,4 +1,4 @@ -import Node from "../core/Node.js"; +import Node, { IntegerType, NumberType } from "../core/Node.js"; import TempNode from "../core/TempNode.js"; export type OperatorNodeOp = @@ -32,244 +32,507 @@ export default class OperatorNode extends TempNode { constructor(op: OperatorNodeOp, ...params: [Node, Node, ...Node[]]); } -type OperatorNodeParameter = Node | number; - -export const add: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const sub: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const mul: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const div: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const mod: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const equal: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const notEqual: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const lessThan: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const greaterThan: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const lessThanEqual: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const greaterThanEqual: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const and: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const or: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const not: (value: OperatorNodeParameter) => OperatorNode; -export const xor: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitAnd: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitNot: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitOr: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitXor: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const shiftLeft: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const shiftRight: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; - -export const incrementBefore: (a: OperatorNodeParameter) => Node; -export const decrementBefore: (a: OperatorNodeParameter) => Node; -export const increment: (a: OperatorNodeParameter) => Node; -export const decrement: (a: OperatorNodeParameter) => Node; - -declare module "../Nodes.js" { - interface Node { - add: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - addAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - sub: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - subAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - mul: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - mulAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - div: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - divAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - mod: ( - b: OperatorNodeParameter, - ) => OperatorNode; - modAssign: ( - b: OperatorNodeParameter, - ) => this; - - equal: ( - b: OperatorNodeParameter, - ) => OperatorNode; - equalAssign: ( - b: OperatorNodeParameter, - ) => this; - - notEqual: ( - b: OperatorNodeParameter, - ) => OperatorNode; - notEqualAssign: ( - b: OperatorNodeParameter, - ) => this; - - lessThan: ( - b: OperatorNodeParameter, - ) => OperatorNode; - lessThanAssign: ( - b: OperatorNodeParameter, - ) => this; - - greaterThan: ( - b: OperatorNodeParameter, - ) => OperatorNode; - greaterThanAssign: ( - b: OperatorNodeParameter, - ) => this; - - lessThanEqual: ( - b: OperatorNodeParameter, - ) => OperatorNode; - lessThanEqualAssign: ( - b: OperatorNodeParameter, - ) => this; - - greaterThanEqual: ( - b: OperatorNodeParameter, - ) => OperatorNode; - greaterThanEqualAssign: ( - b: OperatorNodeParameter, - ) => this; - - and: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - andAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - or: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - orAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - not: () => OperatorNode; - notAssign: () => this; - - xor: ( - b: OperatorNodeParameter, - ) => OperatorNode; - xorAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitAnd: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitAndAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitNot: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitNotAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitOr: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitOrAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitXor: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitXorAssign: ( - b: OperatorNodeParameter, - ) => this; - - shiftLeft: ( - b: OperatorNodeParameter, - ) => OperatorNode; - shiftLeftAssign: ( - b: OperatorNodeParameter, - ) => this; - - shiftRight: ( - b: OperatorNodeParameter, - ) => OperatorNode; - shiftRightAssign: ( - b: OperatorNodeParameter, - ) => this; - - incrementBefore: () => OperatorNode; - incrementBeforeAssign: () => this; - - decrementBefore: () => OperatorNode; - decrementBeforeAssign: () => this; - - increment: () => OperatorNode; - incrementAssign: () => this; - - decrement: () => OperatorNode; - decrementAssign: () => this; +type Vec2OrLess = Node<"vec2">; +type Vec3OrLess = Vec2OrLess | Node<"vec3">; +type Vec4OrLess = Vec3OrLess | Node<"vec4">; + +type NumberToVec = { + float: "vec"; + int: "ivec"; + uint: "uvec"; +}; + +type NumberToVec2 = `${NumberToVec[TNumber]}2`; +type NumberToVec3 = `${NumberToVec[TNumber]}3`; +type NumberToVec4 = `${NumberToVec[TNumber]}4`; + +type Number = Node | number; +type Vec2OrLessOrNumber = Number | Node>; +type Vec3OrLessOrNumber = Vec2OrLessOrNumber | Node>; +type Vec4OrLessOrNumber = Vec3OrLessOrNumber | Node>; + +type AnyNumber = Node<"float"> | Node<"int"> | Node<"uint"> | number; + +// add/sub/mul/div + +// add/sub/mul/div numbers and/or vecs +// Every parameter gets converted to the longest type +// If the parameters are the same length, it gets converted to the first type +// FIXME We handle the case of converting number types, but not converting between vectors of different number types + +interface AddSubMulDivNumberVec { + (a: Number, b: AnyNumber, ...params: AnyNumber[]): Node; + ( + a: Vec2OrLessOrNumber, + b: Vec2OrLessOrNumber, + ...params: Vec2OrLessOrNumber[] + ): Node>; + ( + a: Vec3OrLessOrNumber, + b: Vec3OrLessOrNumber, + ...params: Vec3OrLessOrNumber[] + ): Node>; + ( + a: Vec4OrLessOrNumber, + b: Vec4OrLessOrNumber, + ...params: Vec4OrLessOrNumber[] + ): Node>; +} + +interface AddSubMulDivNumberVecNumberExtensions { + (b: AnyNumber, ...params: AnyNumber[]): Node; + (b: Vec2OrLessOrNumber, ...params: Vec2OrLessOrNumber[]): Node>; + (b: Vec3OrLessOrNumber, ...params: Vec3OrLessOrNumber[]): Node>; + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecNumberAssignExtensions { + ( + b: Vec4OrLessOrNumber<"float"> | Vec4OrLessOrNumber<"int"> | Vec4OrLessOrNumber<"uint">, + ...params: (Vec4OrLessOrNumber<"float"> | Vec4OrLessOrNumber<"int"> | Vec4OrLessOrNumber<"uint">)[] + ): this; +} + +interface AddSubMulDivNumberVecVec2Extensions { + (b: Vec2OrLessOrNumber, ...params: Vec2OrLessOrNumber[]): Node>; + (b: Vec3OrLessOrNumber, ...params: Vec3OrLessOrNumber[]): Node>; + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecVec2AssignExtensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): this; +} + +interface AddSubMulDivNumberVecVec3Extensions { + (b: Vec3OrLessOrNumber, ...params: Vec3OrLessOrNumber[]): Node>; + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecVec3AssignExtensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): this; +} + +interface AddSubMulDivNumberVecVec4Extensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecVec4AssignExtensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): this; +} + +// add/sub/mul mats + +interface AddSubMulMat { + (a: Node<"mat2">, b: Node<"mat2">): Node<"mat2">; + (a: Node<"mat3">, b: Node<"mat3">): Node<"mat3">; + (a: Node<"mat4">, b: Node<"mat4">): Node<"mat4">; +} + +interface AddSubMulMat2Extensions { + (b: Node<"mat2">): Node<"mat2">; +} + +interface AddSubMulMat2AssignExtensions { + (b: Node<"mat2">): this; +} + +interface AddSubMulMat3Extensions { + (b: Node<"mat3">): Node<"mat3">; +} + +interface AddSubMulMat3AssignExtensions { + (b: Node<"mat3">): this; +} + +interface AddSubMulMat4Extensions { + (b: Node<"mat4">): Node<"mat4">; +} + +interface AddSubMulMat4AssignExtensions { + (b: Node<"mat3">): this; +} + +// mut mats and vecs +// The vec parameter gets converted to matrix length + +interface MulMatVec { + (a: Node<"mat2">, b: Vec4OrLess): Node<"vec2">; + (a: Node<"mat3">, b: Vec4OrLess): Node<"vec3">; + (a: Node<"mat4">, b: Vec4OrLess): Node<"vec4">; + (a: Vec4OrLess, b: Node<"mat2">): Node<"vec2">; + (a: Vec4OrLess, b: Node<"mat3">): Node<"vec3">; + (a: Vec4OrLess, b: Node<"mat4">): Node<"vec4">; +} + +interface MulVecMatMat2Extensions { + (b: Vec4OrLess): Node<"vec2">; +} + +interface MulVecMatMat3Extensions { + (b: Vec4OrLess): Node<"vec3">; +} + +interface MulVecMatMat4Extensions { + (b: Vec4OrLess): Node<"vec4">; +} + +interface MulVecMatVecExtensions { + (b: Node<"mat2">): Node<"vec2">; + (b: Node<"mat3">): Node<"vec3">; + (b: Node<"mat4">): Node<"vec4">; +} + +// Exports + +interface AddSub + extends AddSubMulDivNumberVec<"float">, AddSubMulDivNumberVec<"int">, AddSubMulDivNumberVec<"uint">, AddSubMulMat +{} + +export const add: AddSub; +export const sub: AddSub; + +interface Mul + extends + AddSubMulDivNumberVec<"float">, + AddSubMulDivNumberVec<"int">, + AddSubMulDivNumberVec<"uint">, + AddSubMulMat, + MulMatVec +{ +} + +interface MulVec2Extensions + extends AddSubMulDivNumberVecVec2Extensions, MulVecMatVecExtensions +{ +} + +interface MulVec3Extensions + extends AddSubMulDivNumberVecVec3Extensions, MulVecMatVecExtensions +{ +} + +interface MulVec4Extensions + extends AddSubMulDivNumberVecVec4Extensions, MulVecMatVecExtensions +{ +} + +interface MulMat2Extensions extends AddSubMulMat2Extensions, MulVecMatMat2Extensions { +} + +interface MulMat3Extensions extends AddSubMulMat3Extensions, MulVecMatMat3Extensions { +} + +interface MulMat4Extensions extends AddSubMulMat4Extensions, MulVecMatMat4Extensions { +} + +export const mul: Mul; + +interface Div extends AddSubMulDivNumberVec<"float">, AddSubMulDivNumberVec<"int">, AddSubMulDivNumberVec<"uint"> { +} +export const div: Div; + +declare module "../core/Node.js" { + interface FloatExtensions { + mul: (b: Node<"color">) => Node<"vec3">; + } + + interface NumberExtensions { + add: AddSubMulDivNumberVecNumberExtensions; + sub: AddSubMulDivNumberVecNumberExtensions; + mul: AddSubMulDivNumberVecNumberExtensions; + div: AddSubMulDivNumberVecNumberExtensions; + + addAssign: AddSubMulDivNumberVecNumberAssignExtensions; + subAssign: AddSubMulDivNumberVecNumberAssignExtensions; + mulAssign: AddSubMulDivNumberVecNumberAssignExtensions; + divAssign: AddSubMulDivNumberVecNumberAssignExtensions; + } + + interface Vec2Extensions { + add: (b: Node<"color">) => Node<"vec3">; + mul: (b: Node<"color">) => Node<"vec3">; + } + + interface Vec3Extensions { + add: (b: Node<"color">) => Node<"vec3">; + mul: (b: Node<"color">) => Node<"vec3">; + } + + interface Vec4Extensions { + add: (b: Node<"color">) => Node<"vec4">; + mul: (b: Node<"color">) => Node<"vec4">; + } + + interface ColorExtensions { + add: (b: Number<"float">) => Node<"vec3">; + sub: (b: Number<"float">) => Node<"vec3">; + mul: (b: Number<"float">) => Node<"vec3">; + div: (b: Number<"float">) => Node<"vec3">; + } + + interface NumberVec2Extensions { + add: AddSubMulDivNumberVecVec2Extensions; + sub: AddSubMulDivNumberVecVec2Extensions; + mul: MulVec2Extensions; + div: AddSubMulDivNumberVecVec2Extensions; + + addAssign: AddSubMulDivNumberVecVec2AssignExtensions; + subAssign: AddSubMulDivNumberVecVec2AssignExtensions; + mulAssign: AddSubMulDivNumberVecVec2AssignExtensions; + divAssign: AddSubMulDivNumberVecVec2AssignExtensions; + } + + interface NumberVec3Extensions { + add: AddSubMulDivNumberVecVec3Extensions; + sub: AddSubMulDivNumberVecVec3Extensions; + mul: MulVec3Extensions; + div: AddSubMulDivNumberVecVec3Extensions; + + addAssign: AddSubMulDivNumberVecVec3AssignExtensions; + subAssign: AddSubMulDivNumberVecVec3AssignExtensions; + mulAssign: AddSubMulDivNumberVecVec3AssignExtensions; + divAssign: AddSubMulDivNumberVecVec3AssignExtensions; + } + + interface NumberVec4Extensions { + add: AddSubMulDivNumberVecVec4Extensions; + sub: AddSubMulDivNumberVecVec4Extensions; + mul: MulVec4Extensions; + div: AddSubMulDivNumberVecVec4Extensions; + + addAssign: AddSubMulDivNumberVecVec4AssignExtensions; + subAssign: AddSubMulDivNumberVecVec4AssignExtensions; + mulAssign: AddSubMulDivNumberVecVec4AssignExtensions; + divAssign: AddSubMulDivNumberVecVec4AssignExtensions; + } + + interface Matrix2Extensions { + add: AddSubMulMat2Extensions; + sub: AddSubMulMat2Extensions; + mul: MulMat2Extensions; + + addAssign: AddSubMulMat2AssignExtensions; + subAssign: AddSubMulMat2AssignExtensions; + mulAssign: AddSubMulMat2AssignExtensions; + } + + interface Matrix3Extensions { + add: AddSubMulMat3Extensions; + sub: AddSubMulMat3Extensions; + mul: MulMat3Extensions; + + addAssign: AddSubMulMat3AssignExtensions; + subAssign: AddSubMulMat3AssignExtensions; + mulAssign: AddSubMulMat3AssignExtensions; + } + + interface Matrix4Extensions { + add: AddSubMulMat4Extensions; + sub: AddSubMulMat4Extensions; + mul: MulMat4Extensions; + + addAssign: AddSubMulMat4AssignExtensions; + subAssign: AddSubMulMat4AssignExtensions; + mulAssign: AddSubMulMat4AssignExtensions; + } +} + +// mod + +interface Mod { + (a: Number<"float">, b: Vec4OrLessOrNumber<"float">): Node<"float">; + (a: Node<"vec2">, b: Vec4OrLessOrNumber<"float">): Node<"vec2">; + (a: Node<"vec3">, b: Vec4OrLessOrNumber<"float">): Node<"vec3">; + (a: Node<"vec4">, b: Vec4OrLessOrNumber<"float">): Node<"vec4">; + + (a: Number<"int">, b: Vec4OrLessOrNumber<"int">): Node<"int">; + (a: Node<"ivec2">, b: Vec4OrLessOrNumber<"int">): Node<"ivec2">; + (a: Node<"ivec3">, b: Vec4OrLessOrNumber<"int">): Node<"ivec3">; + (a: Node<"ivec4">, b: Vec4OrLessOrNumber<"int">): Node<"ivec4">; + + (a: Number<"uint">, b: Vec4OrLessOrNumber<"uint">): Node<"uint">; + (a: Node<"uvec2">, b: Vec4OrLessOrNumber<"uint">): Node<"uvec2">; + (a: Node<"uvec3">, b: Vec4OrLessOrNumber<"uint">): Node<"uvec3">; + (a: Node<"uvec4">, b: Vec4OrLessOrNumber<"uint">): Node<"uvec4">; +} + +export const mod: Mod; + +declare module "../core/Node.js" { + interface NumberExtensions { + mod: (b: Vec4OrLessOrNumber) => Node; + modAssign: (b: Vec4OrLessOrNumber) => this; + } + interface NumberVec2Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } + interface NumberVec3Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } + interface NumberVec4Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } +} + +// Comparison operators + +interface ComparisonOperator { + (a: Number<"float">, b: Number<"float">): Node<"bool">; + (a: Number<"int"> | Number<"uint">, b: Number<"int"> | Number<"uint">): Node<"bool">; +} +export const equal: ComparisonOperator; +export const notEqual: ComparisonOperator; +export const lessThan: ComparisonOperator; +export const greaterThan: ComparisonOperator; +export const lessThanEqual: ComparisonOperator; +export const greaterThanEqual: ComparisonOperator; + +interface ComparisonOperatorNumberExtensions { + (b: Number): Node<"bool">; +} + +declare module "../core/Node.js" { + interface FloatExtensions { + equal: ComparisonOperatorNumberExtensions<"float">; + notEqual: ComparisonOperatorNumberExtensions<"float">; + lessThan: ComparisonOperatorNumberExtensions<"float">; + greaterThan: ComparisonOperatorNumberExtensions<"float">; + lessThanEqual: ComparisonOperatorNumberExtensions<"float">; + greaterThanEqual: ComparisonOperatorNumberExtensions<"float">; + } + + interface IntExtensions { + equal: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + notEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + } + + interface UintExtensions { + equal: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + notEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + } +} + +// and/or/not/xor + +interface AndOr { + (a: Node<"bool">, b: Node<"bool">, ...params: Node<"bool">[]): Node<"bool">; +} +export const and: AndOr; +export const or: AndOr; + +interface AndOrBoolExtensions { + (b: Node<"bool">, ...params: Node<"bool">[]): Node<"bool">; +} + +export const not: (a: Node<"bool">) => Node<"bool">; +export const xor: (a: Node<"bool">, b: Node<"bool">) => Node<"bool">; + +declare module "../core/Node.js" { + interface BoolExtensions { + and: AndOrBoolExtensions; + or: AndOrBoolExtensions; + not: () => Node<"bool">; + xor: (b: Node<"bool">) => Node<"bool">; + } +} + +// bit operators + +interface UnaryBitOperator { + (a: Number<"int">): Node<"int">; + (a: Number<"uint">): Node<"uint">; +} + +interface BinaryBitOperator { + (a: Number<"int">, b: Number<"int">): Node<"int">; + (a: Number<"uint">, b: Number<"uint">): Node<"uint">; +} + +export const bitAnd: BinaryBitOperator; +export const bitNot: UnaryBitOperator; +export const bitOr: BinaryBitOperator; +export const bitXor: BinaryBitOperator; +export const shiftLeft: BinaryBitOperator; +export const shiftRight: BinaryBitOperator; + +interface BinaryBitOperatorIntegerExtensions { + (b: Number): Node; +} + +interface BinaryBitOperatorIntegerAssignExtensions { + (b: Number): this; +} + +declare module "../core/Node.js" { + interface IntegerExtensions { + bitAnd: BinaryBitOperatorIntegerExtensions; + bitNot: () => Node; + bitOr: BinaryBitOperatorIntegerExtensions; + bitXor: BinaryBitOperatorIntegerExtensions; + shiftLeft: BinaryBitOperatorIntegerExtensions; + shiftRight: BinaryBitOperatorIntegerExtensions; + + bitAndAssign: BinaryBitOperatorIntegerAssignExtensions; + bitNotAssign: () => this; + bitOrAssign: BinaryBitOperatorIntegerAssignExtensions; + bitXorAssign: BinaryBitOperatorIntegerAssignExtensions; + shiftLeftAssign: BinaryBitOperatorIntegerAssignExtensions; + shiftRightAssign: BinaryBitOperatorIntegerAssignExtensions; + } +} + +// increment/decrement + +interface IncrementDecrement { + (a: Number<"int">): Node<"int">; + (a: Number<"uint">): Node<"uint">; +} + +export const incrementBefore: IncrementDecrement; +export const decrementBefore: IncrementDecrement; +export const increment: IncrementDecrement; +export const decrement: IncrementDecrement; + +interface IncrementDecrementIntegerExtensions { + (): Node; +} + +declare module "../core/Node.js" { + interface IntegerExtensions { + incrementBefore: IncrementDecrementIntegerExtensions; + decrementBefore: IncrementDecrementIntegerExtensions; + increment: IncrementDecrementIntegerExtensions; + decrement: IncrementDecrementIntegerExtensions; } } /** * @deprecated "modInt()" is deprecated. Use "mod( int( ... ) )" instead. */ -export const modInt: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; +export const modInt: Mod; -declare module "../Nodes.js" { - interface Nodes { +declare module "../core/Node.js" { + interface NumberExtensions { /** * @deprecated "modInt()" is deprecated. Use "mod( int( ... ) )" instead. */ - modInt: (b: OperatorNodeParameter) => OperatorNode; + modInt: (b: Number) => Node; /** * @deprecated "modInt()" is deprecated. Use "mod( int( ... ) )" instead. */ - modIntAssign: (b: OperatorNodeParameter) => this; + modIntAssign: (b: Number) => this; } } + +export {}; diff --git a/types/three/src/nodes/math/TriNoise3D.d.ts b/types/three/src/nodes/math/TriNoise3D.d.ts index c1ca74b94..e009b7d05 100644 --- a/types/three/src/nodes/math/TriNoise3D.d.ts +++ b/types/three/src/nodes/math/TriNoise3D.d.ts @@ -1,11 +1,11 @@ import Node from "../core/Node.js"; -export const tri: (x: Node) => Node; +export const tri: (x: Node<"float">) => Node<"float">; -export const tri3: (p: Node) => Node; +export const tri3: (p: Node<"vec3">) => Node<"vec3">; export const triNoise3D: ( - position: Node, - speed: Node | number, - time: Node | number, -) => Node; + position: Node<"vec3">, + speed: Node<"float"> | number, + time: Node<"float"> | number, +) => Node<"float">; diff --git a/types/three/src/nodes/pmrem/PMREMNode.d.ts b/types/three/src/nodes/pmrem/PMREMNode.d.ts index 6e52fb81c..a5b385afa 100644 --- a/types/three/src/nodes/pmrem/PMREMNode.d.ts +++ b/types/three/src/nodes/pmrem/PMREMNode.d.ts @@ -2,7 +2,7 @@ import { Texture } from "../../textures/Texture.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class PMREMNode extends TempNode { +declare class PMREMNode extends TempNode<"vec3"> { uvNode: Node | null; levelNode: Node | null; diff --git a/types/three/src/nodes/procedural/Checker.d.ts b/types/three/src/nodes/procedural/Checker.d.ts index bcde98423..ffcf73ce7 100644 --- a/types/three/src/nodes/procedural/Checker.d.ts +++ b/types/three/src/nodes/procedural/Checker.d.ts @@ -1,3 +1,3 @@ import Node from "../core/Node.js"; -export const checker: (coord?: Node) => Node; +export const checker: (coord?: Node<"vec2">) => Node<"float">; diff --git a/types/three/src/nodes/tsl/TSLCore.d.ts b/types/three/src/nodes/tsl/TSLCore.d.ts index e8ebdcbfe..2d6a2e990 100644 --- a/types/three/src/nodes/tsl/TSLCore.d.ts +++ b/types/three/src/nodes/tsl/TSLCore.d.ts @@ -6,91 +6,1705 @@ import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; import { Vector4 } from "../../math/Vector4.js"; import ConstNode from "../core/ConstNode.js"; -import Node from "../core/Node.js"; +import Node, { NumOrBoolType } from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; import StackNode from "../core/StackNode.js"; -import JoinNode from "../utils/JoinNode.js"; export function addMethodChaining(name: string, nodeElement: unknown): void; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { assign: (sourceNode: Node | number) => this; get: (value: string) => Node; } } -type XYZWCharacter = "x" | "y" | "z" | "w"; -type RGBACharacter = "r" | "g" | "b" | "a"; -type STPQCharacter = "s" | "t" | "p" | "q"; - -type XYZWSwizzle = - | `${XYZWCharacter}` - | `${XYZWCharacter}${XYZWCharacter}` - | `${XYZWCharacter}${XYZWCharacter}${XYZWCharacter}` - | `${XYZWCharacter}${XYZWCharacter}${XYZWCharacter}${XYZWCharacter}`; - -type RGBASwizzle = - | `${RGBACharacter}` - | `${RGBACharacter}${RGBACharacter}` - | `${RGBACharacter}${RGBACharacter}${RGBACharacter}` - | `${RGBACharacter}${RGBACharacter}${RGBACharacter}${RGBACharacter}`; - -type STPQSwizzle = - | `${STPQCharacter}` - | `${STPQCharacter}${STPQCharacter}` - | `${STPQCharacter}${STPQCharacter}${STPQCharacter}` - | `${STPQCharacter}${STPQCharacter}${STPQCharacter}${STPQCharacter}`; - -export type SwizzleOption = XYZWSwizzle | RGBASwizzle | STPQSwizzle; - -export type ArrayElementIndex = - | 0 - | 1 - | 2 - | 3 - | 4 - | 5 - | 6 - | 7 - | 8 - | 9 - | 10 - | 11 - | 12 - | 13 - | 14 - | 15 - | 16 - | 17 - | 18 - | 19 - | 20 - | 21 - | 22 - | 23 - | 24 - | 25 - | 26 - | 27 - | 28 - | 29 - | 30 - | 31; - -export type Swizzable = - & { - [Key in SwizzleOption | ArrayElementIndex]: Node; +type NumOrBoolToJsType = { + float: number; + int: number; + uint: number; + bool: boolean; +}; +type NumOrBool = Node | NumOrBoolToJsType[TNumOrBool]; + +type NumOrBoolToVec = { + float: "vec"; + int: "ivec"; + uint: "uvec"; + bool: "bvec"; +}; +type NumOrBoolToVec2 = `${NumOrBoolToVec[TNumOrBool]}2`; +type NumOrBoolToVec3 = `${NumOrBoolToVec[TNumOrBool]}3`; +type NumOrBoolToVec4 = `${NumOrBoolToVec[TNumOrBool]}4`; + +interface Swizzle1From1 { + get x(): Node; + set x(value: NumOrBool); + get r(): Node; + set r(value: NumOrBool); + get s(): Node; + set s(value: NumOrBool); +} + +interface Swizzle1From2 extends Swizzle1From1 { + get y(): Node; + set y(value: NumOrBool); + get g(): Node; + set g(value: NumOrBool); + get t(): Node; + set t(value: NumOrBool); +} + +interface Swizzle1From3 extends Swizzle1From2 { + get z(): Node; + set z(value: NumOrBool); + get b(): Node; + set b(value: NumOrBool); + get p(): Node; + set p(value: NumOrBool); +} + +interface Swizzle1From4 extends Swizzle1From3 { + get w(): Node; + set w(value: NumOrBool); + get a(): Node; + set a(value: NumOrBool); + get q(): Node; + set q(value: NumOrBool); +} + +interface Swizzle2From1 { + get xx(): Node>; + get rr(): Node>; + get ss(): Node>; +} + +interface Swizzle2From2 extends Swizzle2From1 { + get xy(): Node>; + set xy(value: Node> | NumOrBool); + get rg(): Node>; + set rg(value: Node> | NumOrBool); + get st(): Node>; + set st(value: Node> | NumOrBool); + get yx(): Node>; + set yx(value: Node> | NumOrBool); + get gr(): Node>; + set gr(value: Node> | NumOrBool); + get ts(): Node>; + set ts(value: Node> | NumOrBool); + get yy(): Node>; + get gg(): Node>; + get tt(): Node>; +} + +interface Swizzle2From3 extends Swizzle2From2 { + get xz(): Node>; + set xz(value: Node> | NumOrBool); + get rb(): Node>; + set rb(value: Node> | NumOrBool); + get sp(): Node>; + set sp(value: Node> | NumOrBool); + get yz(): Node>; + set yz(value: Node> | NumOrBool); + get gb(): Node>; + set gb(value: Node> | NumOrBool); + get tp(): Node>; + set tp(value: Node> | NumOrBool); + get zx(): Node>; + set zx(value: Node> | NumOrBool); + get br(): Node>; + set br(value: Node> | NumOrBool); + get ps(): Node>; + set ps(value: Node> | NumOrBool); + get zy(): Node>; + set zy(value: Node> | NumOrBool); + get bg(): Node>; + set bg(value: Node> | NumOrBool); + get pt(): Node>; + set pt(value: Node> | NumOrBool); + get zz(): Node>; + get bb(): Node>; + get pp(): Node>; +} + +interface Swizzle2From4 extends Swizzle2From3 { + get xw(): Node>; + set xw(value: Node> | NumOrBool); + get ra(): Node>; + set ra(value: Node> | NumOrBool); + get sq(): Node>; + set sq(value: Node> | NumOrBool); + get yw(): Node>; + set yw(value: Node> | NumOrBool); + get ga(): Node>; + set ga(value: Node> | NumOrBool); + get tq(): Node>; + set tq(value: Node> | NumOrBool); + get zw(): Node>; + set zw(value: Node> | NumOrBool); + get ba(): Node>; + set ba(value: Node> | NumOrBool); + get pq(): Node>; + set pq(value: Node> | NumOrBool); + get wx(): Node>; + set wx(value: Node> | NumOrBool); + get ar(): Node>; + set ar(value: Node> | NumOrBool); + get qs(): Node>; + set qs(value: Node> | NumOrBool); + get wy(): Node>; + set wy(value: Node> | NumOrBool); + get ag(): Node>; + set ag(value: Node> | NumOrBool); + get qt(): Node>; + set qt(value: Node> | NumOrBool); + get wz(): Node>; + set wz(value: Node> | NumOrBool); + get ab(): Node>; + set ab(value: Node> | NumOrBool); + get qp(): Node>; + set qp(value: Node> | NumOrBool); + get ww(): Node>; + get aa(): Node>; + get qq(): Node>; +} + +interface Swizzle3From1 { + get xxx(): Node>; + get rrr(): Node>; + get sss(): Node>; +} + +interface Swizzle3From2 extends Swizzle3From1 { + get xxy(): Node>; + get rrg(): Node>; + get sst(): Node>; + get xyx(): Node>; + get rgr(): Node>; + get sts(): Node>; + get xyy(): Node>; + get rgg(): Node>; + get stt(): Node>; + get yxx(): Node>; + get grr(): Node>; + get tss(): Node>; + get yxy(): Node>; + get grg(): Node>; + get tst(): Node>; + get yyx(): Node>; + get ggr(): Node>; + get tts(): Node>; + get yyy(): Node>; + get ggg(): Node>; + get ttt(): Node>; +} + +interface Swizzle3From3 extends Swizzle3From2 { + get xxz(): Node>; + get rrb(): Node>; + get ssp(): Node>; + get xyz(): Node>; + set xyz(value: Node> | NumOrBool); + get rgb(): Node>; + set rgb(value: Node> | NumOrBool); + get stp(): Node>; + set stp(value: Node> | NumOrBool); + get xzx(): Node>; + get rbr(): Node>; + get sps(): Node>; + get xzy(): Node>; + set xzy(value: Node> | NumOrBool); + get rbg(): Node>; + set rbg(value: Node> | NumOrBool); + get spt(): Node>; + set spt(value: Node> | NumOrBool); + get xzz(): Node>; + get rbb(): Node>; + get spp(): Node>; + get yxz(): Node>; + set yxz(value: Node> | NumOrBool); + get grb(): Node>; + set grb(value: Node> | NumOrBool); + get tsp(): Node>; + set tsp(value: Node> | NumOrBool); + get yyz(): Node>; + get ggb(): Node>; + get ttp(): Node>; + get yzx(): Node>; + set yzx(value: Node> | NumOrBool); + get gbr(): Node>; + set gbr(value: Node> | NumOrBool); + get tps(): Node>; + set tps(value: Node> | NumOrBool); + get yzy(): Node>; + get gbg(): Node>; + get tpt(): Node>; + get yzz(): Node>; + get gbb(): Node>; + get tpp(): Node>; + get zxx(): Node>; + get brr(): Node>; + get pss(): Node>; + get zxy(): Node>; + set zxy(value: Node> | NumOrBool); + get brg(): Node>; + set brg(value: Node> | NumOrBool); + get pst(): Node>; + set pst(value: Node> | NumOrBool); + get zxz(): Node>; + get brb(): Node>; + get psp(): Node>; + get zyx(): Node>; + set zyx(value: Node> | NumOrBool); + get bgr(): Node>; + set bgr(value: Node> | NumOrBool); + get pts(): Node>; + set pts(value: Node> | NumOrBool); + get zyy(): Node>; + get bgg(): Node>; + get ptt(): Node>; + get zyz(): Node>; + get bgb(): Node>; + get ptp(): Node>; + get zzx(): Node>; + get bbr(): Node>; + get pps(): Node>; + get zzy(): Node>; + get bbg(): Node>; + get ppt(): Node>; + get zzz(): Node>; + get bbb(): Node>; + get ppp(): Node>; +} + +interface Swizzle3From4 extends Swizzle3From3 { + get xxw(): Node>; + get rra(): Node>; + get ssq(): Node>; + get xyw(): Node>; + set xyw(value: Node> | NumOrBool); + get rga(): Node>; + set rga(value: Node> | NumOrBool); + get stq(): Node>; + set stq(value: Node> | NumOrBool); + get xzw(): Node>; + set xzw(value: Node> | NumOrBool); + get rba(): Node>; + set rba(value: Node> | NumOrBool); + get spq(): Node>; + set spq(value: Node> | NumOrBool); + get xwx(): Node>; + get rar(): Node>; + get sqs(): Node>; + get xwy(): Node>; + set xwy(value: Node> | NumOrBool); + get rag(): Node>; + set rag(value: Node> | NumOrBool); + get sqt(): Node>; + set sqt(value: Node> | NumOrBool); + get xwz(): Node>; + set xwz(value: Node> | NumOrBool); + get rab(): Node>; + set rab(value: Node> | NumOrBool); + get sqp(): Node>; + set sqp(value: Node> | NumOrBool); + get xww(): Node>; + get raa(): Node>; + get sqq(): Node>; + get yxw(): Node>; + set yxw(value: Node> | NumOrBool); + get gra(): Node>; + set gra(value: Node> | NumOrBool); + get tsq(): Node>; + set tsq(value: Node> | NumOrBool); + get yyw(): Node>; + get gga(): Node>; + get ttq(): Node>; + get yzw(): Node>; + set yzw(value: Node> | NumOrBool); + get gba(): Node>; + set gba(value: Node> | NumOrBool); + get tpq(): Node>; + set tpq(value: Node> | NumOrBool); + get ywx(): Node>; + set ywx(value: Node> | NumOrBool); + get gar(): Node>; + set gar(value: Node> | NumOrBool); + get tqs(): Node>; + set tqs(value: Node> | NumOrBool); + get ywy(): Node>; + get gag(): Node>; + get tqt(): Node>; + get ywz(): Node>; + set ywz(value: Node> | NumOrBool); + get gab(): Node>; + set gab(value: Node> | NumOrBool); + get tqp(): Node>; + set tqp(value: Node> | NumOrBool); + get yww(): Node>; + get gaa(): Node>; + get tqq(): Node>; + get zxw(): Node>; + set zxw(value: Node> | NumOrBool); + get bra(): Node>; + set bra(value: Node> | NumOrBool); + get psq(): Node>; + set psq(value: Node> | NumOrBool); + get zyw(): Node>; + set zyw(value: Node> | NumOrBool); + get bga(): Node>; + set bga(value: Node> | NumOrBool); + get ptq(): Node>; + set ptq(value: Node> | NumOrBool); + get zzw(): Node>; + get bba(): Node>; + get ppq(): Node>; + get zwx(): Node>; + set zwx(value: Node> | NumOrBool); + get bar(): Node>; + set bar(value: Node> | NumOrBool); + get pqs(): Node>; + set pqs(value: Node> | NumOrBool); + get zwy(): Node>; + set zwy(value: Node> | NumOrBool); + get bag(): Node>; + set bag(value: Node> | NumOrBool); + get pqt(): Node>; + set pqt(value: Node> | NumOrBool); + get zwz(): Node>; + get bab(): Node>; + get pqp(): Node>; + get zww(): Node>; + get baa(): Node>; + get pqq(): Node>; + get wxx(): Node>; + get arr(): Node>; + get qss(): Node>; + get wxy(): Node>; + set wxy(value: Node> | NumOrBool); + get arg(): Node>; + set arg(value: Node> | NumOrBool); + get qst(): Node>; + set qst(value: Node> | NumOrBool); + get wxz(): Node>; + set wxz(value: Node> | NumOrBool); + get arb(): Node>; + set arb(value: Node> | NumOrBool); + get qsp(): Node>; + set qsp(value: Node> | NumOrBool); + get wxw(): Node>; + get ara(): Node>; + get qsq(): Node>; + get wyx(): Node>; + set wyx(value: Node> | NumOrBool); + get agr(): Node>; + set agr(value: Node> | NumOrBool); + get qts(): Node>; + set qts(value: Node> | NumOrBool); + get wyy(): Node>; + get agg(): Node>; + get qtt(): Node>; + get wyz(): Node>; + set wyz(value: Node> | NumOrBool); + get agb(): Node>; + set agb(value: Node> | NumOrBool); + get qtp(): Node>; + set qtp(value: Node> | NumOrBool); + get wyw(): Node>; + get aga(): Node>; + get qtq(): Node>; + get wzx(): Node>; + set wzx(value: Node> | NumOrBool); + get abr(): Node>; + set abr(value: Node> | NumOrBool); + get qps(): Node>; + set qps(value: Node> | NumOrBool); + get wzy(): Node>; + set wzy(value: Node> | NumOrBool); + get abg(): Node>; + set abg(value: Node> | NumOrBool); + get qpt(): Node>; + set qpt(value: Node> | NumOrBool); + get wzz(): Node>; + get abb(): Node>; + get qpp(): Node>; + get wzw(): Node>; + get aba(): Node>; + get qpq(): Node>; + get wwx(): Node>; + get aar(): Node>; + get qqs(): Node>; + get wwy(): Node>; + get aag(): Node>; + get qqt(): Node>; + get wwz(): Node>; + get aab(): Node>; + get qqp(): Node>; + get www(): Node>; + get aaa(): Node>; + get qqq(): Node>; +} + +interface Swizzle4From1 { + get xxxx(): Node>; + get rrrr(): Node>; + get ssss(): Node>; +} + +interface Swizzle4From2 extends Swizzle4From1 { + get xxxy(): Node>; + get rrrg(): Node>; + get ssst(): Node>; + get xxyx(): Node>; + get rrgr(): Node>; + get ssts(): Node>; + get xxyy(): Node>; + get rrgg(): Node>; + get sstt(): Node>; + get xyxx(): Node>; + get rgrr(): Node>; + get stss(): Node>; + get xyxy(): Node>; + get rgrg(): Node>; + get stst(): Node>; + get xyyx(): Node>; + get rggr(): Node>; + get stts(): Node>; + get xyyy(): Node>; + get rggg(): Node>; + get sttt(): Node>; + get yxxx(): Node>; + get grrr(): Node>; + get tsss(): Node>; + get yxxy(): Node>; + get grrg(): Node>; + get tsst(): Node>; + get yxyx(): Node>; + get grgr(): Node>; + get tsts(): Node>; + get yxyy(): Node>; + get grgg(): Node>; + get tstt(): Node>; + get yyxx(): Node>; + get ggrr(): Node>; + get ttss(): Node>; + get yyxy(): Node>; + get ggrg(): Node>; + get ttst(): Node>; + get yyyx(): Node>; + get gggr(): Node>; + get ttts(): Node>; + get yyyy(): Node>; + get gggg(): Node>; + get tttt(): Node>; +} + +interface Swizzle4From3 extends Swizzle4From2 { + get xxxz(): Node>; + get rrrb(): Node>; + get sssp(): Node>; + get xxyz(): Node>; + get rrgb(): Node>; + get sstp(): Node>; + get xxzx(): Node>; + get rrbr(): Node>; + get ssps(): Node>; + get xxzy(): Node>; + get rrbg(): Node>; + get sspt(): Node>; + get xxzz(): Node>; + get rrbb(): Node>; + get sspp(): Node>; + get xyxz(): Node>; + get rgrb(): Node>; + get stsp(): Node>; + get xyyz(): Node>; + get rggb(): Node>; + get sttp(): Node>; + get xyzx(): Node>; + get rgbr(): Node>; + get stps(): Node>; + get xyzy(): Node>; + get rgbg(): Node>; + get stpt(): Node>; + get xyzz(): Node>; + get rgbb(): Node>; + get stpp(): Node>; + get xzxx(): Node>; + get rbrr(): Node>; + get spss(): Node>; + get xzxy(): Node>; + get rbrg(): Node>; + get spst(): Node>; + get xzxz(): Node>; + get rbrb(): Node>; + get spsp(): Node>; + get xzyx(): Node>; + get rbgr(): Node>; + get spts(): Node>; + get xzyy(): Node>; + get rbgg(): Node>; + get sptt(): Node>; + get xzyz(): Node>; + get rbgb(): Node>; + get sptp(): Node>; + get xzzx(): Node>; + get rbbr(): Node>; + get spps(): Node>; + get xzzy(): Node>; + get rbbg(): Node>; + get sppt(): Node>; + get xzzz(): Node>; + get rbbb(): Node>; + get sppp(): Node>; + get yxxz(): Node>; + get grrb(): Node>; + get tssp(): Node>; + get yxyz(): Node>; + get grgb(): Node>; + get tstp(): Node>; + get yxzx(): Node>; + get grbr(): Node>; + get tsps(): Node>; + get yxzy(): Node>; + get grbg(): Node>; + get tspt(): Node>; + get yxzz(): Node>; + get grbb(): Node>; + get tspp(): Node>; + get yyxz(): Node>; + get ggrb(): Node>; + get ttsp(): Node>; + get yyyz(): Node>; + get gggb(): Node>; + get tttp(): Node>; + get yyzx(): Node>; + get ggbr(): Node>; + get ttps(): Node>; + get yyzy(): Node>; + get ggbg(): Node>; + get ttpt(): Node>; + get yyzz(): Node>; + get ggbb(): Node>; + get ttpp(): Node>; + get yzxx(): Node>; + get gbrr(): Node>; + get tpss(): Node>; + get yzxy(): Node>; + get gbrg(): Node>; + get tpst(): Node>; + get yzxz(): Node>; + get gbrb(): Node>; + get tpsp(): Node>; + get yzyx(): Node>; + get gbgr(): Node>; + get tpts(): Node>; + get yzyy(): Node>; + get gbgg(): Node>; + get tptt(): Node>; + get yzyz(): Node>; + get gbgb(): Node>; + get tptp(): Node>; + get yzzx(): Node>; + get gbbr(): Node>; + get tpps(): Node>; + get yzzy(): Node>; + get gbbg(): Node>; + get tppt(): Node>; + get yzzz(): Node>; + get gbbb(): Node>; + get tppp(): Node>; + get zxxx(): Node>; + get brrr(): Node>; + get psss(): Node>; + get zxxy(): Node>; + get brrg(): Node>; + get psst(): Node>; + get zxxz(): Node>; + get brrb(): Node>; + get pssp(): Node>; + get zxyx(): Node>; + get brgr(): Node>; + get psts(): Node>; + get zxyy(): Node>; + get brgg(): Node>; + get pstt(): Node>; + get zxyz(): Node>; + get brgb(): Node>; + get pstp(): Node>; + get zxzx(): Node>; + get brbr(): Node>; + get psps(): Node>; + get zxzy(): Node>; + get brbg(): Node>; + get pspt(): Node>; + get zxzz(): Node>; + get brbb(): Node>; + get pspp(): Node>; + get zyxx(): Node>; + get bgrr(): Node>; + get ptss(): Node>; + get zyxy(): Node>; + get bgrg(): Node>; + get ptst(): Node>; + get zyxz(): Node>; + get bgrb(): Node>; + get ptsp(): Node>; + get zyyx(): Node>; + get bggr(): Node>; + get ptts(): Node>; + get zyyy(): Node>; + get bggg(): Node>; + get pttt(): Node>; + get zyyz(): Node>; + get bggb(): Node>; + get pttp(): Node>; + get zyzx(): Node>; + get bgbr(): Node>; + get ptps(): Node>; + get zyzy(): Node>; + get bgbg(): Node>; + get ptpt(): Node>; + get zyzz(): Node>; + get bgbb(): Node>; + get ptpp(): Node>; + get zzxx(): Node>; + get bbrr(): Node>; + get ppss(): Node>; + get zzxy(): Node>; + get bbrg(): Node>; + get ppst(): Node>; + get zzxz(): Node>; + get bbrb(): Node>; + get ppsp(): Node>; + get zzyx(): Node>; + get bbgr(): Node>; + get ppts(): Node>; + get zzyy(): Node>; + get bbgg(): Node>; + get pptt(): Node>; + get zzyz(): Node>; + get bbgb(): Node>; + get pptp(): Node>; + get zzzx(): Node>; + get bbbr(): Node>; + get ppps(): Node>; + get zzzy(): Node>; + get bbbg(): Node>; + get pppt(): Node>; + get zzzz(): Node>; + get bbbb(): Node>; + get pppp(): Node>; +} + +interface Swizzle4From4 extends Swizzle4From3 { + get xxxw(): Node>; + get rrra(): Node>; + get sssq(): Node>; + get xxyw(): Node>; + get rrga(): Node>; + get sstq(): Node>; + get xxzw(): Node>; + get rrba(): Node>; + get sspq(): Node>; + get xxwx(): Node>; + get rrar(): Node>; + get ssqs(): Node>; + get xxwy(): Node>; + get rrag(): Node>; + get ssqt(): Node>; + get xxwz(): Node>; + get rrab(): Node>; + get ssqp(): Node>; + get xxww(): Node>; + get rraa(): Node>; + get ssqq(): Node>; + get xyxw(): Node>; + get rgra(): Node>; + get stsq(): Node>; + get xyyw(): Node>; + get rgga(): Node>; + get sttq(): Node>; + get xyzw(): Node>; + set xyzw(value: Node> | NumOrBool); + get rgba(): Node>; + set rgba(value: Node> | NumOrBool); + get stpq(): Node>; + set stpq(value: Node> | NumOrBool); + get xywx(): Node>; + get rgar(): Node>; + get stqs(): Node>; + get xywy(): Node>; + get rgag(): Node>; + get stqt(): Node>; + get xywz(): Node>; + set xywz(value: Node> | NumOrBool); + get rgab(): Node>; + set rgab(value: Node> | NumOrBool); + get stqp(): Node>; + set stqp(value: Node> | NumOrBool); + get xyww(): Node>; + get rgaa(): Node>; + get stqq(): Node>; + get xzxw(): Node>; + get rbra(): Node>; + get spsq(): Node>; + get xzyw(): Node>; + set xzyw(value: Node> | NumOrBool); + get rbga(): Node>; + set rbga(value: Node> | NumOrBool); + get sptq(): Node>; + set sptq(value: Node> | NumOrBool); + get xzzw(): Node>; + get rbba(): Node>; + get sppq(): Node>; + get xzwx(): Node>; + get rbar(): Node>; + get spqs(): Node>; + get xzwy(): Node>; + set xzwy(value: Node> | NumOrBool); + get rbag(): Node>; + set rbag(value: Node> | NumOrBool); + get spqt(): Node>; + set spqt(value: Node> | NumOrBool); + get xzwz(): Node>; + get rbab(): Node>; + get spqp(): Node>; + get xzww(): Node>; + get rbaa(): Node>; + get spqq(): Node>; + get xwxx(): Node>; + get rarr(): Node>; + get sqss(): Node>; + get xwxy(): Node>; + get rarg(): Node>; + get sqst(): Node>; + get xwxz(): Node>; + get rarb(): Node>; + get sqsp(): Node>; + get xwxw(): Node>; + get rara(): Node>; + get sqsq(): Node>; + get xwyx(): Node>; + get ragr(): Node>; + get sqts(): Node>; + get xwyy(): Node>; + get ragg(): Node>; + get sqtt(): Node>; + get xwyz(): Node>; + set xwyz(value: Node> | NumOrBool); + get ragb(): Node>; + set ragb(value: Node> | NumOrBool); + get sqtp(): Node>; + set sqtp(value: Node> | NumOrBool); + get xwyw(): Node>; + get raga(): Node>; + get sqtq(): Node>; + get xwzx(): Node>; + get rabr(): Node>; + get sqps(): Node>; + get xwzy(): Node>; + set xwzy(value: Node> | NumOrBool); + get rabg(): Node>; + set rabg(value: Node> | NumOrBool); + get sqpt(): Node>; + set sqpt(value: Node> | NumOrBool); + get xwzz(): Node>; + get rabb(): Node>; + get sqpp(): Node>; + get xwzw(): Node>; + get raba(): Node>; + get sqpq(): Node>; + get xwwx(): Node>; + get raar(): Node>; + get sqqs(): Node>; + get xwwy(): Node>; + get raag(): Node>; + get sqqt(): Node>; + get xwwz(): Node>; + get raab(): Node>; + get sqqp(): Node>; + get xwww(): Node>; + get raaa(): Node>; + get sqqq(): Node>; + get yxxw(): Node>; + get grra(): Node>; + get tssq(): Node>; + get yxyw(): Node>; + get grga(): Node>; + get tstq(): Node>; + get yxzw(): Node>; + set yxzw(value: Node> | NumOrBool); + get grba(): Node>; + set grba(value: Node> | NumOrBool); + get tspq(): Node>; + set tspq(value: Node> | NumOrBool); + get yxwx(): Node>; + get grar(): Node>; + get tsqs(): Node>; + get yxwy(): Node>; + get grag(): Node>; + get tsqt(): Node>; + get yxwz(): Node>; + set yxwz(value: Node> | NumOrBool); + get grab(): Node>; + set grab(value: Node> | NumOrBool); + get tsqp(): Node>; + set tsqp(value: Node> | NumOrBool); + get yxww(): Node>; + get graa(): Node>; + get tsqq(): Node>; + get yyxw(): Node>; + get ggra(): Node>; + get ttsq(): Node>; + get yyyw(): Node>; + get ggga(): Node>; + get tttq(): Node>; + get yyzw(): Node>; + get ggba(): Node>; + get ttpq(): Node>; + get yywx(): Node>; + get ggar(): Node>; + get ttqs(): Node>; + get yywy(): Node>; + get ggag(): Node>; + get ttqt(): Node>; + get yywz(): Node>; + get ggab(): Node>; + get ttqp(): Node>; + get yyww(): Node>; + get ggaa(): Node>; + get ttqq(): Node>; + get yzxw(): Node>; + set yzxw(value: Node> | NumOrBool); + get gbra(): Node>; + set gbra(value: Node> | NumOrBool); + get tpsq(): Node>; + set tpsq(value: Node> | NumOrBool); + get yzyw(): Node>; + get gbga(): Node>; + get tptq(): Node>; + get yzzw(): Node>; + get gbba(): Node>; + get tppq(): Node>; + get yzwx(): Node>; + set yzwx(value: Node> | NumOrBool); + get gbar(): Node>; + set gbar(value: Node> | NumOrBool); + get tpqs(): Node>; + set tpqs(value: Node> | NumOrBool); + get yzwy(): Node>; + get gbag(): Node>; + get tpqt(): Node>; + get yzwz(): Node>; + get gbab(): Node>; + get tpqp(): Node>; + get yzww(): Node>; + get gbaa(): Node>; + get tpqq(): Node>; + get ywxx(): Node>; + get garr(): Node>; + get tqss(): Node>; + get ywxy(): Node>; + get garg(): Node>; + get tqst(): Node>; + get ywxz(): Node>; + set ywxz(value: Node> | NumOrBool); + get garb(): Node>; + set garb(value: Node> | NumOrBool); + get tqsp(): Node>; + set tqsp(value: Node> | NumOrBool); + get ywxw(): Node>; + get gara(): Node>; + get tqsq(): Node>; + get ywyx(): Node>; + get gagr(): Node>; + get tqts(): Node>; + get ywyy(): Node>; + get gagg(): Node>; + get tqtt(): Node>; + get ywyz(): Node>; + get gagb(): Node>; + get tqtp(): Node>; + get ywyw(): Node>; + get gaga(): Node>; + get tqtq(): Node>; + get ywzx(): Node>; + set ywzx(value: Node> | NumOrBool); + get gabr(): Node>; + set gabr(value: Node> | NumOrBool); + get tqps(): Node>; + set tqps(value: Node> | NumOrBool); + get ywzy(): Node>; + get gabg(): Node>; + get tqpt(): Node>; + get ywzz(): Node>; + get gabb(): Node>; + get tqpp(): Node>; + get ywzw(): Node>; + get gaba(): Node>; + get tqpq(): Node>; + get ywwx(): Node>; + get gaar(): Node>; + get tqqs(): Node>; + get ywwy(): Node>; + get gaag(): Node>; + get tqqt(): Node>; + get ywwz(): Node>; + get gaab(): Node>; + get tqqp(): Node>; + get ywww(): Node>; + get gaaa(): Node>; + get tqqq(): Node>; + get zxxw(): Node>; + get brra(): Node>; + get pssq(): Node>; + get zxyw(): Node>; + set zxyw(value: Node> | NumOrBool); + get brga(): Node>; + set brga(value: Node> | NumOrBool); + get pstq(): Node>; + set pstq(value: Node> | NumOrBool); + get zxzw(): Node>; + get brba(): Node>; + get pspq(): Node>; + get zxwx(): Node>; + get brar(): Node>; + get psqs(): Node>; + get zxwy(): Node>; + set zxwy(value: Node> | NumOrBool); + get brag(): Node>; + set brag(value: Node> | NumOrBool); + get psqt(): Node>; + set psqt(value: Node> | NumOrBool); + get zxwz(): Node>; + get brab(): Node>; + get psqp(): Node>; + get zxww(): Node>; + get braa(): Node>; + get psqq(): Node>; + get zyxw(): Node>; + set zyxw(value: Node> | NumOrBool); + get bgra(): Node>; + set bgra(value: Node> | NumOrBool); + get ptsq(): Node>; + set ptsq(value: Node> | NumOrBool); + get zyyw(): Node>; + get bgga(): Node>; + get pttq(): Node>; + get zyzw(): Node>; + get bgba(): Node>; + get ptpq(): Node>; + get zywx(): Node>; + set zywx(value: Node> | NumOrBool); + get bgar(): Node>; + set bgar(value: Node> | NumOrBool); + get ptqs(): Node>; + set ptqs(value: Node> | NumOrBool); + get zywy(): Node>; + get bgag(): Node>; + get ptqt(): Node>; + get zywz(): Node>; + get bgab(): Node>; + get ptqp(): Node>; + get zyww(): Node>; + get bgaa(): Node>; + get ptqq(): Node>; + get zzxw(): Node>; + get bbra(): Node>; + get ppsq(): Node>; + get zzyw(): Node>; + get bbga(): Node>; + get pptq(): Node>; + get zzzw(): Node>; + get bbba(): Node>; + get pppq(): Node>; + get zzwx(): Node>; + get bbar(): Node>; + get ppqs(): Node>; + get zzwy(): Node>; + get bbag(): Node>; + get ppqt(): Node>; + get zzwz(): Node>; + get bbab(): Node>; + get ppqp(): Node>; + get zzww(): Node>; + get bbaa(): Node>; + get ppqq(): Node>; + get zwxx(): Node>; + get barr(): Node>; + get pqss(): Node>; + get zwxy(): Node>; + set zwxy(value: Node> | NumOrBool); + get barg(): Node>; + set barg(value: Node> | NumOrBool); + get pqst(): Node>; + set pqst(value: Node> | NumOrBool); + get zwxz(): Node>; + get barb(): Node>; + get pqsp(): Node>; + get zwxw(): Node>; + get bara(): Node>; + get pqsq(): Node>; + get zwyx(): Node>; + set zwyx(value: Node> | NumOrBool); + get bagr(): Node>; + set bagr(value: Node> | NumOrBool); + get pqts(): Node>; + set pqts(value: Node> | NumOrBool); + get zwyy(): Node>; + get bagg(): Node>; + get pqtt(): Node>; + get zwyz(): Node>; + get bagb(): Node>; + get pqtp(): Node>; + get zwyw(): Node>; + get baga(): Node>; + get pqtq(): Node>; + get zwzx(): Node>; + get babr(): Node>; + get pqps(): Node>; + get zwzy(): Node>; + get babg(): Node>; + get pqpt(): Node>; + get zwzz(): Node>; + get babb(): Node>; + get pqpp(): Node>; + get zwzw(): Node>; + get baba(): Node>; + get pqpq(): Node>; + get zwwx(): Node>; + get baar(): Node>; + get pqqs(): Node>; + get zwwy(): Node>; + get baag(): Node>; + get pqqt(): Node>; + get zwwz(): Node>; + get baab(): Node>; + get pqqp(): Node>; + get zwww(): Node>; + get baaa(): Node>; + get pqqq(): Node>; + get wxxx(): Node>; + get arrr(): Node>; + get qsss(): Node>; + get wxxy(): Node>; + get arrg(): Node>; + get qsst(): Node>; + get wxxz(): Node>; + get arrb(): Node>; + get qssp(): Node>; + get wxxw(): Node>; + get arra(): Node>; + get qssq(): Node>; + get wxyx(): Node>; + get argr(): Node>; + get qsts(): Node>; + get wxyy(): Node>; + get argg(): Node>; + get qstt(): Node>; + get wxyz(): Node>; + set wxyz(value: Node> | NumOrBool); + get argb(): Node>; + set argb(value: Node> | NumOrBool); + get qstp(): Node>; + set qstp(value: Node> | NumOrBool); + get wxyw(): Node>; + get arga(): Node>; + get qstq(): Node>; + get wxzx(): Node>; + get arbr(): Node>; + get qsps(): Node>; + get wxzy(): Node>; + set wxzy(value: Node> | NumOrBool); + get arbg(): Node>; + set arbg(value: Node> | NumOrBool); + get qspt(): Node>; + set qspt(value: Node> | NumOrBool); + get wxzz(): Node>; + get arbb(): Node>; + get qspp(): Node>; + get wxzw(): Node>; + get arba(): Node>; + get qspq(): Node>; + get wxwx(): Node>; + get arar(): Node>; + get qsqs(): Node>; + get wxwy(): Node>; + get arag(): Node>; + get qsqt(): Node>; + get wxwz(): Node>; + get arab(): Node>; + get qsqp(): Node>; + get wxww(): Node>; + get araa(): Node>; + get qsqq(): Node>; + get wyxx(): Node>; + get agrr(): Node>; + get qtss(): Node>; + get wyxy(): Node>; + get agrg(): Node>; + get qtst(): Node>; + get wyxz(): Node>; + set wyxz(value: Node> | NumOrBool); + get agrb(): Node>; + set agrb(value: Node> | NumOrBool); + get qtsp(): Node>; + set qtsp(value: Node> | NumOrBool); + get wyxw(): Node>; + get agra(): Node>; + get qtsq(): Node>; + get wyyx(): Node>; + get aggr(): Node>; + get qtts(): Node>; + get wyyy(): Node>; + get aggg(): Node>; + get qttt(): Node>; + get wyyz(): Node>; + get aggb(): Node>; + get qttp(): Node>; + get wyyw(): Node>; + get agga(): Node>; + get qttq(): Node>; + get wyzx(): Node>; + set wyzx(value: Node> | NumOrBool); + get agbr(): Node>; + set agbr(value: Node> | NumOrBool); + get qtps(): Node>; + set qtps(value: Node> | NumOrBool); + get wyzy(): Node>; + get agbg(): Node>; + get qtpt(): Node>; + get wyzz(): Node>; + get agbb(): Node>; + get qtpp(): Node>; + get wyzw(): Node>; + get agba(): Node>; + get qtpq(): Node>; + get wywx(): Node>; + get agar(): Node>; + get qtqs(): Node>; + get wywy(): Node>; + get agag(): Node>; + get qtqt(): Node>; + get wywz(): Node>; + get agab(): Node>; + get qtqp(): Node>; + get wyww(): Node>; + get agaa(): Node>; + get qtqq(): Node>; + get wzxx(): Node>; + get abrr(): Node>; + get qpss(): Node>; + get wzxy(): Node>; + set wzxy(value: Node> | NumOrBool); + get abrg(): Node>; + set abrg(value: Node> | NumOrBool); + get qpst(): Node>; + set qpst(value: Node> | NumOrBool); + get wzxz(): Node>; + get abrb(): Node>; + get qpsp(): Node>; + get wzxw(): Node>; + get abra(): Node>; + get qpsq(): Node>; + get wzyx(): Node>; + set wzyx(value: Node> | NumOrBool); + get abgr(): Node>; + set abgr(value: Node> | NumOrBool); + get qpts(): Node>; + set qpts(value: Node> | NumOrBool); + get wzyy(): Node>; + get abgg(): Node>; + get qptt(): Node>; + get wzyz(): Node>; + get abgb(): Node>; + get qptp(): Node>; + get wzyw(): Node>; + get abga(): Node>; + get qptq(): Node>; + get wzzx(): Node>; + get abbr(): Node>; + get qpps(): Node>; + get wzzy(): Node>; + get abbg(): Node>; + get qppt(): Node>; + get wzzz(): Node>; + get abbb(): Node>; + get qppp(): Node>; + get wzzw(): Node>; + get abba(): Node>; + get qppq(): Node>; + get wzwx(): Node>; + get abar(): Node>; + get qpqs(): Node>; + get wzwy(): Node>; + get abag(): Node>; + get qpqt(): Node>; + get wzwz(): Node>; + get abab(): Node>; + get qpqp(): Node>; + get wzww(): Node>; + get abaa(): Node>; + get qpqq(): Node>; + get wwxx(): Node>; + get aarr(): Node>; + get qqss(): Node>; + get wwxy(): Node>; + get aarg(): Node>; + get qqst(): Node>; + get wwxz(): Node>; + get aarb(): Node>; + get qqsp(): Node>; + get wwxw(): Node>; + get aara(): Node>; + get qqsq(): Node>; + get wwyx(): Node>; + get aagr(): Node>; + get qqts(): Node>; + get wwyy(): Node>; + get aagg(): Node>; + get qqtt(): Node>; + get wwyz(): Node>; + get aagb(): Node>; + get qqtp(): Node>; + get wwyw(): Node>; + get aaga(): Node>; + get qqtq(): Node>; + get wwzx(): Node>; + get aabr(): Node>; + get qqps(): Node>; + get wwzy(): Node>; + get aabg(): Node>; + get qqpt(): Node>; + get wwzz(): Node>; + get aabb(): Node>; + get qqpp(): Node>; + get wwzw(): Node>; + get aaba(): Node>; + get qqpq(): Node>; + get wwwx(): Node>; + get aaar(): Node>; + get qqqs(): Node>; + get wwwy(): Node>; + get aaag(): Node>; + get qqqt(): Node>; + get wwwz(): Node>; + get aaab(): Node>; + get qqqp(): Node>; + get wwww(): Node>; + get aaaa(): Node>; + get qqqq(): Node>; +} + +interface SetSwizzle1 { + setX(value: NumOrBool): Node; + setR(value: NumOrBool): Node; + setS(value: NumOrBool): Node; +} + +interface SetSwizzle2 { + setX(value: NumOrBool): Node>; + setR(value: NumOrBool): Node>; + setS(value: NumOrBool): Node>; + setY(value: NumOrBool): Node>; + setG(value: NumOrBool): Node>; + setT(value: NumOrBool): Node>; + setXY(value: Node> | NumOrBool): Node>; + setRG(value: Node> | NumOrBool): Node>; + setST(value: Node> | NumOrBool): Node>; + setYX(value: Node> | NumOrBool): Node>; + setGR(value: Node> | NumOrBool): Node>; + setTS(value: Node> | NumOrBool): Node>; +} + +interface SetSwizzle3 { + setX(value: NumOrBool): Node>; + setR(value: NumOrBool): Node>; + setS(value: NumOrBool): Node>; + setY(value: NumOrBool): Node>; + setG(value: NumOrBool): Node>; + setT(value: NumOrBool): Node>; + setZ(value: NumOrBool): Node>; + setB(value: NumOrBool): Node>; + setP(value: NumOrBool): Node>; + setXY(value: Node> | NumOrBool): Node>; + setRG(value: Node> | NumOrBool): Node>; + setST(value: Node> | NumOrBool): Node>; + setYX(value: Node> | NumOrBool): Node>; + setGR(value: Node> | NumOrBool): Node>; + setTS(value: Node> | NumOrBool): Node>; + setXZ(value: Node> | NumOrBool): Node>; + setRB(value: Node> | NumOrBool): Node>; + setSP(value: Node> | NumOrBool): Node>; + setYZ(value: Node> | NumOrBool): Node>; + setGB(value: Node> | NumOrBool): Node>; + setTP(value: Node> | NumOrBool): Node>; + setZX(value: Node> | NumOrBool): Node>; + setBR(value: Node> | NumOrBool): Node>; + setPS(value: Node> | NumOrBool): Node>; + setZY(value: Node> | NumOrBool): Node>; + setBG(value: Node> | NumOrBool): Node>; + setPT(value: Node> | NumOrBool): Node>; + setXYZ(value: Node> | NumOrBool): Node>; + setRGB(value: Node> | NumOrBool): Node>; + setSTP(value: Node> | NumOrBool): Node>; + setXZY(value: Node> | NumOrBool): Node>; + setRBG(value: Node> | NumOrBool): Node>; + setSPT(value: Node> | NumOrBool): Node>; + setYXZ(value: Node> | NumOrBool): Node>; + setGRB(value: Node> | NumOrBool): Node>; + setTSP(value: Node> | NumOrBool): Node>; + setYZX(value: Node> | NumOrBool): Node>; + setGBR(value: Node> | NumOrBool): Node>; + setTPS(value: Node> | NumOrBool): Node>; + setZXY(value: Node> | NumOrBool): Node>; + setBRG(value: Node> | NumOrBool): Node>; + setPST(value: Node> | NumOrBool): Node>; + setZYX(value: Node> | NumOrBool): Node>; + setBGR(value: Node> | NumOrBool): Node>; + setPTS(value: Node> | NumOrBool): Node>; +} + +interface SetSwizzle4 { + setX(value: NumOrBool): Node>; + setR(value: NumOrBool): Node>; + setS(value: NumOrBool): Node>; + setY(value: NumOrBool): Node>; + setG(value: NumOrBool): Node>; + setT(value: NumOrBool): Node>; + setZ(value: NumOrBool): Node>; + setB(value: NumOrBool): Node>; + setP(value: NumOrBool): Node>; + setW(value: NumOrBool): Node>; + setA(value: NumOrBool): Node>; + setQ(value: NumOrBool): Node>; + setXY(value: Node> | NumOrBool): Node>; + setRG(value: Node> | NumOrBool): Node>; + setST(value: Node> | NumOrBool): Node>; + setYX(value: Node> | NumOrBool): Node>; + setGR(value: Node> | NumOrBool): Node>; + setTS(value: Node> | NumOrBool): Node>; + setXZ(value: Node> | NumOrBool): Node>; + setRB(value: Node> | NumOrBool): Node>; + setSP(value: Node> | NumOrBool): Node>; + setYZ(value: Node> | NumOrBool): Node>; + setGB(value: Node> | NumOrBool): Node>; + setTP(value: Node> | NumOrBool): Node>; + setZX(value: Node> | NumOrBool): Node>; + setBR(value: Node> | NumOrBool): Node>; + setPS(value: Node> | NumOrBool): Node>; + setZY(value: Node> | NumOrBool): Node>; + setBG(value: Node> | NumOrBool): Node>; + setPT(value: Node> | NumOrBool): Node>; + setXW(value: Node> | NumOrBool): Node>; + setRA(value: Node> | NumOrBool): Node>; + setSQ(value: Node> | NumOrBool): Node>; + setYW(value: Node> | NumOrBool): Node>; + setGA(value: Node> | NumOrBool): Node>; + setTQ(value: Node> | NumOrBool): Node>; + setZW(value: Node> | NumOrBool): Node>; + setBA(value: Node> | NumOrBool): Node>; + setPQ(value: Node> | NumOrBool): Node>; + setWX(value: Node> | NumOrBool): Node>; + setAR(value: Node> | NumOrBool): Node>; + setQS(value: Node> | NumOrBool): Node>; + setWY(value: Node> | NumOrBool): Node>; + setAG(value: Node> | NumOrBool): Node>; + setQT(value: Node> | NumOrBool): Node>; + setWZ(value: Node> | NumOrBool): Node>; + setAB(value: Node> | NumOrBool): Node>; + setQP(value: Node> | NumOrBool): Node>; + setXYZ(value: Node> | NumOrBool): Node>; + setRGB(value: Node> | NumOrBool): Node>; + setSTP(value: Node> | NumOrBool): Node>; + setXZY(value: Node> | NumOrBool): Node>; + setRBG(value: Node> | NumOrBool): Node>; + setSPT(value: Node> | NumOrBool): Node>; + setYXZ(value: Node> | NumOrBool): Node>; + setGRB(value: Node> | NumOrBool): Node>; + setTSP(value: Node> | NumOrBool): Node>; + setYZX(value: Node> | NumOrBool): Node>; + setGBR(value: Node> | NumOrBool): Node>; + setTPS(value: Node> | NumOrBool): Node>; + setZXY(value: Node> | NumOrBool): Node>; + setBRG(value: Node> | NumOrBool): Node>; + setPST(value: Node> | NumOrBool): Node>; + setZYX(value: Node> | NumOrBool): Node>; + setBGR(value: Node> | NumOrBool): Node>; + setPTS(value: Node> | NumOrBool): Node>; + setXYW(value: Node> | NumOrBool): Node>; + setRGA(value: Node> | NumOrBool): Node>; + setSTQ(value: Node> | NumOrBool): Node>; + setXZW(value: Node> | NumOrBool): Node>; + setRBA(value: Node> | NumOrBool): Node>; + setSPQ(value: Node> | NumOrBool): Node>; + setXWY(value: Node> | NumOrBool): Node>; + setRAG(value: Node> | NumOrBool): Node>; + setSQT(value: Node> | NumOrBool): Node>; + setXWZ(value: Node> | NumOrBool): Node>; + setRAB(value: Node> | NumOrBool): Node>; + setSQP(value: Node> | NumOrBool): Node>; + setYXW(value: Node> | NumOrBool): Node>; + setGRA(value: Node> | NumOrBool): Node>; + setTSQ(value: Node> | NumOrBool): Node>; + setYZW(value: Node> | NumOrBool): Node>; + setGBA(value: Node> | NumOrBool): Node>; + setTPQ(value: Node> | NumOrBool): Node>; + setYWX(value: Node> | NumOrBool): Node>; + setGAR(value: Node> | NumOrBool): Node>; + setTQS(value: Node> | NumOrBool): Node>; + setYWZ(value: Node> | NumOrBool): Node>; + setGAB(value: Node> | NumOrBool): Node>; + setTQP(value: Node> | NumOrBool): Node>; + setZXW(value: Node> | NumOrBool): Node>; + setBRA(value: Node> | NumOrBool): Node>; + setPSQ(value: Node> | NumOrBool): Node>; + setZYW(value: Node> | NumOrBool): Node>; + setBGA(value: Node> | NumOrBool): Node>; + setPTQ(value: Node> | NumOrBool): Node>; + setZWX(value: Node> | NumOrBool): Node>; + setBAR(value: Node> | NumOrBool): Node>; + setPQS(value: Node> | NumOrBool): Node>; + setZWY(value: Node> | NumOrBool): Node>; + setBAG(value: Node> | NumOrBool): Node>; + setPQT(value: Node> | NumOrBool): Node>; + setWXY(value: Node> | NumOrBool): Node>; + setARG(value: Node> | NumOrBool): Node>; + setQST(value: Node> | NumOrBool): Node>; + setWXZ(value: Node> | NumOrBool): Node>; + setARB(value: Node> | NumOrBool): Node>; + setQSP(value: Node> | NumOrBool): Node>; + setWYX(value: Node> | NumOrBool): Node>; + setAGR(value: Node> | NumOrBool): Node>; + setQTS(value: Node> | NumOrBool): Node>; + setWYZ(value: Node> | NumOrBool): Node>; + setAGB(value: Node> | NumOrBool): Node>; + setQTP(value: Node> | NumOrBool): Node>; + setWZX(value: Node> | NumOrBool): Node>; + setABR(value: Node> | NumOrBool): Node>; + setQPS(value: Node> | NumOrBool): Node>; + setWZY(value: Node> | NumOrBool): Node>; + setABG(value: Node> | NumOrBool): Node>; + setQPT(value: Node> | NumOrBool): Node>; + setXYZW(value: Node> | NumOrBool): Node>; + setRGBA(value: Node> | NumOrBool): Node>; + setSTPQ(value: Node> | NumOrBool): Node>; + setXYWZ(value: Node> | NumOrBool): Node>; + setRGAB(value: Node> | NumOrBool): Node>; + setSTQP(value: Node> | NumOrBool): Node>; + setXZYW(value: Node> | NumOrBool): Node>; + setRBGA(value: Node> | NumOrBool): Node>; + setSPTQ(value: Node> | NumOrBool): Node>; + setXZWY(value: Node> | NumOrBool): Node>; + setRBAG(value: Node> | NumOrBool): Node>; + setSPQT(value: Node> | NumOrBool): Node>; + setXWYZ(value: Node> | NumOrBool): Node>; + setRAGB(value: Node> | NumOrBool): Node>; + setSQTP(value: Node> | NumOrBool): Node>; + setXWZY(value: Node> | NumOrBool): Node>; + setRABG(value: Node> | NumOrBool): Node>; + setSQPT(value: Node> | NumOrBool): Node>; + setYXZW(value: Node> | NumOrBool): Node>; + setGRBA(value: Node> | NumOrBool): Node>; + setTSPQ(value: Node> | NumOrBool): Node>; + setYXWZ(value: Node> | NumOrBool): Node>; + setGRAB(value: Node> | NumOrBool): Node>; + setTSQP(value: Node> | NumOrBool): Node>; + setYZXW(value: Node> | NumOrBool): Node>; + setGBRA(value: Node> | NumOrBool): Node>; + setTPSQ(value: Node> | NumOrBool): Node>; + setYZWX(value: Node> | NumOrBool): Node>; + setGBAR(value: Node> | NumOrBool): Node>; + setTPQS(value: Node> | NumOrBool): Node>; + setYWXZ(value: Node> | NumOrBool): Node>; + setGARB(value: Node> | NumOrBool): Node>; + setTQSP(value: Node> | NumOrBool): Node>; + setYWZX(value: Node> | NumOrBool): Node>; + setGABR(value: Node> | NumOrBool): Node>; + setTQPS(value: Node> | NumOrBool): Node>; + setZXYW(value: Node> | NumOrBool): Node>; + setBRGA(value: Node> | NumOrBool): Node>; + setPSTQ(value: Node> | NumOrBool): Node>; + setZXWY(value: Node> | NumOrBool): Node>; + setBRAG(value: Node> | NumOrBool): Node>; + setPSQT(value: Node> | NumOrBool): Node>; + setZYXW(value: Node> | NumOrBool): Node>; + setBGRA(value: Node> | NumOrBool): Node>; + setPTSQ(value: Node> | NumOrBool): Node>; + setZYWX(value: Node> | NumOrBool): Node>; + setBGAR(value: Node> | NumOrBool): Node>; + setPTQS(value: Node> | NumOrBool): Node>; + setZWXY(value: Node> | NumOrBool): Node>; + setBARG(value: Node> | NumOrBool): Node>; + setPQST(value: Node> | NumOrBool): Node>; + setZWYX(value: Node> | NumOrBool): Node>; + setBAGR(value: Node> | NumOrBool): Node>; + setPQTS(value: Node> | NumOrBool): Node>; + setWXYZ(value: Node> | NumOrBool): Node>; + setARGB(value: Node> | NumOrBool): Node>; + setQSTP(value: Node> | NumOrBool): Node>; + setWXZY(value: Node> | NumOrBool): Node>; + setARBG(value: Node> | NumOrBool): Node>; + setQSPT(value: Node> | NumOrBool): Node>; + setWYXZ(value: Node> | NumOrBool): Node>; + setAGRB(value: Node> | NumOrBool): Node>; + setQTSP(value: Node> | NumOrBool): Node>; + setWYZX(value: Node> | NumOrBool): Node>; + setAGBR(value: Node> | NumOrBool): Node>; + setQTPS(value: Node> | NumOrBool): Node>; + setWZXY(value: Node> | NumOrBool): Node>; + setABRG(value: Node> | NumOrBool): Node>; + setQPST(value: Node> | NumOrBool): Node>; + setWZYX(value: Node> | NumOrBool): Node>; + setABGR(value: Node> | NumOrBool): Node>; + setQPTS(value: Node> | NumOrBool): Node>; +} + +interface FlipSwizzle1 { + flipX(): Node; + flipR(): Node; + flipS(): Node; +} + +interface FlipSwizzle2 { + flipX(): Node>; + flipR(): Node>; + flipS(): Node>; + flipY(): Node>; + flipG(): Node>; + flipT(): Node>; + flipXY(): Node>; + flipRG(): Node>; + flipST(): Node>; +} + +interface FlipSwizzle3 { + flipX(): Node>; + flipR(): Node>; + flipS(): Node>; + flipY(): Node>; + flipG(): Node>; + flipT(): Node>; + flipZ(): Node>; + flipB(): Node>; + flipP(): Node>; + flipXY(): Node>; + flipRG(): Node>; + flipST(): Node>; + flipXZ(): Node>; + flipRB(): Node>; + flipSP(): Node>; + flipYZ(): Node>; + flipGB(): Node>; + flipTP(): Node>; + flipXYZ(): Node>; + flipRGB(): Node>; + flipSTP(): Node>; +} + +interface FlipSwizzle4 { + flipX(): Node>; + flipR(): Node>; + flipS(): Node>; + flipY(): Node>; + flipG(): Node>; + flipT(): Node>; + flipZ(): Node>; + flipB(): Node>; + flipP(): Node>; + flipW(): Node>; + flipA(): Node>; + flipQ(): Node>; + flipXY(): Node>; + flipRG(): Node>; + flipST(): Node>; + flipXZ(): Node>; + flipRB(): Node>; + flipSP(): Node>; + flipYZ(): Node>; + flipGB(): Node>; + flipTP(): Node>; + flipXW(): Node>; + flipRA(): Node>; + flipSQ(): Node>; + flipYW(): Node>; + flipGA(): Node>; + flipTQ(): Node>; + flipZW(): Node>; + flipBA(): Node>; + flipPQ(): Node>; + flipXYZ(): Node>; + flipRGB(): Node>; + flipSTP(): Node>; + flipXYW(): Node>; + flipRGA(): Node>; + flipSTQ(): Node>; + flipXZW(): Node>; + flipRBA(): Node>; + flipSPQ(): Node>; + flipYZW(): Node>; + flipGBA(): Node>; + flipTPQ(): Node>; + flipXYZW(): Node>; + flipRGBA(): Node>; + flipSTPQ(): Node>; +} + +declare module "../core/Node.js" { + interface NumOrBoolExtensions + extends + Swizzle1From1, + Swizzle2From1, + Swizzle3From1, + Swizzle4From1, + SetSwizzle1, + FlipSwizzle1 + { } - & { - [Key in SwizzleOption as `set${Uppercase}`]: (value: Node) => Node; + + interface NumOrBoolVec2Extensions + extends + Swizzle1From2, + Swizzle2From2, + Swizzle3From2, + Swizzle4From2, + SetSwizzle2, + FlipSwizzle2 + { + } + + interface NumOrBoolVec3Extensions + extends + Swizzle1From3, + Swizzle2From3, + Swizzle3From3, + Swizzle4From3, + SetSwizzle3, + FlipSwizzle3 + { + } + + interface ColorExtensions + extends + Swizzle1From3<"float">, + Swizzle2From3<"float">, + Swizzle3From3<"float">, + Swizzle4From3<"float">, + SetSwizzle3<"float">, + FlipSwizzle3<"float"> + { } - & { - [Key in SwizzleOption as `flip${Uppercase}`]: () => Node; - }; -declare module "../Nodes.js" { - interface Node extends Swizzable { + interface NumOrBoolVec4Extensions + extends + Swizzle1From4, + Swizzle2From4, + Swizzle3From4, + Swizzle4From4, + SetSwizzle4, + FlipSwizzle4 + { } } @@ -99,7 +1713,8 @@ export type NodeObjectOption = Node | number | string; // same logic as in ShaderNodeObject: number,boolean,node->node, otherwise do nothing export type NodeObject = T extends Node ? T - : T extends number | boolean ? ConstNode + : T extends number ? Node<"float"> + : T extends boolean ? Node<"bool"> : T; // opposite of NodeObject: node -> node|boolean|number, otherwise do nothing @@ -192,17 +1807,16 @@ type ConstructedNode = T extends new(...args: any[]) => infer R ? (R extends export type NodeOrType = Node | string; -declare class ShaderCallNodeInternal extends Node { -} +type ShaderCallNodeInternal = Node; -declare class ShaderNodeInternal extends Node {} +type ShaderNodeInternal = Node; export const defined: (v: unknown) => unknown; export const getConstNodeType: (value: NodeOrType) => string | null; export class ShaderNode { - constructor(jsFunc: (inputs: NodeObjects, builder: NodeBuilder) => Node); + constructor(jsFunc: (inputs: NodeObjects, builder: NodeBuilder) => R); call: ( inputs: { [key in keyof T]: T[key] extends Node ? Node : T[key] }, builder?: NodeBuilder, @@ -260,10 +1874,10 @@ interface Layout { }[]; } -export interface ShaderNodeFn { - (...args: Args): ShaderCallNodeInternal; +export interface FnNode { + (...args: Args): TReturn extends void ? ShaderCallNodeInternal : TReturn; - shaderNode: ShaderNodeInternal; + shaderNode: ShaderNodeInternal; id: number; getNodeType: (builder: NodeBuilder) => string | null; @@ -274,15 +1888,18 @@ export interface ShaderNodeFn { once: (subBuilds?: string[] | null) => this; } -export function Fn(jsFunc: (builder: NodeBuilder) => void, layout?: string | Record): ShaderNodeFn<[]>; -export function Fn( - jsFunc: (args: T, builder: NodeBuilder) => void, +export function Fn( + jsFunc: (builder: NodeBuilder) => TReturn, + layout?: string | Record, +): FnNode<[], TReturn>; +export function Fn( + jsFunc: (args: TArgs, builder: NodeBuilder) => TReturn, layout?: string | Record, -): ShaderNodeFn>; -export function Fn( - jsFunc: (args: T, builder: NodeBuilder) => void, +): FnNode, TReturn>; +export function Fn( + jsFunc: (args: TArgs, builder: NodeBuilder) => TReturn, layout?: string | Record, -): ShaderNodeFn<[ProxiedObject]>; +): FnNode<[ProxiedObject], TReturn>; export const setCurrentStack: (stack: StackNode | null) => void; @@ -293,24 +1910,23 @@ export const Switch: (expression: Node) => StackNode; export function Stack(node: Node): Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { toStack: () => Node; - toStackAssign: () => this; } } interface ColorFunction { // The first branch in `ConvertType` will forward the parameters to the `Color` constructor if there are no // parameters or all the parameters are non-objects - (color?: string | number): ConstNode; - (r: number, g: number, b: number): ConstNode; + (color?: string | number): ConstNode<"color", Color>; + (r: number, g: number, b: number): ConstNode<"color", Color>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (color: Color): ConstNode; - (node: Node): Node; + (color: Color): ConstNode<"color", Color>; + (node: Node): Node<"color">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. Not sure which cases are worth considering here. @@ -318,18 +1934,30 @@ interface ColorFunction { export const color: ColorFunction; -interface NumberFunction { - (value?: number): ConstNode; - (node: Node): Node; +interface FloatFunction { + (value?: number): ConstNode<"float", number>; + (node: Node): Node<"float">; } -export const float: NumberFunction; -export const int: NumberFunction; -export const uint: NumberFunction; +export const float: FloatFunction; + +interface IntFunction { + (value?: number): ConstNode<"int", number>; + (node: Node): Node<"int">; +} + +export const int: IntFunction; + +interface UintFunction { + (value?: number): ConstNode<"uint", number>; + (node: Node): Node<"uint">; +} + +export const uint: UintFunction; interface BooleanFunction { - (value?: boolean): ConstNode; - (node: Node): Node; + (value?: boolean): ConstNode<"bool", number>; + (node: Node): Node<"bool">; } export const bool: BooleanFunction; @@ -337,75 +1965,75 @@ export const bool: BooleanFunction; interface Vector2Function { // The first branch in `ConvertType` will forward the parameters to the `Vector2` constructor if there are no // parameters or all the parameters are non-objects - (x?: number, y?: number): ConstNode; + (x?: number, y?: number): ConstNode<"vec2", Vector2>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (value: Vector2): ConstNode; - (node: Node): Node; + (value: Vector2): ConstNode<"vec2", Vector2>; + (node: Node): Node<"vec2">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. - (x: Node | number, y: Node | number): JoinNode; + (x: Node | number, y: Node | number): Node<"vec2">; } export const vec2: Vector2Function; -export const ivec2: Vector2Function; -export const uvec2: Vector2Function; -export const bvec2: (node: Node) => Node; +export const ivec2: (node: Node) => Node<"ivec2">; +export const uvec2: (x: Node<"uint">, y: Node<"uint">) => Node<"uvec2">; +export const bvec2: (node: Node) => Node<"bvec2">; interface Vector3Function { // The first branch in `ConvertType` will forward the parameters to the `Vector3` constructor if there are no // parameters or all the parameters are non-objects - (x?: number, y?: number, z?: number): ConstNode; + (x?: number, y?: number, z?: number): ConstNode<"vec3", Vector3>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (value: Vector3): ConstNode; - (node: Node): Node; + (value: Vector3): ConstNode<"vec3", Vector3>; + (node: Node): Node<"vec3">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. - (x: Node | number, y: Node | number, z?: Node | number): JoinNode; + (x: Node | number, y: Node | number, z?: Node | number): Node<"vec3">; } export const vec3: Vector3Function; -export const ivec3: Vector3Function; -export const uvec3: Vector3Function; -export const bvec3: (node: Node) => Node; +export const ivec3: (node: Node) => Node<"ivec3">; +export const uvec3: (node: Node) => Node<"uvec3">; +export const bvec3: (node: Node) => Node<"bvec3">; interface Vector4Function { // The first branch in `ConvertType` will forward the parameters to the `Vector4` constructor if there are no // parameters or all the parameters are non-objects - (x?: number, y?: number, z?: number, w?: number): ConstNode; + (x?: number, y?: number, z?: number, w?: number): ConstNode<"vec4", Vector4>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (value: Vector4): ConstNode; - (node: Node): Node; + (value: Vector4): ConstNode<"vec4", Vector4>; + (node: Node): Node<"vec4">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. - (x: Node | number, y: Node | number, z?: Node | number, w?: Node | number): JoinNode; + (x: Node | number, y: Node | number, z?: Node | number, w?: Node | number): Node<"vec4">; } export const vec4: Vector4Function; -export const ivec4: Vector4Function; -export const uvec4: Vector4Function; -export const bvec4: (node: Node) => Node; +export const ivec4: (node: Node) => Node<"ivec4">; +export const uvec4: (node: Node) => Node<"uvec4">; +export const bvec4: (node: Node) => Node<"bvec4">; interface Matrix2Function { - (value: Matrix2): ConstNode; - (node: Node): Node; + (value: Matrix2): ConstNode<"mat2", Matrix2>; + (node: Node): Node<"mat2">; } export const mat2: Matrix2Function; interface Matrix3Function { - (value: Matrix3): ConstNode; + (value: Matrix3): ConstNode<"mat3", Matrix3>; ( n11: number | Node, n12: number | Node, @@ -416,20 +2044,20 @@ interface Matrix3Function { n31: number | Node, n32: number | Node, n33: number | Node, - ): Node; - (): ConstNode; + ): Node<"mat3">; + (): ConstNode<"mat3", Matrix3>; ( p1: Node, p2: Node, p3: Node, - ): Node; - (node: Node): Node; + ): Node<"mat3">; + (node: Node): Node<"mat3">; } export const mat3: Matrix3Function; interface Matrix4Function { - (value: Matrix4): ConstNode; + (value: Matrix4): ConstNode<"mat4", Matrix4>; ( n11: number | Node, n12: number | Node, @@ -447,83 +2075,63 @@ interface Matrix4Function { n42: number | Node, n43: number | Node, n44: number | Node, - ): Node; - (): ConstNode; + ): Node<"mat4">; + (): ConstNode<"mat4", Matrix4>; ( p1: Node, p2: Node, p3: Node, p4: Node, - ): Node; - (node: Node): Node; + ): Node<"mat4">; + (node: Node): Node<"mat4">; } export const mat4: Matrix4Function; -export const string: (value?: string) => ConstNode; -export const arrayBuffer: (value: ArrayBuffer) => ConstNode; +export const string: (value?: string) => Node<"string">; +export const arrayBuffer: (value: ArrayBuffer) => Node<"ArrayBuffer">; -declare module "../Nodes.js" { - interface Node { - toColor: () => Node; - toColorAssign: () => this; +declare module "../core/Node.js" { + interface NodeElements { + toColor: () => Node<"color">; - toFloat: () => Node; - toFloatAssign: () => this; + toFloat: () => Node<"float">; - toInt: () => Node; - toIntAssign: () => this; + toInt: () => Node<"int">; - toUint: () => Node; - toUintAssign: () => this; + toUint: () => Node<"uint">; - toBool: () => Node; - toBoolAssign: () => this; + toBool: () => Node<"bool">; - toVec2: () => Node; - toVec2Assign: () => this; + toVec2: () => Node<"vec2">; - toIVec2: () => Node; - toIVec2Assign: () => this; + toIVec2: () => Node<"ivec2">; - toUVec2: () => Node; - toUVec2Assign: () => this; + toUVec2: () => Node<"uvec2">; - toBVec2: () => Node; - toBVec2Assign: () => this; + toBVec2: () => Node<"bvec2">; - toVec3: () => Node; - toVec3Assign: () => this; + toVec3: () => Node<"vec3">; - toIVec3: () => Node; - toIVec3Assign: () => this; + toIVec3: () => Node<"ivec3">; - toUVec3: () => Node; - toUVec3Assign: () => this; + toUVec3: () => Node<"uvec3">; - toBVec3: () => Node; - toBVec3Assign: () => this; + toBVec3: () => Node<"bvec3">; - toVec4: () => Node; - toVec4Assign: () => this; + toVec4: () => Node<"vec4">; - toIVec4: () => Node; - toIVec4Assign: () => this; + toIVec4: () => Node<"ivec4">; - toUVec4: () => Node; - toUVec4Assign: () => this; + toUVec4: () => Node<"uvec4">; - toBVec4: () => Node; - toBVec4Assign: () => this; + toBVec4: () => Node<"bvec4">; - toMat2: () => Node; - toMat2Assign: () => this; + toMat2: () => Node<"mat2">; - toMat3: () => Node; - toMat3Assign: () => this; + toMat3: () => Node<"mat3">; - toMat4: () => Node; - toMat4Assign: () => this; + toMat4: () => Node<"mat4">; } } @@ -531,13 +2139,11 @@ export const element: (node: Node, indexNode: Node) => Node; export const convert: (node: Node, types: string) => Node; export const split: (node: Node, channels?: string) => Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { element: (indexNode: Node) => Node; - elementAssign: (indexNode: Node) => this; convert: (types: string) => Node; - convertAssign: (types: string) => this; } } @@ -546,15 +2152,13 @@ declare module "../Nodes.js" { */ export const append: (node: Node) => Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { /** * @deprecated append() has been renamed to Stack(). */ append: () => Node; - /** - * @deprecated append() has been renamed to Stack(). - */ - appendAssign: () => this; } } + +export {}; diff --git a/types/three/src/nodes/utils/ArrayElementNode.d.ts b/types/three/src/nodes/utils/ArrayElementNode.d.ts index 650f04047..1fdd52347 100644 --- a/types/three/src/nodes/utils/ArrayElementNode.d.ts +++ b/types/three/src/nodes/utils/ArrayElementNode.d.ts @@ -1,9 +1,14 @@ import Node from "../core/Node.js"; -import { TempNode } from "../Nodes.js"; -export default class ArrayElementNode extends TempNode { +interface ArrayElementNodeInterface { node: Node; indexNode: Node; - - constructor(node: Node, indexNode: Node); } + +declare const ArrayElementNode: { + new(node: Node, indexNode: Node): ArrayElementNode; +}; + +type ArrayElementNode = Node & ArrayElementNodeInterface; + +export default ArrayElementNode; diff --git a/types/three/src/nodes/utils/DebugNode.d.ts b/types/three/src/nodes/utils/DebugNode.d.ts index a86c21500..b94734dab 100644 --- a/types/three/src/nodes/utils/DebugNode.d.ts +++ b/types/three/src/nodes/utils/DebugNode.d.ts @@ -13,13 +13,10 @@ export const debug: ( callback?: ((node: NodeBuilder, code: string) => void) | null, ) => DebugNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { debug: ( callback?: ((node: NodeBuilder, code: string) => void) | null, ) => DebugNode; - debugAssign: ( - callback?: ((node: NodeBuilder, code: string) => void) | null, - ) => this; } } diff --git a/types/three/src/nodes/utils/Discard.d.ts b/types/three/src/nodes/utils/Discard.d.ts index 3d148cc4a..c8e3001f8 100644 --- a/types/three/src/nodes/utils/Discard.d.ts +++ b/types/three/src/nodes/utils/Discard.d.ts @@ -3,9 +3,8 @@ import Node from "../core/Node.js"; export const Discard: (conditional?: Node) => Node; export const Return: () => Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { discard: () => Node; - discardAssign: () => this; } } diff --git a/types/three/src/nodes/utils/LoopNode.d.ts b/types/three/src/nodes/utils/LoopNode.d.ts index 9fa5c088b..a0837a579 100644 --- a/types/three/src/nodes/utils/LoopNode.d.ts +++ b/types/three/src/nodes/utils/LoopNode.d.ts @@ -1,21 +1,19 @@ import Node from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; -import { VarNode } from "../Nodes.js"; -interface LoopNodeObjectParameter { +type LoopNodeType = "int" | "uint" | "float"; + +interface LoopNodeObjectParameter { // TODO Expand to other types and update loop function types appropriately - type?: "int" | "uint" | "float"; + type?: TNodeType; // TODO The variable name should affect the type of the loop function // name?: string; - start: number | Node; - end: number | Node; + start: Node | number; + end: Node | number; condition?: string; - update?: VarNode | number | string; } -type LoopNodeParameter = Node | number | LoopNodeObjectParameter; - -declare class LoopNode extends Node { +declare class LoopNode extends Node<"void"> { params: unknown[]; constructor(params?: unknown[]); @@ -26,12 +24,19 @@ declare class LoopNode extends Node { export default LoopNode; interface Loop { - (i: LoopNodeParameter, func: (inputs: { readonly i: Node }) => void): Node; ( - i: LoopNodeParameter, - j: LoopNodeParameter, - func: (inputs: { readonly i: Node; readonly j: Node }) => void, - ): Node; + i: number, + func: (inputs: { readonly i: Node<"int"> }) => void, + ): LoopNode; + ( + i: LoopNodeObjectParameter, + func: (inputs: { readonly i: Node }) => void, + ): LoopNode; + ( + i: LoopNodeObjectParameter, + j: LoopNodeObjectParameter, + func: (inputs: { readonly i: Node; readonly j: Node }) => void, + ): LoopNode; } export const Loop: Loop; diff --git a/types/three/src/nodes/utils/MaxMipLevelNode.d.ts b/types/three/src/nodes/utils/MaxMipLevelNode.d.ts index a25670111..a9a895699 100644 --- a/types/three/src/nodes/utils/MaxMipLevelNode.d.ts +++ b/types/three/src/nodes/utils/MaxMipLevelNode.d.ts @@ -2,7 +2,7 @@ import { Texture } from "../../textures/Texture.js"; import TextureNode from "../accessors/TextureNode.js"; import UniformNode from "../core/UniformNode.js"; -export default class MaxMipLevelNode extends UniformNode<0> { +export default class MaxMipLevelNode extends UniformNode<"float", number> { constructor(textureNode: TextureNode); get textureNode(): TextureNode; diff --git a/types/three/src/nodes/utils/Oscillators.d.ts b/types/three/src/nodes/utils/Oscillators.d.ts index 256da2728..d39733875 100644 --- a/types/three/src/nodes/utils/Oscillators.d.ts +++ b/types/three/src/nodes/utils/Oscillators.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -export const oscSine: (timeNode?: Node) => Node; -export const oscSquare: (timeNode?: Node) => Node; -export const oscTriangle: (timeNode?: Node) => Node; -export const oscSawtooth: (timeNode?: Node) => Node; +export const oscSine: (timeNode?: Node) => Node<"float">; +export const oscSquare: (timeNode?: Node) => Node<"float">; +export const oscTriangle: (timeNode?: Node) => Node<"float">; +export const oscSawtooth: (timeNode?: Node) => Node<"float">; diff --git a/types/three/src/nodes/utils/Packing.d.ts b/types/three/src/nodes/utils/Packing.d.ts index 07a4232f9..0682a52a0 100644 --- a/types/three/src/nodes/utils/Packing.d.ts +++ b/types/three/src/nodes/utils/Packing.d.ts @@ -1,5 +1,10 @@ import Node from "../core/Node.js"; -export const directionToColor: (node: Node) => Node; -export const colorToDirection: (node: Node) => Node; -export const unpackNormal: (xy: Node) => Node; +interface PackingFunction { + (node: Node<"vec3">): Node<"vec3">; + (node: Node<"vec4">): Node<"vec4">; +} + +export const directionToColor: PackingFunction; +export const colorToDirection: PackingFunction; +export const unpackNormal: (xy: Node<"vec2">) => Node<"vec3">; diff --git a/types/three/src/nodes/utils/RemapNode.d.ts b/types/three/src/nodes/utils/RemapNode.d.ts index 1dc4a70c0..79ba17a2e 100644 --- a/types/three/src/nodes/utils/RemapNode.d.ts +++ b/types/three/src/nodes/utils/RemapNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -export default class RemapNode extends Node { +export default class RemapNode extends Node<"float"> { node: Node; inLowNode: Node; inHighNode: Node; @@ -27,32 +27,32 @@ export const remapClamp: ( outHighNode?: Node | number, ) => RemapNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface FloatExtensions { remap: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => RemapNode; remapAssign: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => this; remapClamp: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => RemapNode; remapClampAssign: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => this; } } diff --git a/types/three/src/nodes/utils/RotateNode.d.ts b/types/three/src/nodes/utils/RotateNode.d.ts index 915bc21d3..c75f43175 100644 --- a/types/three/src/nodes/utils/RotateNode.d.ts +++ b/types/three/src/nodes/utils/RotateNode.d.ts @@ -1,14 +1,23 @@ import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -export default class RotateNode extends TempNode { - positionNode: Node; - rotationNode: Node; +interface RotateNodeInterface { + positionNode: Node; + rotationNode: Node<"vec3"> | Node<"float">; +} + +declare const RotateNode: { + new(positionNode: Node<"vec2">, rotationNode: Node<"float"> | number): RotateNode<"vec2">; + new(positionNode: Node<"vec3">, rotationNode: Node<"vec3">): RotateNode<"vec3">; +}; + +type RotateNode = RotateNodeInterface & TempNode; + +export default RotateNode; - constructor(positionNode: Node, rotationNode: Node); +interface Rotate { + (positionNode: Node<"vec2">, rotationNode: Node<"float"> | number): RotateNode<"vec2">; + (positionNode: Node<"vec3">, rotationNode: Node<"vec3">): RotateNode<"vec3">; } -export const rotate: ( - positionNode: Node, - rotationNode: Node | number, -) => RotateNode; +export const rotate: Rotate; diff --git a/types/three/src/nodes/utils/SplitNode.d.ts b/types/three/src/nodes/utils/SplitNode.d.ts index e21de043f..dcc7d823a 100644 --- a/types/three/src/nodes/utils/SplitNode.d.ts +++ b/types/three/src/nodes/utils/SplitNode.d.ts @@ -1,5 +1,4 @@ import Node from "../core/Node.js"; -import { SwizzleOption } from "../tsl/TSLCore.js"; export default class SplitNode extends Node { node: Node; @@ -9,7 +8,7 @@ export default class SplitNode extends Node { * @param node the input node * @param components swizzle like string, default = "x" */ - constructor(node: Node, components?: SwizzleOption); + constructor(node: Node, components?: string); getVectorLength(): number; } diff --git a/types/three/src/nodes/utils/StorageArrayElementNode.d.ts b/types/three/src/nodes/utils/StorageArrayElementNode.d.ts index a8110c508..e85e805b3 100644 --- a/types/three/src/nodes/utils/StorageArrayElementNode.d.ts +++ b/types/three/src/nodes/utils/StorageArrayElementNode.d.ts @@ -2,18 +2,27 @@ import StorageBufferNode from "../accessors/StorageBufferNode.js"; import Node from "../core/Node.js"; import ArrayElementNode from "./ArrayElementNode.js"; -export default class StorageArrayElementNode extends ArrayElementNode { - node: StorageBufferNode; +interface StorageArrayElementNodeInterface { + node: StorageBufferNode; readonly isStorageArrayElementNode: true; - constructor(storageBufferNode: StorageBufferNode, indexNode: Node); - - get storageBufferNode(): StorageBufferNode; - set storageBufferNode(value: StorageBufferNode); + get storageBufferNode(): StorageBufferNode; + set storageBufferNode(value: StorageBufferNode); } -export const storageElement: ( - storageBufferNode: Node, +declare const StorageArrayElementNode: { + new( + storageBufferNode: StorageBufferNode, + indexNode: Node, + ): StorageArrayElementNode; +}; + +type StorageArrayElementNode = ArrayElementNode & StorageArrayElementNodeInterface; + +export default StorageArrayElementNode; + +export const storageElement: ( + storageBufferNode: Node, indexNode: Node, -) => StorageArrayElementNode; +) => StorageArrayElementNode; diff --git a/types/three/src/nodes/utils/Timer.d.ts b/types/three/src/nodes/utils/Timer.d.ts index bc0a8bf9b..0e09d23bc 100644 --- a/types/three/src/nodes/utils/Timer.d.ts +++ b/types/three/src/nodes/utils/Timer.d.ts @@ -1,5 +1,5 @@ -import Node from "../core/Node.js"; +import UniformNode from "../core/UniformNode.js"; -export const time: Node; -export const deltaTime: Node; -export const frameId: Node; +export const time: UniformNode<"float", number>; +export const deltaTime: UniformNode<"float", number>; +export const frameId: UniformNode<"float", number>; diff --git a/types/three/src/nodes/utils/TriplanarTextures.d.ts b/types/three/src/nodes/utils/TriplanarTextures.d.ts index e76f4f7c9..a90a878ef 100644 --- a/types/three/src/nodes/utils/TriplanarTextures.d.ts +++ b/types/three/src/nodes/utils/TriplanarTextures.d.ts @@ -7,7 +7,7 @@ export const triplanarTextures: ( scaleNode?: Node, positionNode?: Node, normalNode?: Node, -) => Node; +) => Node<"vec4">; export const triplanarTexture: ( textureXNode: Node, @@ -16,4 +16,4 @@ export const triplanarTexture: ( scaleNode?: Node, positionNode?: Node, normalNode?: Node, -) => Node; +) => Node<"vec4">; diff --git a/types/three/src/nodes/utils/UVUtils.d.ts b/types/three/src/nodes/utils/UVUtils.d.ts index 5c97558e2..f1a36c6f9 100644 --- a/types/three/src/nodes/utils/UVUtils.d.ts +++ b/types/three/src/nodes/utils/UVUtils.d.ts @@ -1,17 +1,16 @@ import ContextNode from "../core/ContextNode.js"; import Node from "../core/Node.js"; -import OperatorNode from "../math/OperatorNode.js"; -export function replaceDefaultUV(callback: (node: Node) => Node, node?: Node | null): ContextNode; +export function replaceDefaultUV(callback: (node: Node) => Node, node?: Node | null): ContextNode; export const rotateUV: ( - uv: Node, - rotation: Node, - center?: Node, -) => OperatorNode; + uv: Node<"vec2">, + rotation: Node<"float">, + center?: Node<"vec2">, +) => Node<"vec2">; export const spherizeUV: ( - uv: Node, - strength: Node | number, - center?: Node, -) => OperatorNode; + uv: Node<"vec2">, + strength: Node<"float"> | number, + center?: Node<"vec2">, +) => Node<"vec2">; diff --git a/types/three/src/renderers/common/UniformsGroup.d.ts b/types/three/src/renderers/common/UniformsGroup.d.ts index 7f48f89da..727d2ec80 100644 --- a/types/three/src/renderers/common/UniformsGroup.d.ts +++ b/types/three/src/renderers/common/UniformsGroup.d.ts @@ -82,49 +82,49 @@ declare class UniformsGroup extends UniformBuffer { * @param {NumberUniform} uniform - The Number uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateNumber(uniform: NumberNodeUniform): boolean; + updateNumber(uniform: NumberNodeUniform): boolean; /** * Updates a given Vector2 uniform. * * @param {Vector2Uniform} uniform - The Vector2 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector2(uniform: Vector2NodeUniform): boolean; + updateVector2(uniform: Vector2NodeUniform): boolean; /** * Updates a given Vector3 uniform. * * @param {Vector3Uniform} uniform - The Vector3 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector3(uniform: Vector3NodeUniform): boolean; + updateVector3(uniform: Vector3NodeUniform): boolean; /** * Updates a given Vector4 uniform. * * @param {Vector4Uniform} uniform - The Vector4 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector4(uniform: Vector4NodeUniform): boolean; + updateVector4(uniform: Vector4NodeUniform): boolean; /** * Updates a given Color uniform. * * @param {ColorUniform} uniform - The Color uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateColor(uniform: ColorNodeUniform): boolean; + updateColor(uniform: ColorNodeUniform): boolean; /** * Updates a given Matrix3 uniform. * * @param {Matrix3Uniform} uniform - The Matrix3 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateMatrix3(uniform: Matrix3NodeUniform): boolean; + updateMatrix3(uniform: Matrix3NodeUniform): boolean; /** * Updates a given Matrix4 uniform. * * @param {Matrix4Uniform} uniform - The Matrix4 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateMatrix4(uniform: Matrix4NodeUniform): boolean; + updateMatrix4(uniform: Matrix4NodeUniform): boolean; /** * Returns a typed array that matches the given data type. * diff --git a/types/three/src/renderers/common/nodes/NodeUniform.d.ts b/types/three/src/renderers/common/nodes/NodeUniform.d.ts index b5d6209e2..0ba1e0325 100644 --- a/types/three/src/renderers/common/nodes/NodeUniform.d.ts +++ b/types/three/src/renderers/common/nodes/NodeUniform.d.ts @@ -23,14 +23,14 @@ import { * @private * @augments NumberUniform */ -declare class NumberNodeUniform extends NumberUniform { - nodeUniform: NodeUniform; +declare class NumberNodeUniform extends NumberUniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Number uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -51,14 +51,14 @@ declare class NumberNodeUniform extends NumberUniform { * @private * @augments Vector2Uniform */ -declare class Vector2NodeUniform extends Vector2Uniform { - nodeUniform: NodeUniform; +declare class Vector2NodeUniform extends Vector2Uniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Vector2 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -79,14 +79,14 @@ declare class Vector2NodeUniform extends Vector2Uniform { * @private * @augments Vector3Uniform */ -declare class Vector3NodeUniform extends Vector3Uniform { - nodeUniform: NodeUniform; +declare class Vector3NodeUniform extends Vector3Uniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Vector3 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -107,14 +107,14 @@ declare class Vector3NodeUniform extends Vector3Uniform { * @private * @augments Vector4Uniform */ -declare class Vector4NodeUniform extends Vector4Uniform { - nodeUniform: NodeUniform; +declare class Vector4NodeUniform extends Vector4Uniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Vector4 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -135,14 +135,14 @@ declare class Vector4NodeUniform extends Vector4Uniform { * @private * @augments ColorUniform */ -declare class ColorNodeUniform extends ColorUniform { - nodeUniform: NodeUniform; +declare class ColorNodeUniform extends ColorUniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Color uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -163,14 +163,14 @@ declare class ColorNodeUniform extends ColorUniform { * @private * @augments Matrix2Uniform */ -declare class Matrix2NodeUniform extends Matrix2Uniform { - nodeUniform: NodeUniform; +declare class Matrix2NodeUniform extends Matrix2Uniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Matrix2 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -191,14 +191,14 @@ declare class Matrix2NodeUniform extends Matrix2Uniform { * @private * @augments Matrix3Uniform */ -declare class Matrix3NodeUniform extends Matrix3Uniform { - nodeUniform: NodeUniform; +declare class Matrix3NodeUniform extends Matrix3Uniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Matrix3 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -219,14 +219,14 @@ declare class Matrix3NodeUniform extends Matrix3Uniform { * @private * @augments Matrix4Uniform */ -declare class Matrix4NodeUniform extends Matrix4Uniform { - nodeUniform: NodeUniform; +declare class Matrix4NodeUniform extends Matrix4Uniform { + nodeUniform: NodeUniform; /** * Constructs a new node-based Matrix4 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** * Overwritten to return the value of the node uniform. * @@ -251,10 +251,10 @@ export { Vector4NodeUniform, }; export type NodeUniformGPU = - | NumberNodeUniform - | Vector2NodeUniform - | Vector3NodeUniform - | Vector4NodeUniform - | ColorNodeUniform - | Matrix3NodeUniform - | Matrix4NodeUniform; + | NumberNodeUniform + | Vector2NodeUniform + | Vector3NodeUniform + | Vector4NodeUniform + | ColorNodeUniform + | Matrix3NodeUniform + | Matrix4NodeUniform; diff --git a/types/three/src/renderers/common/nodes/Nodes.d.ts b/types/three/src/renderers/common/nodes/Nodes.d.ts index d2a1b20d6..e34da57a3 100644 --- a/types/three/src/renderers/common/nodes/Nodes.d.ts +++ b/types/three/src/renderers/common/nodes/Nodes.d.ts @@ -44,9 +44,9 @@ interface CacheKeyData { } declare module "../../../scenes/Scene.js" { interface Scene { - environmentNode?: Node | null | undefined; - backgroundNode?: Node | null | undefined; - fogNode?: Node | null | undefined; + environmentNode?: Node<"vec3"> | null | undefined; + backgroundNode?: Node<"vec3"> | Node<"vec4"> | Node<"color"> | null | undefined; + fogNode?: Node<"vec4"> | null | undefined; } } /** diff --git a/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts b/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts index 899134218..ca4c75cad 100644 --- a/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +++ b/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts @@ -82,7 +82,10 @@ export default class WGSLNodeBuilder extends NodeBuilder { shaderStage: NodeShaderStage, ): string; - getPropertyName(node: NodeVar | NodeUniform, shaderStage: NodeShaderStage): string; + getPropertyName( + node: NodeVar | NodeUniform, + shaderStage: NodeShaderStage, + ): string; getOutputStructName(): string; diff --git a/types/three/test/unit/src/nodes/display/ColorAdjustment.ts b/types/three/test/unit/src/nodes/display/ColorAdjustment.ts index 4e815e917..bea17804c 100644 --- a/types/three/test/unit/src/nodes/display/ColorAdjustment.ts +++ b/types/three/test/unit/src/nodes/display/ColorAdjustment.ts @@ -8,28 +8,32 @@ import { add, atan2, cos, div, dot, float, mat3, max, mix, mul, ShaderNode, sin, sqrt, sub, vec3 } from "three/tsl"; import { Node, TempNode } from "three/webgpu"; -const luminanceNode = new ShaderNode<{ color: Node }>(({ color }) => { +const luminanceNode = new ShaderNode<{ color: Node<"vec3"> }, Node<"float">>(({ color }) => { const LUMA = vec3(0.2125, 0.7154, 0.0721); return dot(color, LUMA); }); -const saturationNode = new ShaderNode<{ color: Node; adjustment: Node }>(({ color, adjustment }) => { - const intensityNode = luminanceNode.call({ color }); +const saturationNode = new ShaderNode<{ color: Node<"vec3">; adjustment: Node<"float"> }, Node<"vec3">>( + ({ color, adjustment }) => { + const intensityNode = luminanceNode.call({ color }); - return mix(intensityNode, color, adjustment); -}); + return mix(intensityNode, color, adjustment); + }, +); -const vibranceNode = new ShaderNode<{ color: Node; adjustment: Node }>(({ color, adjustment }) => { - const average = div(add(color.r, color.g, color.b), 3.0); +const vibranceNode = new ShaderNode<{ color: Node<"vec3">; adjustment: Node<"float"> }, Node<"vec3">>( + ({ color, adjustment }) => { + const average = div(add(color.r, color.g, color.b), 3.0); - const mx = max(color.r, max(color.g, color.b)); - const amt = mul(sub(mx, average), mul(-3.0, adjustment)); + const mx = max(color.r, max(color.g, color.b)); + const amt = mul(sub(mx, average), mul(-3.0, adjustment)); - return mix(color.rgb, vec3(mx), amt); -}); + return mix(color.rgb, vec3(mx), amt); + }, +); -const hueNode = new ShaderNode<{ color: Node; adjustment: Node }>(({ color, adjustment }) => { +const hueNode = new ShaderNode<{ color: Node<"vec3">; adjustment: Node<"float"> }>(({ color, adjustment }) => { const RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135); const YIQtoRGB = mat3(1.0, 0.9563, 0.621, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046); diff --git a/types/three/test/unit/src/nodes/tsl/TSLCore.ts b/types/three/test/unit/src/nodes/tsl/TSLCore.ts index 33e66378a..66bf4af3b 100644 --- a/types/three/test/unit/src/nodes/tsl/TSLCore.ts +++ b/types/three/test/unit/src/nodes/tsl/TSLCore.ts @@ -8,11 +8,6 @@ import { ConstNode, MaterialNode, Node, PropertyNode } from "three/webgpu"; const s = color(1); s.xyz; -const aa = nodeArray([1, 2, "hello"]); -aa[0].xy = s; -aa[1].w = s; -aa[2] = "hello"; - nodeImmutable(MaterialNode, MaterialNode.ROTATION); nodeImmutable(PropertyNode, "vec4", "DiffuseColor"); @@ -24,8 +19,8 @@ shader.call({ a: s, b: new ConstNode(1) }); const fnWithoutArgs = Fn(() => vec3(1, 2, 3)); fnWithoutArgs(); -const fnWithArrayArgs = Fn(([a, b]: [a: Node, b: Node]) => a.add(b)); +const fnWithArrayArgs = Fn(([a, b]: [a: Node<"float">, b: Node<"vec3">]) => a.add(b)); fnWithArrayArgs(0.5, color(0.0, 0.25, 0.5)); -const fnWithArgs = Fn(({ a, b }: { a: Node; b: Node }) => a.add(b)); +const fnWithArgs = Fn(({ a, b }: { a: Node<"float">; b: Node<"vec3"> }) => a.add(b)); fnWithArgs({ a: 0.5, b: color(0.0, 0.25, 0.5) });