diff --git a/types/three/build/three.core.min.d.ts b/types/three/build/three.core.min.d.ts deleted file mode 100644 index 4af71a0d8085db..00000000000000 --- a/types/three/build/three.core.min.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../src/Three.Core.js"; diff --git a/types/three/build/three.module.min.d.ts b/types/three/build/three.module.min.d.ts deleted file mode 100644 index 1e831f0ed85e81..00000000000000 --- a/types/three/build/three.module.min.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../src/Three.js"; diff --git a/types/three/build/three.tsl.min.d.ts b/types/three/build/three.tsl.min.d.ts deleted file mode 100644 index c326524c42f058..00000000000000 --- a/types/three/build/three.tsl.min.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../src/Three.TSL.js"; diff --git a/types/three/build/three.webgpu.min.d.ts b/types/three/build/three.webgpu.min.d.ts deleted file mode 100644 index f43222f7617a13..00000000000000 --- a/types/three/build/three.webgpu.min.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../src/Three.WebGPU.js"; diff --git a/types/three/build/three.webgpu.nodes.min.d.ts b/types/three/build/three.webgpu.nodes.min.d.ts deleted file mode 100644 index bb2fbdb0cffea9..00000000000000 --- a/types/three/build/three.webgpu.nodes.min.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../src/Three.WebGPU.Nodes.js"; diff --git a/types/three/examples/jsm/Addons.d.ts b/types/three/examples/jsm/Addons.d.ts index 2ce4e684a6b3f5..2fdb93112d3f55 100644 --- a/types/three/examples/jsm/Addons.d.ts +++ b/types/three/examples/jsm/Addons.d.ts @@ -91,15 +91,16 @@ export * from "./loaders/EXRLoader.js"; export * from "./loaders/FBXLoader.js"; export * from "./loaders/FontLoader.js"; export * from "./loaders/GCodeLoader.js"; +export * from "./loaders/GLTFGaussianSplatLoaderExtension.js"; export * from "./loaders/GLTFLoader.js"; export * from "./loaders/HDRCubeTextureLoader.js"; export * from "./loaders/HDRLoader.js"; export * from "./loaders/IESLoader.js"; export * from "./loaders/KMZLoader.js"; +export * from "./loaders/KSPLATLoader.js"; export * from "./loaders/KTX2Loader.js"; export * from "./loaders/KTXLoader.js"; export * from "./loaders/LDrawLoader.js"; -export * from "./loaders/LottieLoader.js"; export * from "./loaders/LUT3dlLoader.js"; export * from "./loaders/LUTCubeLoader.js"; export * from "./loaders/LUTImageLoader.js"; @@ -114,6 +115,8 @@ export * from "./loaders/PDBLoader.js"; export * from "./loaders/PLYLoader.js"; export * from "./loaders/PVRLoader.js"; export * from "./loaders/RGBELoader.js"; +export * from "./loaders/SPLATLoader.js"; +export * from "./loaders/SPZLoader.js"; export * from "./loaders/STLLoader.js"; export * from "./loaders/SVGLoader.js"; export * from "./loaders/TDSLoader.js"; @@ -149,6 +152,7 @@ export * from "./misc/MorphAnimMesh.js"; export * from "./misc/MorphBlendMesh.js"; export * from "./misc/ProgressiveLightMap.js"; export * from "./misc/RollerCoaster.js"; +export * from "./misc/Sculptor.js"; export * from "./misc/TubePainter.js"; export * from "./misc/Volume.js"; export * from "./misc/VolumeSlice.js"; @@ -158,6 +162,7 @@ export * from "./modifiers/EdgeSplitModifier.js"; export * from "./modifiers/SimplifyModifier.js"; export * from "./modifiers/TessellateModifier.js"; +export * from "./objects/GaussianSplat.js"; export * from "./objects/GroundedSkybox.js"; export * from "./objects/Lensflare.js"; export * from "./objects/MarchingCubes.js"; diff --git a/types/three/examples/jsm/controls/TrackballControls.d.ts b/types/three/examples/jsm/controls/TrackballControls.d.ts index a1b10f8ce45d79..d1c8182e5b4e8b 100644 --- a/types/three/examples/jsm/controls/TrackballControls.d.ts +++ b/types/three/examples/jsm/controls/TrackballControls.d.ts @@ -47,6 +47,11 @@ declare class TrackballControls extends Controls { */ panSpeed: number; + /** + * The roll speed used for multi-touch roll. Default is `1`. + */ + rollSpeed: number; + /** * Whether or not rotation is disabled. Default is `false`. */ @@ -62,6 +67,11 @@ declare class TrackballControls extends Controls { */ noPan: boolean; + /** + * Whether two finger twist gesture rolls the camera around its view axis or not. Default is `false`. + */ + multiTouchRoll: boolean; + /** * Whether or not damping is disabled. Default is `false`. */ diff --git a/types/three/examples/jsm/exporters/GLTFExporter.d.ts b/types/three/examples/jsm/exporters/GLTFExporter.d.ts index 539e62b849ad36..c4b914174a5319 100644 --- a/types/three/examples/jsm/exporters/GLTFExporter.d.ts +++ b/types/three/examples/jsm/exporters/GLTFExporter.d.ts @@ -45,6 +45,11 @@ export interface GLTFExporterOptions { * Export custom glTF extensions defined on an object's userData.gltfExtensions property. Default is false. */ includeCustomExtensions?: boolean; + + /** + * Export with a copyright notice embedded in the glTF. Default is null. + */ + copyright?: string; } type TextureUtils = { diff --git a/types/three/examples/jsm/generators/CityGenerator.d.ts b/types/three/examples/jsm/generators/CityGenerator.d.ts index f27c2e9a48e11a..23f3bac5fcfeda 100644 --- a/types/three/examples/jsm/generators/CityGenerator.d.ts +++ b/types/three/examples/jsm/generators/CityGenerator.d.ts @@ -1,6 +1,14 @@ -import { Group, Material, MeshStandardNodeMaterial } from "three/webgpu"; +import { Group, InstancedMesh, Material, MeshStandardNodeMaterial, Node, UniformNode } from "three/webgpu"; +import { BenchGenerator } from "./city/BenchGenerator.js"; +import { CarGenerator } from "./city/CarGenerator.js"; +import { HydrantGenerator } from "./city/HydrantGenerator.js"; +import { PersonGenerator } from "./city/PersonGenerator.js"; import { SidewalkGenerator } from "./city/SidewalkGenerator.js"; import { SkyscraperGenerator } from "./city/SkyscraperGenerator.js"; +import { StreetlightGenerator } from "./city/StreetlightGenerator.js"; +import { StreetTreeGenerator } from "./city/StreetTreeGenerator.js"; +import { TrafficlightGenerator } from "./city/TrafficlightGenerator.js"; +import { TrashcanGenerator } from "./city/TrashcanGenerator.js"; export interface CityGeneratorParameters { seed: number; @@ -12,6 +20,7 @@ export interface CityGeneratorParameters { blocksZ: number; curbHeight: number; curbRadius: number; + sidewalkWidth: number; } export interface CityGeneratorLayout { @@ -23,6 +32,9 @@ export interface CityGeneratorLayout { blocksZ: number; blockW: number; blockD: number; + sidewalkWidth: number; + innerLotX: number; + innerLotZ: number; cityW: number; cityD: number; } @@ -31,6 +43,26 @@ export interface CityGeneratorMaterials { building?: Material | undefined; } +export interface CityGeneratorFurniture { + streetlight: StreetlightGenerator; + trafficlight: TrafficlightGenerator; + trashcan: TrashcanGenerator; + bench: BenchGenerator; + hydrant: HydrantGenerator; + tree: StreetTreeGenerator; + car: CarGenerator; + person: PersonGenerator; +} + +export interface CityGeneratorTower { + x: number; + y: number; + z: number; + w: number; + h: number; + d: number; +} + /** * Lays out a grid of city blocks and fills each lot with a {@link SkyscraperGenerator} * tower of its own seed, height and footprint, optionally on raised sidewalk @@ -52,21 +84,45 @@ export class CityGenerator { parameters: CityGeneratorParameters; layout: CityGeneratorLayout; + /** + * The city seed shared by building and proxy materials. Pass this to + * {@link createBuildingMaterial} to update the palette when rebuilding. + */ + seedNode: UniformNode<"uint", number>; + generators: SkyscraperGenerator[]; + towers: CityGeneratorTower[]; sidewalk: SidewalkGenerator; + furniture: CityGeneratorFurniture; group: Group | null; build(materials?: CityGeneratorMaterials): Group; + + /** + * Builds a lightweight stand-in for the city: one instanced box per tower, + * sized to match, in a single draw call. Intended for cheap global-illumination + * bakes, where the detailed facades and street furniture are unnecessary and the + * boxes still cast the same street shadows and bounce the same warm fill. + * + * Call after {@link CityGenerator#build}, which records the tower boxes. + */ + buildProxy(): InstancedMesh; + + buildFurniture(random: () => number): Group; + dispose(): void; static defaults: CityGeneratorParameters; } /** - * The shared material every tower in a {@link CityGenerator} is dressed with: one flat - * masonry colour per lot, picked from a palette by hashing the lot's grid cell. + * The shared material every tower in a {@link CityGenerator} is dressed with: the per-lot + * {@link buildingColorNode} resolved once per vertex on a skyscraper material. */ -export function createBuildingMaterial(layout: CityGeneratorLayout, seed?: number): MeshStandardNodeMaterial; +export function createBuildingMaterial( + layout: CityGeneratorLayout, + seed?: number | Node<"uint">, +): MeshStandardNodeMaterial; /** * The road surface: wet asphalt with lane lines and crosswalks aligned to a diff --git a/types/three/examples/jsm/generators/ForestGenerator.d.ts b/types/three/examples/jsm/generators/ForestGenerator.d.ts index ea278980c26957..de8a44b091157c 100644 --- a/types/three/examples/jsm/generators/ForestGenerator.d.ts +++ b/types/three/examples/jsm/generators/ForestGenerator.d.ts @@ -21,18 +21,12 @@ export interface ForestGeneratorParameters { } /** - * Carpets a {@link TerrainGenerator} ( or anything exposing `sampleHeight`, - * `sampleSlope`, `minY`, `maxY` and `parameters.size` ) with a forest of hundreds - * of thousands of trees in a single draw call. + * Carpets a {@link TerrainGenerator} with trees in a single instanced draw call. + * Each tree is a distorted icosphere with a baked crown gradient. Altitude, slope + * and a density mask control placement; rotation and scale vary between trees. * - * Each tree is the cheapest thing that still reads as a tree: a ~20-face icosphere - * squashed into a tapered teardrop and lumped with a little noise, carrying a baked - * dark-base / bright-top gradient. Tens of triangles each, so a single - * {@link THREE.InstancedMesh} of half a million of them costs one draw call. Trees - * are placed by rejection sampling against ecological rules — a min/max altitude - * band ( above the mist floor, below the snowline ), a slope limit ( none on - * cliffs ) and a low-frequency density mask that opens clearings — then jittered in - * yaw, lean and ( squared-biased ) scale so the stand never reads as copies. + * Compatible terrain objects expose `sampleHeight`, `sampleSlope`, `minY`, `maxY` + * and `parameters.size`. * * ```js * const forest = new ForestGenerator( { count: 500000 } ); diff --git a/types/three/examples/jsm/generators/TerrainGenerator.d.ts b/types/three/examples/jsm/generators/TerrainGenerator.d.ts index 6e13320c49108c..c789c67a1843e8 100644 --- a/types/three/examples/jsm/generators/TerrainGenerator.d.ts +++ b/types/three/examples/jsm/generators/TerrainGenerator.d.ts @@ -18,22 +18,12 @@ export interface TerrainGeneratorParameters { } /** - * Bakes a procedural mountain range into a single {@link THREE.BufferGeometry} and - * returns a `THREE.Group` ready to add to a scene. + * Bakes a procedural mountain range into a single mesh, returned in a `THREE.Group`. + * Domain-warped, derivative-damped noise shapes the ridges; thermal erosion relaxes + * steep slopes. A TSL material shades grass, rock and snow from altitude and slope. * - * The heightfield is a derivative-damped fractal sum ( Quilez's fake erosion ): each - * octave is suppressed where the running slope is already steep, concentrating detail - * into weathered ridgelines, and a low-frequency domain warp makes those ridges - * meander. A few passes of thermal ( talus ) erosion then relax any slope past the - * angle of repose, settling the fractal's needle-spikes into real crests. - * - * The grid is triangulated with alternating quad diagonals ( a diamond pattern ), so a - * coarse mesh holds its silhouette without a one-way grain. The surface shades itself - * from altitude and slope in TSL — grass, forest, rock, scree and snow, with detail - * normals and aerial perspective — so no material or textures are needed. - * - * The baked height grid is exposed through {@link TerrainGenerator#sampleHeight} so a - * scattered forest ( or anything else ) can sit exactly on the surface. + * The baked grid is available through {@link TerrainGenerator#sampleHeight} for + * placing a forest or other objects on the terrain. * * ```js * const terrain = new TerrainGenerator( { seed: 1 } ); diff --git a/types/three/examples/jsm/generators/TreeGenerator.d.ts b/types/three/examples/jsm/generators/TreeGenerator.d.ts index 704984092921bb..1e5ea7872c3b45 100644 --- a/types/three/examples/jsm/generators/TreeGenerator.d.ts +++ b/types/three/examples/jsm/generators/TreeGenerator.d.ts @@ -1,4 +1,4 @@ -import { Color, Material, Mesh, MeshStandardNodeMaterial, Node } from "three/webgpu"; +import { Color, Material, Mesh, MeshStandardNodeMaterial, Node, Vector3 } from "three/webgpu"; export interface TreeGeneratorParameters { seed: number; @@ -7,6 +7,8 @@ export interface TreeGeneratorParameters { branchAngle: number[]; angleVariance: number; lengthRatio: number; + lengthVariance: number; + branchLengthFalloff: number; trunkLength: number; trunkRadius: number; taper: number; @@ -27,7 +29,7 @@ export interface TreeGeneratorParameters { /** * Grows a procedural tree skeleton — trunk, branches and twigs, each swept as a tapered - * tube — and bakes it into one non-indexed {@link BufferGeometry} (position and normal + * tube — and bakes it into one indexed {@link BufferGeometry} (position and normal * only), ready to instance into a forest. It produces *branches only*; add foliage as a * separate layer. * @@ -65,6 +67,8 @@ export class TreeGenerator { setBranchAngle: (branchAngle: number[]) => this; setAngleVariance: (angleVariance: number) => this; setLengthRatio: (lengthRatio: number) => this; + setLengthVariance: (lengthVariance: number) => this; + setBranchLengthFalloff: (branchLengthFalloff: number) => this; setTrunkLength: (trunkLength: number) => this; setTrunkRadius: (trunkRadius: number) => this; setTaper: (taper: number) => this; @@ -85,13 +89,14 @@ export class TreeGenerator { export interface TreeMaterialParameters { barkColor?: Color | number | Node<"color"> | undefined; + barkScale?: Vector3 | undefined; } /** * A simple bark material for a {@link TreeGenerator} mesh: a low-saturation brown with a * faint, vertically-stretched grain, so trunks read near-black against bright fog. * - * @param {Object} [parameters] - `barkColor` ( a hex, THREE.Color or TSL node ). + * @param {Object} [parameters] - `barkColor` ( a hex, THREE.Color or TSL node ) and `barkScale` ( a THREE.Vector3 ). * @return {MeshStandardNodeMaterial} */ export function createTreeMaterial(parameters?: TreeMaterialParameters): MeshStandardNodeMaterial; diff --git a/types/three/examples/jsm/generators/city/BenchGenerator.d.ts b/types/three/examples/jsm/generators/city/BenchGenerator.d.ts new file mode 100644 index 00000000000000..db85c62e6c0275 --- /dev/null +++ b/types/three/examples/jsm/generators/city/BenchGenerator.d.ts @@ -0,0 +1,29 @@ +import { InstancedMeshGenerator } from "./InstancedMeshGenerator.js"; + +export interface BenchGeneratorParameters { + length: number; + depth: number; + seatHeight: number; + backHeight: number; +} + +/** + * A public street bench: timber slats carried on two cast-iron end frames that + * curl into armrests, with a reclined slatted backrest. Built once and instanced + * across a list of placements, dressed with one cheap material that branches on a + * baked `partId` ( warm stained wood, dark iron ). + * + * The canonical model stands on `y = 0`, centred in X / Z, runs along X and seats + * toward `+Z`, so a placement whose local `+Z` faces the road sits a passer-by + * looking out over it. + * + * ```js + * const benches = new BenchGenerator(); + * scene.add( benches.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class BenchGenerator extends InstancedMeshGenerator { + constructor(parameters?: Partial); + + static defaults: BenchGeneratorParameters; +} diff --git a/types/three/examples/jsm/generators/city/CarGenerator.d.ts b/types/three/examples/jsm/generators/city/CarGenerator.d.ts new file mode 100644 index 00000000000000..90269ddc005b8f --- /dev/null +++ b/types/three/examples/jsm/generators/city/CarGenerator.d.ts @@ -0,0 +1,43 @@ +import { BufferGeometry, ColorRepresentation, Group, Matrix4, MeshStandardNodeMaterial } from "three/webgpu"; + +export interface CarGeneratorPlacement { + matrix: Matrix4; + color: ColorRepresentation; +} + +/** + * A low-poly car fleet with lofted bodies, circular wheel arches, curved + * windscreens and recessed alloy wheels. Separate cabin panels define the + * windows and their frames. Two body types ( sedan and SUV ) are mixed + * deterministically across the fleet, and the taxi colour gets its own sedan with + * a roof sign, so a parked row reads as different vehicles rather than one mould. + * + * Each geometry is built once per type and shared; cars are grouped by body + * type with per-instance paint, so each group is a single instanced draw that + * assigns paint, glass, tyres and lamps using a baked `partId`, panel UVs and + * canonical-space masks. + * + * The canonical model stands with its wheels on `y = 0`, centred in X / Z, facing + * `+Z`, so a placement whose local `+Z` faces the road parks it nose-out. + * + * ```js + * const cars = new CarGenerator(); + * scene.add( cars.build( placements ) ); // placements: { matrix: Matrix4, color }[] + * ``` + */ +export class CarGenerator { + constructor(parameters?: {}); + + parameters: {}; + + geometries: Map; + materials: Map; + mesh: Group | null; + + build(cars: CarGeneratorPlacement[]): Group; + dispose(): void; + + static defaults: {}; + + static taxiColor: number; +} diff --git a/types/three/examples/jsm/generators/city/HydrantGenerator.d.ts b/types/three/examples/jsm/generators/city/HydrantGenerator.d.ts new file mode 100644 index 00000000000000..cece9b7bcf2198 --- /dev/null +++ b/types/three/examples/jsm/generators/city/HydrantGenerator.d.ts @@ -0,0 +1,27 @@ +import { InstancedMeshGenerator } from "./InstancedMeshGenerator.js"; + +export interface HydrantGeneratorParameters { + radius: number; + height: number; +} + +/** + * A classic cast-iron fire hydrant: a stout barrel on a flared footing, capped by a + * domed bonnet and a hex operating nut, with two side outlet nozzles and a larger + * front pumper nozzle. Built once and instanced across a list of placements, dressed + * with one cheap material that branches on a baked `partId` ( weathered red iron, + * bare metal caps ). + * + * The canonical model stands on `y = 0`, centred in X / Z, with the pumper nozzle + * facing `+Z`, so a placement whose local `+Z` faces the road presents it to traffic. + * + * ```js + * const hydrants = new HydrantGenerator(); + * scene.add( hydrants.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class HydrantGenerator extends InstancedMeshGenerator { + constructor(parameters?: Partial); + + static defaults: HydrantGeneratorParameters; +} diff --git a/types/three/examples/jsm/generators/city/InstancedMeshGenerator.d.ts b/types/three/examples/jsm/generators/city/InstancedMeshGenerator.d.ts new file mode 100644 index 00000000000000..7480cccd846f30 --- /dev/null +++ b/types/three/examples/jsm/generators/city/InstancedMeshGenerator.d.ts @@ -0,0 +1,29 @@ +import { BufferGeometry, InstancedMesh, Material, Matrix4 } from "three"; + +export class InstancedMeshGenerator { + constructor( + parameters: Partial, + createGeometry: (parameters: TParameters) => BufferGeometry, + createMaterial: () => Material, + name: string, + receiveShadow?: boolean, + ); + + parameters: TParameters; + + geometry: BufferGeometry | null; + material: Material | null; + mesh: InstancedMesh | null; + + build(placements: Matrix4[]): InstancedMesh; + dispose(): void; +} + +export function createInstances( + geometry: BufferGeometry, + material: Material, + count: number, + name: string, +): InstancedMesh; + +export function updateInstances(mesh: InstancedMesh, placements: Matrix4[]): void; diff --git a/types/three/examples/jsm/generators/city/PersonGenerator.d.ts b/types/three/examples/jsm/generators/city/PersonGenerator.d.ts new file mode 100644 index 00000000000000..08a600afc19905 --- /dev/null +++ b/types/three/examples/jsm/generators/city/PersonGenerator.d.ts @@ -0,0 +1,44 @@ +import { BufferGeometry, Group, Matrix4, MeshStandardNodeMaterial } from "three/webgpu"; + +export interface PersonGeneratorParameters { + height: number; +} + +export interface PersonGeneratorGeometries { + walk: BufferGeometry; + stand: BufferGeometry; +} + +/** + * A low-poly pedestrian crowd with shaped heads, jackets and lofted limbs. + * Two shared poses stand or walk, with sleeves and trousers swept through + * their joints. Each placement gets deterministic proportions and a small + * seed attribute for its complexion, hairstyle and outfit, in two instanced draws. + * + * The material splits the figure into zones on a baked `partId` and hashes + * the seed per zone, drawing clothes, skin and hair from small palettes. + * Local UVs keep facial features, cuffs and shoe soles attached to their parts + * as the figure is posed. + * + * The canonical figure stands on `y = 0`, centred in X / Z and ~1.75 m tall, + * facing `+Z` so a placement turns it to face the road. + * + * ```js + * const people = new PersonGenerator(); + * scene.add( people.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class PersonGenerator { + constructor(parameters?: Partial); + + parameters: PersonGeneratorParameters; + + material: MeshStandardNodeMaterial | null; + geometries: PersonGeneratorGeometries | null; + mesh: Group | null; + + build(placements: Matrix4[]): Group; + dispose(): void; + + static defaults: PersonGeneratorParameters; +} diff --git a/types/three/examples/jsm/generators/city/StreetTreeGenerator.d.ts b/types/three/examples/jsm/generators/city/StreetTreeGenerator.d.ts new file mode 100644 index 00000000000000..6087eb0297cbb0 --- /dev/null +++ b/types/three/examples/jsm/generators/city/StreetTreeGenerator.d.ts @@ -0,0 +1,30 @@ +import { InstancedMeshGenerator } from "./InstancedMeshGenerator.js"; + +export interface StreetTreeGeneratorParameters { + trunkHeight: number; + trunkRadius: number; +} + +/** + * A young street tree set in a curbside pit: a flared bark trunk rising through a + * cast-iron pit grate, branching into a canopy of vertex-jittered leaf clumps. The + * clump normals are blended toward a shared crown sphere so the clumps shade as one + * irregular crown rather than separate balls, and the material adds interior + * self-shadowing and patchy colour so the foliage reads as leaf mass. Built once + * and instanced across a list of placements, dressed with one cheap material that + * branches on a baked `partId`. + * + * The canopy is near rotationally symmetric, so the canonical model stands on + * `y = 0`, centred in X / Z, with its slight lean toward `+Z` matching the other + * pieces of street furniture. + * + * ```js + * const trees = new StreetTreeGenerator(); + * scene.add( trees.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class StreetTreeGenerator extends InstancedMeshGenerator { + constructor(parameters?: Partial); + + static defaults: StreetTreeGeneratorParameters; +} diff --git a/types/three/examples/jsm/generators/city/StreetlightGenerator.d.ts b/types/three/examples/jsm/generators/city/StreetlightGenerator.d.ts new file mode 100644 index 00000000000000..cd54969d506d5e --- /dev/null +++ b/types/three/examples/jsm/generators/city/StreetlightGenerator.d.ts @@ -0,0 +1,28 @@ +import { InstancedMeshGenerator } from "./InstancedMeshGenerator.js"; + +export interface StreetlightGeneratorParameters { + height: number; + reach: number; + radius: number; +} + +/** + * A NYC cobra-head streetlight: a tall tapered mast standing at the curb with a + * curved arm reaching out over the roadway to a drop luminaire. Built once and + * instanced across a list of placements, dressed with one cheap material that + * branches on a baked `partId` ( dark metal pole, pale lamp lens ). + * + * The canonical model stands on `y = 0`, centred in X / Z, with the arm reaching + * toward `+Z`, so a placement whose local `+Z` faces the road throws the lamp + * over it. + * + * ```js + * const lights = new StreetlightGenerator(); + * scene.add( lights.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class StreetlightGenerator extends InstancedMeshGenerator { + constructor(parameters?: Partial); + + static defaults: StreetlightGeneratorParameters; +} diff --git a/types/three/examples/jsm/generators/city/TrafficlightGenerator.d.ts b/types/three/examples/jsm/generators/city/TrafficlightGenerator.d.ts new file mode 100644 index 00000000000000..6afab1e34a3fa2 --- /dev/null +++ b/types/three/examples/jsm/generators/city/TrafficlightGenerator.d.ts @@ -0,0 +1,29 @@ +import { InstancedMeshGenerator } from "./InstancedMeshGenerator.js"; + +export interface TrafficlightGeneratorParameters { + height: number; + reach: number; + radius: number; +} + +/** + * A NYC traffic signal: a round pole at the curb with a horizontal mast arm + * reaching out over the roadway to a vertical three-section signal head, plus a + * pedestrian-signal box on the pole. Built once and instanced across a list of + * placements, dressed with one cheap material that branches on a baked `partId` + * ( dark metal, three coloured lenses ). + * + * The canonical model stands on `y = 0`, centred in X / Z, with the arm reaching + * toward `+Z`, so a placement whose local `+Z` faces the road throws the head + * over it with its lenses aimed back at oncoming traffic. + * + * ```js + * const lights = new TrafficlightGenerator(); + * scene.add( lights.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class TrafficlightGenerator extends InstancedMeshGenerator { + constructor(parameters?: Partial); + + static defaults: TrafficlightGeneratorParameters; +} diff --git a/types/three/examples/jsm/generators/city/TrashcanGenerator.d.ts b/types/three/examples/jsm/generators/city/TrashcanGenerator.d.ts new file mode 100644 index 00000000000000..df22f5714402f1 --- /dev/null +++ b/types/three/examples/jsm/generators/city/TrashcanGenerator.d.ts @@ -0,0 +1,24 @@ +import { InstancedMeshGenerator } from "./InstancedMeshGenerator.js"; + +export interface TrashcanGeneratorParameters { + radius: number; + height: number; +} + +/** + * The NYC green wire-mesh litter basket: a slightly tapered drum with a heavy top + * rim, a foot ring and a dark bag of trash inside. Built once and instanced across + * a list of placements; one cheap material branches on a baked `partId`, drawing + * the mesh weave procedurally from the drum's own UVs so no alpha or extra geometry + * is needed. Canonical model stands on `y = 0`, centred in X / Z. + * + * ```js + * const cans = new TrashcanGenerator(); + * scene.add( cans.build( placements ) ); // placements: Matrix4[] + * ``` + */ +export class TrashcanGenerator extends InstancedMeshGenerator { + constructor(parameters?: Partial); + + static defaults: TrashcanGeneratorParameters; +} diff --git a/types/three/examples/jsm/gpgpu/CountingSort.d.ts b/types/three/examples/jsm/gpgpu/CountingSort.d.ts new file mode 100644 index 00000000000000..5676f1a8a39593 --- /dev/null +++ b/types/three/examples/jsm/gpgpu/CountingSort.d.ts @@ -0,0 +1,31 @@ +import { Node, Renderer, StorageBufferAttribute, StorageBufferNode } from "three/webgpu"; + +export interface CountingSortOptions { + binCount?: number | undefined; + workgroupSize?: number | undefined; +} + +export class CountingSort { + constructor(count: number, options?: CountingSortOptions); + + count: number; + binCount: number; + workgroupSize: number; + + orderAttribute: StorageBufferAttribute; + + orderRead: StorageBufferNode<"uint">; + orderWrite: StorageBufferNode<"uint">; + binRead: StorageBufferNode<"uint">; + binWrite: StorageBufferNode<"uint">; + histogramAtomic: StorageBufferNode<"uint">; + offsetAtomic: StorageBufferNode<"uint">; + + setBinNode(binNode: () => Node): void; + + compute(renderer: Renderer): void; + + computeCPU(binFn: (index: number) => number): void; + + enableWebGLBuffers(): void; +} diff --git a/types/three/examples/jsm/helpers/LightProbeGridHelper.d.ts b/types/three/examples/jsm/helpers/LightProbeGridHelper.d.ts index 449b9229d0f866..5480cba6fbb7c2 100644 --- a/types/three/examples/jsm/helpers/LightProbeGridHelper.d.ts +++ b/types/three/examples/jsm/helpers/LightProbeGridHelper.d.ts @@ -1,7 +1,7 @@ -import { InstancedMesh, ShaderMaterial, SphereGeometry } from "three"; +import { InstancedMesh, NodeMaterial, SphereGeometry } from "three/webgpu"; import { LightProbeGrid } from "../lighting/LightProbeGrid.js"; -declare class LightProbeGridHelper extends InstancedMesh { +declare class LightProbeGridHelper extends InstancedMesh { probes: LightProbeGrid; constructor(probes: LightProbeGrid, sphereSize?: number); diff --git a/types/three/examples/jsm/helpers/LightProbeGridHelperWebGL.d.ts b/types/three/examples/jsm/helpers/LightProbeGridHelperWebGL.d.ts new file mode 100644 index 00000000000000..88f88a026bd4b3 --- /dev/null +++ b/types/three/examples/jsm/helpers/LightProbeGridHelperWebGL.d.ts @@ -0,0 +1,12 @@ +import { InstancedMesh, ShaderMaterial, SphereGeometry } from "three"; +import { LightProbeGridWebGL } from "../lighting/LightProbeGridWebGL.js"; + +declare class LightProbeGridHelperWebGL extends InstancedMesh { + probes: LightProbeGridWebGL; + + constructor(probes: LightProbeGridWebGL, sphereSize?: number); + + update(): void; +} + +export { LightProbeGridHelperWebGL }; diff --git a/types/three/examples/jsm/inspector/Extension.d.ts b/types/three/examples/jsm/inspector/Extension.d.ts index 6a6a383a040b54..6a67dd2f127f97 100644 --- a/types/three/examples/jsm/inspector/Extension.d.ts +++ b/types/three/examples/jsm/inspector/Extension.d.ts @@ -1,3 +1,4 @@ +import { Inspector, InspectorLayoutEvent } from "./Inspector.js"; import { Tab, TabEventMap } from "./ui/Tab.js"; export interface ExtensionEventMap extends TabEventMap {} @@ -6,4 +7,16 @@ export class Extension readonly isExtension: boolean; constructor(name: string); + + init(inspector: Inspector): void; + + serialize(): object | null; + deserialize(data: object): void; + + save(): void; + + dispose(): void; + + onOrientationChange(event?: InspectorLayoutEvent): void; + onLayoutChange(event?: InspectorLayoutEvent): void; } diff --git a/types/three/examples/jsm/inspector/Inspector.d.ts b/types/three/examples/jsm/inspector/Inspector.d.ts index 55fe8c2e7604ff..f446376fce0b57 100644 --- a/types/three/examples/jsm/inspector/Inspector.d.ts +++ b/types/three/examples/jsm/inspector/Inspector.d.ts @@ -1,29 +1,54 @@ +import { ColorGrading } from "./extensions/color-grading/ColorGrading.js"; import { TSLGraphEditor } from "./extensions/tsl-graph/TSLGraphEditor.js"; import { RendererInspector, RendererInspectorEventMap } from "./RendererInspector.js"; import { ParametersGroup } from "./tabs/Parameters.js"; import { Tab } from "./ui/Tab.js"; +export interface InspectorLayoutEvent { + position: "bottom" | "right"; + isVertical: boolean; +} + export interface InspectorEventMap extends RendererInspectorEventMap { resize: {}; + orientationchange: InspectorLayoutEvent; + layoutchange: InspectorLayoutEvent; +} + +export interface InspectorOptions { + nonce?: string | null | undefined; } declare class Inspector extends RendererInspector { + constructor(options?: InspectorOptions); + + nonce: string | null; + createParameters(name: string): ParametersGroup; get domElement(): HTMLDivElement; + onExtension(name: "Color Grading", callback: (extension: ColorGrading) => void): this; onExtension(name: "TSL Graph", callback: (extension: TSLGraphEditor) => void): this; hide(): void; show(): void; + setVisible(value: boolean): this; + getVisible(): boolean; + getSize(): { width: number; height: number }; + isVertical(): boolean; + + setHorizontalAlign(value: "left" | "right"): this; + setVerticalAlign(value: "top" | "bottom"): this; + setActiveTab(tab: Tab): this; addTab(tab: Tab): this; removeTab(tab: Tab): this; - setActiveExtension(name: "TSL Graph", value: boolean): this; + setActiveExtension(name: "Color Grading" | "TSL Graph", value: boolean): this; } export { Inspector }; diff --git a/types/three/examples/jsm/inspector/extensions/color-grading/ColorGrading.d.ts b/types/three/examples/jsm/inspector/extensions/color-grading/ColorGrading.d.ts new file mode 100644 index 00000000000000..e1e9cc35d4785c --- /dev/null +++ b/types/three/examples/jsm/inspector/extensions/color-grading/ColorGrading.d.ts @@ -0,0 +1,34 @@ +import { ToneMapping } from "../../../../../src/constants.js"; +import { Data3DTexture } from "../../../../../src/textures/Data3DTexture.js"; +import { Extension } from "../../Extension.js"; + +export interface ColorGradingJSON { + version: number; + lutSize: number; + selectedToneMapping: ToneMapping; + pipelineOrder: string[]; + modules: { [id: string]: unknown }; + params: { [name: string]: unknown }; +} + +export interface ColorGradingOptions { + nonce?: string | null | undefined; +} + +export class ColorGrading extends Extension { + constructor(options?: ColorGradingOptions); + + lutSize: number; + lutTexture: Data3DTexture | null; + sceneGradingEnabled: boolean; + selectedToneMapping: ToneMapping; + + generate3DLUTData(size?: number, buffer?: Float32Array | null): Float32Array; + + toJSON(): ColorGradingJSON; + + serialize(): ColorGradingJSON; + deserialize(data: ColorGradingJSON): void; + + load(data: ColorGradingJSON | string): void; +} diff --git a/types/three/examples/jsm/inspector/ui/Tab.d.ts b/types/three/examples/jsm/inspector/ui/Tab.d.ts index e45d2c9db5eb0f..f9266198bc4ccd 100644 --- a/types/three/examples/jsm/inspector/ui/Tab.d.ts +++ b/types/three/examples/jsm/inspector/ui/Tab.d.ts @@ -4,4 +4,6 @@ export interface TabEventMap {} export class Tab extends EventDispatcher { constructor(title: string); + + dispose(): void; } diff --git a/types/three/examples/jsm/inspector/ui/Values.d.ts b/types/three/examples/jsm/inspector/ui/Values.d.ts index 4b9d5b36f3f6fa..b2c7633a991976 100644 --- a/types/three/examples/jsm/inspector/ui/Values.d.ts +++ b/types/three/examples/jsm/inspector/ui/Values.d.ts @@ -10,6 +10,9 @@ declare class Value< TEventMap extends ValueEventMap = ValueEventMap, > extends EventDispatcher { onChange(callback: (value: T[K]) => void): this; + debounce(time: number): this; + show(): this; + hide(): this; } export interface ValueNumberParams { diff --git a/types/three/examples/jsm/libs/mikktspace.module.d.ts b/types/three/examples/jsm/libs/mikktspace.module.d.ts new file mode 100644 index 00000000000000..d8fef33a296848 --- /dev/null +++ b/types/three/examples/jsm/libs/mikktspace.module.d.ts @@ -0,0 +1,19 @@ +/** + * Generates vertex tangents for the given position/normal/texcoord attributes. + */ +export function generateTangents( + position: Float32Array, + normal: Float32Array, + texcoord: Float32Array, +): Float32Array; + +export let wasm: unknown; + +export let isReady: boolean; + +/** + * Initializes the WASM module when awaited for the first time. + */ +export const ready: PromiseLike; + +export function dispose(): void; diff --git a/types/three/examples/jsm/libs/zstddec.module.d.ts b/types/three/examples/jsm/libs/zstddec.module.d.ts new file mode 100644 index 00000000000000..b3dc970362a488 --- /dev/null +++ b/types/three/examples/jsm/libs/zstddec.module.d.ts @@ -0,0 +1,5 @@ +export class ZSTDDecoder { + init(): Promise; + + decode(array: Uint8Array, uncompressedSize?: number): Uint8Array; +} diff --git a/types/three/examples/jsm/lighting/LightProbeGrid.d.ts b/types/three/examples/jsm/lighting/LightProbeGrid.d.ts index 3ee393985ae4e4..7e0787afa60c25 100644 --- a/types/three/examples/jsm/lighting/LightProbeGrid.d.ts +++ b/types/three/examples/jsm/lighting/LightProbeGrid.d.ts @@ -1,4 +1,4 @@ -import { Box3, Data3DTexture, Object3D, Scene, Vector3, WebGLRenderer } from "three"; +import { Box3, Data3DTexture, Light, Scene, Vector3, WebGPURenderer } from "three/webgpu"; export interface LightProbeGridBakeOptions { /** @@ -14,41 +14,46 @@ export interface LightProbeGridBakeOptions { */ far?: number | undefined; /** - * Additional bounce passes after the initial direct pass. + * Additional bounce passes. Only available when baking the whole grid. */ bounces?: number | undefined; + /** + * Directions integrated when projecting each cubemap to SH. + */ + sampleCount?: number | undefined; + /** + * Index of the first probe to bake. + */ + start?: number | undefined; + /** + * Number of probes to bake. Defaults to the remaining probes. + */ + count?: number | undefined; + /** + * Starting pass. Zero captures direct light; later passes sample the previous pass. Ranged calls require + * `bounces: 0`. + */ + pass?: number | undefined; } /** * A 3D grid of L2 Spherical Harmonic irradiance probes that provides * position-dependent diffuse global illumination. * - * Note that this class can only be used with {@link WebGLRenderer}. - * A version for {@link WebGPURenderer} will be added at a later point. - * - * All seven packed SH sub-volumes are stored in a **single** RGBA - * `WebGL3DRenderTarget` using a texture-atlas layout along the Z axis. - * Each sub-volume occupies `( nz + 2 )` atlas slices: one padding slice at - * each end (a copy of the nearest edge data slice) to prevent color bleeding - * when the hardware trilinear filter reads across a sub-volume boundary. + * This is the {@link WebGPURenderer} version of `LightProbeGrid`. The grid is a + * {@link Light}, so adding it to the scene applies its baked irradiance to every + * lit node material automatically. When using {@link WebGLRenderer}, import the + * grid from `LightProbeGridWebGL.js` instead. * - * Atlas layout (nz = resolution.z, PADDING = 1): - * ``` - * slice 0 : padding (copy of sub-volume 0, data slice 0) - * slices 1 … nz : sub-volume 0 data - * slice nz + 1 : padding (copy of sub-volume 0, data slice nz-1) - * slice nz + 2 : padding (copy of sub-volume 1, data slice 0) - * slices nz+3 … 2*nz+2 : sub-volume 1 data - * … - * ``` - * Total atlas depth = `7 * ( nz + 2 )`. - * - * Baking is fully GPU-resident: cubemap rendering, SH projection, and - * texture packing all happen on the GPU with zero CPU readback. + * The baked data is stored in a single RGBA `RenderTarget3D` atlas that packs + * the nine L2 SH coefficients into seven sub-volumes stacked along Z. Baking is + * fully GPU-resident: cubemap rendering, SH projection, and texture packing all + * happen on the GPU with zero CPU readback. * + * @augments Light * @three_import import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js'; */ -export class LightProbeGrid extends Object3D { +export class LightProbeGrid extends Light { /** * Constructs a new irradiance probe grid. * @@ -109,7 +114,18 @@ export class LightProbeGrid extends Object3D { */ boundingBox: Box3; /** - * The single RGBA atlas 3D texture storing all seven packed SH sub-volumes. + * Distance in world units over which the grid contribution fades out + * past the volume boundary. `0` applies the contribution everywhere + * (clamped), which matches a single-volume setup. Use a small positive + * value to blend multiple overlapping grids. + * + * @type {number} + * @default 0 + */ + falloff: number; + /** + * The single RGBA atlas 3D texture storing all seven packed SH + * sub-volumes stacked along Z. * * @type {?Data3DTexture} * @default null @@ -130,23 +146,32 @@ export class LightProbeGrid extends Object3D { */ updateBoundingBox(): void; /** - * Bakes all probes by rendering cubemaps at each probe position - * and projecting to L2 SH. Optionally iterates additional passes to - * capture indirect bounces — each extra pass samples the previous pass's - * atlas as indirect light, so a grid added to the scene before baking - * accumulates one bounce per extra pass. + * Bakes probes by rendering cubemaps at each probe position and + * projecting to L2 SH. Optionally iterates additional passes to capture + * indirect bounces: each extra pass samples the previous pass's data as + * indirect light, accumulating one bounce per extra pass. * - * @param {WebGLRenderer} renderer - The renderer. + * Use `start` and `count` to bake a range and publish its cells immediately. + * Indices advance along X, then Z, then Y, filling horizontal layers from bottom + * to top. For incremental indirect bounces, finish the whole grid for `pass: 0`, + * then repeat with `pass: 1`, etc. Start each pass at index 0 to snapshot the + * previous pass before updating its cells. + * + * Shadow-casting instances of `SunLight` are temporarily replaced with + * equivalent directional lights, since their view-fitted shadow cascades + * cannot be frozen across probe renders. + * + * @param {WebGPURenderer} renderer - The renderer. * @param {Scene} scene - The scene to render. * @param {Object} [options] - Bake options. * @param {number} [options.cubemapSize=8] - Resolution of each cubemap face. * @param {number} [options.near=0.1] - Near plane for the cube camera. * @param {number} [options.far=100] - Far plane for the cube camera. - * @param {number} [options.bounces=0] - Additional bounce passes after the initial direct pass. - */ - bake(renderer: WebGLRenderer, scene: Scene, options?: LightProbeGridBakeOptions): void; - /** - * Frees GPU resources. + * @param {number} [options.bounces=0] - Additional bounce passes. Only available when baking the whole grid. + * @param {number} [options.sampleCount=512] - Directions integrated when projecting each cubemap to SH. + * @param {number} [options.start=0] - Index of the first probe to bake. + * @param {number} [options.count] - Number of probes to bake. Defaults to the remaining probes. + * @param {number} [options.pass=0] - Starting pass. Zero captures direct light; later passes sample the previous pass. Ranged calls require `bounces: 0`. */ - dispose(): void; + bake(renderer: WebGPURenderer, scene: Scene, options?: LightProbeGridBakeOptions): void; } diff --git a/types/three/examples/jsm/lighting/LightProbeGridWebGL.d.ts b/types/three/examples/jsm/lighting/LightProbeGridWebGL.d.ts new file mode 100644 index 00000000000000..738a2c1e9741c9 --- /dev/null +++ b/types/three/examples/jsm/lighting/LightProbeGridWebGL.d.ts @@ -0,0 +1,178 @@ +import { Box3, Data3DTexture, Object3D, Scene, Vector3, WebGLRenderer } from "three"; + +export interface LightProbeGridWebGLBakeOptions { + /** + * Resolution of each cubemap face. + */ + cubemapSize?: number | undefined; + /** + * Near plane for the cube camera. + */ + near?: number | undefined; + /** + * Far plane for the cube camera. + */ + far?: number | undefined; + /** + * Additional bounce passes. Only available when baking the whole grid. + */ + bounces?: number | undefined; + /** + * Index of the first probe to bake. + */ + start?: number | undefined; + /** + * Number of probes to bake. Defaults to the remaining probes. + */ + count?: number | undefined; + /** + * Starting pass. Zero captures direct light; later passes sample the previous pass. Ranged calls require + * `bounces: 0`. + */ + pass?: number | undefined; +} + +/** + * A 3D grid of L2 Spherical Harmonic irradiance probes that provides + * position-dependent diffuse global illumination. + * + * Note that this class can only be used with {@link WebGLRenderer}. + * For {@link WebGPURenderer}, use {@link LightProbeGrid}. + * + * All seven packed SH sub-volumes are stored in a **single** RGBA + * `WebGL3DRenderTarget` using a texture-atlas layout along the Z axis. + * Each sub-volume occupies `( nz + 2 )` atlas slices: one padding slice at + * each end (a copy of the nearest edge data slice) to prevent color bleeding + * when the hardware trilinear filter reads across a sub-volume boundary. + * + * Atlas layout (nz = resolution.z, PADDING = 1): + * ``` + * slice 0 : padding (copy of sub-volume 0, data slice 0) + * slices 1 … nz : sub-volume 0 data + * slice nz + 1 : padding (copy of sub-volume 0, data slice nz-1) + * slice nz + 2 : padding (copy of sub-volume 1, data slice 0) + * slices nz+3 … 2*nz+2 : sub-volume 1 data + * … + * ``` + * Total atlas depth = `7 * ( nz + 2 )`. + * + * Baking is fully GPU-resident: cubemap rendering, SH projection, and + * texture packing all happen on the GPU with zero CPU readback. + * + * @three_import import { LightProbeGridWebGL } from 'three/addons/lighting/LightProbeGridWebGL.js'; + */ +export class LightProbeGridWebGL extends Object3D { + /** + * Constructs a new irradiance probe grid. + * + * The volume is centered at the object's position. + * + * @param {number} [width=1] - Full width of the volume along X. + * @param {number} [height=1] - Full height of the volume along Y. + * @param {number} [depth=1] - Full depth of the volume along Z. + * @param {number} [widthProbes] - Number of probes along X. Defaults to `Math.max( 2, Math.round( width ) + 1 )`. + * @param {number} [heightProbes] - Number of probes along Y. Defaults to `Math.max( 2, Math.round( height ) + 1 )`. + * @param {number} [depthProbes] - Number of probes along Z. Defaults to `Math.max( 2, Math.round( depth ) + 1 )`. + */ + constructor( + width?: number, + height?: number, + depth?: number, + widthProbes?: number, + heightProbes?: number, + depthProbes?: number, + ); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isLightProbeGrid: boolean; + /** + * The full width of the volume along X. + * + * @type {number} + */ + width: number; + /** + * The full height of the volume along Y. + * + * @type {number} + */ + height: number; + /** + * The full depth of the volume along Z. + * + * @type {number} + */ + depth: number; + /** + * The number of probes along each axis. + * + * @type {Vector3} + */ + resolution: Vector3; + /** + * The world-space bounding box for the grid. Updated automatically + * by {@link LightProbeGridWebGL#bake}. + * + * @type {Box3} + */ + boundingBox: Box3; + /** + * The single RGBA atlas 3D texture storing all seven packed SH sub-volumes. + * + * @type {?Data3DTexture} + * @default null + */ + texture: Data3DTexture | null; + /** + * Returns the world-space position of the probe at grid indices (ix, iy, iz). + * + * @param {number} ix - X index. + * @param {number} iy - Y index. + * @param {number} iz - Z index. + * @param {Vector3} target - The target vector. + * @return {Vector3} The world-space position. + */ + getProbePosition(ix: number, iy: number, iz: number, target: Vector3): Vector3; + /** + * Updates the world-space bounding box from the current position and size. + */ + updateBoundingBox(): void; + /** + * Bakes probes by rendering cubemaps at each probe position and + * projecting to L2 SH. Optionally iterates additional passes to capture + * indirect bounces: each extra pass samples the previous pass's data as + * indirect light, so a grid added to the scene before baking accumulates + * one bounce per extra pass. + * + * Use `start` and `count` to bake a range and publish its cells immediately. + * Indices advance along X, then Z, then Y, filling horizontal layers from bottom + * to top. For incremental indirect bounces, finish the whole grid for `pass: 0`, + * then repeat with `pass: 1`, etc. Start each pass at index 0 to snapshot the + * previous pass before updating its cells. + * + * Shadow-casting instances of `SunLight` are temporarily replaced with + * equivalent directional lights, since their view-fitted shadow cascades + * cannot be frozen across probe renders. + * + * @param {WebGLRenderer} renderer - The renderer. + * @param {Scene} scene - The scene to render. + * @param {Object} [options] - Bake options. + * @param {number} [options.cubemapSize=8] - Resolution of each cubemap face. + * @param {number} [options.near=0.1] - Near plane for the cube camera. + * @param {number} [options.far=100] - Far plane for the cube camera. + * @param {number} [options.bounces=0] - Additional bounce passes. Only available when baking the whole grid. + * @param {number} [options.start=0] - Index of the first probe to bake. + * @param {number} [options.count] - Number of probes to bake. Defaults to the remaining probes. + * @param {number} [options.pass=0] - Starting pass. Zero captures direct light; later passes sample the previous pass. Ranged calls require `bounces: 0`. + */ + bake(renderer: WebGLRenderer, scene: Scene, options?: LightProbeGridWebGLBakeOptions): void; + /** + * Frees GPU resources. + */ + dispose(): void; +} diff --git a/types/three/examples/jsm/lighting/vxgi/VXGINode.d.ts b/types/three/examples/jsm/lighting/vxgi/VXGINode.d.ts new file mode 100644 index 00000000000000..657b09bf838137 --- /dev/null +++ b/types/three/examples/jsm/lighting/vxgi/VXGINode.d.ts @@ -0,0 +1,100 @@ +import { Camera, SampleNode, Scene, TempNode, TextureNode, UniformNode } from "three/webgpu"; +import { VXGIVolume } from "./VXGIVolume.js"; + +/** + * Post processing node for voxel based global illumination. The scene is voxelized into a + * {@link VXGIVolume} and indirect diffuse light and ambient occlusion are gathered per + * pixel with approximate voxel cone tracing. + * + * The node is a middle path between SSGI and Light Probe Grids: + * + * - Compared to `SSGINode` it is free of screen-space artifacts and provides noticeably more + * consistent lighting, since off-screen surfaces and thin occluders contribute. + * However, it is less dynamic: objects should stay static, because geometry changes require + * a re-voxelization (`needsUpdate = true`) which is too expensive for per-frame animation. + * - Compared to `LightProbeGrid` it supports dynamic lighting without a new baking process and + * produces a better overall lighting quality with less light bleeding. However, it is more + * expensive and therefore less suitable for performance restricted use cases. + * + * Note: This node can only be used with `WebGPURenderer` and a WebGPU backend. + * + * @augments TempNode + * @three_import import { vxgi } from 'three/addons/lighting/vxgi/VXGINode.js'; + */ +declare class VXGINodeInterface { + depthNode: TextureNode; + normalNode: TextureNode | SampleNode<"vec3"> | null; + scene: Scene; + camera: Camera; + + /** + * The voxel volume. Use it to configure bounds, layers and bounces. + */ + volume: VXGIVolume; + + coneCount: UniformNode<"uint", number>; + coneAngle: UniformNode<"float", number>; + giIntensity: UniformNode<"float", number>; + aoIntensity: UniformNode<"float", number>; + aoMinVisibility: UniformNode<"float", number>; + aoDistance: UniformNode<"float", number>; + normalOffset: UniformNode<"float", number>; + debug: UniformNode<"int", number>; + debugLevel: UniformNode<"float", number>; + + /** + * Whether to use temporal filtering or not. Setting this property to `true` requires the + * usage of `TRAANode`. Cone directions are then rotated per frame to converge the noise. + */ + useTemporalFiltering: boolean; + + /** + * Number of cached indirect bounces. See {@link VXGIVolume#bounces}. + */ + bounces: number; + + /** + * Whether the coarser radiance levels are filtered directionally to reduce light bleeding + * through thin walls and floors. See {@link VXGIVolume#directionalRadiance}. + */ + directionalRadiance: boolean; + + /** + * Set to `true` to re-voxelize the scene in the next frame. + */ + needsUpdate: boolean; + + /** + * Set to `true` to re-inject lighting in the next frame. + */ + lightingNeedsUpdate: boolean; + + getAONode(): TextureNode<"float">; + getGINode(): TextureNode<"vec4">; + + setSize(width: number, height: number): void; + + dispose(): void; +} + +declare const VXGINode: { + new( + depthNode: TextureNode, + normalNode: TextureNode | SampleNode<"vec3"> | null, + scene: Scene, + camera: Camera, + resolution?: number, + ): VXGINode; +}; + +type VXGINode = VXGINodeInterface & TempNode<"vec4">; + +export default VXGINode; + +export const vxgi: ( + depthNode: TextureNode, + normalNode: TextureNode | SampleNode<"vec3"> | null, + scene: Scene, + camera: Camera, + resolution?: number, +) => VXGINode; diff --git a/types/three/examples/jsm/lighting/vxgi/VXGIVolume.d.ts b/types/three/examples/jsm/lighting/vxgi/VXGIVolume.d.ts new file mode 100644 index 00000000000000..59158784479895 --- /dev/null +++ b/types/three/examples/jsm/lighting/vxgi/VXGIVolume.d.ts @@ -0,0 +1,245 @@ +import { + Box3, + Layers, + Node, + Renderer, + Scene, + Storage3DTexture, + Texture3DNode, + UniformNode, + Vector3, +} from "three/webgpu"; + +/** + * Holds the voxel representation of a scene for {@link VXGINode}: an anisotropic opacity + * mip chain, a direct radiance volume and a radiance volume with cached bounces. + * + * The representation is a dense variant of the pre-filtered voxel hierarchy of Crassin et al. 2011 + * (a dense mip chain instead of a sparse octree, which keeps cone samples to two texture fetches): + * opacity stores visibility per major axis and is filtered directionally (volumetric integration + * along the axis, averaging across it), radiance is stored opacity-premultiplied and indirect bounces + * are cached in the volume via cone tracing. Only direct lights are injected. + * Voxelization uses conservative rasterization along the dominant triangle axis in a compute shader. + * + * Direct light is injected per voxel instead of splatting photons from a light-view map as in the + * paper: the shadow maps rendered by the renderer are the light-view maps, and every occupied voxel + * pulls its visibility from them (2D maps for directional and spot lights, cube maps for point + * lights) and evaluates its irradiance analytically. This reuses the existing shadow passes, makes + * the injected shadows match the direct lighting exactly and needs neither atomics nor a + * normalization by photon density. Lights without a shadow map fall back to a visibility cone + * traced through the volume. The trade-off is a cost proportional to the number of occupied voxels + * times lights rather than to the light-view resolution, and that only outgoing diffuse radiance + * is stored (no incoming direction distribution for glossy cones). + * + * References: + * - {@link https://research.nvidia.com/publication/2011-09_interactive-indirect-illumination-using-voxel-cone-tracing}: + * Crassin et al., Interactive Indirect Illumination Using Voxel Cone Tracing, Pacific Graphics 2011. + * - {@link https://developer.nvidia.com/content/basics-gpu-voxelization}: Basics of GPU voxelization. + * + * Note: This class can only be used with `WebGPURenderer` and a WebGPU backend. + * + * @three_import import { VXGIVolume } from 'three/addons/lighting/vxgi/VXGIVolume.js'; + */ +export class VXGIVolume { + /** + * Constructs a new volume. + * + * @param {number} [resolution=128] - Number of voxels along the longest axis of the bounds. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer. + */ + constructor(resolution?: number); + /** + * Number of voxels along the longest axis of the bounds. Should not exceed `256`, higher values exceed the maximum storage buffer size of the voxelizer. + * + * @type {number} + * @default 128 + */ + resolution: number; + /** + * The requested world-space bounds of the volume. If empty (the default), the bounds are + * computed from the scene at voxelization. See {@link VXGIVolume#worldBounds} for the + * effective bounds. + * + * @type {Box3} + */ + bounds: Box3; + /** + * The effective world-space bounds of the voxel grid, updated at voxelization. + * + * @type {Box3} + * @readonly + */ + readonly worldBounds: Box3; + /** + * Only meshes that pass this layer test are voxelized. + * + * @type {Layers} + */ + layers: Layers; + /** + * Number of cached indirect bounces stored in the volume. Should be in the range `[0, 2]`. + * + * @type {number} + * @default 1 + */ + bounces: number; + /** + * Triangles with a lower opacity are not voxelized. + * + * @type {number} + * @default 0.1 + */ + minOpacity: number; + /** + * Whether the coarser radiance levels are filtered directionally: along each axis the finer + * voxels are composited front to back using their surface normals, so a cone only gathers + * the surfaces facing it. This reduces light bleeding through thin walls and floors (e.g. a + * sunlit floor brightening the ceiling of the room below) at the cost of additional memory + * and a more expensive radiance lookup. Changing it triggers a re-voxelization. + * + * @type {boolean} + * @default false + */ + directionalRadiance: boolean; + /** + * Maximum number of lights injected into the volume. + * + * @type {number} + * @default 8 + */ + maxLights: number; + /** + * Set to `true` to re-voxelize the scene in the next update. + * + * @type {boolean} + * @default true + */ + needsUpdate: boolean; + /** + * Set to `true` to re-inject lighting in the next update. Changes of the lights and of the + * injection parameters are detected automatically, so this is rarely needed. + * + * @type {boolean} + * @default true + */ + lightingNeedsUpdate: boolean; + /** + * Maximum cone length in world units. `0` means unbounded. + * + * @type {UniformNode} + * @default 0 + */ + maxDistance: UniformNode<"float", number>; + /** + * Step size relative to the texel size of the sampled mip level. + * + * @type {UniformNode} + * @default 0.5 + */ + stepScale: UniformNode<"float", number>; + /** + * Aperture in degrees of the visibility cones traced towards lights that do not provide a + * shadow map. Wider cones are cheaper but soften the injected shadows. + * + * @type {UniformNode} + * @default 10 + */ + shadowConeAngle: UniformNode<"float", number>; + /** + * Aperture of the cones used for the cached bounces in degrees. + * + * @type {UniformNode} + * @default 60 + */ + bounceConeAngle: UniformNode<"float", number>; + /** + * The minimum corner of the volume. + * + * @type {UniformNode} + */ + boundsMinNode: UniformNode<"vec3", Vector3>; + /** + * The size of the volume. + * + * @type {UniformNode} + */ + volumeSizeNode: UniformNode<"vec3", Vector3>; + /** + * The size of a voxel. + * + * @type {UniformNode} + */ + voxelSizeNode: UniformNode<"float", number>; + /** + * The highest valid mip level of the voxel textures. + * + * @type {UniformNode} + */ + maxLevelNode: UniformNode<"float", number>; + /** + * The per-axis opacity of the scene (`xyz`) and the occupancy (`w`) as a mip chain. + * + * @type {Storage3DTexture} + */ + opacityTexture: Storage3DTexture; + /** + * The radiance of the scene including cached bounces, premultiplied by occupancy, as a mip chain. + * With {@link VXGIVolume#directionalRadiance} only the finest level is used and the coarser + * levels live in {@link VXGIVolume#directionalTexture}. + * + * @type {Storage3DTexture} + */ + radianceTexture: Storage3DTexture; + /** + * Texture node of {@link VXGIVolume#opacityTexture}. Stays valid across re-allocations of the volume. + * + * @type {Texture3DNode} + */ + opacityNode: Texture3DNode; + /** + * Texture node of {@link VXGIVolume#radianceTexture}. Stays valid across re-allocations of the volume. + * + * @type {Texture3DNode} + */ + radianceNode: Texture3DNode; + /** + * The coarser radiance levels filtered directionally for the six directions a ray can travel + * (+x, -x, +y, -y, +z, -z), only allocated with {@link VXGIVolume#directionalRadiance}. Each + * texel holds the radiance of the surfaces facing the direction premultiplied by their weight + * (`rgb`) and the weight (`a`); occlusion comes from the opacity mip chain. The six directions + * are stored side by side along x in one half-resolution mip chain; level `n` of the volume is + * its level `n - 1`. + * + * @type {Storage3DTexture} + */ + directionalTexture: Storage3DTexture; + /** + * Texture node of {@link VXGIVolume#directionalTexture}. Stays valid across re-allocations of the volume. + * + * @type {Texture3DNode} + */ + directionalNode: Texture3DNode; + /** + * The width of one direction block of the directional texture in texels (at its level 0). + * + * @type {UniformNode} + */ + directionalWidthNode: UniformNode<"float", number>; + /** + * The effective maximum cone length as a node. + * + * @type {Node} + */ + get traceDistanceNode(): Node<"float">; + /** + * Updates the volume if required. Voxelizes the scene when `needsUpdate` is set and re-injects + * lighting when `lightingNeedsUpdate` is set or a light has changed. + * + * @param {Renderer} renderer - The renderer. + * @param {Scene} scene - The scene. + */ + update(renderer: Renderer, scene: Scene): void; + /** + * Frees internal resources. + */ + dispose(): void; +} diff --git a/types/three/examples/jsm/lights/SunLight.d.ts b/types/three/examples/jsm/lights/SunLight.d.ts new file mode 100644 index 00000000000000..71303561815ffd --- /dev/null +++ b/types/three/examples/jsm/lights/SunLight.d.ts @@ -0,0 +1,53 @@ +import { ColorRepresentation, JSONMeta, Light, LightJSON, LightShadowJSON } from "three"; +import { SunLightShadow } from "./SunLightShadow.js"; + +export interface SunLightJSON extends LightJSON { + shadow: LightShadowJSON; +} + +/** + * A sun-like light that gets emitted in a specific direction, with rays that + * are all parallel, and casts cascaded shadow maps via {@link SunLightShadow}, + * suited for lighting large scenes. + * + * Unlike {@link DirectionalLight}, the light has no target: like + * {@link HemisphereLight}, its direction is defined by its position. The + * light shines from its position towards the origin and points straight + * down by default. + * + * ```js + * const sun = new SunLight( 0xfff2e3, 3 ); + * sun.position.set( 1, 1, 1 ); + * sun.castShadow = true; + * scene.add( sun ); + * ``` + * + * When used with `WebGPURenderer`, the light must be registered with the + * renderer's node library first: + * ```js + * renderer.library.addLight( SunLightNode, SunLight ); + * ``` + * + * @three_import import { SunLight } from 'three/addons/lights/SunLight.js'; + */ +export class SunLight extends Light { + /** + * Constructs a new sun light. + * + * @param {(number|Color|string)} [color=0xffffff] - The light's color. + * @param {number} [intensity=1] - The light's strength/intensity. + */ + constructor(color?: ColorRepresentation, intensity?: number); + /** + * This flag can be used for type testing. + * + * @default true + */ + readonly isSunLight: boolean; + /** + * This property holds the light's shadow configuration. + */ + shadow: SunLightShadow; + copy(source: SunLight): this; + toJSON(meta?: JSONMeta): SunLightJSON; +} diff --git a/types/three/examples/jsm/lights/SunLightNode.d.ts b/types/three/examples/jsm/lights/SunLightNode.d.ts new file mode 100644 index 00000000000000..32f9d44f5a1a1f --- /dev/null +++ b/types/three/examples/jsm/lights/SunLightNode.d.ts @@ -0,0 +1,25 @@ +import { AnalyticLightNode, Node } from "three/webgpu"; +import { SunLight } from "./SunLight.js"; +import { SunShadowNode } from "./SunShadowNode.js"; + +/** + * Module for representing sun lights as nodes. Register it with the + * renderer's node library to use {@link SunLight} with `WebGPURenderer`: + * ```js + * renderer.library.addLight( SunLightNode, SunLight ); + * ``` + * + * @three_import import { SunLightNode } from 'three/addons/lights/SunLightNode.js'; + */ +export class SunLightNode extends AnalyticLightNode { + /** + * Overwritten to setup the cascaded shadows of sun lights. + * + * @return {SunShadowNode} The created shadow node. + */ + setupShadowNode(): SunShadowNode; + setupDirect(): { + lightDirection: Node<"vec3">; + lightColor: Node; + }; +} diff --git a/types/three/examples/jsm/lights/SunLightShadow.d.ts b/types/three/examples/jsm/lights/SunLightShadow.d.ts new file mode 100644 index 00000000000000..bafeadc0c0e50c --- /dev/null +++ b/types/three/examples/jsm/lights/SunLightShadow.d.ts @@ -0,0 +1,57 @@ +import { Camera, Frustum, Light, LightShadow, Matrix4, OrthographicCamera } from "three"; + +/** + * Represents the shadow configuration of {@link SunLight}, using two + * cascaded shadow maps (CSM). + * + * The shadow camera projection is fitted automatically to slices of the view + * frustum, up to a distance of `camera.far` (or the view camera's far plane, + * whichever is smaller), and adjacent cascades blend into each other over a + * small depth range. `camera.left/right/top/bottom` are ignored. + * + * The default `mapSize` is `1024x1024` per cascade. + * + * @three_import import { SunLightShadow } from 'three/addons/lights/SunLightShadow.js'; + */ +export class SunLightShadow extends LightShadow { + /** + * Constructs a new sun light shadow. + */ + constructor(); + /** + * This flag can be used for type testing. + * + * @default true + */ + readonly isSunLightShadow: boolean; + /** + * Returns the shadow camera of the given cascade. + * + * @param {number} [cascadeIndex=0] - The cascade index. + * @return {OrthographicCamera} The shadow camera. + */ + getCamera(cascadeIndex?: number): OrthographicCamera; + /** + * Returns the shadow matrix of the given cascade. + * + * @param {number} [cascadeIndex=0] - The cascade index. + * @return {Matrix4} The shadow matrix. + */ + getMatrix(cascadeIndex?: number): Matrix4; + /** + * Returns the shadow camera frustum of the given cascade. Used internally by + * the renderer to cull objects. + * + * @param {number} [cascadeIndex=0] - The cascade index. + * @return {Frustum} The shadow camera frustum. + */ + getFrustum(cascadeIndex?: number): Frustum; + /** + * Update the matrices for the cascade cameras and shadows, used internally + * by the renderer. + * + * @param {Light} light - The light for which the shadow is being rendered. + * @param {Camera} viewCamera - The camera the scene is rendered with. + */ + updateMatrices(light: Light, viewCamera?: Camera): void; +} diff --git a/types/three/examples/jsm/lights/SunShadowNode.d.ts b/types/three/examples/jsm/lights/SunShadowNode.d.ts new file mode 100644 index 00000000000000..2c646560f6c230 --- /dev/null +++ b/types/three/examples/jsm/lights/SunShadowNode.d.ts @@ -0,0 +1,53 @@ +import { DepthTexture, Node, NodeBuilder, NodeFrame, RenderTarget, ShadowNode } from "three/webgpu"; +import { SunLight } from "./SunLight.js"; +import { SunLightShadow } from "./SunLightShadow.js"; + +export function sunShadow(light: SunLight, shadow?: SunLightShadow | null): SunShadowNode; +/** + * Represents the cascaded shadow map of a {@link SunLight}. + * + * The two cascade cameras are fitted by {@link SunLightShadow} and rendered + * into the viewports of a single shadow map atlas. Each fragment walks the + * cascades back to front, blending across the fade bands between them. + * + * @three_import import { sunShadow } from 'three/addons/lights/SunShadowNode.js'; + */ +export class SunShadowNode extends ShadowNode { + /** + * Constructs a new sun shadow node. + * + * @param {SunLight} light - The shadow casting sun light. + * @param {?SunLightShadow} [shadow=null] - An optional sun light shadow. + */ + constructor(light: SunLight, shadow?: SunLightShadow | null); + /** + * Overwrites the default implementation to size the render target as the cascade atlas. + * + * @param {SunLightShadow} shadow - The light shadow object. + * @param {NodeBuilder} builder - A reference to the current node builder. + * @return {Object} An object containing the shadow map and depth texture. + */ + setupRenderTarget(shadow: SunLightShadow, builder: NodeBuilder): { + shadowMap: RenderTarget; + depthTexture: DepthTexture; + }; + /** + * Sets up the atlas render target and shadow output node. + * + * @param {NodeBuilder} builder - A reference to the current node builder. + * @return {Node} The shadow output node. + */ + setupShadow(builder: NodeBuilder): Node<"float">; + /** + * Renders the two cascades into the viewports of the shadow map atlas. + * + * @param {NodeFrame} frame - A reference to the current node frame. + */ + renderShadow(frame: NodeFrame): void; + /** + * Overwritten as a no-op since VSM is not supported for cascaded shadow maps. + * + * @param {Renderer} renderer - A reference to the current renderer. + */ + vsmPass(): void; +} diff --git a/types/three/examples/jsm/loaders/3DMLoader.d.ts b/types/three/examples/jsm/loaders/3DMLoader.d.ts index 35568203f8fc4c..19057eeb5d79a6 100644 --- a/types/three/examples/jsm/loaders/3DMLoader.d.ts +++ b/types/three/examples/jsm/loaders/3DMLoader.d.ts @@ -4,7 +4,9 @@ export class Rhino3dmLoader extends Loader { constructor(manager?: LoadingManager); parse(data: ArrayBufferLike, onLoad: (object: Object3D) => void, onError?: (event: ErrorEvent) => void): void; + parseAsync(data: ArrayBufferLike): Promise; setLibraryPath(path: string): Rhino3dmLoader; setWorkerLimit(workerLimit: number): Rhino3dmLoader; + setSubdivisionLevel(level: number): Rhino3dmLoader; dispose(): Rhino3dmLoader; } diff --git a/types/three/examples/jsm/loaders/FBXLoader.d.ts b/types/three/examples/jsm/loaders/FBXLoader.d.ts index b5eac71d0be0a2..5279ec3450ebb4 100644 --- a/types/three/examples/jsm/loaders/FBXLoader.d.ts +++ b/types/three/examples/jsm/loaders/FBXLoader.d.ts @@ -2,6 +2,7 @@ import { Group, Loader, LoadingManager } from "three"; export class FBXLoader extends Loader { constructor(manager?: LoadingManager); + trimAnimationClips: boolean; parse(FBXBuffer: ArrayBuffer | string, path: string): Group; } diff --git a/types/three/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.d.ts b/types/three/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.d.ts new file mode 100644 index 00000000000000..31f4d8d5dbf339 --- /dev/null +++ b/types/three/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.d.ts @@ -0,0 +1,14 @@ +import { Group } from "three"; +import { GaussianSplat } from "../objects/GaussianSplat.js"; +import { GLTFParser } from "./GLTFLoader.js"; + +declare class GLTFGaussianSplatLoaderExtension { + constructor(parser: GLTFParser); + + name: string; + parser: GLTFParser; + + loadMesh(meshIndex: number): Promise | null; +} + +export { GLTFGaussianSplatLoaderExtension }; diff --git a/types/three/examples/jsm/loaders/GLTFLoader.d.ts b/types/three/examples/jsm/loaders/GLTFLoader.d.ts index ad18a1f8baaf5a..66e259c9f756ac 100644 --- a/types/three/examples/jsm/loaders/GLTFLoader.d.ts +++ b/types/three/examples/jsm/loaders/GLTFLoader.d.ts @@ -64,13 +64,14 @@ export class GLTFLoader extends Loader { parseAsync(data: ArrayBuffer | string, path: string): Promise; } -export type GLTFReferenceType = "materials" | "nodes" | "textures" | "meshes"; +export type GLTFReferenceType = "materials" | "nodes" | "textures" | "meshes" | "primitives"; export interface GLTFReference { materials?: number; nodes?: number; textures?: number; meshes?: number; + primitives?: number; } export class GLTFParser { diff --git a/types/three/examples/jsm/loaders/GaussianSplatPLYLoader.d.ts b/types/three/examples/jsm/loaders/GaussianSplatPLYLoader.d.ts new file mode 100644 index 00000000000000..f2b20cedd5481e --- /dev/null +++ b/types/three/examples/jsm/loaders/GaussianSplatPLYLoader.d.ts @@ -0,0 +1,9 @@ +import { BufferGeometry, Loader, LoadingManager } from "three"; + +declare class GaussianSplatPLYLoader extends Loader { + constructor(manager?: LoadingManager); + + parse(data: ArrayBuffer | string): BufferGeometry; +} + +export { GaussianSplatPLYLoader }; diff --git a/types/three/examples/jsm/loaders/KSPLATLoader.d.ts b/types/three/examples/jsm/loaders/KSPLATLoader.d.ts new file mode 100644 index 00000000000000..79508fc7b48d49 --- /dev/null +++ b/types/three/examples/jsm/loaders/KSPLATLoader.d.ts @@ -0,0 +1,9 @@ +import { BufferGeometry, Loader, LoadingManager } from "three"; + +declare class KSPLATLoader extends Loader { + constructor(manager?: LoadingManager); + + parse(buffer: ArrayBuffer): BufferGeometry; +} + +export { KSPLATLoader }; diff --git a/types/three/examples/jsm/loaders/LottieLoader.d.ts b/types/three/examples/jsm/loaders/LottieLoader.d.ts deleted file mode 100644 index 69d614e3095387..00000000000000 --- a/types/three/examples/jsm/loaders/LottieLoader.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { CanvasTexture, Loader, LoadingManager } from "three"; - -export class LottieLoader extends Loader { - /** - * @deprecated The loader has been deprecated and will be removed with r186. Use lottie-web instead and create your - * animated texture manually. - */ - constructor(manager?: LoadingManager); - - load( - url: string, - onLoad?: (data: CanvasTexture) => void, - onProgress?: (event: ProgressEvent) => void, - onError?: (err: unknown) => void, - ): CanvasTexture; - - setQuality(value: number): void; -} diff --git a/types/three/examples/jsm/loaders/MaterialXLoader.d.ts b/types/three/examples/jsm/loaders/MaterialXLoader.d.ts index e9fcafad3d09c8..d96024c95103de 100644 --- a/types/three/examples/jsm/loaders/MaterialXLoader.d.ts +++ b/types/three/examples/jsm/loaders/MaterialXLoader.d.ts @@ -1,5 +1,70 @@ import { Loader, LoadingManager, MeshPhysicalNodeMaterial } from "three/webgpu"; +import { MaterialXInterfaceValidator } from "./materialx/MaterialXInterfaceValidation.js"; +import { MaterialXLogEntry } from "./materialx/MaterialXLog.js"; -export class MaterialXLoader extends Loader<{ materials: Record }> { +export interface MaterialXLoadOptions { + /** + * The UV space of the MaterialX document. + * + * @default 'bottom-left' + */ + uvSpace?: "bottom-left" | "top-left"; + /** + * The name of the material to translate. When not set, all materials are translated. + */ + materialName?: string | null; + /** + * Called with the root node of the parsed document so additional problems can be added to the log. + */ + interfaceValidator?: MaterialXInterfaceValidator; + /** + * Whether to throw when the translation produced errors. + * + * @default true + */ + throwOnErrors?: boolean; + /** + * The path used to resolve the resources of the MaterialX document. + */ + path?: string; + /** + * Resolves the URI of a resource contained in a MaterialX archive. + */ + archiveResolver?: ((uri: string) => string | null) | null; +} + +export interface MaterialXResult { + materials: Record; + log: MaterialXLogEntry[]; + errors: MaterialXLogEntry[]; + warnings: MaterialXLogEntry[]; +} + +export class MaterialXLoader extends Loader { constructor(manager?: LoadingManager); + + dispose(): this; + + load( + url: string, + onLoad: (data: MaterialXResult) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (err: unknown) => void, + options?: MaterialXLoadOptions, + ): this; + + loadAsync(url: string, options?: MaterialXLoadOptions): Promise; + loadAsync( + url: string, + onProgress?: (event: ProgressEvent) => void, + options?: MaterialXLoadOptions, + ): Promise; + + parseBuffer( + data: ArrayBuffer | Uint8Array | string, + url?: string, + options?: MaterialXLoadOptions, + ): MaterialXResult; + + parse(text: string, options?: MaterialXLoadOptions): MaterialXResult; } diff --git a/types/three/examples/jsm/loaders/SPLATLoader.d.ts b/types/three/examples/jsm/loaders/SPLATLoader.d.ts new file mode 100644 index 00000000000000..814f32691a9b66 --- /dev/null +++ b/types/three/examples/jsm/loaders/SPLATLoader.d.ts @@ -0,0 +1,9 @@ +import { BufferGeometry, Loader, LoadingManager } from "three"; + +declare class SPLATLoader extends Loader { + constructor(manager?: LoadingManager); + + parse(buffer: ArrayBuffer): BufferGeometry; +} + +export { SPLATLoader }; diff --git a/types/three/examples/jsm/loaders/SPZLoader.d.ts b/types/three/examples/jsm/loaders/SPZLoader.d.ts new file mode 100644 index 00000000000000..ae56ad704fa131 --- /dev/null +++ b/types/three/examples/jsm/loaders/SPZLoader.d.ts @@ -0,0 +1,18 @@ +import { BufferGeometry, Loader, LoadingManager } from "three"; +import { ZSTDDecoder } from "../libs/zstddec.module.js"; + +declare class SPZLoader extends Loader { + constructor(manager?: LoadingManager); + + parse( + buffer: ArrayBuffer, + onLoad?: (geometry: BufferGeometry) => void, + onError?: (err: unknown) => void, + ): BufferGeometry | Promise | undefined; + + parseRawSPZ(bytes: Uint8Array): BufferGeometry; + + parseRawSPZV4(bytes: Uint8Array, zstd: ZSTDDecoder): BufferGeometry; +} + +export { SPZLoader }; diff --git a/types/three/examples/jsm/loaders/materialx/MaterialXHextile.d.ts b/types/three/examples/jsm/loaders/materialx/MaterialXHextile.d.ts new file mode 100644 index 00000000000000..528331eba1ef86 --- /dev/null +++ b/types/three/examples/jsm/loaders/materialx/MaterialXHextile.d.ts @@ -0,0 +1,24 @@ +import { Node } from "three/webgpu"; + +export function mxHextileComputeBlendWeights( + luminanceWeights: Node<"vec3">, + tileWeights: Node<"vec3">, + falloff: Node<"float"> | number, +): Node<"vec3">; + +export interface MaterialXHextileCoord { + coords: Node<"vec2">[]; + ddx: Node<"vec2">[]; + ddy: Node<"vec2">[]; + weights: Node<"vec3">; +} + +export function mxHextileCoord( + coord: Node<"vec2">, + rotation: Node<"float"> | number, + rotationRange: Node<"vec2">, + scale: Node<"float"> | number, + scaleRange: Node<"vec2">, + offset: Node<"float"> | number, + offsetRange: Node<"vec2">, +): MaterialXHextileCoord; diff --git a/types/three/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.d.ts b/types/three/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.d.ts new file mode 100644 index 00000000000000..e164e8a1066bac --- /dev/null +++ b/types/three/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.d.ts @@ -0,0 +1,8 @@ +import { MaterialXLog } from "./MaterialXLog.js"; + +/** + * Validates the interfaces of the parsed MaterialX document, adding any problems it finds to the log. + */ +export type MaterialXInterfaceValidator = (rootNode: any, log: MaterialXLog) => void; + +export function createStrictInterfaceValidator(): MaterialXInterfaceValidator; diff --git a/types/three/examples/jsm/loaders/materialx/MaterialXLog.d.ts b/types/three/examples/jsm/loaders/materialx/MaterialXLog.d.ts new file mode 100644 index 00000000000000..7840fe6c67ea6b --- /dev/null +++ b/types/three/examples/jsm/loaders/materialx/MaterialXLog.d.ts @@ -0,0 +1,33 @@ +export interface MaterialXLogCode { + label: string; + severity: "error" | "warning"; +} + +export const MaterialXLogCodes: { + UNSUPPORTED_NODE: MaterialXLogCode; + IGNORED_SURFACE_INPUT: MaterialXLogCode; + MISSING_REFERENCE: MaterialXLogCode; + MISSING_MATERIAL: MaterialXLogCode; + INVALID_VALUE: MaterialXLogCode; + UNKNOWN_INPUT: MaterialXLogCode; + INVALID_OUTPUT_CONNECTION: MaterialXLogCode; + TYPE_MISMATCH: MaterialXLogCode; +}; + +export interface MaterialXLogEntry { + code: string; + severity: "error" | "warning"; + message: string; + nodeName?: string; +} + +export class MaterialXLog { + constructor(); + + entries: MaterialXLogEntry[]; + + readonly errors: MaterialXLogEntry[]; + readonly warnings: MaterialXLogEntry[]; + + add(code: MaterialXLogCode, message: string, nodeName?: string | null): void; +} diff --git a/types/three/examples/jsm/misc/Sculptor.d.ts b/types/three/examples/jsm/misc/Sculptor.d.ts new file mode 100644 index 00000000000000..1febe5cbff0d91 --- /dev/null +++ b/types/three/examples/jsm/misc/Sculptor.d.ts @@ -0,0 +1,259 @@ +import { Camera } from "../../../src/cameras/Camera.js"; +import { BufferGeometry } from "../../../src/core/BufferGeometry.js"; +import { EventDispatcher } from "../../../src/core/EventDispatcher.js"; +import { Ray } from "../../../src/math/Ray.js"; +import { Vector3 } from "../../../src/math/Vector3.js"; +import { Mesh } from "../../../src/objects/Mesh.js"; + +export type SculptorTool = + | "clay" + | "brush" + | "inflate" + | "smooth" + | "flatten" + | "pinch" + | "crease" + | "drag" + | "scale"; + +export interface SculptorEventMap { + /** + * Fires when a pointer or programmatic stroke begins. + */ + start: {}; + + /** + * Fires after the sculpt geometry has been updated. + */ + change: {}; + + /** + * Fires after the active stroke finishes and exact bounds are up to date. + */ + end: {}; +} + +/** + * Sculpts triangle meshes with adaptive topology. + * + * ```js + * const sculptor = new Sculptor( mesh, camera ) + * .setTool( 'inflate' ) + * .setSize( 75 ) + * .setStrength( 0.3 ); + * sculptor.connect( renderer.domElement ); + * ``` + * + * Replaces `mesh.geometry` with a welded geometry containing positions, normals + * and indices. The source geometry is unchanged and is not disposed. + * + * The mesh must use one material and a non-zero uniform world scale without + * shear. Skinned, instanced and batched meshes are not supported. + * + * Sculptor manages bounds, draw range and spare buffer capacity. Geometry and + * attributes may be replaced as capacity changes; do not cache them. Use + * {@link Sculptor#getGeometry} for a compact copy for export or geometry processing. + * + * @three_import import { Sculptor } from 'three/addons/misc/Sculptor.js'; + */ +export class Sculptor extends EventDispatcher { + /** + * @param {Mesh} mesh - The mesh to sculpt. + * @param {Camera} camera - The camera used for pointer picking. + */ + constructor(mesh: Mesh, camera: Camera); + /** + * The mesh being sculpted. + * + * @type {Mesh} + * @readonly + */ + readonly mesh: Mesh; + /** + * The camera used for pointer picking. + * + * @type {Camera} + */ + camera: Camera; + /** + * The element receiving pointer events, or `null` while disconnected. + * + * @type {?HTMLElement} + * @default null + */ + domElement: HTMLElement | null; + /** + * Whether pointer input is enabled. Does not affect programmatic strokes. + * + * @type {boolean} + * @default true + */ + enabled: boolean; + /** + * Connects pointer input to a DOM element. + * + * @param {HTMLElement} element - The element receiving pointer events. + */ + connect(element: HTMLElement): void; + /** + * Disconnects pointer input and finishes the active stroke. + */ + disconnect(): void; + /** + * Disconnects the sculptor. The mesh and its geometry are not disposed. + */ + dispose(): void; + /** + * Applies a ray stamp, starting a stroke on a hit. Call + * {@link Sculptor#endStroke} after the last stamp. + * + * Returns `false` without updating the hit during a pointer stroke. + * Drag and Scale require pointer input. + * + * @param {Ray} ray - The world-space ray, with a non-zero direction. + * @param {number} worldRadius - The brush radius in world units. + * @return {boolean} Whether the ray hit the mesh. + */ + strokeFromRay(ray: Ray, worldRadius: number): boolean; + /** + * Begins a stroke and fires `start`. Does nothing while a stroke is active. + * Called automatically by pointer input or the first successful ray stamp. + * + * @return {Sculptor} A reference to this sculptor. + */ + beginStroke(): Sculptor; + /** + * Releases pointer capture, balances the octree and updates exact bounds, + * then fires `end`. Does nothing while idle. Called automatically when a + * pointer stroke ends or is cancelled. + * + * @return {Sculptor} A reference to this sculptor. + */ + endStroke(): Sculptor; + /** + * Returns an independent copy of the active vertices and triangles, without + * spare capacity. Suitable for export or geometry processing. The caller owns it. + * + * @return {BufferGeometry} A new geometry containing the active vertices and triangles. + */ + getGeometry(): BufferGeometry; + /** + * Returns the active sculpting tool. + * + * @return {('clay'|'brush'|'inflate'|'smooth'|'flatten'|'pinch'|'crease'|'drag'|'scale')} The tool name. + */ + getTool(): SculptorTool; + /** + * Selects a tool and restores its size, strength and negative setting. + * + * @param {('clay'|'brush'|'inflate'|'smooth'|'flatten'|'pinch'|'crease'|'drag'|'scale')} value - The tool name. + * @return {Sculptor} A reference to this sculptor. + */ + setTool(value: SculptorTool): Sculptor; + /** + * Returns the pointer brush radius in CSS pixels. + * + * @return {number} The brush radius. + */ + getSize(): number; + /** + * Sets the pointer brush radius in CSS pixels. + * + * @param {number} value - A value between 5 and 500. + * @return {Sculptor} A reference to this sculptor. + */ + setSize(value: number): Sculptor; + /** + * Returns the strength of the active tool. + * + * @return {number} The tool strength. + */ + getStrength(): number; + /** + * Sets the strength of the active tool. + * A value of `0` disables deformation, but not adaptive remeshing. + * Drag and Scale use pointer movement instead of this setting. + * + * @param {number} value - A value between 0 and 1. + * @return {Sculptor} A reference to this sculptor. + */ + setStrength(value: number): Sculptor; + /** + * Returns whether the active tool applies its inverse effect. + * + * @return {boolean} Whether the tool direction is inverted. + */ + getNegative(): boolean; + /** + * Sets whether the active tool applies its inverse effect. + * + * @param {boolean} value - Whether the tool direction is inverted. + * @return {Sculptor} A reference to this sculptor. + */ + setNegative(value: boolean): Sculptor; + /** + * Returns the adaptive-topology detail. `0` freezes topology. + * + * @return {number} The detail level. + */ + getDetail(): number; + /** + * Sets the adaptive-topology detail. Higher values produce shorter edges + * relative to the brush radius; `0` freezes topology. Remeshing splits long + * edges and collapses short ones, and can alter the surface even at zero strength. + * + * @param {number} value - A value between 0 and 1. + * @return {Sculptor} A reference to this sculptor. + */ + setDetail(value: number): Sculptor; + /** + * Returns whether a pointer or programmatic stroke is active. + * + * @return {boolean} Whether a stroke is active. + */ + isSculpting(): boolean; + /** + * Returns whether the latest pick or stroke ray hit the mesh. + * + * @return {boolean} Whether the latest ray hit the mesh. + */ + hasHit(): boolean; + /** + * Copies the current local-space hit position into the target vector. + * Returns a zero vector when there is no hit. + * + * @param {Vector3} target - The vector to receive the hit position. + * @return {Vector3} The target vector. + */ + getHitPoint(target: Vector3): Vector3; + /** + * Copies the current local-space unit surface normal into the target vector. + * Returns a zero vector when there is no hit. + * + * @param {Vector3} target - The vector to receive the surface normal. + * @return {Vector3} The target vector. + */ + getHitNormal(target: Vector3): Vector3; + /** + * Returns the brush radius in world units, or `0` without a hit. + * + * @return {number} The brush radius in world units. + */ + getWorldRadius(): number; + /** + * Updates the current hit from a world-space ray without sculpting. + * + * @param {Ray} ray - The world-space ray, with a non-zero direction. + * @param {number} worldRadius - The brush radius in world units. + * @return {boolean} Whether the ray hit the mesh. + */ + pickFromRay(ray: Ray, worldRadius: number): boolean; + /** + * Updates the current hit from client coordinates without sculpting. + * + * @param {number} clientX - Horizontal client coordinate in CSS pixels. + * @param {number} clientY - Vertical client coordinate in CSS pixels. + * @return {boolean} Whether the pointer ray hit the mesh. + */ + pickFromPointer(clientX: number, clientY: number): boolean; +} diff --git a/types/three/examples/jsm/modifiers/SimplifyModifier.d.ts b/types/three/examples/jsm/modifiers/SimplifyModifier.d.ts index 53d13bf1194c1c..2438b90dfd0d0d 100644 --- a/types/three/examples/jsm/modifiers/SimplifyModifier.d.ts +++ b/types/three/examples/jsm/modifiers/SimplifyModifier.d.ts @@ -2,5 +2,5 @@ import { BufferGeometry } from "three"; export class SimplifyModifier { constructor(); - modify(geometry: BufferGeometry, count: number): BufferGeometry; + modify(geometry: BufferGeometry, count: number): Promise; } diff --git a/types/three/examples/jsm/objects/GaussianSplat.d.ts b/types/three/examples/jsm/objects/GaussianSplat.d.ts new file mode 100644 index 00000000000000..d4a5b75503bd9f --- /dev/null +++ b/types/three/examples/jsm/objects/GaussianSplat.d.ts @@ -0,0 +1,35 @@ +import { + Box3, + BufferGeometry, + Camera, + InstancedBufferGeometry, + Mesh, + NodeMaterial, + Renderer, + Sphere, +} from "three/webgpu"; + +export interface GaussianSplatOptions { + autoSort?: boolean | undefined; +} + +declare class GaussianSplat extends Mesh { + constructor(splatGeometry: BufferGeometry, options?: GaussianSplatOptions); + + readonly isGaussianSplat: true; + + splatGeometry: BufferGeometry; + boundingBox: Box3 | null; + boundingSphere: Sphere | null; + autoSort: boolean; + + updateSphericalHarmonics(renderer: Renderer, camera: Camera): boolean; + + computeBoundingBox(): void; + + computeBoundingSphere(): void; + + updateSort(renderer: Renderer, camera: Camera): boolean; +} + +export { GaussianSplat }; diff --git a/types/three/examples/jsm/objects/SkyMesh.d.ts b/types/three/examples/jsm/objects/SkyMesh.d.ts index 9b40f26bb821a1..160d3f3ae345ea 100644 --- a/types/three/examples/jsm/objects/SkyMesh.d.ts +++ b/types/three/examples/jsm/objects/SkyMesh.d.ts @@ -6,7 +6,6 @@ declare class SkyMesh extends Mesh { mieCoefficient: UniformNode<"float", number>; mieDirectionalG: UniformNode<"float", number>; sunPosition: UniformNode<"vec3", Vector3>; - upUniform: UniformNode<"vec3", Vector3>; cloudScale: UniformNode<"float", number>; cloudSpeed: UniformNode<"float", number>; cloudCoverage: UniformNode<"float", number>; diff --git a/types/three/examples/jsm/renderers/CSS2DRenderer.d.ts b/types/three/examples/jsm/renderers/CSS2DRenderer.d.ts index 5b1d19db249fa0..85ccac741c1e17 100644 --- a/types/three/examples/jsm/renderers/CSS2DRenderer.d.ts +++ b/types/three/examples/jsm/renderers/CSS2DRenderer.d.ts @@ -3,6 +3,7 @@ import { Camera, Object3D, Scene, Vector2 } from "three"; declare class CSS2DObject extends Object3D { element: HTMLElement; center: Vector2; + rotation2D: number; constructor(element: HTMLElement); diff --git a/types/three/examples/jsm/transpiler/AST.d.ts b/types/three/examples/jsm/transpiler/AST.d.ts index 425aed4f292dd8..d20b34ffc205fe 100644 --- a/types/three/examples/jsm/transpiler/AST.d.ts +++ b/types/three/examples/jsm/transpiler/AST.d.ts @@ -248,10 +248,11 @@ export class For { } export class While { - constructor(condition: Statement, body?: Statement[]); + constructor(condition: Statement, body?: Statement[], doWhile?: boolean); condition: Statement; body: Statement[]; + doWhile: boolean; readonly isWhile: true; } diff --git a/types/three/examples/jsm/transpiler/TSLEncoder.d.ts b/types/three/examples/jsm/transpiler/TSLEncoder.d.ts index 1790c4552bd12b..91b0093174ee11 100644 --- a/types/three/examples/jsm/transpiler/TSLEncoder.d.ts +++ b/types/three/examples/jsm/transpiler/TSLEncoder.d.ts @@ -32,10 +32,12 @@ export default class TSLEncoder { emitBody(body: Statement[]): string; emitTernary(node: Ternary): string; emitConditional(node: Conditional): string; + isVariableUsed(node: Statement | Statement[], varName: string): boolean; emitLoop(node: For): string; emitSwitch(switchNode: Switch): string; emitFor(node: For): string; emitForWhile(node: For): string; + emitDoWhile(node: While): string; emitWhile(node: While): string; emitVariables(node: VariableDeclaration, isRoot?: boolean): string; emitVarying(node: Varying): string; diff --git a/types/three/examples/jsm/tsl/WebGLNodesHandler.d.ts b/types/three/examples/jsm/tsl/WebGLNodesHandler.d.ts index 0a6440052e3003..d019ceba3c93ba 100644 --- a/types/three/examples/jsm/tsl/WebGLNodesHandler.d.ts +++ b/types/three/examples/jsm/tsl/WebGLNodesHandler.d.ts @@ -1,5 +1,6 @@ import { Camera } from "../../../src/cameras/Camera.js"; import { Object3D } from "../../../src/core/Object3D.js"; +import { Light } from "../../../src/lights/Light.js"; import { Material } from "../../../src/materials/Material.js"; import { WebGLProgramParametersWithUniforms } from "../../../src/renderers/webgl/WebGLPrograms.js"; import { WebGLRenderer } from "../../../src/renderers/WebGLRenderer.js"; @@ -8,7 +9,9 @@ export class WebGLNodesHandler { constructor(); setRenderer(renderer: WebGLRenderer): void; - renderStart(scene: Object3D, camera: Camera): void; + renderStart(scene: Object3D, camera: Camera, targetScene?: Object3D): void; + updateLights(lights: Light[]): void; renderEnd(): void; + setObject(object: Object3D, material: Material): void; build(material: Material, object: Object3D, parameters: WebGLProgramParametersWithUniforms): void; } diff --git a/types/three/examples/jsm/tsl/display/BloomNode.d.ts b/types/three/examples/jsm/tsl/display/BloomNode.d.ts index 924496fab0825e..6cf5fb34116418 100644 --- a/types/three/examples/jsm/tsl/display/BloomNode.d.ts +++ b/types/three/examples/jsm/tsl/display/BloomNode.d.ts @@ -1,4 +1,4 @@ -import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; +import { Node, TempNode, TextureNode, UniformNode, Vector3 } from "three/webgpu"; declare class BloomNode extends TempNode<"vec4"> { inputNode: Node<"vec4">; @@ -8,6 +8,8 @@ declare class BloomNode extends TempNode<"vec4"> { smoothWidth: UniformNode<"float", number>; + bloomTintColors: Vector3[]; + highPassFn: ( params: { input: Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts b/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts index bee7ffe002f6ed..ff5c449b0ac7ed 100644 --- a/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts +++ b/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts @@ -1,17 +1,17 @@ -import { Node, TempNode, UniformNode } from "three/webgpu"; +import { Node, TempNode } from "three/webgpu"; declare class DotScreenNode extends TempNode { inputNode: Node; - angle: UniformNode<"float", number>; - scale: UniformNode<"float", number>; + angle: Node<"float">; + scale: Node<"float">; - constructor(inputNode: Node, angle?: number, scale?: number); + constructor(inputNode: Node, angle?: Node<"float"> | number, scale?: Node<"float"> | number); } export default DotScreenNode; export const dotScreen: ( node: Node, - angle?: number, - scale?: number, + angle?: Node<"float"> | number, + scale?: Node<"float"> | number, ) => DotScreenNode; diff --git a/types/three/examples/jsm/tsl/display/GTAONode.d.ts b/types/three/examples/jsm/tsl/display/GTAONode.d.ts index 2ec5689b87a687..1bfd811bc8770b 100644 --- a/types/three/examples/jsm/tsl/display/GTAONode.d.ts +++ b/types/three/examples/jsm/tsl/display/GTAONode.d.ts @@ -1,4 +1,4 @@ -import { Camera, Node, TempNode, TextureNode, UniformNode, Vector2 } from "three/webgpu"; +import { Camera, Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; declare class GTAONode extends TempNode<"float"> { depthNode: Node; @@ -7,9 +7,14 @@ declare class GTAONode extends TempNode<"float"> { resolutionScale: number; radius: UniformNode<"float", number>; - resolution: UniformNode<"vec2", Vector2>; thickness: UniformNode<"float", number>; + /** + * @deprecated since r186. The new distance model "Quadratic Ray Stepping" does not need it anymore. + */ distanceExponent: UniformNode<"float", number>; + /** + * @deprecated since r186. The new distance model "Quadratic Ray Stepping" does not need it anymore. + */ distanceFallOff: UniformNode<"float", number>; scale: UniformNode<"float", number>; samples: UniformNode<"float", number>; diff --git a/types/three/examples/jsm/tsl/display/OITPassNode.d.ts b/types/three/examples/jsm/tsl/display/OITPassNode.d.ts new file mode 100644 index 00000000000000..3ae9e4c97bae23 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/OITPassNode.d.ts @@ -0,0 +1,64 @@ +import { Camera, Node, PassNode, PassNodeOptions, Scene } from "three/webgpu"; + +/** + * A render pass node that renders the scene with Order-Independent Transparency + * based on the Weighted Blended OIT technique by McGuire and Bavoil. + * + * Transparent objects are rendered in a separate pass into two accumulation + * targets (a weighted color sum and the pixel's revealage) which are + * then composited over the rest of the scene. Since the result does not depend + * on the draw order, artifacts from sorting-based transparency like popping or + * incorrectly resolved intersecting geometry are avoided. + * + * Only transparent materials using `NormalBlending` and no transmission qualify + * for OIT. All other objects are rendered as usual. + * + * MSAA is only supported with the WebGPU backend. + * + * MRT configurations assigned via `setMRT()` apply to the default pass only. + * OIT-qualified objects contribute to the color output but not to custom + * MRT outputs since a pixel may accumulate multiple transparent surfaces. + * + * ```js + * const renderPipeline = new THREE.RenderPipeline( renderer ); + * renderPipeline.outputNode = oitPass( scene, camera ); + * ``` + * + * References: + * - {@link https://jcgt.org/published/0002/02/09/} + * - {@link https://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html} + * + * @augments PassNode + * @three_import import { oitPass } from 'three/addons/tsl/display/OITPassNode.js'; + */ +declare class OITPassNode extends PassNode { + /** + * Constructs a new OIT pass node. + * + * @param {Scene} scene - The scene to render. + * @param {Camera} camera - The camera to render the scene with. + * @param {Object} [options={}] - Options for the internal render target. + */ + constructor(scene: Scene, camera: Camera, options?: PassNodeOptions); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isOITPassNode: boolean; + /** + * The depth-based weight of a transparent fragment, see equations (7) to (9) + * in the paper. When `null`, equation (9) is used. Must be assigned before + * the first render. + * + * @type {?Node} + * @default null + */ + weightNode: Node<"float"> | null; +} + +export default OITPassNode; + +export function oitPass(scene: Scene, camera: Camera, options?: PassNodeOptions): OITPassNode; diff --git a/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts b/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts index 2171a3b33495c6..9df1ee78d33e37 100644 --- a/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts +++ b/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts @@ -1,15 +1,15 @@ -import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; +import { Node, TempNode, TextureNode } from "three/webgpu"; export default class RGBShiftNode extends TempNode { textureNode: TextureNode; - amount: UniformNode<"float", number>; - angle: UniformNode<"float", number>; + amount: Node<"float">; + angle: Node<"float">; - constructor(textureNode: TextureNode, amount?: number, angle?: number); + constructor(textureNode: TextureNode, amount?: Node<"float"> | number, angle?: Node<"float"> | number); getTextureNode(): TextureNode; setSize(width: number, height: number): void; } -export const rgbShift: (node: Node, amount?: number, angle?: number) => RGBShiftNode; +export const rgbShift: (node: Node, amount?: Node<"float"> | number, angle?: Node<"float"> | number) => RGBShiftNode; diff --git a/types/three/examples/jsm/tsl/display/SSAONode.d.ts b/types/three/examples/jsm/tsl/display/SSAONode.d.ts new file mode 100644 index 00000000000000..d0d32db5dff67b --- /dev/null +++ b/types/three/examples/jsm/tsl/display/SSAONode.d.ts @@ -0,0 +1,116 @@ +import { Camera, Node, TempNode, TextureNode, UniformNode, Vector2 } from "three/webgpu"; + +/** + * Post processing node for a fast, screen-space ambient occlusion (SSAO). + * + * It point-samples a per-pixel rotated Vogel disk and estimates obscurance with a single depth tap + * per sample, trading the ground-truth accuracy of {@link GTAONode}'s horizon ray-marching for + * lower cost. A built-in separable, depth-aware blur denoises the result so it can be used without + * temporal accumulation. + * ```js + * const scenePass = pass( scene, camera ); + * scenePass.setMRT( mrt( { output, normal: normalView } ) ); + * const scenePassColor = scenePass.getTextureNode( 'output' ); + * const scenePassDepth = scenePass.getTextureNode( 'depth' ); + * const scenePassNormal = scenePass.getTextureNode( 'normal' ); + * + * const aoPass = ssao( scenePassDepth, scenePassNormal, camera ); + * + * renderPipeline.outputNode = scenePassColor.mul( aoPass.r ); + * ``` + * + * @augments TempNode + * @three_import import { ssao } from 'three/addons/tsl/display/SSAONode.js'; + */ +declare class SSAONode extends TempNode<"float"> { + /** + * Constructs a new SSAO node. + * + * @param {Node} depthNode - A node that represents the scene's depth. + * @param {Node} normalNode - A node that represents the scene's normals. + * @param {Camera} camera - The camera the scene is rendered with. + */ + constructor(depthNode: Node, normalNode: Node, camera: Camera); + /** + * A node that represents the scene's depth. + * + * @type {Node} + */ + depthNode: Node; + /** + * A node that represents the scene's normals. + * + * @type {Node} + */ + normalNode: Node; + /** + * The resolution scale. The effect renders at a fraction of the drawing buffer + * for extra speed; `0.5` is a good default for a low-frequency signal like AO. + * + * @type {number} + * @default 0.5 + */ + resolutionScale: number; + /** + * The world-space radius the occlusion is gathered within. + * + * @type {UniformNode} + */ + radius: UniformNode<"float", number>; + /** + * The strength of the occlusion. + * + * @type {UniformNode} + */ + intensity: UniformNode<"float", number>; + /** + * An angle bias that suppresses self-occlusion on near-flat surfaces. + * + * @type {UniformNode} + */ + bias: UniformNode<"float", number>; + /** + * How many samples are used to estimate the occlusion. A higher value + * results in a smoother result at a higher runtime cost. + * + * @type {UniformNode} + */ + samples: UniformNode<"float", number>; + /** + * Whether the depth-aware blur that denoises the raw AO is applied or not. + * + * @type {boolean} + * @default true + */ + blurEnabled: boolean; + /** + * How strongly the blur rejects samples across depth discontinuities, + * relative to the AO radius. A higher value keeps edges crisper. + * + * @type {UniformNode} + */ + blurSharpness: UniformNode<"float", number>; + /** + * The resolution of the effect. Set from the drawing buffer size and `resolutionScale`. + * + * @type {Vector2} + */ + resolution: Vector2; + /** + * Returns the result of the effect as a texture node. + * + * @return {PassTextureNode} A texture node that represents the result of the effect. + */ + getTextureNode(): TextureNode; + /** + * Sets the size of the effect. + * + * @param {number} width - The width of the effect. + * @param {number} height - The height of the effect. + */ + setSize(width: number, height: number): void; +} + +export default SSAONode; + +export function ssao(depthNode: Node, normalNode: Node, camera: Camera): SSAONode; diff --git a/types/three/examples/jsm/tsl/display/SSGINode.d.ts b/types/three/examples/jsm/tsl/display/SSGINode.d.ts index 9a6180dceed3e6..dc23def1249493 100644 --- a/types/three/examples/jsm/tsl/display/SSGINode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSGINode.d.ts @@ -19,8 +19,8 @@ declare class SSGINode extends TempNode<"vec4"> { constructor(beautyNode: Node, depthNode: Node, normalNode: Node, camera: PerspectiveCamera); - getAONode(): TextureNode; - getGINode(): TextureNode; + getAONode(): TextureNode<"float">; + getGINode(): TextureNode<"vec3">; } export default SSGINode; diff --git a/types/three/examples/jsm/tsl/display/depthAwareBlur.d.ts b/types/three/examples/jsm/tsl/display/depthAwareBlur.d.ts new file mode 100644 index 00000000000000..1bb3c53e364e76 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/depthAwareBlur.d.ts @@ -0,0 +1,10 @@ +import { Camera, Node } from "three/webgpu"; + +export const depthAwareBlur: ( + inputNode: Node, + depthNode: Node, + directionNode: Node<"vec2">, + camera: Camera, + sharpness?: Node<"float"> | number, + radius?: Node<"float"> | number, +) => Node<"float">; diff --git a/types/three/examples/jsm/tsl/display/hashBlur.d.ts b/types/three/examples/jsm/tsl/display/hashBlur.d.ts index f17f8a36cb3942..453a6c99d00613 100644 --- a/types/three/examples/jsm/tsl/display/hashBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/hashBlur.d.ts @@ -1,8 +1,7 @@ import { Node } from "three/webgpu"; interface HashBlurOptions { - size?: Node | undefined; - mask?: Node | null | undefined; + repeats?: Node | number | undefined; premultipliedAlpha?: boolean | undefined; } diff --git a/types/three/examples/jsm/tsl/math/voronoiNoise.d.ts b/types/three/examples/jsm/tsl/math/voronoiNoise.d.ts new file mode 100644 index 00000000000000..86252e86232ade --- /dev/null +++ b/types/three/examples/jsm/tsl/math/voronoiNoise.d.ts @@ -0,0 +1,52 @@ +import { Node, Vector2, Vector3 } from "three/webgpu"; + +/** + * @module VoronoiNoise + * @three_import import { voronoi2d, voronoi3d } from 'three/addons/tsl/math/voronoiNoise.js'; + */ +/** + * Generates a pseudo-random vec2 from the given coordinate. + * + * Reference: {@link https://www.shadertoy.com/view/MslGD8}. + * + * @tsl + * @function + * @param {Node} p - The input coordinate. + * @return {Node} A pseudo-random value in the range `[0, 1]`. + */ +export const hash2d: (p: Node<"vec2"> | Vector2) => Node<"vec2">; +/** + * Animated 2D Voronoi noise. The feature points orbit inside their cells so the + * resulting pattern morphs over time. + * + * Reference: {@link https://www.shadertoy.com/view/MslGD8}. + * + * @tsl + * @function + * @param {Node} p - The input coordinate. + * @param {Node} time - The animation time. + * @return {Node} The squared distance to the closest feature point, roughly in the range `[0, 1]`. + */ +export const voronoi2d: (p: Node<"vec2"> | Vector2, time: Node<"float"> | number) => Node<"float">; +/** + * Generates a pseudo-random vec3 from the given coordinate. + * + * @tsl + * @function + * @param {Node} p - The input coordinate. + * @return {Node} A pseudo-random value in the range `[0, 1]`. + */ +export const hash3d: (p: Node<"vec3"> | Vector3) => Node<"vec3">; +/** + * Animated 3D Voronoi noise. Like {@link voronoi2d} but with a volumetric input + * coordinate so the pattern can be applied to arbitrary surfaces without + * projection artifacts. Evaluates 27 cells instead of 9 and is therefore + * considerably more expensive than the 2D version. + * + * @tsl + * @function + * @param {Node} p - The input coordinate. + * @param {Node} time - The animation time. + * @return {Node} The squared distance to the closest feature point, roughly in the range `[0, 1]`. + */ +export const voronoi3d: (p: Node<"vec3"> | Vector3, time: Node<"float"> | number) => Node<"float">; diff --git a/types/three/examples/jsm/tsl/utils/Raymarching.d.ts b/types/three/examples/jsm/tsl/utils/Raymarching.d.ts index 664df29d623bdb..1320dd0d1d1b5e 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<"vec3"> }) => void) - | FunctionNode<{ positionRay: Node<"vec3"> }>, + | ((params: { positionRay: Node<"vec3">; stepSize: Node<"float"> }) => void) + | FunctionNode<{ positionRay: Node<"vec3">; stepSize: Node<"float"> }>, ) => void; diff --git a/types/three/examples/jsm/tsl/utils/SoftParticles.d.ts b/types/three/examples/jsm/tsl/utils/SoftParticles.d.ts new file mode 100644 index 00000000000000..969fffb91fb561 --- /dev/null +++ b/types/three/examples/jsm/tsl/utils/SoftParticles.d.ts @@ -0,0 +1,21 @@ +import { Node } from "three/webgpu"; + +/** + * Computes an opacity node for soft particles, based on the "Soft Particles" white + * paper (NVIDIA, Tristan Lorach). + * + * @tsl + * @function + * @param {Object} [parameters={}] - The configuration parameters. + * @param {Node} [parameters.opacity=float(1)] - The sprite's base opacity, which the soft fade is multiplied with. + * @param {Node|number} [parameters.distance=1] - The world-space distance over which the sprite fades out against the scene. + * @param {Node|number} [parameters.contrast=2] - The contrast power of the fade curve. `1` is linear, higher values sharpen the transition. + * @param {Node} [parameters.viewportDepth=viewportDepthTexture()] - The opaque scene depth the particles fade against. + * @return {Node} The opacity node to assign to `material.opacityNode`. + */ +export function softParticles({ opacity, distance, contrast, viewportDepth }?: { + opacity?: Node<"float">; + distance?: Node<"float"> | number; + contrast?: Node<"float"> | number; + viewportDepth?: Node<"float">; +}): Node<"float">; diff --git a/types/three/examples/jsm/utils/GaussianSplatUtils.d.ts b/types/three/examples/jsm/utils/GaussianSplatUtils.d.ts new file mode 100644 index 00000000000000..de2e74f0e4e3b6 --- /dev/null +++ b/types/three/examples/jsm/utils/GaussianSplatUtils.d.ts @@ -0,0 +1,68 @@ +import { BufferGeometry } from "three"; + +export const SH_C0: number; + +export const SH_BAND_COMPONENTS: number[]; + +export const SH_BAND_WORDS: number[]; + +export function sigmoid(value: number): number; + +export function sh0ToLinear(coefficient: number): number; + +export function linearToSH0(color: number): number; + +export function writeColorBytes( + target: Uint8ClampedArray, + offset: number, + r: number, + g: number, + b: number, + a: number, +): void; + +export function writeColorBytesFromSH0( + target: Uint8ClampedArray, + offset: number, + r: number, + g: number, + b: number, + a: number, +): void; + +export function writeCovariance( + target: Float32Array, + offset: number, + sx: number, + sy: number, + sz: number, + qx: number, + qy: number, + qz: number, + qw: number, +): void; + +export interface PackedSphericalHarmonicsBand { + packed: Uint32Array; + bytes: Uint8ClampedArray; +} + +export function createPackedSphericalHarmonicsBand(count: number, degree: number): PackedSphericalHarmonicsBand; + +export function getSphericalHarmonicsDegree(geometry?: BufferGeometry): number; + +export interface GaussianSplatSphericalHarmonics { + sh1?: Uint32Array | undefined; + sh2?: Uint32Array | undefined; + sh3?: Uint32Array | undefined; + sphericalHarmonics1?: Uint32Array | undefined; + sphericalHarmonics2?: Uint32Array | undefined; + sphericalHarmonics3?: Uint32Array | undefined; +} + +export function createGaussianSplatGeometry( + centers: Float32Array, + covariances: Float32Array, + colors: Uint8Array | Uint8ClampedArray, + sphericalHarmonics?: GaussianSplatSphericalHarmonics, +): BufferGeometry; diff --git a/types/three/package.json b/types/three/package.json index fc1125abbfaf38..c13ee966b66c9e 100644 --- a/types/three/package.json +++ b/types/three/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/three", - "version": "0.185.9999", + "version": "0.186.9999", "projects": [ "https://threejs.org/" ], @@ -24,7 +24,7 @@ "@tweenjs/tween.js": "~23.1.3", "@types/stats.js": "*", "@types/webxr": ">=0.5.17", - "fflate": "~0.8.2", + "fflate": "~0.8.3", "meshoptimizer": "~1.1.1" }, "devDependencies": { diff --git a/types/three/src/Three.Core.d.ts b/types/three/src/Three.Core.d.ts index ff2fd96f5ec447..c5f3709a59deec 100644 --- a/types/three/src/Three.Core.d.ts +++ b/types/three/src/Three.Core.d.ts @@ -73,12 +73,12 @@ export type { DirectionalLightShadow } from "./lights/DirectionalLightShadow.js" export * from "./lights/HemisphereLight.js"; export * from "./lights/Light.js"; export * from "./lights/LightProbe.js"; -export type { LightShadow, LightShadowJSON } from "./lights/LightShadow.js"; +export * from "./lights/LightShadow.js"; export * from "./lights/PointLight.js"; export type { PointLightShadow } from "./lights/PointLightShadow.js"; export * from "./lights/RectAreaLight.js"; export * from "./lights/SpotLight.js"; -export type { SpotLightShadow } from "./lights/SpotLightShadow.js"; +export type { SpotLightShadow, SpotLightShadowJSON } from "./lights/SpotLightShadow.js"; export * from "./loaders/AnimationLoader.js"; export * from "./loaders/AudioLoader.js"; export * from "./loaders/BufferGeometryLoader.js"; @@ -168,8 +168,8 @@ export * from "./textures/DepthTexture.js"; export * from "./textures/ExternalTexture.js"; export * from "./textures/FramebufferTexture.js"; export * from "./textures/HTMLTexture.js"; -export * from "./textures/Source.js"; export * from "./textures/Texture.js"; +export * from "./textures/TextureSource.js"; export * from "./textures/VideoFrameTexture.js"; export * from "./textures/VideoTexture.js"; export { createCanvasElement, error, getConsoleFunction, log, setConsoleFunction, warn, warnOnce } from "./utils.js"; diff --git a/types/three/src/Three.TSL.d.ts b/types/three/src/Three.TSL.d.ts index acd4a55d937673..7efbbc47ef34a9 100644 --- a/types/three/src/Three.TSL.d.ts +++ b/types/three/src/Three.TSL.d.ts @@ -2,6 +2,7 @@ import * as TSL from "./nodes/TSL.js"; export const BRDF_GGX: typeof TSL.BRDF_GGX; export const BRDF_Lambert: typeof TSL.BRDF_Lambert; +export const BRDF_Sheen: typeof TSL.BRDF_Sheen; export const BasicPointShadowFilter: typeof TSL.BasicPointShadowFilter; export const BasicShadowFilter: typeof TSL.BasicShadowFilter; export const Break: typeof TSL.Break; @@ -9,23 +10,35 @@ export const Const: typeof TSL.Const; export const Continue: typeof TSL.Continue; export const DFGLUT: typeof TSL.DFGLUT; export const D_GGX: typeof TSL.D_GGX; +export const D_GGX_Anisotropic: typeof TSL.D_GGX_Anisotropic; export const Discard: typeof TSL.Discard; export const EPSILON: typeof TSL.EPSILON; +export const EnvironmentBRDF: typeof TSL.EnvironmentBRDF; export const F_Schlick: typeof TSL.F_Schlick; export const Fn: typeof TSL.Fn; +export const HALF_PI: typeof TSL.HALF_PI; export const INFINITY: typeof TSL.INFINITY; export const If: typeof TSL.If; +export const LTC_Evaluate: typeof TSL.LTC_Evaluate; +export const LTC_Evaluate_Volume: typeof TSL.LTC_Evaluate_Volume; +export const LTC_Uv: typeof TSL.LTC_Uv; export const Loop: typeof TSL.Loop; export const NodeAccess: typeof TSL.NodeAccess; export const NodeShaderStage: typeof TSL.NodeShaderStage; export const NodeType: typeof TSL.NodeType; export const NodeUpdateType: typeof TSL.NodeUpdateType; +export const OnAfterObjectUpdate: typeof TSL.OnAfterObjectUpdate; +export const OnAfterRenderPipeline: typeof TSL.OnAfterRenderPipeline; +export const OnBeforeFrameUpdate: typeof TSL.OnBeforeFrameUpdate; +export const OnBeforeMaterialUpdate: typeof TSL.OnBeforeMaterialUpdate; +export const OnBeforeObjectUpdate: typeof TSL.OnBeforeObjectUpdate; +export const OnBeforeRenderPipeline: typeof TSL.OnBeforeRenderPipeline; +export const OnFrameUpdate: typeof TSL.OnFrameUpdate; +export const OnMaterialUpdate: typeof TSL.OnMaterialUpdate; +export const OnObjectUpdate: typeof TSL.OnObjectUpdate; export const PCFShadowFilter: typeof TSL.PCFShadowFilter; -export const PCFSoftShadowFilter: typeof TSL.PCFSoftShadowFilter; export const PI: typeof TSL.PI; export const PI2: typeof TSL.PI2; -export const TWO_PI: typeof TSL.TWO_PI; -export const HALF_PI: typeof TSL.HALF_PI; export const PointShadowFilter: typeof TSL.PointShadowFilter; export const Return: typeof TSL.Return; export const Schlick_to_F0: typeof TSL.Schlick_to_F0; @@ -33,8 +46,10 @@ export const ShaderNode: typeof TSL.ShaderNode; export const Stack: typeof TSL.Stack; export const Switch: typeof TSL.Switch; export const TBNViewMatrix: typeof TSL.TBNViewMatrix; +export const TWO_PI: typeof TSL.TWO_PI; export const VSMShadowFilter: typeof TSL.VSMShadowFilter; export const V_GGX_SmithCorrelated: typeof TSL.V_GGX_SmithCorrelated; +export const V_GGX_SmithCorrelated_Anisotropic: typeof TSL.V_GGX_SmithCorrelated_Anisotropic; export const Var: typeof TSL.Var; export const VarIntent: typeof TSL.VarIntent; export const abs: typeof TSL.abs; @@ -53,7 +68,6 @@ export const anisotropy: typeof TSL.anisotropy; export const anisotropyB: typeof TSL.anisotropyB; export const anisotropyT: typeof TSL.anisotropyT; export const any: typeof TSL.any; -export const append: typeof TSL.append; export const array: typeof TSL.array; export const asin: typeof TSL.asin; export const asinh: typeof TSL.asinh; @@ -78,6 +92,8 @@ export const backgroundBlurriness: typeof TSL.backgroundBlurriness; export const backgroundIntensity: typeof TSL.backgroundIntensity; export const backgroundRotation: typeof TSL.backgroundRotation; export const batch: typeof TSL.batch; +export const batchColor: typeof TSL.batchColor; +export const batchIndirectIndex: typeof TSL.batchIndirectIndex; export const bentNormalView: typeof TSL.bentNormalView; export const billboarding: typeof TSL.billboarding; export const bitAnd: typeof TSL.bitAnd; @@ -87,6 +103,7 @@ export const bitXor: typeof TSL.bitXor; export const bitangentGeometry: typeof TSL.bitangentGeometry; export const bitangentLocal: typeof TSL.bitangentLocal; export const bitangentView: typeof TSL.bitangentView; +export const bitangentViewFrame: typeof TSL.bitangentViewFrame; export const bitangentWorld: typeof TSL.bitangentWorld; export const bitcast: typeof TSL.bitcast; export const blendBurn: typeof TSL.blendBurn; @@ -94,14 +111,14 @@ export const blendColor: typeof TSL.blendColor; export const blendDodge: typeof TSL.blendDodge; export const blendOverlay: typeof TSL.blendOverlay; export const blendScreen: typeof TSL.blendScreen; -export const blur: typeof TSL.blur; export const bool: typeof TSL.bool; export const buffer: typeof TSL.buffer; export const bufferAttribute: typeof TSL.bufferAttribute; -export const bumpMap: typeof TSL.bumpMap; export const builtin: typeof TSL.builtin; export const builtinAOContext: typeof TSL.builtinAOContext; +export const builtinGIContext: typeof TSL.builtinGIContext; export const builtinShadowContext: typeof TSL.builtinShadowContext; +export const bumpMap: typeof TSL.bumpMap; export const bvec2: typeof TSL.bvec2; export const bvec3: typeof TSL.bvec3; export const bvec4: typeof TSL.bvec4; @@ -128,6 +145,8 @@ export const clearcoat: typeof TSL.clearcoat; export const clearcoatNormalView: typeof TSL.clearcoatNormalView; export const clearcoatRoughness: typeof TSL.clearcoatRoughness; export const clipSpace: typeof TSL.clipSpace; +export const clipping: typeof TSL.clipping; +export const clippingAlpha: typeof TSL.clippingAlpha; export const code: typeof TSL.code; export const color: typeof TSL.color; export const colorSpaceToWorking: typeof TSL.colorSpaceToWorking; @@ -139,11 +158,11 @@ export const context: typeof TSL.context; export const convert: typeof TSL.convert; export const convertColorSpace: typeof TSL.convertColorSpace; export const convertToTexture: typeof TSL.convertToTexture; +export const cos: typeof TSL.cos; +export const cosh: typeof TSL.cosh; export const countLeadingZeros: typeof TSL.countLeadingZeros; export const countOneBits: typeof TSL.countOneBits; export const countTrailingZeros: typeof TSL.countTrailingZeros; -export const cos: typeof TSL.cos; -export const cosh: typeof TSL.cosh; export const cross: typeof TSL.cross; export const cubeTexture: typeof TSL.cubeTexture; export const cubeTextureBase: typeof TSL.cubeTextureBase; @@ -158,13 +177,13 @@ export const defaultShaderStages: typeof TSL.defaultShaderStages; export const defined: typeof TSL.defined; export const degrees: typeof TSL.degrees; export const deltaTime: typeof TSL.deltaTime; -export const densityFog: typeof TSL.densityFog; export const densityFogFactor: typeof TSL.densityFogFactor; export const depth: typeof TSL.depth; export const depthPass: typeof TSL.depthPass; export const determinant: typeof TSL.determinant; export const difference: typeof TSL.difference; export const diffuseColor: typeof TSL.diffuseColor; +export const diffuseContribution: typeof TSL.diffuseContribution; export const directPointLight: typeof TSL.directPointLight; export const directionToColor: typeof TSL.directionToColor; export const directionToFaceDirection: typeof TSL.directionToFaceDirection; @@ -172,6 +191,8 @@ export const dispersion: typeof TSL.dispersion; export const distance: typeof TSL.distance; export const div: typeof TSL.div; export const dot: typeof TSL.dot; +export const dot4I8Packed: typeof TSL.dot4I8Packed; +export const dot4U8Packed: typeof TSL.dot4U8Packed; export const drawIndex: typeof TSL.drawIndex; export const dynamicBufferAttribute: typeof TSL.dynamicBufferAttribute; export const element: typeof TSL.element; @@ -200,18 +221,14 @@ export const gain: typeof TSL.gain; export const gapSize: typeof TSL.gapSize; export const getConstNodeType: typeof TSL.getConstNodeType; export const getCurrentStack: typeof TSL.getCurrentStack; -export const getDirection: typeof TSL.getDirection; export const getDistanceAttenuation: typeof TSL.getDistanceAttenuation; export const getGeometryRoughness: typeof TSL.getGeometryRoughness; export const getNormalFromDepth: typeof TSL.getNormalFromDepth; -export const interleavedGradientNoise: typeof TSL.interleavedGradientNoise; -export const vogelDiskSample: typeof TSL.vogelDiskSample; export const getParallaxCorrectNormal: typeof TSL.getParallaxCorrectNormal; export const getRoughness: typeof TSL.getRoughness; export const getScreenPosition: typeof TSL.getScreenPosition; +export const getScreenPositionFromClip: typeof TSL.getScreenPositionFromClip; export const getShIrradianceAt: typeof TSL.getShIrradianceAt; -export const getShadowMaterial: typeof TSL.getShadowMaterial; -export const getShadowRenderObjectFunction: typeof TSL.getShadowRenderObjectFunction; export const getTextureIndex: typeof TSL.getTextureIndex; export const getViewPosition: typeof TSL.getViewPosition; export const globalId: typeof TSL.globalId; @@ -220,13 +237,16 @@ export const glslFn: typeof TSL.glslFn; export const grayscale: typeof TSL.grayscale; export const greaterThan: typeof TSL.greaterThan; export const greaterThanEqual: typeof TSL.greaterThanEqual; +export const hardwareClipping: typeof TSL.hardwareClipping; export const hash: typeof TSL.hash; export const highpModelNormalViewMatrix: typeof TSL.highpModelNormalViewMatrix; export const highpModelViewMatrix: typeof TSL.highpModelViewMatrix; export const hue: typeof TSL.hue; export const increment: typeof TSL.increment; export const incrementBefore: typeof TSL.incrementBefore; +export const inspect: typeof TSL.inspect; export const instance: typeof TSL.instance; +export const instanceColor: typeof TSL.instanceColor; export const instanceIndex: typeof TSL.instanceIndex; export const instancedArray: typeof TSL.instancedArray; export const instancedBufferAttribute: typeof TSL.instancedBufferAttribute; @@ -234,6 +254,7 @@ export const instancedDynamicBufferAttribute: typeof TSL.instancedDynamicBufferA export const instancedMesh: typeof TSL.instancedMesh; export const int: typeof TSL.int; export const intBitsToFloat: typeof TSL.intBitsToFloat; +export const interleavedGradientNoise: typeof TSL.interleavedGradientNoise; export const inverse: typeof TSL.inverse; export const inverseSqrt: typeof TSL.inverseSqrt; export const inversesqrt: typeof TSL.inversesqrt; @@ -243,6 +264,7 @@ export const ior: typeof TSL.ior; export const iridescence: typeof TSL.iridescence; export const iridescenceIOR: typeof TSL.iridescenceIOR; export const iridescenceThickness: typeof TSL.iridescenceThickness; +export const isolate: typeof TSL.isolate; export const ivec2: typeof TSL.ivec2; export const ivec3: typeof TSL.ivec3; export const ivec4: typeof TSL.ivec4; @@ -302,6 +324,7 @@ export const materialPointSize: typeof TSL.materialPointSize; export const materialReference: typeof TSL.materialReference; export const materialReflectivity: typeof TSL.materialReflectivity; export const materialRefractionRatio: typeof TSL.materialRefractionRatio; +export const materialRetroreflectivity: typeof TSL.materialRetroreflectivity; export const materialRotation: typeof TSL.materialRotation; export const materialRoughness: typeof TSL.materialRoughness; export const materialSheen: typeof TSL.materialSheen; @@ -338,9 +361,11 @@ export const mx_aastep: typeof TSL.mx_aastep; export const mx_add: typeof TSL.mx_add; export const mx_atan2: typeof TSL.mx_atan2; export const mx_cell_noise_float: typeof TSL.mx_cell_noise_float; +export const mx_cell_noise_vec3: typeof TSL.mx_cell_noise_vec3; export const mx_contrast: typeof TSL.mx_contrast; export const mx_divide: typeof TSL.mx_divide; export const mx_fractal_noise_float: typeof TSL.mx_fractal_noise_float; +export const mx_fractal_noise_float_2d: typeof TSL.mx_fractal_noise_float_2d; export const mx_fractal_noise_vec2: typeof TSL.mx_fractal_noise_vec2; export const mx_fractal_noise_vec3: typeof TSL.mx_fractal_noise_vec3; export const mx_fractal_noise_vec4: typeof TSL.mx_fractal_noise_vec4; @@ -366,6 +391,7 @@ export const mx_rotate2d: typeof TSL.mx_rotate2d; export const mx_rotate3d: typeof TSL.mx_rotate3d; export const mx_safepower: typeof TSL.mx_safepower; export const mx_separate: typeof TSL.mx_separate; +export const mx_smoothstep: typeof TSL.mx_smoothstep; export const mx_splitlr: typeof TSL.mx_splitlr; export const mx_splittb: typeof TSL.mx_splittb; export const mx_srgb_texture_to_lin_rec709: typeof TSL.mx_srgb_texture_to_lin_rec709; @@ -375,8 +401,11 @@ export const mx_transform_uv: typeof TSL.mx_transform_uv; export const mx_unifiednoise2d: typeof TSL.mx_unifiednoise2d; export const mx_unifiednoise3d: typeof TSL.mx_unifiednoise3d; export const mx_worley_noise_float: typeof TSL.mx_worley_noise_float; +export const mx_worley_noise_float_2d: typeof TSL.mx_worley_noise_float_2d; +export const mx_worley_noise_float_3d: typeof TSL.mx_worley_noise_float_3d; export const mx_worley_noise_vec2: typeof TSL.mx_worley_noise_vec2; export const mx_worley_noise_vec3: typeof TSL.mx_worley_noise_vec3; +export const mx_worley_noise_vec3_style: typeof TSL.mx_worley_noise_vec3_style; export const negate: typeof TSL.negate; export const negateOnBackSide: typeof TSL.negateOnBackSide; export const neutralToneMapping: typeof TSL.neutralToneMapping; @@ -386,6 +415,7 @@ export const nodeObject: typeof TSL.nodeObject; export const nodeObjectIntent: typeof TSL.nodeObjectIntent; export const nodeObjects: typeof TSL.nodeObjects; export const nodeProxy: typeof TSL.nodeProxy; +export const nodeProxyConstructor: typeof TSL.nodeProxyConstructor; export const nodeProxyIntent: typeof TSL.nodeProxyIntent; export const normalFlat: typeof TSL.normalFlat; export const normalGeometry: typeof TSL.normalGeometry; @@ -406,10 +436,6 @@ export const objectRadius: typeof TSL.objectRadius; export const objectScale: typeof TSL.objectScale; export const objectViewPosition: typeof TSL.objectViewPosition; export const objectWorldMatrix: typeof TSL.objectWorldMatrix; -export const OnBeforeObjectUpdate: typeof TSL.OnBeforeObjectUpdate; -export const OnBeforeMaterialUpdate: typeof TSL.OnBeforeMaterialUpdate; -export const OnObjectUpdate: typeof TSL.OnObjectUpdate; -export const OnMaterialUpdate: typeof TSL.OnMaterialUpdate; export const oneMinus: typeof TSL.oneMinus; export const or: typeof TSL.or; export const orthographicDepthToViewZ: typeof TSL.orthographicDepthToViewZ; @@ -422,10 +448,16 @@ export const outputStruct: typeof TSL.outputStruct; export const overloadingFn: typeof TSL.overloadingFn; export const overrideNode: typeof TSL.overrideNode; export const overrideNodes: typeof TSL.overrideNodes; +export const pack4xI8: typeof TSL.pack4xI8; +export const pack4xI8Clamp: typeof TSL.pack4xI8Clamp; +export const pack4xU8: typeof TSL.pack4xU8; +export const pack4xU8Clamp: typeof TSL.pack4xU8Clamp; export const packHalf2x16: typeof TSL.packHalf2x16; +export const packNormalToRGB: typeof TSL.packNormalToRGB; export const packSnorm2x16: typeof TSL.packSnorm2x16; +export const packSnorm4x8: typeof TSL.packSnorm4x8; export const packUnorm2x16: typeof TSL.packUnorm2x16; -export const packNormalToRGB: typeof TSL.packNormalToRGB; +export const packUnorm4x8: typeof TSL.packUnorm4x8; export const parabola: typeof TSL.parabola; export const parallaxDirection: typeof TSL.parallaxDirection; export const parallaxUV: typeof TSL.parallaxUV; @@ -452,10 +484,13 @@ export const pow3: typeof TSL.pow3; export const pow4: typeof TSL.pow4; export const premultiplyAlpha: typeof TSL.premultiplyAlpha; export const property: typeof TSL.property; +export const quadBroadcast: typeof TSL.quadBroadcast; +export const quadSwapDiagonal: typeof TSL.quadSwapDiagonal; +export const quadSwapX: typeof TSL.quadSwapX; +export const quadSwapY: typeof TSL.quadSwapY; export const radians: typeof TSL.radians; export const rand: typeof TSL.rand; export const range: typeof TSL.range; -export const rangeFog: typeof TSL.rangeFog; export const rangeFogFactor: typeof TSL.rangeFogFactor; export const reciprocal: typeof TSL.reciprocal; export const reference: typeof TSL.reference; @@ -474,6 +509,7 @@ export const renderGroup: typeof TSL.renderGroup; export const renderOutput: typeof TSL.renderOutput; export const rendererReference: typeof TSL.rendererReference; export const replaceDefaultUV: typeof TSL.replaceDefaultUV; +export const retroreflectivity: typeof TSL.retroreflectivity; export const rotate: typeof TSL.rotate; export const rotateUV: typeof TSL.rotateUV; export const roughness: typeof TSL.roughness; @@ -505,12 +541,13 @@ export const shiftRight: typeof TSL.shiftRight; export const shininess: typeof TSL.shininess; export const sign: typeof TSL.sign; export const sin: typeof TSL.sin; -export const sinh: typeof TSL.sinh; export const sinc: typeof TSL.sinc; +export const sinh: typeof TSL.sinh; export const skinning: typeof TSL.skinning; export const smoothstep: typeof TSL.smoothstep; export const smoothstepElement: typeof TSL.smoothstepElement; export const specularColor: typeof TSL.specularColor; +export const specularColorBlended: typeof TSL.specularColorBlended; export const specularF90: typeof TSL.specularF90; export const spherizeUV: typeof TSL.spherizeUV; export const split: typeof TSL.split; @@ -521,10 +558,12 @@ export const step: typeof TSL.step; export const stepElement: typeof TSL.stepElement; export const storage: typeof TSL.storage; export const storageBarrier: typeof TSL.storageBarrier; +export const storageElement: typeof TSL.storageElement; export const storageTexture: typeof TSL.storageTexture; export const storageTexture3D: typeof TSL.storageTexture3D; export const struct: typeof TSL.struct; export const sub: typeof TSL.sub; +export const subBuild: typeof TSL.subBuild; export const subgroupAdd: typeof TSL.subgroupAdd; export const subgroupAll: typeof TSL.subgroupAll; export const subgroupAnd: typeof TSL.subgroupAnd; @@ -532,7 +571,6 @@ export const subgroupAny: typeof TSL.subgroupAny; export const subgroupBallot: typeof TSL.subgroupBallot; export const subgroupBroadcast: typeof TSL.subgroupBroadcast; export const subgroupBroadcastFirst: typeof TSL.subgroupBroadcastFirst; -export const subBuild: typeof TSL.subBuild; export const subgroupElect: typeof TSL.subgroupElect; export const subgroupExclusiveAdd: typeof TSL.subgroupExclusiveAdd; export const subgroupExclusiveMul: typeof TSL.subgroupExclusiveMul; @@ -550,20 +588,22 @@ export const subgroupShuffleXor: typeof TSL.subgroupShuffleXor; export const subgroupSize: typeof TSL.subgroupSize; export const subgroupXor: typeof TSL.subgroupXor; export const tan: typeof TSL.tan; -export const tanh: typeof TSL.tanh; export const tangentGeometry: typeof TSL.tangentGeometry; export const tangentLocal: typeof TSL.tangentLocal; export const tangentView: typeof TSL.tangentView; +export const tangentViewFrame: typeof TSL.tangentViewFrame; export const tangentWorld: typeof TSL.tangentWorld; +export const tanh: typeof TSL.tanh; export const texture: typeof TSL.texture; export const texture3D: typeof TSL.texture3D; +export const texture3DLevel: typeof TSL.texture3DLevel; +export const texture3DLoad: typeof TSL.texture3DLoad; export const textureBarrier: typeof TSL.textureBarrier; export const textureBicubic: typeof TSL.textureBicubic; export const textureBicubicLevel: typeof TSL.textureBicubicLevel; -export const textureCubeUV: typeof TSL.textureCubeUV; +export const textureLevel: typeof TSL.textureLevel; export const textureLoad: typeof TSL.textureLoad; export const textureSize: typeof TSL.textureSize; -export const textureLevel: typeof TSL.textureLevel; export const textureStore: typeof TSL.textureStore; export const thickness: typeof TSL.thickness; export const time: typeof TSL.time; @@ -589,13 +629,18 @@ export const uintBitsToFloat: typeof TSL.uintBitsToFloat; export const uniform: typeof TSL.uniform; export const uniformArray: typeof TSL.uniformArray; export const uniformCubeTexture: typeof TSL.uniformCubeTexture; -export const uniformGroup: typeof TSL.uniformGroup; export const uniformFlow: typeof TSL.uniformFlow; +export const uniformGroup: typeof TSL.uniformGroup; export const uniformTexture: typeof TSL.uniformTexture; +export const unpack4xI8: typeof TSL.unpack4xI8; +export const unpack4xU8: typeof TSL.unpack4xU8; export const unpackHalf2x16: typeof TSL.unpackHalf2x16; +export const unpackNormal: typeof TSL.unpackNormal; +export const unpackRGBToNormal: typeof TSL.unpackRGBToNormal; export const unpackSnorm2x16: typeof TSL.unpackSnorm2x16; +export const unpackSnorm4x8: typeof TSL.unpackSnorm4x8; export const unpackUnorm2x16: typeof TSL.unpackUnorm2x16; -export const unpackRGBToNormal: typeof TSL.unpackRGBToNormal; +export const unpackUnorm4x8: typeof TSL.unpackUnorm4x8; export const unpremultiplyAlpha: typeof TSL.unpremultiplyAlpha; export const userData: typeof TSL.userData; export const uv: typeof TSL.uv; @@ -624,12 +669,12 @@ export const viewportDepthTexture: typeof TSL.viewportDepthTexture; export const viewportLinearDepth: typeof TSL.viewportLinearDepth; export const viewportMipTexture: typeof TSL.viewportMipTexture; export const viewportOpaqueMipTexture: typeof TSL.viewportOpaqueMipTexture; -export const viewportResolution: typeof TSL.viewportResolution; export const viewportSafeUV: typeof TSL.viewportSafeUV; export const viewportSharedTexture: typeof TSL.viewportSharedTexture; export const viewportSize: typeof TSL.viewportSize; export const viewportTexture: typeof TSL.viewportTexture; export const viewportUV: typeof TSL.viewportUV; +export const vogelDiskSample: typeof TSL.vogelDiskSample; export const wgsl: typeof TSL.wgsl; export const wgslFn: typeof TSL.wgslFn; export const workgroupArray: typeof TSL.workgroupArray; diff --git a/types/three/src/Three.WebGPU.Nodes.d.ts b/types/three/src/Three.WebGPU.Nodes.d.ts index 3139398e180fd5..37e11f057236c0 100644 --- a/types/three/src/Three.WebGPU.Nodes.d.ts +++ b/types/three/src/Three.WebGPU.Nodes.d.ts @@ -3,6 +3,7 @@ export * from "./Three.Core.js"; export * from "./materials/nodes/NodeMaterials.js"; export type { default as Backend } from "./renderers/common/Backend.js"; export { default as BundleGroup } from "./renderers/common/BundleGroup.js"; +export { default as DirectRenderPipeline } from "./renderers/common/DirectRenderPipeline.js"; export { default as PMREMGenerator } from "./renderers/common/extras/PMREMGenerator.js"; export { default as Lighting } from "./renderers/common/Lighting.js"; export { default as PostProcessing } from "./renderers/common/PostProcessing.js"; diff --git a/types/three/src/Three.WebGPU.d.ts b/types/three/src/Three.WebGPU.d.ts index 6ef9efdceded68..6591952cc63b26 100644 --- a/types/three/src/Three.WebGPU.d.ts +++ b/types/three/src/Three.WebGPU.d.ts @@ -3,6 +3,7 @@ export * from "./Three.Core.js"; export * from "./materials/nodes/NodeMaterials.js"; export { default as Backend } from "./renderers/common/Backend.js"; export { default as BundleGroup } from "./renderers/common/BundleGroup.js"; +export { default as DirectRenderPipeline } from "./renderers/common/DirectRenderPipeline.js"; export { default as PMREMGenerator } from "./renderers/common/extras/PMREMGenerator.js"; export { default as Lighting } from "./renderers/common/Lighting.js"; export { default as PostProcessing } from "./renderers/common/PostProcessing.js"; diff --git a/types/three/src/animation/AnimationUtils.d.ts b/types/three/src/animation/AnimationUtils.d.ts index 0f643ad2ed9d1c..8767851ad8e030 100644 --- a/types/three/src/animation/AnimationUtils.d.ts +++ b/types/three/src/animation/AnimationUtils.d.ts @@ -1,6 +1,7 @@ import { TypedArray, TypedArrayConstructor } from "../core/BufferAttribute.js"; import { isTypedArray } from "../utils.js"; import { AnimationClip } from "./AnimationClip.js"; +import { KeyframeTrackSettings } from "./KeyframeTrack.js"; /** * Converts an array to a specific type. @@ -10,6 +11,13 @@ import { AnimationClip } from "./AnimationClip.js"; * @return {TypedArray} The converted array. */ export function convertArray(array: TypedArray | number[], type: TypedArrayConstructor): TypedArray; +/** + * Returns `true` if the given keyframe track settings hold Bezier tangent data. + * + * @param {?Object} settings - The settings of a keyframe track. + * @return {boolean} Whether both tangent arrays are defined or not. + */ +export function hasTangents(settings?: Partial | null): boolean; /** * Returns an array by which times and values can be sorted. * @@ -95,6 +103,14 @@ export class AnimationUtils { * @return {boolean} Whether the given object is a typed array. */ static isTypedArray(object: unknown): boolean; + /** + * Returns `true` if the given keyframe track settings hold Bezier tangent data. + * + * @static + * @param {?Object} settings - The settings of a keyframe track. + * @return {boolean} Whether both tangent arrays are defined or not. + */ + static hasTangents(settings?: Partial | null): boolean; /** * Returns an array by which times and values can be sorted. * diff --git a/types/three/src/animation/KeyframeTrack.d.ts b/types/three/src/animation/KeyframeTrack.d.ts index f9697d86cdc250..4fc0c1a1cf2bdf 100644 --- a/types/three/src/animation/KeyframeTrack.d.ts +++ b/types/three/src/animation/KeyframeTrack.d.ts @@ -5,12 +5,21 @@ import { CubicInterpolant } from "../math/interpolants/CubicInterpolant.js"; import { DiscreteInterpolant } from "../math/interpolants/DiscreteInterpolant.js"; import { LinearInterpolant } from "../math/interpolants/LinearInterpolant.js"; +export interface KeyframeTrackSettings { + inTangents: TypedArray | number[]; + outTangents: TypedArray | number[]; +} + export interface KeyframeTrackJSON { name: string; times: number[]; values: number[]; interpolation?: InterpolationModes; type: string; + settings?: { + inTangents: number[]; + outTangents: number[]; + }; } /** @@ -55,6 +64,11 @@ export class KeyframeTrack { * The keyframe values. */ values: Float32Array; + /** + * The interpolation settings. Holds the Bezier tangent data which is + * required when using `InterpolateBezier` as the interpolation type. + */ + settings?: KeyframeTrackSettings; /** * Factory method for creating a new discrete interpolant. * diff --git a/types/three/src/constants.d.ts b/types/three/src/constants.d.ts index 7ea818f27f5d96..89beccc1fa18b0 100644 --- a/types/three/src/constants.d.ts +++ b/types/three/src/constants.d.ts @@ -27,6 +27,9 @@ export type CullFace = typeof CullFaceNone | typeof CullFaceBack | typeof CullFa // Shadowing Type export const BasicShadowMap: 0; export const PCFShadowMap: 1; +/** + * @deprecated since r186. Use {@link PCFShadowMap} instead. + */ export const PCFSoftShadowMap: 2; export const VSMShadowMap: 3; export type ShadowMapType = typeof BasicShadowMap | typeof PCFShadowMap | typeof PCFSoftShadowMap | typeof VSMShadowMap; @@ -836,6 +839,16 @@ export const Compatibility: { }; export type Compatibility = typeof Compatibility.TEXTURE_COMPARE; +export const RenderObjectRefreshType: { + NONE: 0; + SHARED: 1; + FULL: 2; +}; +export type RenderObjectRefreshType = + | typeof RenderObjectRefreshType.NONE + | typeof RenderObjectRefreshType.SHARED + | typeof RenderObjectRefreshType.FULL; + /////////////////////////////////////////////////////////////////////////////// // Texture - Internal Pixel Formats diff --git a/types/three/src/core/Object3D.d.ts b/types/three/src/core/Object3D.d.ts index 984aae83354677..d1b5d28eb2c45c 100644 --- a/types/three/src/core/Object3D.d.ts +++ b/types/three/src/core/Object3D.d.ts @@ -3,6 +3,8 @@ import { Camera } from "../cameras/Camera.js"; import { ShapeJSON } from "../extras/core/Shape.js"; import { Material, MaterialJSON } from "../materials/Material.js"; import { Euler } from "../math/Euler.js"; +import { Frustum } from "../math/Frustum.js"; +import { FrustumArray } from "../math/FrustumArray.js"; import { Matrix3 } from "../math/Matrix3.js"; import { Matrix4, Matrix4Tuple } from "../math/Matrix4.js"; import { Quaternion } from "../math/Quaternion.js"; @@ -11,8 +13,8 @@ import { Group } from "../objects/Group.js"; import { SkeletonJSON } from "../objects/Skeleton.js"; import { WebGLRenderer } from "../renderers/WebGLRenderer.js"; import { Scene } from "../scenes/Scene.js"; -import { SourceJSON } from "../textures/Source.js"; import { TextureJSON } from "../textures/Texture.js"; +import { TextureSourceJSON } from "../textures/TextureSource.js"; import { BufferGeometry, BufferGeometryJSON } from "./BufferGeometry.js"; import { EventDispatcher } from "./EventDispatcher.js"; import { Layers } from "./Layers.js"; @@ -55,7 +57,7 @@ export interface JSONMeta { geometries: Record; materials: Record; textures: Record; - images: Record; + images: Record; shapes: Record; skeletons: Record; animations: Record; @@ -82,6 +84,11 @@ export interface Object3DEventMap { * Fires when a new child object has been removed. */ childremoved: { child: Object3D }; + + /** + * Fires when the 3D object has been disposed of. + */ + dispose: {}; } /** @@ -633,6 +640,15 @@ export class Object3D ext */ raycast(raycaster: Raycaster, intersects: Intersection[]): void; + /** + * Abstract method to test whether this 3D object intersects the given frustum. + * @remarks Renderable 3D objects such as {@link THREE.Mesh | Mesh}, {@link THREE.Line | Line} or {@link THREE.Points | Points} implement this method in order to use frustum culling. + * @param frustum The frustum to test. + * @returns Whether this 3D object intersects the given frustum or not. + * @defaultValue `() => {}` + */ + intersectsFrustum(frustum: Frustum | FrustumArray): boolean | undefined; + /** * Executes the callback on this object and all descendants. * @remarks Note: Modifying the scene graph inside the callback is discouraged. @@ -699,4 +715,11 @@ export class Object3D ext * `false`, descendants are left unchanged. Default is `true`. */ copy(object: Object3D, recursive?: boolean): this; + + /** + * Frees the GPU-related resources allocated by this instance. + * @remarks Call this method whenever this instance is no longer used in your app. + * Geometries, materials and textures are potentially shared with other 3D objects and must be disposed of separately. + */ + dispose(): void; } diff --git a/types/three/src/core/RenderTarget.d.ts b/types/three/src/core/RenderTarget.d.ts index f4039c1e5cb95e..044e02d5e0b315 100644 --- a/types/three/src/core/RenderTarget.d.ts +++ b/types/three/src/core/RenderTarget.d.ts @@ -6,8 +6,12 @@ import { EventDispatcher } from "./EventDispatcher.js"; export interface RenderTargetOptions extends TextureParameters { depthBuffer?: boolean | undefined; // true stencilBuffer?: boolean | undefined; // false + resolveColorBuffer?: boolean | undefined; // true resolveDepthBuffer?: boolean | undefined; // true resolveStencilBuffer?: boolean | undefined; // true + storeMultisampledColorBuffer?: boolean | undefined; // true + storeMultisampledDepthBuffer?: boolean | undefined; // true + storeMultisampledStencilBuffer?: boolean | undefined; // true depthTexture?: DepthTexture | null | undefined; // null /** * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. @@ -53,18 +57,64 @@ export class RenderTarget< stencilBuffer: boolean; /** - * Defines whether the depth buffer should be resolved when rendering into a multisampled render target. + * Whether to resolve the color buffer or not. When set to `false`, the color attachments do not receive the + * resolved (single-sampled) output of a render pass and the render target's textures are left untouched. The + * rendered content is then only accessible within the render pass itself. + * + * Only relevant for multisampled render targets. + * @default true + */ + resolveColorBuffer: boolean; + + /** + * Whether to resolve the depth buffer or not. When set to `false`, the depth texture does not receive the resolved + * depth output of a render pass which saves memory bandwidth. Use this setting when the depth data of a render pass + * are not required afterwards. + * + * Only relevant for multisampled render targets in WebGL. WebGPU does not support depth resolves; sampling the + * depth texture of a multisampled render target accesses the multisampled data directly, see + * {@link RenderTarget#storeMultisampledDepthBuffer}. * @default true */ resolveDepthBuffer: boolean; /** - * Defines whether the stencil buffer should be resolved when rendering into a multisampled render target. - * This property has no effect when {@link .resolveDepthBuffer} is set to `false`. + * Whether to resolve the stencil buffer or not. Analogous to {@link RenderTarget#resolveDepthBuffer} but for the + * stencil aspect. * @default true */ resolveStencilBuffer: boolean; + /** + * Whether to store the multisampled color buffer or not. When set to `false`, the multisampled data are discarded + * at the end of a render pass, right after they have been resolved. This saves memory bandwidth, especially on + * tile-based GPUs, and is the recommended setting for render targets that are fully redrawn each frame and whose + * output is only accessed via the resolved textures (e.g. scene passes in post-processing chains). + * + * Must be kept `true` when the multisampled data are needed after the render pass ends, e.g. when rendering into + * the target without clearing or when the scene contains transmissive objects which require a mid-pass framebuffer + * copy. + * @default true + */ + storeMultisampledColorBuffer: boolean; + + /** + * Whether to store the multisampled depth buffer or not. When set to `false`, the multisampled depth data are + * discarded at the end of a render pass which saves memory bandwidth. + * + * Must be kept `true` in WebGPU when the depth texture of a multisampled render target is sampled (e.g. by + * depth-based post-processing effects) since depth is read directly from the multisampled data. + * @default true + */ + storeMultisampledDepthBuffer: boolean; + + /** + * Whether to store the multisampled stencil buffer or not. Analogous to + * {@link RenderTarget#storeMultisampledDepthBuffer} but for the stencil aspect. + * @default true + */ + storeMultisampledStencilBuffer: boolean; + /** * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. * @default 0 diff --git a/types/three/src/geometries/TorusGeometry.d.ts b/types/three/src/geometries/TorusGeometry.d.ts index 291f8cfbfdb35b..579659f2514896 100644 --- a/types/three/src/geometries/TorusGeometry.d.ts +++ b/types/three/src/geometries/TorusGeometry.d.ts @@ -6,6 +6,8 @@ export interface TorusGeometryJSON { radialSegments: number; tubularSegments: number; arc: number; + thetaStart: number; + thetaLength: number; } /** diff --git a/types/three/src/helpers/ArrowHelper.d.ts b/types/three/src/helpers/ArrowHelper.d.ts index 3123106dc0853f..6c5b8b897a1485 100644 --- a/types/three/src/helpers/ArrowHelper.d.ts +++ b/types/three/src/helpers/ArrowHelper.d.ts @@ -69,9 +69,4 @@ export class ArrowHelper extends Object3D { */ setColor(color: ColorRepresentation): void; copy(source: ArrowHelper): this; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/AxesHelper.d.ts b/types/three/src/helpers/AxesHelper.d.ts index 725a0fb9b7f426..2beac5205939e5 100644 --- a/types/three/src/helpers/AxesHelper.d.ts +++ b/types/three/src/helpers/AxesHelper.d.ts @@ -30,9 +30,4 @@ export class AxesHelper extends LineSegments { yAxisColor: ColorRepresentation, zAxisColor: ColorRepresentation, ): AxesHelper; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/Box3Helper.d.ts b/types/three/src/helpers/Box3Helper.d.ts index b19984bf4c169b..8ab7e7938464cf 100644 --- a/types/three/src/helpers/Box3Helper.d.ts +++ b/types/three/src/helpers/Box3Helper.d.ts @@ -25,9 +25,4 @@ export class Box3Helper extends LineSegments { * The box being visualized. */ box: Box3; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/BoxHelper.d.ts b/types/three/src/helpers/BoxHelper.d.ts index 91b857e1338211..7b2736d73b35ac 100644 --- a/types/three/src/helpers/BoxHelper.d.ts +++ b/types/three/src/helpers/BoxHelper.d.ts @@ -45,9 +45,4 @@ export class BoxHelper extends LineSegments { */ setFromObject(object: Object3D): BoxHelper; copy(source: BoxHelper, recursive?: boolean): this; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/CameraHelper.d.ts b/types/three/src/helpers/CameraHelper.d.ts index bb331f5781f11f..501f1dcaab485a 100644 --- a/types/three/src/helpers/CameraHelper.d.ts +++ b/types/three/src/helpers/CameraHelper.d.ts @@ -51,9 +51,4 @@ export class CameraHelper extends LineSegments { * Updates the helper based on the projection matrix of the camera. */ update(): void; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/DirectionalLightHelper.d.ts b/types/three/src/helpers/DirectionalLightHelper.d.ts index e80d1711c34a86..12687f4d9e72d7 100644 --- a/types/three/src/helpers/DirectionalLightHelper.d.ts +++ b/types/three/src/helpers/DirectionalLightHelper.d.ts @@ -47,11 +47,6 @@ export class DirectionalLightHelper extends Object3D { * Represents the target line of the directional light. */ targetLine: Line; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; /** * Updates the helper to match the position and direction of the * light being visualized. diff --git a/types/three/src/helpers/GridHelper.d.ts b/types/three/src/helpers/GridHelper.d.ts index 380fc43cc87665..b86ccba563b6cb 100644 --- a/types/three/src/helpers/GridHelper.d.ts +++ b/types/three/src/helpers/GridHelper.d.ts @@ -25,9 +25,4 @@ export class GridHelper extends LineSegments * @param {number|Color|string} [color2=0x888888] - The color of the lines of the grid. */ constructor(size?: number, divisions?: number, color1?: ColorRepresentation, color2?: ColorRepresentation); - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/HemisphereLightHelper.d.ts b/types/three/src/helpers/HemisphereLightHelper.d.ts index 35c26eb6abb173..dfed124952ada1 100644 --- a/types/three/src/helpers/HemisphereLightHelper.d.ts +++ b/types/three/src/helpers/HemisphereLightHelper.d.ts @@ -36,11 +36,6 @@ export class HemisphereLightHelper extends Object3D { */ color: ColorRepresentation | undefined; material: MeshBasicMaterial; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; /** * Updates the helper to match the position and direction of the * light being visualized. diff --git a/types/three/src/helpers/PlaneHelper.d.ts b/types/three/src/helpers/PlaneHelper.d.ts index 73d2a85592f626..cd2e7bc4ca20d3 100644 --- a/types/three/src/helpers/PlaneHelper.d.ts +++ b/types/three/src/helpers/PlaneHelper.d.ts @@ -30,9 +30,4 @@ export class PlaneHelper extends Line { * @default 1 */ size: number; - /** - * Updates the helper to match the position and direction of the - * light being visualized. - */ - dispose(): void; } diff --git a/types/three/src/helpers/PointLightHelper.d.ts b/types/three/src/helpers/PointLightHelper.d.ts index cb419f061a2206..e2217256daaa02 100644 --- a/types/three/src/helpers/PointLightHelper.d.ts +++ b/types/three/src/helpers/PointLightHelper.d.ts @@ -35,11 +35,6 @@ export class PointLightHelper extends Mesh { * If not set, the helper will take the color of the light. */ color: ColorRepresentation | undefined; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; /** * Updates the helper to match the position of the * light being visualized. diff --git a/types/three/src/helpers/PolarGridHelper.d.ts b/types/three/src/helpers/PolarGridHelper.d.ts index 62b26685063ea5..d9d8706357fb38 100644 --- a/types/three/src/helpers/PolarGridHelper.d.ts +++ b/types/three/src/helpers/PolarGridHelper.d.ts @@ -34,9 +34,4 @@ export class PolarGridHelper extends LineSegments { color1?: ColorRepresentation, color2?: ColorRepresentation, ); - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/SkeletonHelper.d.ts b/types/three/src/helpers/SkeletonHelper.d.ts index b8f9814299392a..96fa91d262f861 100644 --- a/types/three/src/helpers/SkeletonHelper.d.ts +++ b/types/three/src/helpers/SkeletonHelper.d.ts @@ -41,9 +41,4 @@ export class SkeletonHelper extends LineSegments { * @return {SkeletonHelper} A reference to this helper. */ setColors(color1: Color, color2: Color): SkeletonHelper; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/SpotLightHelper.d.ts b/types/three/src/helpers/SpotLightHelper.d.ts index 0c56b5ed1626f7..0c6a79d238a7ac 100644 --- a/types/three/src/helpers/SpotLightHelper.d.ts +++ b/types/three/src/helpers/SpotLightHelper.d.ts @@ -37,11 +37,6 @@ export class SpotLightHelper extends Object3D { */ color: ColorRepresentation | undefined; cone: LineSegments; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; /** * Updates the helper to match the position and direction of the * light being visualized. diff --git a/types/three/src/lights/Light.d.ts b/types/three/src/lights/Light.d.ts index 785754da572903..a53afaee8b78ae 100644 --- a/types/three/src/lights/Light.d.ts +++ b/types/three/src/lights/Light.d.ts @@ -1,4 +1,4 @@ -import { JSONMeta, Object3D, Object3DEventMap, Object3DJSON } from "../core/Object3D.js"; +import { JSONMeta, Object3D, Object3DJSON } from "../core/Object3D.js"; import { Color, ColorRepresentation } from "../math/Color.js"; export interface LightJSON extends Object3DJSON { @@ -6,15 +6,11 @@ export interface LightJSON extends Object3DJSON { intensity: number; } -export interface LightEventMap extends Object3DEventMap { - dispose: {}; -} - /** * Abstract base class for lights - all other light types inherit the * properties and methods described here. */ -export abstract class Light extends Object3D { +export abstract class Light extends Object3D { /** * Constructs a new light. * @@ -38,11 +34,6 @@ export abstract class Light extends Object3D { * @default 1 */ intensity: number; - /** - * Frees the GPU-related resources allocated by this instance. Call this - * method whenever this instance is no longer used in your app. - */ - dispose(): void; copy(source: Light, recursive?: boolean): this; toJSON(meta?: JSONMeta): LightJSON; } diff --git a/types/three/src/lights/LightShadow.d.ts b/types/three/src/lights/LightShadow.d.ts index 534a4124c471dc..19e4de84a58408 100644 --- a/types/three/src/lights/LightShadow.d.ts +++ b/types/three/src/lights/LightShadow.d.ts @@ -14,6 +14,7 @@ export interface LightShadowJSON { bias?: number; normalBias?: number; radius?: number; + blurSamples?: number; mapSize?: Vector2Tuple; camera: Omit; @@ -140,6 +141,13 @@ export abstract class LightShadow { * @return {number} The viewport count. */ getViewportCount(): number; + /** + * Used internally by the renderer to get the camera that renders the given viewport. + * + * @param {number} [viewportIndex=0] - The viewport index. + * @return {Camera} The shadow camera. + */ + getCamera(viewportIndex?: number): TCamera; /** * Gets the shadow cameras frustum. Used internally by the renderer to cull objects. * diff --git a/types/three/src/lights/SpotLight.d.ts b/types/three/src/lights/SpotLight.d.ts index 2b1e77c58275f5..5717616cd92ee2 100644 --- a/types/three/src/lights/SpotLight.d.ts +++ b/types/three/src/lights/SpotLight.d.ts @@ -2,8 +2,7 @@ import { JSONMeta, Object3D } from "../core/Object3D.js"; import { ColorRepresentation } from "../math/Color.js"; import { Texture } from "../textures/Texture.js"; import { Light, LightJSON } from "./Light.js"; -import { LightShadowJSON } from "./LightShadow.js"; -import { SpotLightShadow } from "./SpotLightShadow.js"; +import { SpotLightShadow, SpotLightShadowJSON } from "./SpotLightShadow.js"; export interface SpotLightJSON extends LightJSON { distance: number; @@ -14,7 +13,7 @@ export interface SpotLightJSON extends LightJSON { target: string; map?: string | undefined; - shadow: LightShadowJSON; + shadow: SpotLightShadowJSON; } /** diff --git a/types/three/src/lights/SpotLightShadow.d.ts b/types/three/src/lights/SpotLightShadow.d.ts index 8eab600c403579..7419239f5ede40 100644 --- a/types/three/src/lights/SpotLightShadow.d.ts +++ b/types/three/src/lights/SpotLightShadow.d.ts @@ -1,5 +1,10 @@ import { PerspectiveCamera } from "../cameras/PerspectiveCamera.js"; -import { LightShadow } from "./LightShadow.js"; +import { LightShadow, LightShadowJSON } from "./LightShadow.js"; + +export interface SpotLightShadowJSON extends LightShadowJSON { + focus?: number; + aspect?: number; +} /** * Represents the shadow configuration of directional lights. @@ -29,4 +34,11 @@ export class SpotLightShadow extends LightShadow { */ aspect: number; copy(source: SpotLightShadow): this; + /** + * Serializes the light shadow into JSON. + * + * @return {Object} A JSON object representing the serialized light shadow. + * @see {@link ObjectLoader#parse} + */ + toJSON(): SpotLightShadowJSON; } diff --git a/types/three/src/loaders/ObjectLoader.d.ts b/types/three/src/loaders/ObjectLoader.d.ts index 9cc81c481f4b6b..482b6f37761d9a 100644 --- a/types/three/src/loaders/ObjectLoader.d.ts +++ b/types/three/src/loaders/ObjectLoader.d.ts @@ -3,8 +3,8 @@ import { BufferGeometry } from "../core/BufferGeometry.js"; import { InstancedBufferGeometry } from "../core/InstancedBufferGeometry.js"; import { Object3D } from "../core/Object3D.js"; import { Material } from "../materials/Material.js"; -import { Source } from "../textures/Source.js"; import { Texture } from "../textures/Texture.js"; +import { TextureSource } from "../textures/TextureSource.js"; import { Loader } from "./Loader.js"; import { LoadingManager } from "./LoadingManager.js"; @@ -23,9 +23,9 @@ export class ObjectLoader extends Loader { parseGeometries(json: unknown): { [key: string]: InstancedBufferGeometry | BufferGeometry }; parseMaterials(json: unknown, textures: { [key: string]: Texture }): { [key: string]: Material }; parseAnimations(json: unknown): { [key: string]: AnimationClip }; - parseImages(json: unknown, onLoad?: () => void): { [key: string]: Source }; - parseImagesAsync(json: unknown): Promise<{ [key: string]: Source }>; - parseTextures(json: unknown, images: { [key: string]: Source }): { [key: string]: Texture }; + parseImages(json: unknown, onLoad?: () => void): { [key: string]: TextureSource }; + parseImagesAsync(json: unknown): Promise<{ [key: string]: TextureSource }>; + parseTextures(json: unknown, images: { [key: string]: TextureSource }): { [key: string]: Texture }; parseObject( data: unknown, geometries: { [key: string]: InstancedBufferGeometry | BufferGeometry }, diff --git a/types/three/src/materials/Material.d.ts b/types/three/src/materials/Material.d.ts index 5a3ccb0aa87e26..149a3155674d41 100644 --- a/types/three/src/materials/Material.d.ts +++ b/types/three/src/materials/Material.d.ts @@ -6,6 +6,7 @@ import { BlendingSrcFactor, Combine, DepthModes, + DepthPackingStrategies, NormalMapTypes, Side, StencilFunc, @@ -16,14 +17,14 @@ import { EventDispatcher } from "../core/EventDispatcher.js"; import { JSONMeta, Object3D } from "../core/Object3D.js"; import { Color, ColorRepresentation } from "../math/Color.js"; import { EulerTuple } from "../math/Euler.js"; -import { Plane } from "../math/Plane.js"; +import { Plane, PlaneJSON } from "../math/Plane.js"; import { Vector2Tuple } from "../math/Vector2.js"; import { Group } from "../objects/Group.js"; import { WebGLProgramParametersWithUniforms } from "../renderers/webgl/WebGLPrograms.js"; import { WebGLRenderer } from "../renderers/WebGLRenderer.js"; import { Scene } from "../scenes/Scene.js"; -import { SourceJSON } from "../textures/Source.js"; import { Texture, TextureJSON } from "../textures/Texture.js"; +import { TextureSourceJSON } from "../textures/TextureSource.js"; export interface MaterialProperties { /** @@ -472,6 +473,10 @@ export interface MaterialJSON { depthWrite?: boolean; colorWrite?: boolean; + clippingPlanes?: PlaneJSON[]; + clipIntersection?: boolean; + clipShadows?: boolean; + stencilWriteMask?: number; stencilFunc?: StencilFunc; stencilRef?: number; @@ -483,11 +488,15 @@ export interface MaterialJSON { rotation?: number; + depthPacking?: DepthPackingStrategies; + polygonOffset?: boolean; polygonOffsetFactor?: number; polygonOffsetUnits?: number; linewidth?: number; + linecap?: string; + linejoin?: string; dashSize?: number; gapSize?: number; scale?: number; @@ -516,7 +525,7 @@ export interface MaterialJSON { userData?: Record; textures?: Array>; - images?: SourceJSON[]; + images?: TextureSourceJSON[]; } export interface MaterialEventMap { diff --git a/types/three/src/materials/MeshPhysicalMaterial.d.ts b/types/three/src/materials/MeshPhysicalMaterial.d.ts index 581d5b3a5dd004..972bd9f6c26d44 100644 --- a/types/three/src/materials/MeshPhysicalMaterial.d.ts +++ b/types/three/src/materials/MeshPhysicalMaterial.d.ts @@ -276,6 +276,16 @@ export interface MeshPhysicalMaterialProperties extends MeshStandardMaterialProp * @default 0 */ get dispersion(): number; + set retroreflectivity(value: number); + /** + * The strength of retroreflection, from `0.0` to `1.0`. A value of `1.0` + * evaluates the material's microfacet reflection with the view direction + * reflected about the surface normal, redirecting the specular lobe back + * toward the light source. + * + * @default 0 + */ + get retroreflectivity(): number; set sheen(value: number); /** * The intensity of the sheen layer, from `0.0` to `1.0`. @@ -319,6 +329,8 @@ export interface MeshPhysicalMaterialParameters * transparent materials are less reflective. Physically-based transmission provides a more * realistic option for thin, transparent surfaces like glass. * - Advanced reflectivity: More flexible reflectivity for non-metallic materials. + * - Retroreflection: Redirects specular light back toward the light source for + * safety materials like road markings and reflective tape. * - Sheen: Can be used for representing cloth and fabric materials. * * As a result of these complex shading features, `MeshPhysicalMaterial` has a diff --git a/types/three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts index aff931a92e688c..6cd5dd4f89ae1a 100644 --- a/types/three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts @@ -181,6 +181,17 @@ export interface MeshPhysicalNodeMaterialNodeProperties extends MeshStandardNode * @default null */ dispersionNode: Node | null; + /** + * The retroreflective strength of physical materials is by default inferred from the + * `retroreflectivity` property. This node property allows to overwrite the default + * and define the retroreflective strength with a node instead. + * + * If you don't want to overwrite the retroreflective strength but modify the existing + * value instead, use {@link materialRetroreflectivity}. + * + * @default null + */ + retroreflectivityNode: Node | null; /** * The anisotropy of physical materials is by default inferred from the * `anisotropy` property. This node property allows to overwrite the default @@ -249,6 +260,12 @@ declare class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial { * @default true */ get useDispersion(): boolean; + /** + * Whether the lighting model should use retroreflection or not. + * + * @default true + */ + get useRetroreflection(): boolean; /** * Setups the physical specific node variables. * diff --git a/types/three/src/materials/nodes/NodeMaterial.d.ts b/types/three/src/materials/nodes/NodeMaterial.d.ts index e84b00a8a57d1b..5c81c5f54c3e10 100644 --- a/types/three/src/materials/nodes/NodeMaterial.d.ts +++ b/types/three/src/materials/nodes/NodeMaterial.d.ts @@ -240,9 +240,11 @@ export interface NodeMaterialNodeProperties { */ castShadowNode: Node | null; /** - * This node can be used to define the final output of the material. + * This node can be used to overwrite the final output of the material. * - * TODO: Explain the differences to `fragmentNode`. + * Unlike {@link NodeMaterial#fragmentNode}, the built-in material logic + * (diffuse color, lighting, etc.) is still evaluated; assigning a node + * only replaces the resulting output color. * * @default null */ @@ -368,7 +370,6 @@ declare class NodeMaterial extends Material { * Setups the computation of the material's diffuse color. * * @param {NodeBuilder} builder - The current node builder. - * @param {BufferGeometry} geometry - The geometry. */ setupDiffuseColor(builder: NodeBuilder): void; /** diff --git a/types/three/src/math/FrustumArray.d.ts b/types/three/src/math/FrustumArray.d.ts index 3edb6fa87fc473..d37bb828a8d41b 100644 --- a/types/three/src/math/FrustumArray.d.ts +++ b/types/three/src/math/FrustumArray.d.ts @@ -73,7 +73,7 @@ export class FrustumArray { /** * Copies the values of the given frustum array to this instance. * - * @param {FrustumArray} frustumArray - The frustum array to copy. + * @param {FrustumArray} source - The frustum array to copy. * @return {FrustumArray} A reference to this frustum array. */ copy(source: FrustumArray): this; diff --git a/types/three/src/math/MathUtils.d.ts b/types/three/src/math/MathUtils.d.ts index 48f10a3c3ceff3..f80fe22a14348e 100644 --- a/types/three/src/math/MathUtils.d.ts +++ b/types/three/src/math/MathUtils.d.ts @@ -101,12 +101,28 @@ export function setQuaternionFromProperEuler(q: Quaternion, a: number, b: number export function denormalize( value: number, - array: Float32Array | Uint32Array | Uint16Array | Uint8Array | Int32Array | Int16Array | Int8Array, + array: + | Float32Array + | Uint32Array + | Uint16Array + | Uint8Array + | Uint8ClampedArray + | Int32Array + | Int16Array + | Int8Array, ): number; export function normalize( value: number, - array: Float32Array | Uint32Array | Uint16Array | Uint8Array | Int32Array | Int16Array | Int8Array, + array: + | Float32Array + | Uint32Array + | Uint16Array + | Uint8Array + | Uint8ClampedArray + | Int32Array + | Int16Array + | Int8Array, ): number; export const MathUtils: { diff --git a/types/three/src/math/Matrix4.d.ts b/types/three/src/math/Matrix4.d.ts index d3f35995c254d6..82249ce4c97706 100644 --- a/types/three/src/math/Matrix4.d.ts +++ b/types/three/src/math/Matrix4.d.ts @@ -187,7 +187,7 @@ export class Matrix4 { */ setFromMatrix3(m: Matrix3): this; /** - * Extracts the basis of this matrix into the three axis vectors provided. + * Extracts the basis vectors of this matrix into the three vectors provided. * * @param {Vector3} xAxis - The basis's x axis. * @param {Vector3} yAxis - The basis's y axis. @@ -277,8 +277,6 @@ export class Matrix4 { /** * Computes and returns the determinant of this matrix. * - * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html). - * * @return {number} The determinant. */ determinant(): number; @@ -327,7 +325,7 @@ export class Matrix4 { */ invert(): this; /** - * Multiplies the columns of this matrix by the given vector. + * Scales each of the first three columns of this matrix by the corresponding component of the given vector. * * @param {Vector3} v - The scale vector. * @return {Matrix4} A reference to this matrix. @@ -383,9 +381,6 @@ export class Matrix4 { * Sets this matrix as a rotational transformation around the given axis by * the given angle. * - * This is a somewhat controversial but mathematically sound alternative to - * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199). - * * @param {Vector3} axis - The normalized rotation axis. * @param {number} angle - The rotation in radians. * @return {Matrix4} A reference to this matrix. diff --git a/types/three/src/math/Plane.d.ts b/types/three/src/math/Plane.d.ts index 65c0e349669869..ab8699a28e3d31 100644 --- a/types/three/src/math/Plane.d.ts +++ b/types/three/src/math/Plane.d.ts @@ -44,4 +44,12 @@ export class Plane { * @deprecated Use {@link Plane#intersectsLine .intersectsLine()} instead. */ isIntersectionLine(l: any): any; + + toJSON(): PlaneJSON; + fromJSON(json: PlaneJSON): this; +} + +export interface PlaneJSON { + normal: number[]; + constant: number; } diff --git a/types/three/src/nodes/Nodes.d.ts b/types/three/src/nodes/Nodes.d.ts index 0bb64c0da0253b..06ea55ef418919 100644 --- a/types/three/src/nodes/Nodes.d.ts +++ b/types/three/src/nodes/Nodes.d.ts @@ -60,6 +60,7 @@ export { default as ModelNode } from "./accessors/ModelNode.js"; export { default as Object3DNode } from "./accessors/Object3DNode.js"; export { default as PointUVNode } from "./accessors/PointUVNode.js"; export { default as ReferenceBaseNode } from "./accessors/ReferenceBaseNode.js"; +export { default as ReferenceElementNode } from "./accessors/ReferenceElementNode.js"; export { default as ReferenceNode } from "./accessors/ReferenceNode.js"; export { default as RendererReferenceNode } from "./accessors/RendererReferenceNode.js"; export { default as StorageBufferNode } from "./accessors/StorageBufferNode.js"; @@ -84,7 +85,7 @@ export { default as BumpMapNode } from "./display/BumpMapNode.js"; export { default as ColorSpaceNode } from "./display/ColorSpaceNode.js"; export { default as FrontFacingNode } from "./display/FrontFacingNode.js"; export { default as NormalMapNode } from "./display/NormalMapNode.js"; -export { default as PassNode, PassNodeScope } from "./display/PassNode.js"; +export { default as PassNode, PassNodeOptions, PassNodeScope } from "./display/PassNode.js"; export { default as RenderOutputNode } from "./display/RenderOutputNode.js"; export { default as ScreenNode, ScreenNodeScope } from "./display/ScreenNode.js"; export { default as ToneMappingNode } from "./display/ToneMappingNode.js"; @@ -134,6 +135,7 @@ export { default as BitcountNode } from "./math/BitcountNode.js"; export { default as ConditionalNode } from "./math/ConditionalNode.js"; export { default as MathNode } from "./math/MathNode.js"; export { default as OperatorNode } from "./math/OperatorNode.js"; +export { default as Packed4x8IntegerNode } from "./math/Packed4x8IntegerNode.js"; export { default as PackFloatNode } from "./math/PackFloatNode.js"; export { default as UnpackFloatNode } from "./math/UnpackFloatNode.js"; diff --git a/types/three/src/nodes/TSL.d.ts b/types/three/src/nodes/TSL.d.ts index f96ea47f821e48..ea8c5cce2893ef 100644 --- a/types/three/src/nodes/TSL.d.ts +++ b/types/three/src/nodes/TSL.d.ts @@ -24,6 +24,7 @@ export * from "./math/BitcastNode.js"; export * from "./math/BitcountNode.js"; export * from "./math/Hash.js"; export * from "./math/MathUtils.js"; +export * from "./math/Packed4x8IntegerNode.js"; export * from "./math/PackFloatNode.js"; export * from "./math/TriNoise3D.js"; export * from "./math/UnpackFloatNode.js"; @@ -45,6 +46,7 @@ export * from "./utils/RTTNode.js"; export * from "./utils/SampleNode.js"; export * from "./utils/SpriteSheetUV.js"; export * from "./utils/SpriteUtils.js"; +export * from "./utils/StorageArrayElementNode.js"; export * from "./utils/Timer.js"; export * from "./utils/TriplanarTextures.js"; export * from "./utils/UVUtils.js"; @@ -62,6 +64,7 @@ export * from "./accessors/BufferAttributeNode.js"; export * from "./accessors/BufferNode.js"; export * from "./accessors/BuiltinNode.js"; export * from "./accessors/Camera.js"; +export * from "./accessors/ClippingNode.js"; export * from "./accessors/CubeTextureNode.js"; export * from "./accessors/Instance.js"; export * from "./accessors/MaterialNode.js"; @@ -83,6 +86,7 @@ export * from "./accessors/StorageBufferNode.js"; export * from "./accessors/StorageTexture3DNode.js"; export * from "./accessors/StorageTextureNode.js"; export * from "./accessors/Tangent.js"; +export * from "./accessors/TangentUtils.js"; export * from "./accessors/Texture3DNode.js"; export * from "./accessors/TextureBicubic.js"; export * from "./accessors/TextureNode.js"; @@ -142,12 +146,11 @@ export * from "./lighting/LightsNode.js"; export * from "./lighting/PointLightNode.js"; export * from "./lighting/PointShadowNode.js"; export * from "./lighting/ShadowBaseNode.js"; -export * from "./lighting/ShadowFilterNode.js"; -export * from "./lighting/ShadowNode.js"; +export { BasicShadowFilter, PCFShadowFilter, VSMShadowFilter } from "./lighting/ShadowFilterNode.js"; +export { shadow } from "./lighting/ShadowNode.js"; // pmrem export * from "./pmrem/PMREMNode.js"; -export * from "./pmrem/PMREMUtils.js"; // procedural export * from "./procedural/Checker.js"; @@ -161,11 +164,16 @@ export * from "./materialx/MaterialXNodes.js"; // functions export { default as BRDF_GGX } from "./functions/BSDF/BRDF_GGX.js"; export { default as BRDF_Lambert } from "./functions/BSDF/BRDF_Lambert.js"; +export { default as BRDF_Sheen } from "./functions/BSDF/BRDF_Sheen.js"; export { default as D_GGX } from "./functions/BSDF/D_GGX.js"; +export { default as D_GGX_Anisotropic } from "./functions/BSDF/D_GGX_Anisotropic.js"; export { default as DFGLUT } from "./functions/BSDF/DFGLUT.js"; +export { default as EnvironmentBRDF } from "./functions/BSDF/EnvironmentBRDF.js"; export { default as F_Schlick } from "./functions/BSDF/F_Schlick.js"; +export { LTC_Evaluate, LTC_Evaluate_Volume, LTC_Uv } from "./functions/BSDF/LTC.js"; export { default as Schlick_to_F0 } from "./functions/BSDF/Schlick_to_F0.js"; export { default as V_GGX_SmithCorrelated } from "./functions/BSDF/V_GGX_SmithCorrelated.js"; +export { default as V_GGX_SmithCorrelated_Anisotropic } from "./functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js"; export * from "./lighting/LightUtils.js"; diff --git a/types/three/src/nodes/accessors/Batch.d.ts b/types/three/src/nodes/accessors/Batch.d.ts index c40e0be334ebfb..309ae884e41994 100644 --- a/types/three/src/nodes/accessors/Batch.d.ts +++ b/types/three/src/nodes/accessors/Batch.d.ts @@ -7,6 +7,12 @@ import VaryingNode from "../core/VaryingNode.js"; * @type {VaryingNode} */ export const batchColor: VaryingNode<"vec4">; +/** + * TSL object representing a varying property for the batch indirect index (instance ID). + * + * @type {VaryingNode} + */ +export const batchIndirectIndex: VaryingNode<"uint">; /** * TSL function representing the vertex shader batching setup. * Applies the batch transformation matrix to positionLocal, normalLocal, and tangentLocal. diff --git a/types/three/src/nodes/accessors/Instance.d.ts b/types/three/src/nodes/accessors/Instance.d.ts index 01b282ac14ef9a..22b6e41c1b5f12 100644 --- a/types/three/src/nodes/accessors/Instance.d.ts +++ b/types/three/src/nodes/accessors/Instance.d.ts @@ -15,12 +15,10 @@ export const instanceColor: VaryingNode<"vec3">; * * @tsl * @function - * @param {number} count - The instance count. * @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} matrices - The instanced transformation matrices. * @param {?InstancedBufferAttribute|StorageInstancedBufferAttribute} [colors=null] - The optional instanced colors. */ export const instance: ( - count: number, matrices: InstancedBufferAttribute | StorageInstancedBufferAttribute, colors?: InstancedBufferAttribute | StorageInstancedBufferAttribute | null, ) => void; diff --git a/types/three/src/nodes/accessors/MaterialNode.d.ts b/types/three/src/nodes/accessors/MaterialNode.d.ts index 433586ec27f2d3..ee8ce1dfd387fb 100644 --- a/types/three/src/nodes/accessors/MaterialNode.d.ts +++ b/types/three/src/nodes/accessors/MaterialNode.d.ts @@ -128,6 +128,7 @@ export const materialLineWidth: MaterialNode<"float">; export const materialLineDashOffset: MaterialNode<"float">; export const materialPointSize: MaterialNode<"float">; export const materialDispersion: MaterialNode<"float">; +export const materialRetroreflectivity: MaterialNode<"float">; export const materialLightMap: MaterialNode<"vec3">; export const materialAO: MaterialNode<"float">; export const materialAnisotropyVector: Node<"vec2">; diff --git a/types/three/src/nodes/accessors/ReferenceElementNode.d.ts b/types/three/src/nodes/accessors/ReferenceElementNode.d.ts new file mode 100644 index 00000000000000..46aab773c82ff5 --- /dev/null +++ b/types/three/src/nodes/accessors/ReferenceElementNode.d.ts @@ -0,0 +1,15 @@ +import Node from "../core/Node.js"; +import ArrayElementNode from "../utils/ArrayElementNode.js"; +import ReferenceBaseNode from "./ReferenceBaseNode.js"; +import ReferenceNode from "./ReferenceNode.js"; + +export default class ReferenceElementNode extends ArrayElementNode { + referenceNode: ReferenceBaseNode | ReferenceNode | null; + + readonly isReferenceElementNode: true; + + constructor( + referenceNode: ReferenceBaseNode | ReferenceNode, + indexNode: Node, + ); +} diff --git a/types/three/src/nodes/accessors/TextureNode.d.ts b/types/three/src/nodes/accessors/TextureNode.d.ts index e2ed0eb54dc838..faaf997f32fd47 100644 --- a/types/three/src/nodes/accessors/TextureNode.d.ts +++ b/types/three/src/nodes/accessors/TextureNode.d.ts @@ -44,6 +44,8 @@ interface TextureNodeInterface { gather(gatherNode?: Node<"int"> | number): this; + isSampleCompare(): boolean; + depth(depthNode: Node): this; offset(offsetNode: Node<"ivec2">): this; @@ -64,12 +66,21 @@ type TextureNode = TextureNodeInterface & UniformNode TextureNode; +export const texture: { + ( + value?: Texture | TextureNode, + uvNode?: Node | null, + levelNode?: Node | number | null, + biasNode?: Node | null, + ): TextureNode; + // eslint-disable-next-line @definitelytyped/no-unnecessary-generics + ( + value?: Texture | TextureNode, + uvNode?: Node | null, + levelNode?: Node | number | null, + biasNode?: Node | null, + ): TextureNode; +}; export const uniformTexture: ( value?: Texture, diff --git a/types/three/src/nodes/accessors/UniformArrayNode.d.ts b/types/three/src/nodes/accessors/UniformArrayNode.d.ts index cd1406ad75b2ec..1bf47f67a41a0c 100644 --- a/types/three/src/nodes/accessors/UniformArrayNode.d.ts +++ b/types/three/src/nodes/accessors/UniformArrayNode.d.ts @@ -13,6 +13,8 @@ interface UniformArrayNodeInterface { getPaddedType(): string; + updateBuffer(): void; + element: (indexNode: Node | number) => UniformArrayElementNode; } diff --git a/types/three/src/nodes/core/AttributeNode.d.ts b/types/three/src/nodes/core/AttributeNode.d.ts index c1da1a7ddf02c9..ee831da8f94587 100644 --- a/types/three/src/nodes/core/AttributeNode.d.ts +++ b/types/three/src/nodes/core/AttributeNode.d.ts @@ -8,14 +8,14 @@ interface AttributeNodeInterface { } declare const AttributeNode: { - new(attributeName: string, TNodeType?: string | null): AttributeNode; + new(attributeName: string, nodeType?: TNodeType | null): AttributeNode; }; type AttributeNode = Node & AttributeNodeInterface; export default AttributeNode; -export const attribute: ( +export const attribute: ( name: string, nodeType?: TNodeType | null, ) => AttributeNode; diff --git a/types/three/src/nodes/core/ContextNode.d.ts b/types/three/src/nodes/core/ContextNode.d.ts index 8d209fcafb4c3d..ed3fca03647c42 100644 --- a/types/three/src/nodes/core/ContextNode.d.ts +++ b/types/three/src/nodes/core/ContextNode.d.ts @@ -31,6 +31,13 @@ export function builtinShadowContext(shadowNode: Node, light: Light, node?: Node export function builtinAOContext(aoNode: Node, node?: Node | null): ContextNode; +/** + * TSL function for defining a built-in global illumination context for a given node. The AO node + * modulates the indirect lighting of the materials, the GI node is added to their irradiance + * without being modulated by the AO since it already accounts for occlusion. + */ +export function builtinGIContext(aoNode: Node, giNode: Node, node?: Node | null): ContextNode; + /** * @deprecated "label()" has been deprecated. Use "setName()" instead. */ @@ -52,5 +59,7 @@ declare module "./Node.js" { builtinShadowContext: (shadowNode: Node, light: Light) => ContextNode; builtinAOContext: (aoValue: Node) => ContextNode; + + builtinGIContext: (aoValue: Node, giValue: Node) => ContextNode; } } diff --git a/types/three/src/nodes/core/InspectorNode.d.ts b/types/three/src/nodes/core/InspectorNode.d.ts index f6b38084453cb1..5fbb9e27af550d 100644 --- a/types/three/src/nodes/core/InspectorNode.d.ts +++ b/types/three/src/nodes/core/InspectorNode.d.ts @@ -6,7 +6,7 @@ declare class InspectorNode extends Node { export default InspectorNode; -export function inspector(node: T, name?: string, callback?: (node: T) => Node): T; +export function inspect(node: T, name?: string, callback?: (node: T) => Node): T; declare module "./Node.js" { interface NodeElements { diff --git a/types/three/src/nodes/core/MRTNode.d.ts b/types/three/src/nodes/core/MRTNode.d.ts index d203c07ce1f79c..48c73f7367c9b8 100644 --- a/types/three/src/nodes/core/MRTNode.d.ts +++ b/types/three/src/nodes/core/MRTNode.d.ts @@ -1,4 +1,6 @@ +import { ColorRepresentation } from "../../math/Color.js"; import BlendMode from "../../renderers/common/BlendMode.js"; +import Color4 from "../../renderers/common/Color4.js"; import { Texture } from "../../textures/Texture.js"; import { Node } from "../Nodes.js"; import OutputStructNode from "./OutputStructNode.js"; @@ -10,6 +12,8 @@ declare class MRTNode extends OutputStructNode { blendModes: { [name: string]: BlendMode }; + clearColors: { [name: string]: Color4 }; + readonly isMRTNode: true; constructor(outputNodes: { [name: string]: Node }); @@ -18,6 +22,10 @@ declare class MRTNode extends OutputStructNode { getBlendMode(name: string): BlendMode; + setClearColor(name: string, color: ColorRepresentation, alpha?: number): this; + + getClearColor(name: string): Color4 | null; + has(name: string): boolean; get: (name: string) => Node; diff --git a/types/three/src/nodes/core/Node.d.ts b/types/three/src/nodes/core/Node.d.ts index d03d3c0f8eb0bf..216badc5820c3f 100644 --- a/types/three/src/nodes/core/Node.d.ts +++ b/types/three/src/nodes/core/Node.d.ts @@ -305,21 +305,24 @@ declare class NodeClass /** * Returns the update type of {@link Node#update}. * + * @param {NodeFrame} [frame] - The current node frame. * @return {NodeUpdateType} The update type. */ - getUpdateType(): NodeUpdateType; + getUpdateType(frame?: NodeFrame): NodeUpdateType; /** * Returns the update type of {@link Node#updateBefore}. * + * @param {NodeFrame} [frame] - The current node frame. * @return {NodeUpdateType} The update type. */ - getUpdateBeforeType(): NodeUpdateType; + getUpdateBeforeType(frame?: NodeFrame): NodeUpdateType; /** * Returns the update type of {@link Node#updateAfter}. * + * @param {NodeFrame} [frame] - The current node frame. * @return {NodeUpdateType} The update type. */ - getUpdateAfterType(): NodeUpdateType; + getUpdateAfterType(frame?: NodeFrame): NodeUpdateType; /** * Certain types are composed of multiple elements. For example a `vec3` * is composed of three `float` values. This method returns the type of diff --git a/types/three/src/nodes/core/NodeBuilder.d.ts b/types/three/src/nodes/core/NodeBuilder.d.ts index 9046d36ce790da..be1caf3f19478d 100644 --- a/types/three/src/nodes/core/NodeBuilder.d.ts +++ b/types/three/src/nodes/core/NodeBuilder.d.ts @@ -2,11 +2,24 @@ import { BufferGeometry } from "../../core/BufferGeometry.js"; import { Object3D } from "../../core/Object3D.js"; import { Material } from "../../materials/Material.js"; import Renderer from "../../renderers/common/Renderer.js"; +import RenderPipeline from "../../renderers/common/RenderPipeline.js"; +import ComputeNode from "../gpgpu/ComputeNode.js"; export default abstract class NodeBuilder { object: Object3D; material: Material; geometry: BufferGeometry; + + /** + * The compute node, if building for compute. + */ + compute: ComputeNode | null; + renderer: Renderer; context: unknown; + + /** + * A reference to the render pipeline. + */ + readonly renderPipeline: RenderPipeline; } diff --git a/types/three/src/nodes/core/NodeFrame.d.ts b/types/three/src/nodes/core/NodeFrame.d.ts index 45db8458da37f2..8b583a78f2a859 100644 --- a/types/three/src/nodes/core/NodeFrame.d.ts +++ b/types/three/src/nodes/core/NodeFrame.d.ts @@ -3,6 +3,7 @@ import { Object3D } from "../../core/Object3D.js"; import { Material } from "../../materials/Material.js"; import Renderer from "../../renderers/common/Renderer.js"; import { Scene } from "../../scenes/Scene.js"; +import ComputeNode from "../gpgpu/ComputeNode.js"; import Node from "./Node.js"; export default class NodeFrame { @@ -24,6 +25,7 @@ export default class NodeFrame { camera: Camera | null; object: Object3D | null; scene: Scene | null; + compute: ComputeNode | null; constructor(); diff --git a/types/three/src/nodes/core/PropertyNode.d.ts b/types/three/src/nodes/core/PropertyNode.d.ts index fbe7674a1f1df6..d50506ab635ad8 100644 --- a/types/three/src/nodes/core/PropertyNode.d.ts +++ b/types/three/src/nodes/core/PropertyNode.d.ts @@ -62,4 +62,5 @@ export const thickness: PropertyNode<"float">; export const attenuationDistance: PropertyNode<"float">; export const attenuationColor: PropertyNode<"color">; export const dispersion: PropertyNode<"float">; +export const retroreflectivity: PropertyNode<"float">; export const ambientOcclusion: PropertyNode<"float">; diff --git a/types/three/src/nodes/core/StructNode.d.ts b/types/three/src/nodes/core/StructNode.d.ts index 7173a8167458be..e936fd5c365f5e 100644 --- a/types/three/src/nodes/core/StructNode.d.ts +++ b/types/three/src/nodes/core/StructNode.d.ts @@ -1,3 +1,10 @@ +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 Node from "./Node.js"; import StructTypeNode, { MembersLayout } from "./StructTypeNode.js"; @@ -9,10 +16,22 @@ declare class StructNode extends Node { export default StructNode; +export type StructValue = + | Node + | number + | boolean + | Vector2 + | Vector3 + | Vector4 + | Matrix2 + | Matrix3 + | Matrix4 + | Color; + export interface Struct { (): StructNode; (values: Node[]): StructNode; - (...values: Node[]): StructNode; + (...values: StructValue[]): StructNode; } export const struct: (membersLayout: MembersLayout, name?: string | null) => Struct; diff --git a/types/three/src/nodes/core/UniformNode.d.ts b/types/three/src/nodes/core/UniformNode.d.ts index 86b9ce66e02169..20c7f713afdb6e 100644 --- a/types/three/src/nodes/core/UniformNode.d.ts +++ b/types/three/src/nodes/core/UniformNode.d.ts @@ -71,6 +71,14 @@ declare class UniformNodeClass extends InputNode { * @return {string} The uniform hash. */ getUniformHash(builder: NodeBuilder): string; + /** + * Uniform nodes with the same hash share a single uniform. This method returns the node + * the shared uniform refers to which is the first node registered for the hash. + * + * @param {NodeBuilder} builder - The current node builder. + * @return {UniformNode} The node the shared uniform refers to. + */ + getSharedNode(builder: NodeBuilder): UniformNode; onUpdate( callback: (this: this, frame: NodeFrame, self: this) => TValue | undefined, updateType: NodeUpdateType, diff --git a/types/three/src/nodes/display/PassNode.d.ts b/types/three/src/nodes/display/PassNode.d.ts index afa2c193fac4a8..f940b036ba6e11 100644 --- a/types/three/src/nodes/display/PassNode.d.ts +++ b/types/three/src/nodes/display/PassNode.d.ts @@ -4,6 +4,7 @@ import { Object3D } from "../../core/Object3D.js"; import { RenderTarget, RenderTargetOptions } from "../../core/RenderTarget.js"; import { Material } from "../../materials/Material.js"; import { Vector4 } from "../../math/Vector4.js"; +import Lighting from "../../renderers/common/Lighting.js"; import Renderer from "../../renderers/common/Renderer.js"; import { Texture } from "../../textures/Texture.js"; import TextureNode from "../accessors/TextureNode.js"; @@ -31,22 +32,36 @@ declare class PassMultipleTextureNode extends PassTextureNode { updateTexture(): void; } +export interface PassNodeOptions extends RenderTargetOptions { + autoClear?: boolean | undefined; // true + autoClearColor?: boolean | undefined; // true + autoClearDepth?: boolean | undefined; // true + autoClearStencil?: boolean | undefined; // true +} + declare class PassNode extends TempNode<"vec4"> { scope: PassNodeScope; scene: Object3D; camera: Camera; + options: PassNodeOptions; renderTarget: RenderTarget; overrideMaterial: Material | null; transparent: boolean; opaque: boolean; + lighting: Lighting | null; + + autoClear: boolean; + autoClearColor: boolean; + autoClearDepth: boolean; + autoClearStencil: boolean; contextNode: ContextNode | null; readonly isPassNode: true; - constructor(scope: PassNodeScope, scene: Object3D, camera: Camera, options?: RenderTargetOptions); + constructor(scope: PassNodeScope, scene: Object3D, camera: Camera, options?: PassNodeOptions); setResolutionScale(resolution: number): this; @@ -96,14 +111,14 @@ declare class PassNode extends TempNode<"vec4"> { dispose(): void; - static COLOR: "color"; - static DEPTH: "depth"; + static get COLOR(): "color"; + static get DEPTH(): "depth"; } export type PassNodeScope = typeof PassNode.COLOR | typeof PassNode.DEPTH; export default PassNode; -export const pass: (scene: Object3D, camera: Camera, options?: RenderTargetOptions) => PassNode; +export const pass: (scene: Object3D, camera: Camera, options?: PassNodeOptions) => PassNode; export const passTexture: (pass: PassNode, texture: Texture) => PassTextureNode; -export const depthPass: (scene: Object3D, camera: Camera, options?: RenderTargetOptions) => PassNode; +export const depthPass: (scene: Object3D, camera: Camera, options?: PassNodeOptions) => PassNode; diff --git a/types/three/src/nodes/display/ScreenNode.d.ts b/types/three/src/nodes/display/ScreenNode.d.ts index fd03907a1c53b3..8663d41ab0e9b9 100644 --- a/types/three/src/nodes/display/ScreenNode.d.ts +++ b/types/three/src/nodes/display/ScreenNode.d.ts @@ -1,11 +1,11 @@ import Node from "../core/Node.js"; +import UniformNode from "../core/UniformNode.js"; export type ScreenNodeScope = | typeof ScreenNode.COORDINATE | typeof ScreenNode.VIEWPORT | typeof ScreenNode.SIZE - | typeof ScreenNode.UV - | typeof ScreenNode.DPR; + | typeof ScreenNode.UV; interface ScreenNodeInterface { scope: ScreenNodeScope; @@ -18,13 +18,11 @@ declare const ScreenNode: { 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">; COORDINATE: "coordinate"; VIEWPORT: "viewport"; SIZE: "size"; UV: "uv"; - DPR: "dpr"; }; type ScreenNode = Node & ScreenNodeInterface; @@ -33,7 +31,7 @@ export default ScreenNode; // Screen -export const screenDPR: ScreenNode<"float">; +export const screenDPR: UniformNode<"float", number>; export const screenUV: ScreenNode<"vec2">; export const screenSize: ScreenNode<"vec2">; export const screenCoordinate: ScreenNode<"vec2">; @@ -44,10 +42,3 @@ 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: Node<"vec2">; diff --git a/types/three/src/nodes/functions/BSDF/BRDF_GGX.d.ts b/types/three/src/nodes/functions/BSDF/BRDF_GGX.d.ts index 1bcb4d1c37117b..757725f1085d99 100644 --- a/types/three/src/nodes/functions/BSDF/BRDF_GGX.d.ts +++ b/types/three/src/nodes/functions/BSDF/BRDF_GGX.d.ts @@ -7,6 +7,7 @@ declare const BRDF_GGX: (args: { f90: Node; roughness: Node; f?: Node | undefined; + viewDirection?: Node | undefined; USE_IRIDESCENCE?: Node | undefined; USE_ANISOTROPY?: Node | undefined; }) => OperatorNode; diff --git a/types/three/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.d.ts b/types/three/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.d.ts deleted file mode 100644 index 76955c74cd9ecc..00000000000000 --- a/types/three/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import Node from "../../core/Node.js"; -import OperatorNode from "../../math/OperatorNode.js"; - -declare const BRDF_GGX_Multiscatter: (args: { - lightDirection: Node; - f0: Node; - f90: Node; - roughness: Node; - f?: Node | undefined; - USE_IRIDESCENCE?: Node | undefined; - USE_ANISOTROPY?: Node | undefined; -}) => OperatorNode; - -export default BRDF_GGX_Multiscatter; diff --git a/types/three/src/nodes/functions/BSDF/DFGLUT.d.ts b/types/three/src/nodes/functions/BSDF/DFGLUT.d.ts index c06fb8ce1e351b..98dab2927daeda 100644 --- a/types/three/src/nodes/functions/BSDF/DFGLUT.d.ts +++ b/types/three/src/nodes/functions/BSDF/DFGLUT.d.ts @@ -2,7 +2,8 @@ import Node from "../../core/Node.js"; import OperatorNode from "../../math/OperatorNode.js"; /** - * Precomputed DFG LUT for Image-Based Lighting + * Precomputed DFG LUT for physically based specular lighting, used by both + * image-based lighting and direct-light multi-scattering energy compensation * Resolution: 16x16 * Samples: 4096 per texel * Format: RG16F (2 half floats per texel: scale, bias) diff --git a/types/three/src/nodes/functions/BSDF/EnvironmentBRDF.d.ts b/types/three/src/nodes/functions/BSDF/EnvironmentBRDF.d.ts new file mode 100644 index 00000000000000..12e0ffe56b30df --- /dev/null +++ b/types/three/src/nodes/functions/BSDF/EnvironmentBRDF.d.ts @@ -0,0 +1,8 @@ +import Node from "../../core/Node.js"; +import OperatorNode from "../../math/OperatorNode.js"; + +declare const EnvironmentBRDF: ( + args: { dotNV: Node; specularColor: Node; specularF90: Node; roughness: Node }, +) => OperatorNode; + +export default EnvironmentBRDF; diff --git a/types/three/src/nodes/functions/PhysicalLightingModel.d.ts b/types/three/src/nodes/functions/PhysicalLightingModel.d.ts index d2894c668b2978..21038ae38cf7ee 100644 --- a/types/three/src/nodes/functions/PhysicalLightingModel.d.ts +++ b/types/three/src/nodes/functions/PhysicalLightingModel.d.ts @@ -8,6 +8,7 @@ export default class PhysicalLightingModel extends LightingModel { anisotropy: boolean; transmission: boolean; dispersion: boolean; + retroreflection: boolean; clearcoatRadiance: Node | null; clearcoatSpecularDirect: Node | null; @@ -15,9 +16,10 @@ export default class PhysicalLightingModel extends LightingModel { sheenSpecularDirect: Node | null; sheenSpecularIndirect: Node | null; iridescenceFresnel: Node | null; - iridescenceF0: Node | null; iridescenceF0Dielectric: Node | null; iridescenceF0Metallic: Node | null; + dfg: Node | null; + multiScatteringCompensation: Node | null; constructor( clearcoat?: boolean, @@ -26,6 +28,7 @@ export default class PhysicalLightingModel extends LightingModel { anisotropy?: boolean, transmission?: boolean, dispersion?: boolean, + retroreflection?: boolean, ); computeMultiscattering( diff --git a/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts b/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts index 17fab186050257..48fea137de56f7 100644 --- a/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +++ b/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts @@ -25,15 +25,15 @@ declare const AtomicFunctionNode: { valueNode: Node | null, ): AtomicFunctionNode; - ATOMIC_LOAD: "atomicLoad"; - ATOMIC_STORE: "atomicStore"; - ATOMIC_ADD: "atomicAdd"; - ATOMIC_SUB: "atomicSub"; - ATOMIC_MAX: "atomicMax"; - ATOMIC_MIN: "atomicMin"; - ATOMIC_AND: "atomicAnd"; - ATOMIC_OR: "atomicOr"; - ATOMIC_XOR: "atomicXor"; + readonly ATOMIC_LOAD: "atomicLoad"; + readonly ATOMIC_STORE: "atomicStore"; + readonly ATOMIC_ADD: "atomicAdd"; + readonly ATOMIC_SUB: "atomicSub"; + readonly ATOMIC_MAX: "atomicMax"; + readonly ATOMIC_MIN: "atomicMin"; + readonly ATOMIC_AND: "atomicAnd"; + readonly ATOMIC_OR: "atomicOr"; + readonly ATOMIC_XOR: "atomicXor"; }; export type AtomicFunctionNode = Node & AtomicFunctionNodeInterface; diff --git a/types/three/src/nodes/gpgpu/SubgroupFunctionNode.d.ts b/types/three/src/nodes/gpgpu/SubgroupFunctionNode.d.ts index f4eee26639bb2d..c77c5cc3ebb64c 100644 --- a/types/three/src/nodes/gpgpu/SubgroupFunctionNode.d.ts +++ b/types/three/src/nodes/gpgpu/SubgroupFunctionNode.d.ts @@ -7,7 +7,7 @@ export type SubgroupFunctionNodeMethod1 = | typeof SubgroupFunctionNode.SUBGROUP_BALLOT | typeof SubgroupFunctionNode.SUBGROUP_ADD | typeof SubgroupFunctionNode.SUBGROUP_INCLUSIVE_ADD - | typeof SubgroupFunctionNode.SUBGROUP_EXCLUSIVE_AND + | typeof SubgroupFunctionNode.SUBGROUP_EXCLUSIVE_ADD | typeof SubgroupFunctionNode.SUBGROUP_MUL | typeof SubgroupFunctionNode.SUBGROUP_INCLUSIVE_MUL | typeof SubgroupFunctionNode.SUBGROUP_EXCLUSIVE_MUL @@ -37,35 +37,35 @@ declare class SubgroupFunctionNode extends TempNode { constructor(method: SubgroupFunctionNodeMethod2, aNode: Node, bNode: Node); // 0 inputs - static SUBGROUP_ELECT: "subgroupElect"; + static get SUBGROUP_ELECT(): "subgroupElect"; // 1 input - static SUBGROUP_BALLOT: "subgroupBallot"; - static SUBGROUP_ADD: "subgroupAdd"; - static SUBGROUP_INCLUSIVE_ADD: "subgroupInclusiveAdd"; - static SUBGROUP_EXCLUSIVE_AND: "subgroupExclusiveAdd"; - static SUBGROUP_MUL: "subgroupMul"; - static SUBGROUP_INCLUSIVE_MUL: "subgroupInclusiveMul"; - static SUBGROUP_EXCLUSIVE_MUL: "subgroupExclusiveMul"; - static SUBGROUP_AND: "subgroupAnd"; - static SUBGROUP_OR: "subgroupOr"; - static SUBGROUP_XOR: "subgroupXor"; - static SUBGROUP_MIN: "subgroupMin"; - static SUBGROUP_MAX: "subgroupMax"; - static SUBGROUP_ALL: "subgroupAll"; - static SUBGROUP_ANY: "subgroupAny"; - static SUBGROUP_BROADCAST_FIRST: "subgroupBroadcastFirst"; - static QUAD_SWAP_X: "quadSwapX"; - static QUAD_SWAP_Y: "quadSwapY"; - static QUAD_SWAP_DIAGONAL: "quadSwapDiagonal"; + static get SUBGROUP_BALLOT(): "subgroupBallot"; + static get SUBGROUP_ADD(): "subgroupAdd"; + static get SUBGROUP_INCLUSIVE_ADD(): "subgroupInclusiveAdd"; + static get SUBGROUP_EXCLUSIVE_ADD(): "subgroupExclusiveAdd"; + static get SUBGROUP_MUL(): "subgroupMul"; + static get SUBGROUP_INCLUSIVE_MUL(): "subgroupInclusiveMul"; + static get SUBGROUP_EXCLUSIVE_MUL(): "subgroupExclusiveMul"; + static get SUBGROUP_AND(): "subgroupAnd"; + static get SUBGROUP_OR(): "subgroupOr"; + static get SUBGROUP_XOR(): "subgroupXor"; + static get SUBGROUP_MIN(): "subgroupMin"; + static get SUBGROUP_MAX(): "subgroupMax"; + static get SUBGROUP_ALL(): "subgroupAll"; + static get SUBGROUP_ANY(): "subgroupAny"; + static get SUBGROUP_BROADCAST_FIRST(): "subgroupBroadcastFirst"; + static get QUAD_SWAP_X(): "quadSwapX"; + static get QUAD_SWAP_Y(): "quadSwapY"; + static get QUAD_SWAP_DIAGONAL(): "quadSwapDiagonal"; // 2 inputs - static SUBGROUP_BROADCAST: "subgroupBroadcast"; - static SUBGROUP_SHUFFLE: "subgroupShuffle"; - static SUBGROUP_SHUFFLE_XOR: "subgroupShuffleXor"; - static SUBGROUP_SHUFFLE_UP: "subgroupShuffleUp"; - static SUBGROUP_SHUFFLE_DOWN: "subgroupShuffleDown"; - static QUAD_BROADCAST: "quadBroadcast"; + static get SUBGROUP_BROADCAST(): "subgroupBroadcast"; + static get SUBGROUP_SHUFFLE(): "subgroupShuffle"; + static get SUBGROUP_SHUFFLE_XOR(): "subgroupShuffleXor"; + static get SUBGROUP_SHUFFLE_UP(): "subgroupShuffleUp"; + static get SUBGROUP_SHUFFLE_DOWN(): "subgroupShuffleDown"; + static get QUAD_BROADCAST(): "quadBroadcast"; } export default SubgroupFunctionNode; @@ -84,9 +84,9 @@ export const subgroupOr: (e: Node) => Node; export const subgroupXor: (e: Node) => Node; export const subgroupMin: (e: Node) => Node; export const subgroupMax: (e: Node) => Node; -export const subgroupAll: () => Node; -export const subgroupAny: () => Node; -export const subgroupBroadcastFirst: (e: Node, id: Node) => Node; +export const subgroupAll: (e: Node) => Node; +export const subgroupAny: (e: Node) => Node; +export const subgroupBroadcastFirst: (e: Node) => Node; export const quadSwapX: (e: Node) => Node; export const quadSwapY: (e: Node) => Node; export const quadSwapDiagonal: (e: Node) => Node; diff --git a/types/three/src/nodes/gpgpu/WorkgroupInfoNode.d.ts b/types/three/src/nodes/gpgpu/WorkgroupInfoNode.d.ts index ccd2de83e5371c..67bfa821589764 100644 --- a/types/three/src/nodes/gpgpu/WorkgroupInfoNode.d.ts +++ b/types/three/src/nodes/gpgpu/WorkgroupInfoNode.d.ts @@ -4,6 +4,8 @@ declare class WorkgroupInfoNode extends Node { bufferType: string; bufferCount: number; + isAtomic: boolean; + readonly isWorkgroupInfoNode: true; elementType: string; @@ -11,6 +13,10 @@ declare class WorkgroupInfoNode extends Node { scope: string; constructor(scope: string, bufferType: string, bufferCount?: number); + + setAtomic(value: boolean): this; + + toAtomic(): this; } export default WorkgroupInfoNode; diff --git a/types/three/src/nodes/lighting/LightsNode.d.ts b/types/three/src/nodes/lighting/LightsNode.d.ts index 02da38c8f69722..fa95966897e045 100644 --- a/types/three/src/nodes/lighting/LightsNode.d.ts +++ b/types/three/src/nodes/lighting/LightsNode.d.ts @@ -38,6 +38,8 @@ declare class LightsNode extends Node { getLights(): Light[]; + getBuiltinLights(): Light[]; + get hasLights(): boolean; } diff --git a/types/three/src/nodes/lighting/ShadowBaseNode.d.ts b/types/three/src/nodes/lighting/ShadowBaseNode.d.ts index bb2f2b1d66cd9c..95dc6305e0f246 100644 --- a/types/three/src/nodes/lighting/ShadowBaseNode.d.ts +++ b/types/three/src/nodes/lighting/ShadowBaseNode.d.ts @@ -1,6 +1,17 @@ +import { Camera } from "../../cameras/Camera.js"; +import { BufferGeometry } from "../../core/BufferGeometry.js"; +import { Object3D } from "../../core/Object3D.js"; import { Light } from "../../lights/Light.js"; +import { LightShadow } from "../../lights/LightShadow.js"; +import { Material } from "../../materials/Material.js"; +import NodeMaterial from "../../materials/nodes/NodeMaterial.js"; +import { Group } from "../../objects/Group.js"; +import ClippingContext from "../../renderers/common/ClippingContext.js"; +import Renderer from "../../renderers/common/Renderer.js"; +import { Scene } from "../../scenes/Scene.js"; import Node from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; +import LightsNode from "./LightsNode.js"; declare class ShadowBaseNode extends Node { light: Light; @@ -9,6 +20,25 @@ declare class ShadowBaseNode extends Node { constructor(light: Light); + getShadowMaterial(): NodeMaterial; + + disposeShadowMaterial(): void; + + getShadowRenderObjectFunction( + renderer: Renderer, + shadow?: LightShadow, + ): ( + object: Object3D, + scene: Scene, + _camera: Camera, + geometry: BufferGeometry, + material: Material, + group: Group, + lightsNode: LightsNode, + clippingContext?: ClippingContext | null, + passId?: string | null, + ) => void; + setupShadowPosition(builder: NodeBuilder): void; } diff --git a/types/three/src/nodes/lighting/ShadowFilterNode.d.ts b/types/three/src/nodes/lighting/ShadowFilterNode.d.ts index 2f2d802f796888..1dcaa14fda27e2 100644 --- a/types/three/src/nodes/lighting/ShadowFilterNode.d.ts +++ b/types/three/src/nodes/lighting/ShadowFilterNode.d.ts @@ -1,5 +1,3 @@ -import { Light } from "../../lights/Light.js"; -import NodeMaterial from "../../materials/nodes/NodeMaterial.js"; import Node from "../core/Node.js"; export const BasicShadowFilter: ( @@ -13,17 +11,7 @@ export const PCFShadowFilter: ( shadow: Node, ) => Node; -export const PCFSoftShadowFilter: ( - depthTexture: Node, - shadowCoord: Node, - shadow: Node, -) => Node; - export const VSMShadowFilter: ( depthTexture: Node, shadowCoord: Node, ) => Node; - -export const getShadowMaterial: (light: Light) => NodeMaterial; - -export const disposeShadowMaterial: (light: Light) => void; diff --git a/types/three/src/nodes/lighting/ShadowNode.d.ts b/types/three/src/nodes/lighting/ShadowNode.d.ts index de744ea5e3a6e9..7259fa9241780e 100644 --- a/types/three/src/nodes/lighting/ShadowNode.d.ts +++ b/types/three/src/nodes/lighting/ShadowNode.d.ts @@ -1,33 +1,7 @@ -import { Camera } from "../../cameras/Camera.js"; -import { BufferGeometry } from "../../core/BufferGeometry.js"; -import { Object3D } from "../../core/Object3D.js"; import { Light } from "../../lights/Light.js"; import { LightShadow } from "../../lights/LightShadow.js"; -import { Material } from "../../materials/Material.js"; -import { Group } from "../../objects/Group.js"; -import ClippingContext from "../../renderers/common/ClippingContext.js"; -import Renderer from "../../renderers/common/Renderer.js"; -import { Scene } from "../../scenes/Scene.js"; -import LightsNode from "./LightsNode.js"; import ShadowBaseNode from "./ShadowBaseNode.js"; -export const getShadowRenderObjectFunction: ( - renderer: Renderer, - shadow: LightShadow, - shadowType: number, - useVelocity: boolean, -) => ( - object: Object3D, - scene: Scene, - _camera: Camera, - geometry: BufferGeometry, - material: Material, - group: Group, - lightsNode: LightsNode, - clippingContext?: ClippingContext | null, - passId?: string | null, -) => void; - declare class ShadowNode extends ShadowBaseNode { constructor(light: Light, shadow: LightShadow | null); } diff --git a/types/three/src/nodes/materialx/lib/mx_hsv.d.ts b/types/three/src/nodes/materialx/MaterialXColor.d.ts similarity index 72% rename from types/three/src/nodes/materialx/lib/mx_hsv.d.ts rename to types/three/src/nodes/materialx/MaterialXColor.d.ts index 1be021162de7cf..95814d9d2aa661 100644 --- a/types/three/src/nodes/materialx/lib/mx_hsv.d.ts +++ b/types/three/src/nodes/materialx/MaterialXColor.d.ts @@ -1,4 +1,4 @@ -import Node from "../../core/Node.js"; +import Node from "../core/Node.js"; export const mx_hsvtorgb: (hsv: Node) => Node; diff --git a/types/three/src/nodes/materialx/lib/mx_transform_color.d.ts b/types/three/src/nodes/materialx/MaterialXColorTransform.d.ts similarity index 66% rename from types/three/src/nodes/materialx/lib/mx_transform_color.d.ts rename to types/three/src/nodes/materialx/MaterialXColorTransform.d.ts index 1ae9a26e334817..126abe31896c5a 100644 --- a/types/three/src/nodes/materialx/lib/mx_transform_color.d.ts +++ b/types/three/src/nodes/materialx/MaterialXColorTransform.d.ts @@ -1,3 +1,3 @@ -import Node from "../../core/Node.js"; +import Node from "../core/Node.js"; export const mx_srgb_texture_to_lin_rec709: (color_immutable: Node) => Node; diff --git a/types/three/src/nodes/materialx/MaterialXCore.d.ts b/types/three/src/nodes/materialx/MaterialXCore.d.ts new file mode 100644 index 00000000000000..b797f765a0ed4f --- /dev/null +++ b/types/three/src/nodes/materialx/MaterialXCore.d.ts @@ -0,0 +1,5 @@ +import Node from "../core/Node.js"; + +export const mx_rotate2d: (input: Node, amount?: Node | number) => Node; + +export const mx_rotate3d: (input: Node, amount?: Node | number, axis?: Node) => Node; diff --git a/types/three/src/nodes/materialx/MaterialXNodes.d.ts b/types/three/src/nodes/materialx/MaterialXNodes.d.ts index a55c8f0430fb80..cfa221a5b9e51e 100644 --- a/types/three/src/nodes/materialx/MaterialXNodes.d.ts +++ b/types/three/src/nodes/materialx/MaterialXNodes.d.ts @@ -1,7 +1,8 @@ import Node from "../core/Node.js"; import MathNode from "../math/MathNode.js"; -import { mx_hsvtorgb, mx_rgbtohsv } from "./lib/mx_hsv.js"; -import { mx_srgb_texture_to_lin_rec709 } from "./lib/mx_transform_color.js"; +import { mx_hsvtorgb, mx_rgbtohsv } from "./MaterialXColor.js"; +import { mx_srgb_texture_to_lin_rec709 } from "./MaterialXColorTransform.js"; +import { mx_rotate2d, mx_rotate3d } from "./MaterialXCore.js"; export const mx_aastep: (threshold: Node | number, value: Node | number) => MathNode; @@ -11,8 +12,8 @@ export const mx_ramplr: ( texcoord?: Node, ) => MathNode; export const mx_ramptb: ( - valuet: Node | number, valueb: Node | number, + valuet: Node | number, texcoord?: Node, ) => MathNode; @@ -31,8 +32,8 @@ export const mx_splitlr: ( texcoord?: Node, ) => MathNode; export const mx_splittb: ( - valuet: Node | number, valueb: Node | number, + valuet: Node | number, center: Node | number, texcoord?: Node, ) => MathNode; @@ -67,6 +68,25 @@ export const mx_noise_vec4: ( pivot?: Node | number, ) => Node<"vec4">; +export const mx_smoothstep: ( + inNode: Node | number, + low?: Node | number, + high?: Node | number, +) => MathNode; + +export function mx_cell_noise_vec3(texcoord?: Node): Node<"vec3">; + +export function mx_worley_noise_float_2d( + texcoord?: Node, + jitter?: Node | number, + style?: Node | number, +): Node<"float">; +export function mx_worley_noise_float_3d( + texcoord?: Node, + jitter?: Node | number, + style?: Node | number, +): Node<"float">; + export const mx_unifiednoise2d: ( noiseType: Node, texcoord?: Node, @@ -79,7 +99,8 @@ export const mx_unifiednoise2d: ( octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, -) => Node; + style?: Node | number, +) => Node<"float">; export const mx_unifiednoise3d: ( noiseType: Node, texcoord?: Node, @@ -92,11 +113,13 @@ export const mx_unifiednoise3d: ( octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, -) => Node; + style?: Node | number, +) => Node<"float">; export function mx_worley_noise_float( texcoord?: Node, jitter?: Node | number, + style?: Node | number, ): Node<"float">; export function mx_worley_noise_vec2( texcoord?: Node, @@ -105,10 +128,24 @@ export function mx_worley_noise_vec2( export function mx_worley_noise_vec3( texcoord?: Node, jitter?: Node | number, + metric?: Node | number, +): Node<"vec3">; +export function mx_worley_noise_vec3_style( + texcoord?: Node, + jitter?: Node | number, + style?: Node | number, + metric?: Node | number, ): Node<"vec3">; export function mx_cell_noise_float(texcoord?: Node): Node<"float">; +export function mx_fractal_noise_float_2d( + texcoord?: Node, + octaves?: Node | number, + lacunarity?: Node | number, + diminish?: Node | number, + amplitude?: Node | number, +): Node<"float">; export function mx_fractal_noise_float( position?: Node, octaves?: Node | number, @@ -138,6 +175,7 @@ export function mx_fractal_noise_vec4( amplitude?: Node | number, ): Node<"vec4">; +export { mx_rotate2d, mx_rotate3d }; export { mx_hsvtorgb, mx_rgbtohsv, mx_srgb_texture_to_lin_rec709 }; export const mx_add: (in1: Node, in2?: Node) => Node; @@ -162,10 +200,7 @@ export const mx_place2d: ( scale?: Node, rotate?: Node, offset?: Node, + operationorder?: Node | number, ) => Node; -export const mx_rotate2d: (input: Node, amount: Node) => Node; - -export const mx_rotate3d: (input: Node, amount: Node, axis: Node) => Node; - -export const mx_heighttonormal: (input: Node, scale: Node) => Node; +export const mx_heighttonormal: (input: Node, scale?: Node | number, texcoord?: Node) => Node; diff --git a/types/three/src/nodes/materialx/lib/mx_noise.d.ts b/types/three/src/nodes/materialx/MaterialXNoise.d.ts similarity index 86% rename from types/three/src/nodes/materialx/lib/mx_noise.d.ts rename to types/three/src/nodes/materialx/MaterialXNoise.d.ts index 309908a2d3cb1f..aec9cd8b0acf78 100644 --- a/types/three/src/nodes/materialx/lib/mx_noise.d.ts +++ b/types/three/src/nodes/materialx/MaterialXNoise.d.ts @@ -1,4 +1,4 @@ -import Node from "../../core/Node.js"; +import Node from "../core/Node.js"; export const mx_select: ( b_immutable: Node | boolean, @@ -233,12 +233,19 @@ export const mx_cell_noise_vec3_0: (p_immutable: Node) => Node; export const mx_cell_noise_vec3_1: (p_immutable: Node) => Node; -export const mx_cell_noise_vec3_2: (p_immutable: Node) => Node; +export const mx_cell_noise_vec3_2: (positionInput: Node) => Node; export const mx_cell_noise_vec3_3: (p_immutable: Node) => Node; export const mx_cell_noise_vec3: (p_immutable: Node) => Node; +export const mx_fractal_noise_float_2d: ( + p_immutable: Node, + octaves_immutable: Node | number, + lacunarity_immutable: Node | number, + diminish_immutable: Node | number, +) => Node; + export const mx_fractal_noise_float: ( p_immutable: Node, octaves_immutable: Node | number, @@ -302,84 +309,107 @@ export const mx_worley_distance: ( metric_immutable?: Node | number, ) => Node; -export const mx_worley_noise_float_0: ( +export const mx_worley_noise_float_3d: ( + positionInput: Node, + jitterInput: Node | number, + styleInput: Node | number, +) => Node; + +export const mx_worley_noise_float_2d: ( + texcoordInput: Node, + jitterInput: Node | number, + styleInput: Node | number, +) => Node; + +export const mx_worley_noise_float: ( + positionInput: Node, + jitterInput: Node | number, + styleInput: Node | number, +) => Node; + +export const mx_worley_noise_vec2_0: ( p_immutable: Node, jitter_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_vec2_0: ( +export const mx_worley_noise_vec3_0: ( p_immutable: Node, jitter_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_vec3_0: ( +export const mx_worley_noise_vec2_1: ( p_immutable: Node, jitter_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_float_1: ( +export const mx_worley_noise_vec2: ( p_immutable: Node, jitter_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_float: ( +export const mx_worley_noise_vec3_1: ( p_immutable: Node, jitter_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_vec2_1: ( +export const mx_worley_noise_vec3: ( p_immutable: Node, jitter_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_vec2: ( +export const mx_worley_noise_vec3_style_0: ( p_immutable: Node, jitter_immutable: Node | number, + style_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_vec3_1: ( +export const mx_worley_noise_vec3_style_1: ( p_immutable: Node, jitter_immutable: Node | number, + style_immutable: Node | number, metric_immutable: Node | number, ) => Node; -export const mx_worley_noise_vec3: ( +export const mx_worley_noise_vec3_style: ( p_immutable: Node, jitter_immutable: Node | number, + style_immutable: Node | number, metric_immutable: Node | number, ) => Node; export const mx_unifiednoise2d: ( - noiseType_immutable: Node, - texcoord_immutable: Node, - freq_immutable: Node, - offset_immutable: Node, - jitter_immutable: Node, - outmin_immutable: Node, - outmax_immutable: Node, - clampoutput_immutable: Node, - octaves_immutable: Node, - lacunarity_immutable: Node, - diminish_immutable: Node, + noiseTypeInput: Node, + texcoordInput: Node, + freqInput: Node, + offsetInput: Node, + jitterInput: Node, + outminInput: Node, + outmaxInput: Node, + clampoutputInput: Node, + octavesInput: Node, + lacunarityInput: Node, + diminishInput: Node, + styleInput: Node, ) => Node; export const mx_unifiednoise3d: ( - noiseType_immutable: Node, - position_immutable: Node, - freq_immutable: Node, - offset_immutable: Node, - jitter_immutable: Node, - outmin_immutable: Node, - outmax_immutable: Node, - clampoutput_immutable: Node, - octaves_immutable: Node, - lacunarity_immutable: Node, - diminish_immutable: Node, + noiseTypeInput: Node, + positionInput: Node, + freqInput: Node, + offsetInput: Node, + jitterInput: Node, + outminInput: Node, + outmaxInput: Node, + clampoutputInput: Node, + octavesInput: Node, + lacunarityInput: Node, + diminishInput: Node, + styleInput: Node, ) => Node; diff --git a/types/three/src/nodes/math/BitcountNode.d.ts b/types/three/src/nodes/math/BitcountNode.d.ts index 59d9b0e6d443a2..3fbd85500a4800 100644 --- a/types/three/src/nodes/math/BitcountNode.d.ts +++ b/types/three/src/nodes/math/BitcountNode.d.ts @@ -11,9 +11,9 @@ declare class BitcountNode extends MathNode { constructor(method: BitcountNodeMethod, aNode: Node); - static COUNT_TRAILING_ZEROS: "countTrailingZeros"; - static COUNT_LEADING_ZEROS: "countLeadingZeros"; - static COUNT_ONE_BITS: "countOneBits"; + static get COUNT_TRAILING_ZEROS(): "countTrailingZeros"; + static get COUNT_LEADING_ZEROS(): "countLeadingZeros"; + static get COUNT_ONE_BITS(): "countOneBits"; } export default BitcountNode; diff --git a/types/three/src/nodes/math/MathNode.d.ts b/types/three/src/nodes/math/MathNode.d.ts index cdfa2ff736b655..6ebae708765b4c 100644 --- a/types/three/src/nodes/math/MathNode.d.ts +++ b/types/three/src/nodes/math/MathNode.d.ts @@ -686,9 +686,9 @@ declare module "../core/Node.js" { interface Mix { (a: FloatOrNumber, b: FloatOrNumber, t: FloatOrNumber): Node<"float">; - (a: Vec2OrFloat, b: Vec2OrFloat, t: FloatOrNumber): Node<"vec2">; - (a: Vec3OrFloat, b: Vec3OrFloat, t: FloatOrNumber): Node<"vec3">; - (a: Vec4OrFloat | Vec3, b: Vec4OrFloat | Vec3, t: FloatOrNumber): Node<"vec4">; + (a: Vec2OrFloat, b: Vec2OrFloat, t: Vec2OrFloat): Node<"vec2">; + (a: Vec3OrFloat, b: Vec3OrFloat, t: Vec3OrFloat): Node<"vec3">; + (a: Vec4OrFloat | Vec3, b: Vec4OrFloat | Vec3, t: Vec4OrFloat | Vec3): Node<"vec4">; } export const mix: Mix; diff --git a/types/three/src/nodes/math/OperatorNode.d.ts b/types/three/src/nodes/math/OperatorNode.d.ts index e2603058791fe5..b15b69d536e916 100644 --- a/types/three/src/nodes/math/OperatorNode.d.ts +++ b/types/three/src/nodes/math/OperatorNode.d.ts @@ -329,37 +329,21 @@ interface Mul interface MulNumExtension extends AddSubMulDivNumberVecNumExtensions, MulMatNumNumExtensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec3">; -} - -interface AddVec2Extensions extends AddSubMulDivNumberVecVec2Extensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec3">; -} - -interface AddVec3Extensions extends AddSubMulDivNumberVecVec3Extensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec3">; -} - -interface AddVec4Extensions extends AddSubMulDivNumberVecVec4Extensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec4">; } interface MulVec2Extensions extends AddSubMulDivNumberVecVec2Extensions, MulVecMatVecExtensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec3">; } interface MulVec3Extensions extends AddSubMulDivNumberVecVec3Extensions, MulVecMatVecExtensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec3">; } interface MulVec4Extensions extends AddSubMulDivNumberVecVec4Extensions, MulVecMatVecExtensions { - (b: TNum extends "float" ? Node<"color"> : never): Node<"vec4">; } interface MulMat2Extensions extends AddSubMulMat2Extensions, MulMatNumMat2Extensions, MulVecMatMat2Extensions { @@ -387,6 +371,10 @@ interface Div extends AddSubMulDivNumberVec<"float">, AddSubMulDivNumberVec<"int export const div: Div; declare module "../core/Node.js" { + interface FloatExtensions { + mul: (b: Node<"color">) => Node<"vec3">; + } + interface NumExtensions { add: AddSubMulDivNumberVecNumExtensions; sub: AddSubMulDivNumberVecNumExtensions; @@ -399,6 +387,21 @@ declare module "../core/Node.js" { 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">; @@ -407,7 +410,7 @@ declare module "../core/Node.js" { } interface NumVec2Extensions { - add: AddVec2Extensions; + add: AddSubMulDivNumberVecVec2Extensions; sub: AddSubMulDivNumberVecVec2Extensions; mul: MulVec2Extensions; div: AddSubMulDivNumberVecVec2Extensions; @@ -419,7 +422,7 @@ declare module "../core/Node.js" { } interface NumVec3Extensions { - add: AddVec3Extensions; + add: AddSubMulDivNumberVecVec3Extensions; sub: AddSubMulDivNumberVecVec3Extensions; mul: MulVec3Extensions; div: AddSubMulDivNumberVecVec3Extensions; @@ -431,7 +434,7 @@ declare module "../core/Node.js" { } interface NumVec4Extensions { - add: AddVec4Extensions; + add: AddSubMulDivNumberVecVec4Extensions; sub: AddSubMulDivNumberVecVec4Extensions; mul: MulVec4Extensions; div: AddSubMulDivNumberVecVec4Extensions; diff --git a/types/three/src/nodes/math/PackFloatNode.d.ts b/types/three/src/nodes/math/PackFloatNode.d.ts index 9c0c0094214aa8..ca1d2cc42e7074 100644 --- a/types/three/src/nodes/math/PackFloatNode.d.ts +++ b/types/three/src/nodes/math/PackFloatNode.d.ts @@ -3,9 +3,12 @@ import TempNode from "../core/TempNode.js"; export type PackFloatNodeEncoding = "snorm" | "unorm" | "float16"; +export type PackFloatNodeLayout = "2x16" | "4x8"; + declare class PackFloatNode extends TempNode { vectorNode: Node; encoding: PackFloatNodeEncoding; + layout: PackFloatNodeLayout; readonly isPackFloatNode: true; @@ -17,3 +20,5 @@ export default PackFloatNode; export const packSnorm2x16: (value: Node) => PackFloatNode; export const packUnorm2x16: (value: Node) => PackFloatNode; export const packHalf2x16: (value: Node) => PackFloatNode; +export const packSnorm4x8: (value: Node) => PackFloatNode; +export const packUnorm4x8: (value: Node) => PackFloatNode; diff --git a/types/three/src/nodes/math/Packed4x8IntegerNode.d.ts b/types/three/src/nodes/math/Packed4x8IntegerNode.d.ts new file mode 100644 index 00000000000000..b7ad0923fdfcd7 --- /dev/null +++ b/types/three/src/nodes/math/Packed4x8IntegerNode.d.ts @@ -0,0 +1,49 @@ +import Node from "../core/Node.js"; +import TempNode from "../core/TempNode.js"; + +export type Packed4x8IntegerNodeMethod1 = + | typeof Packed4x8IntegerNode.PACK4X_I8 + | typeof Packed4x8IntegerNode.PACK4X_U8 + | typeof Packed4x8IntegerNode.PACK4X_I8_CLAMP + | typeof Packed4x8IntegerNode.PACK4X_U8_CLAMP + | typeof Packed4x8IntegerNode.UNPACK4X_I8 + | typeof Packed4x8IntegerNode.UNPACK4X_U8; + +export type Packed4x8IntegerNodeMethod2 = + | typeof Packed4x8IntegerNode.DOT4_U8_PACKED + | typeof Packed4x8IntegerNode.DOT4_I8_PACKED; + +declare class Packed4x8IntegerNode extends TempNode { + method: string; + aNode: Node; + bNode: Node | null; + + readonly isPacked4x8IntegerNode: true; + + constructor(method: Packed4x8IntegerNodeMethod1, aNode: Node, bNode?: null); + constructor(method: Packed4x8IntegerNodeMethod2, aNode: Node, bNode: Node); + + // 1 input + static get PACK4X_I8(): "pack4xI8"; + static get PACK4X_U8(): "pack4xU8"; + static get PACK4X_I8_CLAMP(): "pack4xI8Clamp"; + static get PACK4X_U8_CLAMP(): "pack4xU8Clamp"; + static get UNPACK4X_I8(): "unpack4xI8"; + static get UNPACK4X_U8(): "unpack4xU8"; + + // 2 inputs + static get DOT4_U8_PACKED(): "dot4U8Packed"; + static get DOT4_I8_PACKED(): "dot4I8Packed"; +} + +export default Packed4x8IntegerNode; + +export const pack4xI8: (value: Node) => Packed4x8IntegerNode; +export const pack4xU8: (value: Node) => Packed4x8IntegerNode; +export const pack4xI8Clamp: (value: Node) => Packed4x8IntegerNode; +export const pack4xU8Clamp: (value: Node) => Packed4x8IntegerNode; +export const unpack4xI8: (value: Node) => Packed4x8IntegerNode; +export const unpack4xU8: (value: Node) => Packed4x8IntegerNode; + +export const dot4U8Packed: (a: Node, b: Node) => Packed4x8IntegerNode; +export const dot4I8Packed: (a: Node, b: Node) => Packed4x8IntegerNode; diff --git a/types/three/src/nodes/math/UnpackFloatNode.d.ts b/types/three/src/nodes/math/UnpackFloatNode.d.ts index a0c913fe7fccbc..044a26a810e3f2 100644 --- a/types/three/src/nodes/math/UnpackFloatNode.d.ts +++ b/types/three/src/nodes/math/UnpackFloatNode.d.ts @@ -1,10 +1,11 @@ import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -import { PackFloatNodeEncoding } from "./PackFloatNode.js"; +import { PackFloatNodeEncoding, PackFloatNodeLayout } from "./PackFloatNode.js"; declare class PackFloatNode extends TempNode { uintNode: Node; encoding: PackFloatNodeEncoding; + layout: PackFloatNodeLayout; readonly isPackFloatNode: true; @@ -16,3 +17,5 @@ export default PackFloatNode; export const unpackSnorm2x16: (value: Node) => PackFloatNode; export const unpackUnorm2x16: (value: Node) => PackFloatNode; export const unpackHalf2x16: (value: Node) => PackFloatNode; +export const unpackSnorm4x8: (value: Node) => PackFloatNode; +export const unpackUnorm4x8: (value: Node) => PackFloatNode; diff --git a/types/three/src/nodes/pmrem/PMREMUtils.d.ts b/types/three/src/nodes/pmrem/PMREMUtils.d.ts index 3dc918bbf8e7e8..c5989edc37a7db 100644 --- a/types/three/src/nodes/pmrem/PMREMUtils.d.ts +++ b/types/three/src/nodes/pmrem/PMREMUtils.d.ts @@ -1,7 +1,5 @@ import Node from "../core/Node.js"; -export const getDirection: (uv_immutable: Node, face: Node) => Node; - export const textureCubeUV: ( envMap: Node, sampleDir_immutable: Node, @@ -11,14 +9,10 @@ export const textureCubeUV: ( CUBEUV_MAX_MIP: Node, ) => Node; -export const blur: ( - n: Node, - latitudinal: Node, - poleAxis: Node, +export const sphericalGaussianBlur: ( + SAMPLES: Node, + sigma: Node, outputDirection: Node, - weights: Node, - samples: Node, - dTheta: Node, mipInt: Node, envMap: Node, CUBEUV_TEXEL_WIDTH: Node, diff --git a/types/three/src/nodes/tsl/TSLCore.d.ts b/types/three/src/nodes/tsl/TSLCore.d.ts index ca0b09f290b8ac..b9c3bad6f54d8b 100644 --- a/types/three/src/nodes/tsl/TSLCore.d.ts +++ b/types/three/src/nodes/tsl/TSLCore.d.ts @@ -19,7 +19,7 @@ export function addMethodChaining(name: string, nodeElement: unknown): void; declare module "../core/Node.js" { interface NodeElements { - assign: (sourceNode: Node | number) => this; + assign: (sourceNode: Node | number | boolean) => this; get: (value: string) => Node; } } @@ -2275,7 +2275,7 @@ interface Mat3Function { // ConstNode (value: Matrix3): VarNode<"mat3", ConstNode<"mat3", Matrix3>>; // ConvertNode - (node: Node<"mat3">): VarNode<"mat3", ConvertNode<"mat3">>; + (node: Node<"mat3"> | Node<"mat4">): VarNode<"mat3", ConvertNode<"mat3">>; // The fall-through branch will be triggered if there is more than one parameter, and one of the parameters is an // object @@ -2417,18 +2417,4 @@ declare module "../core/Node.js" { } } -/** - * @deprecated append() has been renamed to Stack(). - */ -export const append: (node: Node) => Node; - -declare module "../core/Node.js" { - interface NodeElements { - /** - * @deprecated append() has been renamed to Stack(). - */ - append: () => Node; - } -} - export {}; diff --git a/types/three/src/nodes/utils/EventNode.d.ts b/types/three/src/nodes/utils/EventNode.d.ts index a2f8e4043cc548..def49f9d676677 100644 --- a/types/three/src/nodes/utils/EventNode.d.ts +++ b/types/three/src/nodes/utils/EventNode.d.ts @@ -12,9 +12,12 @@ declare class EventNode extends Node { static OBJECT: "object"; static MATERIAL: "material"; static FRAME: "frame"; + static AFTER_OBJECT: "afterObject"; static BEFORE_OBJECT: "beforeObject"; static BEFORE_MATERIAL: "beforeMaterial"; static BEFORE_FRAME: "beforeFrame"; + static BEFORE_RENDER_PIPELINE: "beforeRenderPipeline"; + static AFTER_RENDER_PIPELINE: "afterRenderPipeline"; } export default EventNode; @@ -25,8 +28,14 @@ export const OnMaterialUpdate: (callback: (frame: NodeFrame) => void) => Node; export const OnFrameUpdate: (callback: (frame: NodeFrame) => void) => Node; +export const OnAfterObjectUpdate: (callback: (frame: NodeFrame) => void) => Node; + export const OnBeforeObjectUpdate: (callback: (frame: NodeFrame) => void) => Node; export const OnBeforeMaterialUpdate: (callback: (frame: NodeFrame) => void) => Node; export const OnBeforeFrameUpdate: (callback: (frame: NodeFrame) => void) => Node; + +export const OnBeforeRenderPipeline: (callback: () => void) => Node; + +export const OnAfterRenderPipeline: (callback: () => void) => Node; diff --git a/types/three/src/nodes/utils/LoopNode.d.ts b/types/three/src/nodes/utils/LoopNode.d.ts index b803426f2bdf6f..c59defd1171ed7 100644 --- a/types/three/src/nodes/utils/LoopNode.d.ts +++ b/types/three/src/nodes/utils/LoopNode.d.ts @@ -25,7 +25,8 @@ declare class LoopNode extends Node<"void"> { export default LoopNode; interface Loop { - (i: number, func: (inputs: { readonly i: Node<"int"> }) => void): LoopNode; + (func: () => void): LoopNode; + (i: Node | number, func: (inputs: { readonly i: Node<"int"> }) => void): LoopNode; ( i: LoopNodeObjectParameter, func: (inputs: { readonly i: Node }) => void, diff --git a/types/three/src/nodes/utils/PostProcessingUtils.d.ts b/types/three/src/nodes/utils/PostProcessingUtils.d.ts index 0b24e78ba385ea..8a56d71d34167a 100644 --- a/types/three/src/nodes/utils/PostProcessingUtils.d.ts +++ b/types/three/src/nodes/utils/PostProcessingUtils.d.ts @@ -28,6 +28,14 @@ export const getScreenPosition: ( projectionMatrix: Node, ) => Node<"vec2">; +/** + * Converts a clip-space position into a screen position expressed as uv coordinates. + * + * @param {vec4} clipPosition - The position in clip space. + * @return {vec2} The screen position expressed as uv coordinates. + */ +export const getScreenPositionFromClip: (clipPosition: Node) => Node<"vec2">; + /** * Computes a normal vector based on depth data. Can be used as a fallback when no normal render target is available or * if flat surface normals are required. diff --git a/types/three/src/nodes/utils/RTTNode.d.ts b/types/three/src/nodes/utils/RTTNode.d.ts index 6d12d2dfce60ce..40ada6e45e84fe 100644 --- a/types/three/src/nodes/utils/RTTNode.d.ts +++ b/types/three/src/nodes/utils/RTTNode.d.ts @@ -2,6 +2,11 @@ import { RenderTarget, RenderTargetOptions } from "../../core/RenderTarget.js"; import TextureNode from "../accessors/TextureNode.js"; import Node from "../core/Node.js"; +export interface RTTNodeOptions extends RenderTargetOptions { + autoUpdate?: boolean | undefined; // true + resolutionScale?: number | undefined; // 1 +} + declare class RTTNode extends TextureNode { readonly isRTTNode: true; @@ -14,7 +19,7 @@ declare class RTTNode extends TextureNode { textureNeedsUpdate: boolean; autoUpdate: boolean; - constructor(node: Node, width?: number | null, height?: number | null, options?: RenderTargetOptions); + constructor(node: Node, width?: number | null, height?: number | null, options?: RTTNodeOptions); get autoResize(): boolean; @@ -31,11 +36,11 @@ export const rtt: ( node: Node, width?: number | null, height?: number | null, - options?: RenderTargetOptions, + options?: RTTNodeOptions, ) => RTTNode; export const convertToTexture: ( node: Node, width?: number | null, height?: number | null, - options?: RenderTargetOptions, + options?: RTTNodeOptions, ) => RTTNode; diff --git a/types/three/src/nodes/utils/RotateNode.d.ts b/types/three/src/nodes/utils/RotateNode.d.ts index c75f4317598d2b..4b5546c966b07d 100644 --- a/types/three/src/nodes/utils/RotateNode.d.ts +++ b/types/three/src/nodes/utils/RotateNode.d.ts @@ -1,14 +1,17 @@ +import { EulerOrder } from "../../math/Euler.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; interface RotateNodeInterface { positionNode: Node; rotationNode: Node<"vec3"> | Node<"float">; + setOrder(value: EulerOrder): this; + getOrder(): EulerOrder; } declare const RotateNode: { new(positionNode: Node<"vec2">, rotationNode: Node<"float"> | number): RotateNode<"vec2">; - new(positionNode: Node<"vec3">, rotationNode: Node<"vec3">): RotateNode<"vec3">; + new(positionNode: Node<"vec3">, rotationNode: Node<"vec3">, order?: EulerOrder): RotateNode<"vec3">; }; type RotateNode = RotateNodeInterface & TempNode; @@ -17,7 +20,7 @@ export default RotateNode; interface Rotate { (positionNode: Node<"vec2">, rotationNode: Node<"float"> | number): RotateNode<"vec2">; - (positionNode: Node<"vec3">, rotationNode: Node<"vec3">): RotateNode<"vec3">; + (positionNode: Node<"vec3">, rotationNode: Node<"vec3">, order?: EulerOrder): RotateNode<"vec3">; } export const rotate: Rotate; diff --git a/types/three/src/nodes/utils/SpriteUtils.d.ts b/types/three/src/nodes/utils/SpriteUtils.d.ts index a29cf54db97a15..063b9968b3f60b 100644 --- a/types/three/src/nodes/utils/SpriteUtils.d.ts +++ b/types/three/src/nodes/utils/SpriteUtils.d.ts @@ -1,5 +1,5 @@ import Node from "../core/Node.js"; export const billboarding: ( - args?: { position?: Node | null; horizontal?: boolean; vertical?: boolean }, + args?: { position?: Node | null; horizontal?: boolean; vertical?: boolean; horizontalRotation?: boolean }, ) => Node; diff --git a/types/three/src/objects/InstancedMesh.d.ts b/types/three/src/objects/InstancedMesh.d.ts index 1ae604a6155c88..e35f5cfb171c2a 100644 --- a/types/three/src/objects/InstancedMesh.d.ts +++ b/types/three/src/objects/InstancedMesh.d.ts @@ -20,10 +20,6 @@ export interface InstancedMeshJSON extends MeshJSONObject { object: InstancedMeshJSONObject; } -export interface InstancedMeshEventMap extends Object3DEventMap { - dispose: {}; -} - /** * A special version of {@link THREE.Mesh | Mesh} with instanced rendering support * @remarks @@ -39,7 +35,7 @@ export interface InstancedMeshEventMap extends Object3DEventMap { export class InstancedMesh< TGeometry extends BufferGeometry = BufferGeometry, TMaterial extends Material | Material[] = Material | Material[], - TEventMap extends InstancedMeshEventMap = InstancedMeshEventMap, + TEventMap extends Object3DEventMap = Object3DEventMap, > extends Mesh { /** * Read-only flag to check if a given object is of type {@link InstancedMesh}. diff --git a/types/three/src/objects/Line.d.ts b/types/three/src/objects/Line.d.ts index 2d76dec69cff86..143c267a809e4f 100644 --- a/types/three/src/objects/Line.d.ts +++ b/types/three/src/objects/Line.d.ts @@ -1,6 +1,8 @@ import { BufferGeometry } from "../core/BufferGeometry.js"; import { Object3D, Object3DEventMap } from "../core/Object3D.js"; import { Material } from "../materials/Material.js"; +import { Frustum } from "../math/Frustum.js"; +import { FrustumArray } from "../math/FrustumArray.js"; /** * A continuous line. @@ -84,4 +86,11 @@ export class Line< * Resets the {@link morphTargetInfluences | .morphTargetInfluences} and {@link morphTargetDictionary | .morphTargetDictionary} properties. */ updateMorphTargets(): void; + + /** + * Returns `true` if this line intersects the given frustum. + * @param frustum The frustum to test. + * @returns Whether this line intersects the given frustum or not. + */ + intersectsFrustum(frustum: Frustum | FrustumArray): boolean; } diff --git a/types/three/src/objects/Mesh.d.ts b/types/three/src/objects/Mesh.d.ts index 558ab502b1b72e..db0d560db141f5 100644 --- a/types/three/src/objects/Mesh.d.ts +++ b/types/three/src/objects/Mesh.d.ts @@ -1,6 +1,8 @@ import { BufferGeometry } from "../core/BufferGeometry.js"; import { JSONMeta, Object3D, Object3DEventMap, Object3DJSON, Object3DJSONObject } from "../core/Object3D.js"; import { Material } from "../materials/Material.js"; +import { Frustum } from "../math/Frustum.js"; +import { FrustumArray } from "../math/FrustumArray.js"; import { Vector3 } from "../math/Vector3.js"; export interface MeshJSONObject extends Object3DJSONObject { @@ -98,5 +100,12 @@ export class Mesh< */ getVertexPosition(index: number, target: Vector3): Vector3; + /** + * Returns `true` if this mesh intersects the given frustum. + * @param frustum The frustum to test. + * @returns Whether this mesh intersects the given frustum or not. + */ + intersectsFrustum(frustum: Frustum | FrustumArray): boolean; + toJSON(meta?: JSONMeta): MeshJSON; } diff --git a/types/three/src/objects/Points.d.ts b/types/three/src/objects/Points.d.ts index 3cba2c74bb19c8..ce9fd43eebb7f0 100644 --- a/types/three/src/objects/Points.d.ts +++ b/types/three/src/objects/Points.d.ts @@ -1,6 +1,8 @@ import { BufferGeometry, NormalOrGLBufferAttributes } from "../core/BufferGeometry.js"; import { Object3D, Object3DEventMap } from "../core/Object3D.js"; import { Material } from "../materials/Material.js"; +import { Frustum } from "../math/Frustum.js"; +import { FrustumArray } from "../math/FrustumArray.js"; /** * A class for displaying {@link Points} @@ -63,4 +65,11 @@ export class Points< * @remarks Resets the {@link morphTargetInfluences} and {@link morphTargetDictionary} properties. */ updateMorphTargets(): void; + + /** + * Returns `true` if this point cloud intersects the given frustum. + * @param frustum The frustum to test. + * @returns Whether this point cloud intersects the given frustum or not. + */ + intersectsFrustum(frustum: Frustum | FrustumArray): boolean; } diff --git a/types/three/src/objects/Sprite.d.ts b/types/three/src/objects/Sprite.d.ts index 868c7005a8ab6a..da443bcab5dd94 100644 --- a/types/three/src/objects/Sprite.d.ts +++ b/types/three/src/objects/Sprite.d.ts @@ -1,6 +1,8 @@ import { BufferGeometry } from "../core/BufferGeometry.js"; import { Object3D, Object3DEventMap } from "../core/Object3D.js"; import { SpriteMaterial } from "../materials/Materials.js"; +import { Frustum } from "../math/Frustum.js"; +import { FrustumArray } from "../math/FrustumArray.js"; import { Vector2 } from "../math/Vector2.js"; /** @@ -70,4 +72,11 @@ export class Sprite exten * @default 1 */ count: number; + + /** + * Returns `true` if this sprite intersects the given frustum. + * @param frustum The frustum to test. + * @returns Whether this sprite intersects the given frustum or not. + */ + intersectsFrustum(frustum: Frustum | FrustumArray): boolean; } diff --git a/types/three/src/renderers/WebGLRenderer.d.ts b/types/three/src/renderers/WebGLRenderer.d.ts index 7dc1b4a4df145b..3051a208aa0347 100644 --- a/types/three/src/renderers/WebGLRenderer.d.ts +++ b/types/three/src/renderers/WebGLRenderer.d.ts @@ -90,6 +90,17 @@ export interface WebGLDebug { */ checkShaderErrors: boolean; + /** + * Diagnostics configuration for the shader generation. Only relevant for TSL. + */ + diagnostics: { + /** + * Whether declaration names that collide with reserved keywords of the shading language should be renamed or + * not. + */ + keywords: boolean; + }; + /** * A callback function that can be used for custom error reporting. The callback receives the WebGL context, an * instance of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader. diff --git a/types/three/src/renderers/common/BundleGroup.d.ts b/types/three/src/renderers/common/BundleGroup.d.ts index 937afe339a2b2a..e414dd64bb3c01 100644 --- a/types/three/src/renderers/common/BundleGroup.d.ts +++ b/types/three/src/renderers/common/BundleGroup.d.ts @@ -6,6 +6,10 @@ import { Group } from "../../objects/Group.js"; * are considered as one render bundle and processed as such by * the renderer. * + * Only renderable 3D objects are allowed in a bundle group. Other + * types like lights are not supported and must be added to the scene + * outside of the group. + * * This module is only fully supported by `WebGPURenderer` with a WebGPU backend. * With a WebGL backend, the group can technically be rendered but without * any performance improvements. diff --git a/types/three/src/renderers/common/ClippingContext.d.ts b/types/three/src/renderers/common/ClippingContext.d.ts index b6f1a53c4ac964..bf3bb43ee41f24 100644 --- a/types/three/src/renderers/common/ClippingContext.d.ts +++ b/types/three/src/renderers/common/ClippingContext.d.ts @@ -21,6 +21,13 @@ declare class ClippingContext { * @param {?ClippingContext} [parentContext=null] - A reference to the parent clipping context. */ constructor(parentContext?: ClippingContext | null); + /** + * The id of the clipping context. + * + * @type {number} + * @readonly + */ + readonly id: number; /** * The clipping context's version. * diff --git a/types/three/src/renderers/common/Color4.d.ts b/types/three/src/renderers/common/Color4.d.ts new file mode 100644 index 00000000000000..501f1fbd39012b --- /dev/null +++ b/types/three/src/renderers/common/Color4.d.ts @@ -0,0 +1,53 @@ +import { Color, ColorRepresentation } from "../../math/Color.js"; + +/** + * A four-component version of {@link Color} which is internally + * used by the renderer to represents clear color with alpha as + * one object. + * + * @private + */ +declare class Color4 extends Color { + /** + * The alpha value. + */ + a: number; + + /** + * Constructs a new four-component color. + * You can also pass a single THREE.Color, hex or + * string argument to this constructor. + * + * @param r - The red value. + * @param g - The green value. + * @param b - The blue value. + * @param a - The alpha value. + */ + constructor(r?: ColorRepresentation, g?: number, b?: number, a?: number); + + /** + * Overwrites the default to honor alpha. + * You can also pass a single THREE.Color, hex or + * string argument to this method. + */ + set(...args: [color: ColorRepresentation] | [r: number, g: number, b: number, a?: number]): this; + + /** + * Overwrites the default to honor alpha. + * + * @param color - The color to copy. + * @return A reference to this object. + */ + copy(color: Color4): this; + + /** + * Overwrites the default to honor alpha. + * + * @return The cloned color. + */ + clone(): this; + + [Symbol.iterator](): Generator; +} + +export default Color4; diff --git a/types/three/src/renderers/common/Constants.d.ts b/types/three/src/renderers/common/Constants.d.ts index 0ded1192bf06f5..93988f36efee97 100644 --- a/types/three/src/renderers/common/Constants.d.ts +++ b/types/three/src/renderers/common/Constants.d.ts @@ -7,6 +7,3 @@ export declare const AttributeType: { export type AttributeType = (typeof AttributeType)[keyof typeof AttributeType]; export const GPU_CHUNK_BYTES: 16; - -export const BlendColorFactor: 211; -export const OneMinusBlendColorFactor: 212; diff --git a/types/three/src/renderers/common/DirectRenderPipeline.d.ts b/types/three/src/renderers/common/DirectRenderPipeline.d.ts new file mode 100644 index 00000000000000..c1bdc8baede979 --- /dev/null +++ b/types/three/src/renderers/common/DirectRenderPipeline.d.ts @@ -0,0 +1,20 @@ +import { Camera } from "../../cameras/Camera.js"; +import { Object3D } from "../../core/Object3D.js"; +import { Node } from "../../nodes/Nodes.js"; +import Renderer from "./Renderer.js"; +import RenderPipeline from "./RenderPipeline.js"; + +// `render()` is omitted from the base type since it is overloaded with a different signature. +declare const DirectRenderPipeline_base: { + new(renderer: Renderer, outputNode?: Node): Omit; +}; + +declare class DirectRenderPipeline extends DirectRenderPipeline_base { + readonly isDirectRenderPipeline: true; + + constructor(renderer: Renderer, outputNode?: Node); + + render(scene: Object3D, camera: Camera): void; +} + +export default DirectRenderPipeline; diff --git a/types/three/src/renderers/common/InspectorBase.d.ts b/types/three/src/renderers/common/InspectorBase.d.ts index b45122f358976a..9dba213abaf9bb 100644 --- a/types/three/src/renderers/common/InspectorBase.d.ts +++ b/types/three/src/renderers/common/InspectorBase.d.ts @@ -9,12 +9,11 @@ import { Texture } from "../../textures/Texture.js"; import Renderer from "./Renderer.js"; export interface InspectorBaseEventMap { + dispose: {}; } /** * InspectorBase is the base class for all inspectors. - * - * @class InspectorBase */ declare class InspectorBase extends EventDispatcher @@ -25,6 +24,20 @@ declare class InspectorBase void; - /** - * When an override material is in use, this property points to the current - * source material during the rendering of a render object. - * - * @private - * @type {?Material} - * @default null - */ - private _currentSourceMaterial; /** * Whether the renderer should render transparent render objects or not. * @@ -326,6 +318,9 @@ declare class Renderer { * Debug configuration. * @typedef {Object} DebugConfig * @property {boolean} checkShaderErrors - Whether shader errors should be checked or not. + * @property {Object} diagnostics - Diagnostics configuration for the shader generation. + * @property {boolean} diagnostics.keywords - Whether declaration names that collide with reserved keywords should be renamed or not. + * @property {?Function} onNodeBuilderCreated - A callback function that is executed after a node builder has been created and before it is built. * @property {?Function} onShaderError - A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now. * @property {Function} getShaderAsync - Allows the get the raw shader code for the given scene, camera and 3D object. */ @@ -339,6 +334,16 @@ declare class Renderer { * - Whether shader errors should be checked or not. */ checkShaderErrors: boolean; + /** + * - Diagnostics configuration for the shader generation. + */ + diagnostics: { + keywords: boolean; + }; + /** + * - A callback function that is executed after a node builder has been created and before it is built. + */ + onNodeBuilderCreated: ((nodeBuilder: NodeBuilder, object: unknown) => void) | null; /** * - A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now. */ @@ -395,9 +400,29 @@ declare class Renderer { * @param {Object3D} scene - The scene or 3D object to precompile. * @param {Camera} camera - The camera that is used to render the scene. * @param {?Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added. + * @param {onProgressCallback} [onProgress] - Executed while the compilation is in progress. + * @return {Promise} A Promise that resolves when the compile has been finished. + */ + compileAsync( + scene: Object3D, + camera: Camera, + targetScene?: Scene | null, + onProgress?: ((event: ProgressEvent) => void) | null, + ): Promise; + /** + * Compile compute programs. This can be useful to avoid a + * phenomenon which is called "shader compilation stutter", which occurs when + * rendering an object with a new shader for the first time. + * + * @async + * @param {Node|Array} computeNodes - The compute node(s). + * @param {onProgressCallback} [onProgress] - Executed while the compilation is in progress. * @return {Promise} A Promise that resolves when the compile has been finished. */ - compileAsync(scene: Object3D, camera: Camera, targetScene?: Scene | null): Promise; + compileComputeAsync( + computeNodes: ComputeNode | ComputeNode[], + onProgress?: ((event: ProgressEvent) => void) | null, + ): Promise; /** * Renders the scene in an async fashion. * @@ -647,6 +672,11 @@ declare class Renderer { * @param {boolean} boolean - Whether the scissor test should be enabled or not. */ setScissorTest(boolean: boolean): void; + /** + * Resets the backend's internal state cache. Useful when the rendering context is shared with + * other libraries that change the state. A no-op for the WebGPU backend. + */ + resetState(): void; /** * Returns the viewport definition. * @@ -786,6 +816,8 @@ declare class Renderer { /** * Returns `true` if a framebuffer target is needed to perform tone mapping or color space conversion. * If this is the case, the renderer allocates an internal render target for that purpose. + * + * @type {boolean} */ get needsFrameBufferTarget(): boolean; /** @@ -799,8 +831,8 @@ declare class Renderer { * The current number of samples used for multi-sample anti-aliasing (MSAA). * * When rendering to a custom render target, the number of samples of that render target is used. - * If the renderer needs an internal framebuffer target for tone mapping or color space conversion, - * the number of samples is set to 0. + * The number of samples is set to 0 when the renderer needs an internal framebuffer target for + * tone mapping or color space conversion, or when rendering a fullscreen quad to screen. * * @type {number} */ @@ -829,7 +861,7 @@ declare class Renderer { * Frees all internal resources of the renderer. Call this method if the renderer * is no longer in use by your app. */ - dispose(): void; + dispose(): Promise; /** * Sets the given render target. Calling this method means the renderer does not * target the default framebuffer (meaning the canvas) anymore but a custom framebuffer. @@ -1043,7 +1075,7 @@ declare class Renderer { * @param {number} width - The width of the copy region. * @param {number} height - The height of the copy region. * @param {number} [textureIndex=0] - The texture index of a MRT render target. - * @param {number} [faceIndex=0] - The active cube face index. + * @param {number} [faceIndex=0] - The cube face, depth slice or array layer index. * @return {Promise} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array. */ readRenderTargetPixelsAsync( @@ -1094,9 +1126,15 @@ declare class Renderer { * @param {Object3D} scene - The scene or 3D object to precompile. * @param {Camera} camera - The camera that is used to render the scene. * @param {Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added. - * @return {function(Object3D, Camera, ?Scene): Promise|undefined} A Promise that resolves when the compile has been finished. + * @param {onProgressCallback} [onProgress] - Executed while the compilation is in progress. + * @return {function(Object3D, Camera, ?Scene, ?onProgressCallback): Promise|undefined} A Promise that resolves when the compile has been finished. */ - get compile(): (scene: Object3D, camera: Camera, targetScene?: Scene | null) => Promise; + get compile(): ( + scene: Object3D, + camera: Camera, + targetScene?: Scene | null, + onProgress?: ((event: ProgressEvent) => void) | null, + ) => Promise; } export default Renderer; diff --git a/types/three/src/renderers/common/XRManager.d.ts b/types/three/src/renderers/common/XRManager.d.ts index a39eeebed441c6..ba4905cfcad7a7 100644 --- a/types/three/src/renderers/common/XRManager.d.ts +++ b/types/three/src/renderers/common/XRManager.d.ts @@ -21,6 +21,7 @@ export interface XRManagerEventMap { export interface LayerAttributes { stencil?: boolean | undefined; + samples?: number | undefined; } interface XRGPUBinding {} @@ -178,9 +179,9 @@ declare class XRManager * Browser-side `XRWebGLBinding.foveateBoundTexture()` failures are treated as * non-fatal so they do not interrupt rendering. * - * @param {RenderTarget} renderTarget - The internal render target. + * @param {?RenderTarget} renderTarget - The internal render target. */ - foveateBoundTexture(renderTarget: RenderTarget): void; + foveateBoundTexture(renderTarget: RenderTarget | null): void; /** * Returns the current XR WebGPU binding. * @@ -215,6 +216,7 @@ declare class XRManager * @param {Function} rendercall - A callback function that renders the layer. Similar to code in * the default animation loop, this method can be used to update/transform 3D object in the layer's scene. * @param {Object} [attributes={}] - Allows to configure the layer's render target. + * @param {number} [attributes.samples] - The scene MSAA sample count. Defaults to the renderer's sample count. * @return {Mesh} A mesh representing the quadratic XR layer. This mesh should be added to the XR scene. */ createQuadLayer( @@ -241,6 +243,7 @@ declare class XRManager * @param {Function} rendercall - A callback function that renders the layer. Similar to code in * the default animation loop, this method can be used to update/transform 3D object in the layer's scene. * @param {Object} [attributes={}] - Allows to configure the layer's render target. + * @param {number} [attributes.samples] - The scene MSAA sample count. Defaults to the renderer's sample count. * @return {Mesh} A mesh representing the cylindrical XR layer. This mesh should be added to the XR scene. */ createCylinderLayer( diff --git a/types/three/src/renderers/common/nodes/NodeLibrary.d.ts b/types/three/src/renderers/common/nodes/NodeLibrary.d.ts index bd54195252d8e4..019d66f29e59e8 100644 --- a/types/three/src/renderers/common/nodes/NodeLibrary.d.ts +++ b/types/three/src/renderers/common/nodes/NodeLibrary.d.ts @@ -1,3 +1,10 @@ +import { ToneMapping } from "../../../constants.js"; +import { Light } from "../../../lights/Light.js"; +import { Material } from "../../../materials/Material.js"; +import NodeMaterial from "../../../materials/nodes/NodeMaterial.js"; +import Node from "../../../nodes/core/Node.js"; +import AnalyticLightNode from "../../../nodes/lighting/AnalyticLightNode.js"; + /** * The purpose of a node library is to assign node implementations * to existing library features. In `WebGPURenderer` lights, materials @@ -7,6 +14,116 @@ * @private */ declare class NodeLibrary { + /** + * A weak map that maps lights to light nodes. + * + * @type {WeakMap} + */ + lightNodes: WeakMap<{ + new(): Light; + }, { + new(light: Light): AnalyticLightNode; + }>; + /** + * A map that maps materials to node materials. + * + * @type {Map} + */ + materialNodes: Map; + /** + * A map that maps tone mapping techniques (constants) + * to tone mapping node functions. + * + * @type {Map} + */ + toneMappingNodes: Map Node>; + /** + * Returns a matching node material instance for the given material object. + * + * This method also assigns/copies the properties of the given material object + * to the node material. This is done to make sure the current material + * configuration carries over to the node version. + * + * @param {Material} material - A material. + * @return {NodeMaterial} The corresponding node material. + */ + fromMaterial(material: Material): NodeMaterial; + /** + * Adds a tone mapping node function for a tone mapping technique (constant). + * + * @param {Function} toneMappingNode - The tone mapping node function. + * @param {number} toneMapping - The tone mapping. + */ + addToneMapping(toneMappingNode: (color: Node, exposure: Node) => Node, toneMapping: ToneMapping): void; + /** + * Returns a tone mapping node function for a tone mapping technique (constant). + * + * @param {number} toneMapping - The tone mapping. + * @return {?Function} The tone mapping node function. Returns `null` if no node function is found. + */ + getToneMappingFunction(toneMapping: ToneMapping): ((color: Node, exposure: Node) => Node) | null; + /** + * Returns a node material class definition for a material type. + * + * @param {string} materialType - The material type. + * @return {?NodeMaterial.constructor} The node material class definition. Returns `null` if no node material is found. + */ + getMaterialNodeClass(materialType: string): (new() => NodeMaterial) | null; + /** + * Adds a node material class definition for a given material type. + * + * @param {NodeMaterial.constructor} materialNodeClass - The node material class definition. + * @param {string} materialClassType - The material type. + */ + addMaterial(materialNodeClass: { + new(): NodeMaterial; + }, materialClassType: string): void; + /** + * Returns a light node class definition for a light class definition. + * + * @param {Light.constructor} light - The light class definition. + * @return {?AnalyticLightNode.constructor} The light node class definition. Returns `null` if no light node is found. + */ + getLightNodeClass(light: { + new(): Light; + }): + | ({ + new(light: Light): AnalyticLightNode; + }) + | null; + /** + * Adds a light node class definition for a given light class definition. + * + * @param {AnalyticLightNode.constructor} lightNodeClass - The light node class definition. + * @param {Light.constructor} lightClass - The light class definition. + */ + addLight(lightNodeClass: { + new(light: TLight): AnalyticLightNode; + }, lightClass: { + new(): TLight; + }): void; + /** + * Adds a node class definition for the given type to the provided type library. + * + * @param {Node.constructor} nodeClass - The node class definition. + * @param {number|string} type - The object type. + * @param {Map} library - The type library. + */ + addType(nodeClass: TNodeClass, type: TType, library: Map): void; + /** + * Adds a node class definition for the given class definition to the provided type library. + * + * @param {Node.constructor} nodeClass - The node class definition. + * @param {Node.constructor} baseClass - The class definition. + * @param {WeakMap} library - The type library. + */ + addClass( + nodeClass: TNodeClass, + baseClass: TBaseClass, + library: WeakMap, + ): void; } export default NodeLibrary; diff --git a/types/three/src/renderers/shaders/UniformsLib.d.ts b/types/three/src/renderers/shaders/UniformsLib.d.ts index f089e7d648fc6b..b5353ff71b6bb3 100644 --- a/types/three/src/renderers/shaders/UniformsLib.d.ts +++ b/types/three/src/renderers/shaders/UniformsLib.d.ts @@ -79,6 +79,25 @@ export const UniformsLib: { lights: { ambientLightColor: IUniform; lightProbe: IUniform; + sunLights: { + value: unknown[]; + properties: { + direction: {}; + color: {}; + }; + }; + sunLightShadows: { + value: unknown[]; + properties: { + shadowIntensity: number; + shadowBias: {}; + shadowNormalBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + sunShadowMatrix: IUniform; + sunShadowCascade: IUniform; directionalLights: { value: unknown[]; properties: { diff --git a/types/three/src/renderers/webgl/WebGLLights.d.ts b/types/three/src/renderers/webgl/WebGLLights.d.ts index 249490a419ca51..542bcbe873d93e 100644 --- a/types/three/src/renderers/webgl/WebGLLights.d.ts +++ b/types/three/src/renderers/webgl/WebGLLights.d.ts @@ -6,12 +6,14 @@ export interface WebGLLightsState { version: number; hash: { + sunLength: number; directionalLength: number; pointLength: number; spotLength: number; rectAreaLength: number; hemiLength: number; + numSunShadows: number; numDirectionalShadows: number; numPointShadows: number; numSpotShadows: number; @@ -22,6 +24,11 @@ export interface WebGLLightsState { ambient: number[]; probe: unknown[]; + sun: unknown[]; + sunShadow: unknown[]; + sunShadowMap: unknown[]; + sunShadowMatrix: unknown[]; + sunShadowCascade: unknown[]; directional: unknown[]; directionalShadow: unknown[]; directionalShadowMap: unknown[]; diff --git a/types/three/src/renderers/webgl/WebGLPrograms.d.ts b/types/three/src/renderers/webgl/WebGLPrograms.d.ts index 2145a2399fe756..7670bd3420a240 100644 --- a/types/three/src/renderers/webgl/WebGLPrograms.d.ts +++ b/types/three/src/renderers/webgl/WebGLPrograms.d.ts @@ -67,6 +67,7 @@ export interface WebGLProgramParameters { clearcoatRoughnessMap: boolean; dispersion: boolean; + retroreflection: boolean; iridescence: boolean; iridescenceMap: boolean; @@ -160,6 +161,7 @@ export interface WebGLProgramParameters { morphTargetsCount: number; morphTextureStride: number; + numSunLights: number; numDirLights: number; numPointLights: number; numSpotLights: number; @@ -167,6 +169,7 @@ export interface WebGLProgramParameters { numRectAreaLights: number; numHemiLights: number; + numSunLightShadows: number; numDirLightShadows: number; numPointLightShadows: number; numSpotLightShadows: number; diff --git a/types/three/src/textures/Texture.d.ts b/types/three/src/textures/Texture.d.ts index 1b2eda2327f2c7..efb7a50a69637d 100644 --- a/types/three/src/textures/Texture.d.ts +++ b/types/three/src/textures/Texture.d.ts @@ -16,7 +16,7 @@ import { Matrix3 } from "../math/Matrix3.js"; import { Vector2 } from "../math/Vector2.js"; import { CompressedTextureMipmap } from "./CompressedTexture.js"; import { CubeTexture } from "./CubeTexture.js"; -import { Source } from "./Source.js"; +import { TextureSource } from "./TextureSource.js"; // NOTE: DOM upload fields are not implemented where parameters are accepted. export interface TextureParameters { @@ -182,7 +182,7 @@ export class Texture; + source: TextureSource; /** * The width of the texture in pixels. diff --git a/types/three/src/textures/Source.d.ts b/types/three/src/textures/TextureSource.d.ts similarity index 65% rename from types/three/src/textures/Source.d.ts rename to types/three/src/textures/TextureSource.d.ts index 80c50bdeff73f4..f0152c8ddf6ef0 100644 --- a/types/three/src/textures/Source.d.ts +++ b/types/three/src/textures/TextureSource.d.ts @@ -9,23 +9,23 @@ export type SerializedImage = type: string; }; -export class SourceJSON { +export interface TextureSourceJSON { uuid: string; url: SerializedImage | SerializedImage[]; } /** - * Represents the data {@link Source} of a texture. - * @see {@link https://threejs.org/docs/index.html#api/en/textures/Source | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/Source.js | Source} + * Represents the data {@link TextureSource} of a texture. + * @see {@link https://threejs.org/docs/index.html#api/en/textures/TextureSource | Official Documentation} + * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/TextureSource.js | TextureSource} */ -export class Source { +export class TextureSource { /** - * Flag to check if a given object is of type {@link Source}. + * Flag to check if a given object is of type {@link TextureSource}. * @remarks This is a _constant_ value * @defaultValue `true` */ - readonly isSource: true; + readonly isTextureSource: true; readonly id: number; @@ -58,7 +58,7 @@ export class Source { version: number; /** - * Create a new instance of {@link Source} + * Create a new instance of {@link TextureSource} * @param data The data definition of a texture. Default `null` */ constructor(data: TData); @@ -72,8 +72,28 @@ export class Source { set needsUpdate(value: boolean); /** - * Convert the data {@link Source} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}. + * Convert the data {@link TextureSource} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}. * @param meta Optional object containing metadata. */ - toJSON(meta?: string | {}): SourceJSON; + toJSON(meta?: string | {}): TextureSourceJSON; +} + +/** + * @deprecated since r186. Use {@link TextureSource} instead. `Source` has been renamed to `TextureSource`. + */ +export class Source extends TextureSource { + /** + * Create a new instance of {@link Source} + * @param data The data definition of a texture. Default `null` + * @deprecated since r186. Use {@link TextureSource} instead. + */ + constructor(data: TData); + + /** + * Flag to check if a given object is of type {@link Source}. + * @remarks This is a _constant_ value + * @deprecated since r186. Use {@link TextureSource.isTextureSource} instead. + * @defaultValue `true` + */ + readonly isSource: true; } diff --git a/types/three/test/unit/examples/jsm/tsl/display/CRT.ts b/types/three/test/unit/examples/jsm/tsl/display/CRT.ts deleted file mode 100644 index b903d3c73db095..00000000000000 --- a/types/three/test/unit/examples/jsm/tsl/display/CRT.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { barrelMask } from "three/addons/tsl/display/CRT.js"; -import { uv } from "three/tsl"; - -barrelMask(uv()); diff --git a/types/three/test/unit/src/nodes/materialx/lib/mx_hsv.ts b/types/three/test/unit/src/nodes/materialx/MaterialXColor.ts similarity index 100% rename from types/three/test/unit/src/nodes/materialx/lib/mx_hsv.ts rename to types/three/test/unit/src/nodes/materialx/MaterialXColor.ts diff --git a/types/three/test/unit/src/nodes/materialx/lib/mx_transform_color.ts b/types/three/test/unit/src/nodes/materialx/MaterialXColorTransform.ts similarity index 100% rename from types/three/test/unit/src/nodes/materialx/lib/mx_transform_color.ts rename to types/three/test/unit/src/nodes/materialx/MaterialXColorTransform.ts diff --git a/types/three/test/unit/src/nodes/materialx/MaterialXCore.ts b/types/three/test/unit/src/nodes/materialx/MaterialXCore.ts new file mode 100644 index 00000000000000..69b285feb18a46 --- /dev/null +++ b/types/three/test/unit/src/nodes/materialx/MaterialXCore.ts @@ -0,0 +1,8 @@ +import { mx_rotate2d, mx_rotate3d, vec2, vec3 } from "three/tsl"; + +mx_rotate2d(vec2(0)); +mx_rotate2d(vec2(0), 90); + +mx_rotate3d(vec3(0)); +mx_rotate3d(vec3(0), 90); +mx_rotate3d(vec3(0), 90, vec3(0, 1, 0)); diff --git a/types/three/test/unit/src/nodes/materialx/MaterialXNodes.ts b/types/three/test/unit/src/nodes/materialx/MaterialXNodes.ts index e51f6b156e4b68..243f725e83b8a2 100644 --- a/types/three/test/unit/src/nodes/materialx/MaterialXNodes.ts +++ b/types/three/test/unit/src/nodes/materialx/MaterialXNodes.ts @@ -1,8 +1,10 @@ import { mx_aastep, mx_cell_noise_float, + mx_cell_noise_vec3, mx_contrast, mx_fractal_noise_float, + mx_fractal_noise_float_2d, mx_fractal_noise_vec2, mx_fractal_noise_vec3, mx_fractal_noise_vec4, @@ -14,13 +16,17 @@ import { mx_ramptb, mx_rgbtohsv, mx_safepower, + mx_smoothstep, mx_splitlr, mx_splittb, mx_srgb_texture_to_lin_rec709, mx_transform_uv, mx_worley_noise_float, + mx_worley_noise_float_2d, + mx_worley_noise_float_3d, mx_worley_noise_vec2, mx_worley_noise_vec3, + mx_worley_noise_vec3_style, vec2, vec3, } from "three/tsl"; @@ -53,16 +59,29 @@ mx_noise_vec3(vec2(0), 1, 0); mx_noise_vec4(); mx_noise_vec4(vec2(0), 1, 0); +mx_smoothstep(0.5); +mx_smoothstep(0.5, 0, 1); + mx_worley_noise_float(); -mx_worley_noise_float(vec2(0), 1); +mx_worley_noise_float(vec2(0), 1, 0); +mx_worley_noise_float_2d(); +mx_worley_noise_float_2d(vec2(0), 1, 0); +mx_worley_noise_float_3d(); +mx_worley_noise_float_3d(vec3(0), 1, 0); mx_worley_noise_vec2(); mx_worley_noise_vec2(vec2(0), 1); mx_worley_noise_vec3(); -mx_worley_noise_vec3(vec2(0), 1); +mx_worley_noise_vec3(vec2(0), 1, 1); +mx_worley_noise_vec3_style(); +mx_worley_noise_vec3_style(vec3(0), 1, 0, 0); mx_cell_noise_float(); mx_cell_noise_float(vec2(0)); +mx_cell_noise_vec3(); +mx_cell_noise_vec3(vec2(0)); +mx_fractal_noise_float_2d(); +mx_fractal_noise_float_2d(vec2(0), 3, 2, 0.5, 1); mx_fractal_noise_float(); mx_fractal_noise_float(vec2(0), 3, 2, 0.5, 1); mx_fractal_noise_vec2(); diff --git a/types/three/test/unit/src/nodes/materialx/lib/mx_noise.ts b/types/three/test/unit/src/nodes/materialx/MaterialXNoise.ts similarity index 81% rename from types/three/test/unit/src/nodes/materialx/lib/mx_noise.ts rename to types/three/test/unit/src/nodes/materialx/MaterialXNoise.ts index 3ad95ebe684a4b..7ea515d32cbab9 100644 --- a/types/three/test/unit/src/nodes/materialx/lib/mx_noise.ts +++ b/types/three/test/unit/src/nodes/materialx/MaterialXNoise.ts @@ -9,6 +9,7 @@ import { mx_floor, mx_floorfrac, mx_fractal_noise_float, + mx_fractal_noise_float_2d, mx_fractal_noise_vec2, mx_fractal_noise_vec3, mx_fractal_noise_vec4, @@ -26,10 +27,13 @@ import { mx_trilerp, mx_worley_distance, mx_worley_noise_float, + mx_worley_noise_float_2d, + mx_worley_noise_float_3d, mx_worley_noise_vec2, mx_worley_noise_vec3, -} from "three/src/nodes/materialx/lib/mx_noise.js"; -import { float, vec2 } from "three/tsl"; + mx_worley_noise_vec3_style, +} from "three/src/nodes/materialx/MaterialXNoise.js"; +import { float, vec2, vec3 } from "three/tsl"; mx_select(true, 1, 0); mx_negate_if(true, 1); @@ -59,11 +63,15 @@ mx_perlin_noise_float(vec2(0)); mx_perlin_noise_vec3(vec2(0)); mx_cell_noise_float(vec2(0)); mx_cell_noise_vec3(vec2(0)); +mx_fractal_noise_float_2d(vec2(0), 3, 2, 0.5); mx_fractal_noise_float(vec2(0), 3, 2, 0.5); mx_fractal_noise_vec3(vec2(0), 3, 2, 0.5); mx_fractal_noise_vec2(vec2(0), 3, 2, 0.5); mx_fractal_noise_vec4(vec2(0), 3, 2, 0.5); mx_worley_distance(vec2(0), 1, 2, 3, 0, 0, 0, 1, 1); mx_worley_noise_float(vec2(0), 1, 1); +mx_worley_noise_float_2d(vec2(0), 1, 0); +mx_worley_noise_float_3d(vec3(0), 1, 0); mx_worley_noise_vec2(vec2(0), 1, 1); mx_worley_noise_vec3(vec2(0), 1, 1); +mx_worley_noise_vec3_style(vec3(0), 1, 0, 0); diff --git a/types/three/test/unit/src/nodes/math/OperatorNode.ts b/types/three/test/unit/src/nodes/math/OperatorNode.ts deleted file mode 100644 index 53c2bf67a4850b..00000000000000 --- a/types/three/test/unit/src/nodes/math/OperatorNode.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { color, float, vec2, vec3, vec4 } from "three/tsl"; -import { Node } from "three/webgpu"; - -const v: Node<"vec3"> = vec3(1, 2, 3).mul(2); -const colorProduct: Node<"vec3"> = vec3(1, 2, 3).mul(color(1, 1, 1)); -const sum: Node<"vec3"> = vec3(1, 2, 3).add(2); -const colorSum: Node<"vec3"> = vec3(1, 2, 3).add(color(1, 1, 1)); - -const floatColorProduct: Node<"vec3"> = float(1).mul(color(1, 1, 1)); -const vec2ColorProduct: Node<"vec3"> = vec2(1, 2).mul(color(1, 1, 1)); -const vec4ColorProduct: Node<"vec4"> = vec4(1, 2, 3, 4).mul(color(1, 1, 1)); diff --git a/types/three/test/unit/src/renderers/common/nodes/NodeLibrary.ts b/types/three/test/unit/src/renderers/common/nodes/NodeLibrary.ts new file mode 100644 index 00000000000000..402aeeb2fd7663 --- /dev/null +++ b/types/three/test/unit/src/renderers/common/nodes/NodeLibrary.ts @@ -0,0 +1,34 @@ +import { neutralToneMapping } from "three/tsl"; +import { + AnalyticLightNode, + Light, + MeshBasicMaterial, + MeshBasicNodeMaterial, + NeutralToneMapping, + WebGPURenderer, +} from "three/webgpu"; + +const renderer = new WebGPURenderer(); + +// Registering a custom light node for a custom light, see +// https://github.com/three-types/three-ts-types/issues/2323 + +class CustomLight extends Light { +} + +class CustomLightNode extends AnalyticLightNode { +} + +renderer.library.addLight(CustomLightNode, CustomLight); +renderer.library.getLightNodeClass(CustomLight); + +// Materials. + +renderer.library.addMaterial(MeshBasicNodeMaterial, "MeshBasicMaterial"); +renderer.library.getMaterialNodeClass("MeshBasicMaterial"); +renderer.library.fromMaterial(new MeshBasicMaterial()); + +// Tone mapping. + +renderer.library.addToneMapping(neutralToneMapping, NeutralToneMapping); +renderer.library.getToneMappingFunction(NeutralToneMapping); diff --git a/types/three/test/unit/src/textures/Texture.ts b/types/three/test/unit/src/textures/Texture.ts index ddd30d62f082a7..f145f51412d6e9 100644 --- a/types/three/test/unit/src/textures/Texture.ts +++ b/types/three/test/unit/src/textures/Texture.ts @@ -4,7 +4,7 @@ import * as THREE from "three"; const imageLoader = new THREE.ImageLoader(); imageLoader.load("/path/to/image.png", image => { - const source = new THREE.Source(image); + const source = new THREE.TextureSource(image); const material = new THREE.MeshBasicMaterial(); material.map = new THREE.Texture(); diff --git a/types/three/tsconfig.json b/types/three/tsconfig.json index 7e270b638fa6bb..d391178a088c00 100644 --- a/types/three/tsconfig.json +++ b/types/three/tsconfig.json @@ -36,17 +36,16 @@ "test/unit/examples/jsm/postprocessing/EffectComposer.ts", "test/unit/examples/jsm/postprocessing/SavePass.ts", "test/unit/examples/jsm/shaders/ACESFilmicToneMappingShader.ts", - "test/unit/examples/jsm/tsl/display/CRT.ts", "test/unit/src/audio/AudioContext.ts", "test/unit/src/core/EventDispatcher.ts", "test/unit/src/core/Uniform.ts", "test/unit/src/math/Vector3.ts", "test/unit/src/nodes/display/ColorAdjustment.ts", - "test/unit/src/nodes/math/OperatorNode.ts", - "test/unit/src/nodes/materialx/lib/mx_hsv.ts", - "test/unit/src/nodes/materialx/lib/mx_noise.ts", - "test/unit/src/nodes/materialx/lib/mx_transform_color.ts", + "test/unit/src/nodes/materialx/MaterialXColor.ts", + "test/unit/src/nodes/materialx/MaterialXColorTransform.ts", + "test/unit/src/nodes/materialx/MaterialXCore.ts", "test/unit/src/nodes/materialx/MaterialXNodes.ts", + "test/unit/src/nodes/materialx/MaterialXNoise.ts", "test/unit/src/extras/Earcut.ts", "test/unit/src/renderers/webgl/WebGLUtils.ts", "test/unit/src/textures/Texture.ts"