diff --git a/types/dom-navigation/.eslintrc.json b/types/dom-navigation/.eslintrc.json new file mode 100644 index 00000000000000..4c387a7c50e573 --- /dev/null +++ b/types/dom-navigation/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@definitelytyped/no-type-only-packages": "off" + } +} diff --git a/types/dom-navigation/index.d.ts b/types/dom-navigation/index.d.ts index 0111ac4d85a933..08e17b7e5483ea 100644 --- a/types/dom-navigation/index.d.ts +++ b/types/dom-navigation/index.d.ts @@ -1,183 +1,3 @@ -interface Window { - readonly navigation: Navigation; -} +// As of TS 6.0, the dom-navigation types are included in lib.dom.d.ts. -interface NavigationEventMap { - navigate: NavigateEvent; - navigatesuccess: Event; - navigateerror: ErrorEvent; - currententrychange: NavigationCurrentEntryChangeEvent; -} - -interface NavigationResult { - committed: Promise; - finished: Promise; -} - -declare class Navigation extends EventTarget { - entries(): NavigationHistoryEntry[]; - readonly currentEntry: NavigationHistoryEntry | null; - updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void; - readonly transition: NavigationTransition | null; - - readonly canGoBack: boolean; - readonly canGoForward: boolean; - - navigate(url: string, options?: NavigationNavigateOptions): NavigationResult; - reload(options?: NavigationReloadOptions): NavigationResult; - - traverseTo(key: string, options?: NavigationOptions): NavigationResult; - back(options?: NavigationOptions): NavigationResult; - forward(options?: NavigationOptions): NavigationResult; - - onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null; - onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null; - onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null; - oncurrententrychange: ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null; - - addEventListener( - type: K, - listener: (this: Navigation, ev: NavigationEventMap[K]) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: (this: Navigation, ev: NavigationEventMap[K]) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; -} - -declare class NavigationTransition { - readonly navigationType: NavigationTypeString; - readonly from: NavigationHistoryEntry; - readonly finished: Promise; -} - -interface NavigationHistoryEntryEventMap { - dispose: Event; -} - -interface NavigationHistoryEntry extends EventTarget { - readonly key: string; - readonly id: string; - readonly url: string | null; - readonly index: number; - readonly sameDocument: boolean; - - getState(): unknown; - - ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null; - - addEventListener( - type: K, - listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, - options?: boolean | AddEventListenerOptions, - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | AddEventListenerOptions, - ): void; - removeEventListener( - type: K, - listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, - options?: boolean | EventListenerOptions, - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: boolean | EventListenerOptions, - ): void; -} - -declare var NavigationHistoryEntry: { - prototype: NavigationHistoryEntry; - new(): NavigationHistoryEntry; -}; - -type NavigationTypeString = "reload" | "push" | "replace" | "traverse"; - -interface NavigationUpdateCurrentEntryOptions { - state: unknown; -} - -interface NavigationOptions { - info?: unknown; -} - -interface NavigationNavigateOptions extends NavigationOptions { - state?: unknown; - history?: "auto" | "push" | "replace"; -} - -interface NavigationReloadOptions extends NavigationOptions { - state?: unknown; -} - -declare class NavigationCurrentEntryChangeEvent extends Event { - constructor(type: string, eventInit?: NavigationCurrentEntryChangeEventInit); - - readonly navigationType: NavigationTypeString | null; - readonly from: NavigationHistoryEntry; -} - -interface NavigationCurrentEntryChangeEventInit extends EventInit { - navigationType?: NavigationTypeString | null; - from: NavigationHistoryEntry; -} - -declare class NavigateEvent extends Event { - constructor(type: string, eventInit?: NavigateEventInit); - - readonly navigationType: NavigationTypeString; - readonly canIntercept: boolean; - readonly userInitiated: boolean; - readonly hashChange: boolean; - readonly hasUAVisualTransition: boolean; - readonly destination: NavigationDestination; - readonly signal: AbortSignal; - readonly formData: FormData | null; - readonly downloadRequest: string | null; - readonly info?: unknown; - - intercept(options?: NavigationInterceptOptions): void; - scroll(): void; -} - -interface NavigateEventInit extends EventInit { - navigationType?: NavigationTypeString; - canIntercept?: boolean; - userInitiated?: boolean; - hashChange?: boolean; - destination: NavigationDestination; - signal: AbortSignal; - formData?: FormData | null; - downloadRequest?: string | null; - info?: unknown; -} - -interface NavigationInterceptOptions { - handler?: () => Promise; - focusReset?: "after-transition" | "manual"; - scroll?: "after-transition" | "manual"; -} - -declare class NavigationDestination { - readonly url: string; - readonly key: string | null; - readonly id: string | null; - readonly index: number; - readonly sameDocument: boolean; - - getState(): unknown; -} +type NavigationTypeString = NavigationType; diff --git a/types/dom-navigation/package.json b/types/dom-navigation/package.json index 7e3254112b4617..40a367ac0a1a61 100644 --- a/types/dom-navigation/package.json +++ b/types/dom-navigation/package.json @@ -7,6 +7,14 @@ "projects": [ "https://wicg.github.io/navigation-api" ], + "types": "index", + "typesVersions": { + "<=5.9": { + "*": [ + "ts5.9/*" + ] + } + }, "devDependencies": { "@types/dom-navigation": "workspace:." }, diff --git a/types/dom-navigation/ts5.9/dom-navigation-tests.ts b/types/dom-navigation/ts5.9/dom-navigation-tests.ts new file mode 100644 index 00000000000000..fd3f3df450b616 --- /dev/null +++ b/types/dom-navigation/ts5.9/dom-navigation-tests.ts @@ -0,0 +1,66 @@ +const navigation = window.navigation; + +const entries: NavigationHistoryEntry[] = navigation.entries(); +const entry: NavigationHistoryEntry | null = navigation.currentEntry; +if (entry) { + const key: string = entry.key; + const id: string = entry.id; + const url: string | null = entry.url; + const index: number = entry.index; + const sameDocument: boolean = entry.sameDocument; + const state: unknown = entry.getState(); + entry.ondispose = () => {}; + const listener = () => {}; + entry.addEventListener("dispose", listener); + entry.removeEventListener("dispose", listener); +} +navigation.updateCurrentEntry({ state: "" as unknown }); +const transition: NavigationTransition | null = navigation.transition; +if (transition) { + const navigationType: NavigationTypeString = transition.navigationType; + const from: NavigationHistoryEntry = transition.from; + const finished: Promise = transition.finished; +} +const canGoBack: boolean = navigation.canGoBack; +const canGoForward: boolean = navigation.canGoForward; +navigation.navigate("/url", { state: "" as unknown, history: "replace", info: "" as unknown }); +navigation.reload({ state: "" as unknown, info: "" as unknown }); +navigation.traverseTo("", { info: "" as unknown }); +navigation.back({ info: "" as unknown }); +navigation.forward({ info: "" as unknown }); +const navigateListener = (e: NavigateEvent) => { + const navigationType: NavigationTypeString = e.navigationType; + const canIntercept: boolean = e.canIntercept; + const userInitiated: boolean = e.userInitiated; + const hashChange: boolean = e.hashChange; + const hasUAVisualTransition: boolean = e.hasUAVisualTransition; + const destination: NavigationDestination = e.destination; + const url: string = destination.url; + const key: string | null = destination.key; + const id: string | null = destination.id; + const index: number = destination.index; + const sameDocument: boolean = destination.sameDocument; + const state: unknown = destination.getState(); + const signal: AbortSignal = e.signal; + const formData: FormData | null = e.formData; + const downloadRequest: string | null = e.downloadRequest; + const info: unknown = e.info; +}; +navigation.onnavigate = navigateListener; +navigation.addEventListener("navigate", navigateListener); +navigation.removeEventListener("navigate", navigateListener); +const navigateSuccessListener = (e: Event) => {}; +navigation.onnavigatesuccess = navigateSuccessListener; +navigation.addEventListener("navigatesuccess", navigateSuccessListener); +navigation.removeEventListener("navigatesuccess", navigateSuccessListener); +const navigateErrorListener = (e: Event) => {}; +navigation.onnavigateerror = navigateErrorListener; +navigation.addEventListener("navigateerror", navigateErrorListener); +navigation.removeEventListener("navigateerror", navigateErrorListener); +const currentEntryChangeListener = (e: NavigationCurrentEntryChangeEvent) => { + const navigationType: NavigationTypeString | null = e.navigationType; + const from: NavigationHistoryEntry = e.from; +}; +navigation.oncurrententrychange = currentEntryChangeListener; +navigation.addEventListener("currententrychange", currentEntryChangeListener); +navigation.removeEventListener("currententrychange", currentEntryChangeListener); diff --git a/types/dom-navigation/ts5.9/index.d.ts b/types/dom-navigation/ts5.9/index.d.ts new file mode 100644 index 00000000000000..0111ac4d85a933 --- /dev/null +++ b/types/dom-navigation/ts5.9/index.d.ts @@ -0,0 +1,183 @@ +interface Window { + readonly navigation: Navigation; +} + +interface NavigationEventMap { + navigate: NavigateEvent; + navigatesuccess: Event; + navigateerror: ErrorEvent; + currententrychange: NavigationCurrentEntryChangeEvent; +} + +interface NavigationResult { + committed: Promise; + finished: Promise; +} + +declare class Navigation extends EventTarget { + entries(): NavigationHistoryEntry[]; + readonly currentEntry: NavigationHistoryEntry | null; + updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void; + readonly transition: NavigationTransition | null; + + readonly canGoBack: boolean; + readonly canGoForward: boolean; + + navigate(url: string, options?: NavigationNavigateOptions): NavigationResult; + reload(options?: NavigationReloadOptions): NavigationResult; + + traverseTo(key: string, options?: NavigationOptions): NavigationResult; + back(options?: NavigationOptions): NavigationResult; + forward(options?: NavigationOptions): NavigationResult; + + onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null; + onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null; + onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null; + oncurrententrychange: ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null; + + addEventListener( + type: K, + listener: (this: Navigation, ev: NavigationEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener( + type: K, + listener: (this: Navigation, ev: NavigationEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; +} + +declare class NavigationTransition { + readonly navigationType: NavigationTypeString; + readonly from: NavigationHistoryEntry; + readonly finished: Promise; +} + +interface NavigationHistoryEntryEventMap { + dispose: Event; +} + +interface NavigationHistoryEntry extends EventTarget { + readonly key: string; + readonly id: string; + readonly url: string | null; + readonly index: number; + readonly sameDocument: boolean; + + getState(): unknown; + + ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null; + + addEventListener( + type: K, + listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener( + type: K, + listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; +} + +declare var NavigationHistoryEntry: { + prototype: NavigationHistoryEntry; + new(): NavigationHistoryEntry; +}; + +type NavigationTypeString = "reload" | "push" | "replace" | "traverse"; + +interface NavigationUpdateCurrentEntryOptions { + state: unknown; +} + +interface NavigationOptions { + info?: unknown; +} + +interface NavigationNavigateOptions extends NavigationOptions { + state?: unknown; + history?: "auto" | "push" | "replace"; +} + +interface NavigationReloadOptions extends NavigationOptions { + state?: unknown; +} + +declare class NavigationCurrentEntryChangeEvent extends Event { + constructor(type: string, eventInit?: NavigationCurrentEntryChangeEventInit); + + readonly navigationType: NavigationTypeString | null; + readonly from: NavigationHistoryEntry; +} + +interface NavigationCurrentEntryChangeEventInit extends EventInit { + navigationType?: NavigationTypeString | null; + from: NavigationHistoryEntry; +} + +declare class NavigateEvent extends Event { + constructor(type: string, eventInit?: NavigateEventInit); + + readonly navigationType: NavigationTypeString; + readonly canIntercept: boolean; + readonly userInitiated: boolean; + readonly hashChange: boolean; + readonly hasUAVisualTransition: boolean; + readonly destination: NavigationDestination; + readonly signal: AbortSignal; + readonly formData: FormData | null; + readonly downloadRequest: string | null; + readonly info?: unknown; + + intercept(options?: NavigationInterceptOptions): void; + scroll(): void; +} + +interface NavigateEventInit extends EventInit { + navigationType?: NavigationTypeString; + canIntercept?: boolean; + userInitiated?: boolean; + hashChange?: boolean; + destination: NavigationDestination; + signal: AbortSignal; + formData?: FormData | null; + downloadRequest?: string | null; + info?: unknown; +} + +interface NavigationInterceptOptions { + handler?: () => Promise; + focusReset?: "after-transition" | "manual"; + scroll?: "after-transition" | "manual"; +} + +declare class NavigationDestination { + readonly url: string; + readonly key: string | null; + readonly id: string | null; + readonly index: number; + readonly sameDocument: boolean; + + getState(): unknown; +} diff --git a/types/dom-navigation/ts5.9/tsconfig.json b/types/dom-navigation/ts5.9/tsconfig.json new file mode 100644 index 00000000000000..01e7e8859372af --- /dev/null +++ b/types/dom-navigation/ts5.9/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dom-navigation-tests.ts" + ] +} diff --git a/types/dom-navigation/tsconfig.json b/types/dom-navigation/tsconfig.json index 01e7e8859372af..c90b5a2c4d72c8 100644 --- a/types/dom-navigation/tsconfig.json +++ b/types/dom-navigation/tsconfig.json @@ -11,7 +11,8 @@ "strictNullChecks": true, "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "exactOptionalPropertyTypes": true }, "files": [ "index.d.ts", diff --git a/types/nova-editor-node/package.json b/types/nova-editor-node/package.json index fba96830b4097e..c1ad752674d522 100644 --- a/types/nova-editor-node/package.json +++ b/types/nova-editor-node/package.json @@ -10,10 +10,5 @@ "devDependencies": { "@types/nova-editor-node": "workspace:." }, - "owners": [ - { - "name": "Cameron Little", - "githubUsername": "apexskier" - } - ] + "owners": [] } diff --git a/types/npmcli__arborist/package.json b/types/npmcli__arborist/package.json index 338362027d2211..585c408f871641 100644 --- a/types/npmcli__arborist/package.json +++ b/types/npmcli__arborist/package.json @@ -19,10 +19,6 @@ { "name": "Emily M Klassen", "githubUsername": "forivall" - }, - { - "name": "Russell Haering", - "githubUsername": "russellhaering" } ] } diff --git a/types/three/.eslintrc.json b/types/three/.eslintrc.json index 79ee5b5a1a5836..848216e00f01b5 100644 --- a/types/three/.eslintrc.json +++ b/types/three/.eslintrc.json @@ -1,5 +1,10 @@ { "rules": { - "@definitelytyped/no-single-element-tuple-type": "off" + "@definitelytyped/no-relative-import-in-test": "off", + "@definitelytyped/no-single-element-tuple-type": "off", + "@definitelytyped/prefer-declare-function": "off", + "@definitelytyped/strict-export-declare-modifiers": "off", + "@typescript-eslint/no-empty-interface": "off", + "jsdoc/check-tag-names": "off" } } diff --git a/types/three/examples/jsm/Addons.d.ts b/types/three/examples/jsm/Addons.d.ts index a901ce0e811759..285b5e3a1f02df 100644 --- a/types/three/examples/jsm/Addons.d.ts +++ b/types/three/examples/jsm/Addons.d.ts @@ -123,8 +123,6 @@ export * from "./loaders/VTKLoader.js"; export * from "./loaders/XYZLoader.js"; export * from "./materials/LDrawConditionalLineMaterial.js"; -export * from "./materials/MeshGouraudMaterial.js"; -export * from "./materials/MeshPostProcessingMaterial.js"; export * from "./math/Capsule.js"; export * from "./math/ColorConverter.js"; @@ -225,7 +223,6 @@ export * from "./shaders/FocusShader.js"; export * from "./shaders/FreiChenShader.js"; export * from "./shaders/FXAAShader.js"; export * from "./shaders/GammaCorrectionShader.js"; -export * from "./shaders/GodRaysShader.js"; export * from "./shaders/GTAOShader.js"; export * from "./shaders/HalftoneShader.js"; export * from "./shaders/HorizontalBlurShader.js"; diff --git a/types/three/examples/jsm/controls/OrbitControls.d.ts b/types/three/examples/jsm/controls/OrbitControls.d.ts index 3c64bec28508de..da803c4b554e68 100644 --- a/types/three/examples/jsm/controls/OrbitControls.d.ts +++ b/types/three/examples/jsm/controls/OrbitControls.d.ts @@ -208,6 +208,9 @@ declare class OrbitControls extends Controls { */ constructor(object: Camera, domElement?: HTMLElement | SVGElement | null); + set cursorStyle(type: "auto" | "grab"); + get cursorStyle(): "auto" | "grab"; + /** * Get the current vertical rotation, in radians. */ @@ -245,6 +248,42 @@ declare class OrbitControls extends Controls { */ reset(): void; + /** + * Programmatically pan the camera. + * + * @param {number} deltaX - The horizontal pan amount in pixels. + * @param {number} deltaY - The vertical pan amount in pixels. + */ + pan(deltaX: number, deltaY: number): void; + + /** + * Programmatically dolly in (zoom in for perspective camera). + * + * @param {number} dollyScale - The dolly scale factor. + */ + dollyIn(dollyScale: number): void; + + /** + * Programmatically dolly out (zoom out for perspective camera). + * + * @param {number} dollyScale - The dolly scale factor. + */ + dollyOut(dollyScale: number): void; + + /** + * Programmatically rotate the camera left (around the vertical axis). + * + * @param {number} angle - The rotation angle in radians. + */ + rotateLeft(angle: number): void; + + /** + * Programmatically rotate the camera up (around the horizontal axis). + * + * @param {number} angle - The rotation angle in radians. + */ + rotateUp(angle: number): void; + /** * Update the controls. Must be called after any manual changes to the camera's transform, or in the update loop if * {@link .autoRotate} or {@link .enableDamping} are set. `deltaTime`, in seconds, is optional, and is only required diff --git a/types/three/examples/jsm/effects/AnaglyphEffect.d.ts b/types/three/examples/jsm/effects/AnaglyphEffect.d.ts index 2313c4f426432d..b7da1009c17299 100644 --- a/types/three/examples/jsm/effects/AnaglyphEffect.d.ts +++ b/types/three/examples/jsm/effects/AnaglyphEffect.d.ts @@ -5,6 +5,10 @@ declare class AnaglyphEffect { colorMatrixRight: Matrix3; + eyeSep: number; + + planeDistance: number; + setSize: (width: number, height: number) => void; render: (scene: Scene, camera: Camera) => void; diff --git a/types/three/examples/jsm/environments/ColorEnvironment.d.ts b/types/three/examples/jsm/environments/ColorEnvironment.d.ts new file mode 100644 index 00000000000000..1a16ce83821409 --- /dev/null +++ b/types/three/examples/jsm/environments/ColorEnvironment.d.ts @@ -0,0 +1,9 @@ +import { ColorRepresentation, Scene } from "three"; + +declare class ColorEnvironment extends Scene { + constructor(color?: ColorRepresentation); + + dispose(): void; +} + +export { ColorEnvironment }; diff --git a/types/three/examples/jsm/gpgpu/BitonicSort.d.ts b/types/three/examples/jsm/gpgpu/BitonicSort.d.ts index d6a04a21c2886b..6f25304690b505 100644 --- a/types/three/examples/jsm/gpgpu/BitonicSort.d.ts +++ b/types/three/examples/jsm/gpgpu/BitonicSort.d.ts @@ -1,20 +1,20 @@ import { Node, Renderer, StorageBufferNode } from "three/webgpu"; -export const getBitonicFlipIndices: (index: Node, blockHeight: Node) => Node; +export const getBitonicFlipIndices: (index: Node, blockHeight: Node) => Node<"uvec2">; -export const getBitonicDisperseIndices: (index: Node, swapSpan: Node) => Node; +export const getBitonicDisperseIndices: (index: Node, swapSpan: Node) => Node<"uvec2">; export interface BitonicSortOptions { workgroupSize?: number | undefined; } -export class BitonicSort { - infoStorage: StorageBufferNode; +export class BitonicSort { + infoStorage: StorageBufferNode; swapOpCount: number; stepCount: number; - constructor(renderer: Renderer, dataBuffer: StorageBufferNode, options?: BitonicSortOptions); + constructor(renderer: Renderer, dataBuffer: StorageBufferNode, options?: BitonicSortOptions); computeStep(renderer: Renderer): Promise; compute(renderer: Renderer): Promise; diff --git a/types/three/examples/jsm/helpers/AnimationPathHelper.d.ts b/types/three/examples/jsm/helpers/AnimationPathHelper.d.ts new file mode 100644 index 00000000000000..9a0a6f79fb1886 --- /dev/null +++ b/types/three/examples/jsm/helpers/AnimationPathHelper.d.ts @@ -0,0 +1,38 @@ +import { + AnimationClip, + BufferGeometry, + ColorRepresentation, + Line, + LineBasicMaterial, + Object3D, + Points, + PointsMaterial, +} from "three"; + +export interface AnimationPathHelperOptions { + color?: ColorRepresentation | undefined; + markerColor?: ColorRepresentation | undefined; + divisions?: number | undefined; + showMarkers?: boolean | undefined; + markerSize?: number | undefined; +} + +declare class AnimationPathHelper extends Object3D { + readonly isAnimationPathHelper: boolean; + + root: Object3D; + clip: AnimationClip; + object: Object3D; + divisions: number; + + line: Line; + points: Points | null; + + constructor(root: Object3D, clip: AnimationClip, object: Object3D, options?: AnimationPathHelperOptions); + + setColor(color: ColorRepresentation): void; + setMarkerColor(color: ColorRepresentation): void; + dispose(): void; +} + +export { AnimationPathHelper }; diff --git a/types/three/examples/jsm/helpers/ViewHelper.d.ts b/types/three/examples/jsm/helpers/ViewHelper.d.ts index d0f9fbb37eb91c..fad9ab248421d2 100644 --- a/types/three/examples/jsm/helpers/ViewHelper.d.ts +++ b/types/three/examples/jsm/helpers/ViewHelper.d.ts @@ -1,10 +1,11 @@ import { Camera, Object3D, Vector3, WebGLRenderer } from "three"; -export class ViewHelper extends Object3D { +declare class ViewHelper extends Object3D { readonly isViewHelper: true; animating: boolean; center: Vector3; + location: { top: number | null; right: number; bottom: number; left: number | null }; render: (renderer: WebGLRenderer) => void; handleClick: (event: MouseEvent) => boolean; @@ -15,3 +16,5 @@ export class ViewHelper extends Object3D { constructor(camera: Camera, domElement: HTMLElement); } + +export { ViewHelper }; diff --git a/types/three/examples/jsm/inspector/tabs/Parameters.d.ts b/types/three/examples/jsm/inspector/tabs/Parameters.d.ts index c1a9d2e5227d32..fb1a609863a1e6 100644 --- a/types/three/examples/jsm/inspector/tabs/Parameters.d.ts +++ b/types/three/examples/jsm/inspector/tabs/Parameters.d.ts @@ -1,3 +1,4 @@ +import { Item } from "../ui/Item.js"; import { Tab } from "../ui/Tab.js"; import { ValueButton, ValueCheckbox, ValueColor, ValueNumber, ValueSelect, ValueSlider } from "../ui/Values.js"; @@ -52,6 +53,8 @@ interface ValueColorWithParameters< declare class ParametersGroup { name: string; + paramList: Item; + constructor(parameters: never, name: string); add( diff --git a/types/three/examples/jsm/inspector/ui/Item.d.ts b/types/three/examples/jsm/inspector/ui/Item.d.ts new file mode 100644 index 00000000000000..0a2cb1474253ed --- /dev/null +++ b/types/three/examples/jsm/inspector/ui/Item.d.ts @@ -0,0 +1,5 @@ +export class Item { + domElement: HTMLDivElement; + + constructor(...data: readonly unknown[]); +} diff --git a/types/three/examples/jsm/libs/meshopt_decoder.module.d.ts b/types/three/examples/jsm/libs/meshopt_decoder.module.d.ts index 2b15567e19daea..8f7ed9999ca3a2 100644 --- a/types/three/examples/jsm/libs/meshopt_decoder.module.d.ts +++ b/types/three/examples/jsm/libs/meshopt_decoder.module.d.ts @@ -1 +1 @@ -export * from "meshoptimizer/meshopt_decoder.module.js"; +export * from "meshoptimizer/decoder"; diff --git a/types/three/examples/jsm/lights/LightProbeGenerator.d.ts b/types/three/examples/jsm/lights/LightProbeGenerator.d.ts index 4b398442b932e7..9c366dfdfa9096 100644 --- a/types/three/examples/jsm/lights/LightProbeGenerator.d.ts +++ b/types/three/examples/jsm/lights/LightProbeGenerator.d.ts @@ -1,10 +1,16 @@ import { CubeTexture, LightProbe, WebGLCubeRenderTarget, WebGLRenderer } from "three"; -import { WebGPURenderer } from "three/webgpu"; +import { CubeRenderTarget, WebGPURenderer } from "three/webgpu"; -export namespace LightProbeGenerator { - function fromCubeTexture(cubeTexture: CubeTexture): LightProbe; - function fromCubeRenderTarget( - renderer: WebGLRenderer | WebGPURenderer, +declare class LightProbeGenerator { + static fromCubeTexture(cubeTexture: CubeTexture): LightProbe; + static fromCubeRenderTarget( + renderer: WebGLRenderer, cubeRenderTarget: WebGLCubeRenderTarget, ): Promise; + static fromCubeRenderTarget( + renderer: WebGPURenderer, + cubeRenderTarget: CubeRenderTarget, + ): Promise; } + +export { LightProbeGenerator }; diff --git a/types/three/examples/jsm/loaders/ColladaLoader.d.ts b/types/three/examples/jsm/loaders/ColladaLoader.d.ts index 38fab405580b8f..70efc74fe7013e 100644 --- a/types/three/examples/jsm/loaders/ColladaLoader.d.ts +++ b/types/three/examples/jsm/loaders/ColladaLoader.d.ts @@ -1,11 +1,34 @@ import { Loader, Scene } from "three"; +export interface ColladaKinematics { + joints: unknown; + getJointValue: unknown; + setJointValue: unknown; +} + +export interface ColladaLibrary { + animations: Record; + clips: Record; + controllers: Record; + images: Record; + effects: Record; + materials: Record; + cameras: Record; + lights: Record; + geometries: Record; + nodes: Record; + visualScenes: Record; + kinematicsModels: Record; + physicsModels: Record; + kinematicsScenes: Record; +} + export interface Collada { - kinematics: object; - library: object; + kinematics?: ColladaKinematics; + library?: ColladaLibrary; scene: Scene; } -export class ColladaLoader extends Loader { - parse(text: string, path: string): Collada; +export class ColladaLoader extends Loader { + parse(text: string, path: string): Collada | null; } diff --git a/types/three/examples/jsm/materials/MeshGouraudMaterial.d.ts b/types/three/examples/jsm/materials/MeshGouraudMaterial.d.ts deleted file mode 100644 index 7d2fb5d97d1c09..00000000000000 --- a/types/three/examples/jsm/materials/MeshGouraudMaterial.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * MeshGouraudMaterial - * - * Lambert illumination model with Gouraud (per-vertex) shading - */ - -import { ShaderMaterial, ShaderMaterialParameters } from "three"; - -/** - * @deprecated Use THREE.MeshLambertMaterial instead. - */ -export class MeshGouraudMaterial extends ShaderMaterial { - isMeshGouraudMaterial: true; - - constructor(parameters?: ShaderMaterialParameters); - - copy(source: MeshGouraudMaterial): this; -} diff --git a/types/three/examples/jsm/materials/MeshPostProcessingMaterial.d.ts b/types/three/examples/jsm/materials/MeshPostProcessingMaterial.d.ts deleted file mode 100644 index 46fca567b13a5d..00000000000000 --- a/types/three/examples/jsm/materials/MeshPostProcessingMaterial.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { MeshPhysicalMaterial, MeshPhysicalMaterialParameters, Texture } from "three"; - -export interface MeshPostProcessingMaterialParameters extends MeshPhysicalMaterialParameters { - aoPassMap?: Texture | null | undefined; - aoPassMapScale?: number | undefined; -} - -export class MeshPostProcessingMaterial extends MeshPhysicalMaterial { - constructor(parameters: MeshPostProcessingMaterialParameters); - - get aoPassMap(): Texture | null | undefined; - set aoPassMap(aoPassMap: Texture | null | undefined); -} diff --git a/types/three/examples/jsm/objects/SkyMesh.d.ts b/types/three/examples/jsm/objects/SkyMesh.d.ts index be7f71535e7e72..7a8922f0404723 100644 --- a/types/three/examples/jsm/objects/SkyMesh.d.ts +++ b/types/three/examples/jsm/objects/SkyMesh.d.ts @@ -1,12 +1,17 @@ import { BoxGeometry, Mesh, NodeMaterial, UniformNode, Vector3 } from "three/webgpu"; declare class SkyMesh extends Mesh { - turbidity: UniformNode; - rayleigh: UniformNode; - mieCoefficient: UniformNode; - mieDirectionalG: UniformNode; - sunPosition: UniformNode; - upUniform: UniformNode; + turbidity: UniformNode<"float", number>; + rayleigh: UniformNode<"float", number>; + mieCoefficient: UniformNode<"float", number>; + mieDirectionalG: UniformNode<"float", number>; + sunPosition: UniformNode<"vec3", Vector3>; + upUniform: UniformNode<"vec3", Vector3>; + cloudScale: UniformNode<"float", number>; + cloudSpeed: UniformNode<"float", number>; + cloudCoverage: UniformNode<"float", number>; + cloudDensity: UniformNode<"float", number>; + cloudElevation: UniformNode<"float", number>; /** * @deprecated diff --git a/types/three/examples/jsm/objects/Water2Mesh.d.ts b/types/three/examples/jsm/objects/Water2Mesh.d.ts index 5ed9cf4002d2ba..ca39102ee86ee9 100644 --- a/types/three/examples/jsm/objects/Water2Mesh.d.ts +++ b/types/three/examples/jsm/objects/Water2Mesh.d.ts @@ -30,19 +30,19 @@ declare class WaterMesh extends Mesh { constructor(geometry: BufferGeometry, options: WaterMeshOptions); } -declare class WaterNode extends TempNode { +declare class WaterNode extends TempNode<"vec4"> { waterBody: WaterMesh; normalMap0: TextureNode; normalMap1: TextureNode; flowMap: TextureNode; - color: UniformNode; - flowDirection: UniformNode; - flowSpeed: UniformNode; - reflectivity: UniformNode; - scale: UniformNode; - flowConfig: UniformNode; + color: UniformNode<"color", Color>; + flowDirection: UniformNode<"vec2", Vector2>; + flowSpeed: UniformNode<"float", number>; + reflectivity: UniformNode<"float", number>; + scale: UniformNode<"float", number>; + flowConfig: UniformNode<"vec3", Vector3>; constructor(options: WaterMeshOptions, waterBody: WaterMesh); diff --git a/types/three/examples/jsm/objects/WaterMesh.d.ts b/types/three/examples/jsm/objects/WaterMesh.d.ts index fe90d37007e1b4..196b9fb627186c 100644 --- a/types/three/examples/jsm/objects/WaterMesh.d.ts +++ b/types/three/examples/jsm/objects/WaterMesh.d.ts @@ -27,12 +27,12 @@ declare class WaterMesh extends Mesh { resolutionScale: number; waterNormals: TextureNode; - alpha: UniformNode; - size: UniformNode; - sunColor: UniformNode; - sunDirection: UniformNode; - waterColor: UniformNode; - distortionScale: UniformNode; + alpha: UniformNode<"float", number>; + size: UniformNode<"float", number>; + sunColor: UniformNode<"color", Color>; + sunDirection: UniformNode<"vec3", Vector3>; + waterColor: UniformNode<"color", Color>; + distortionScale: UniformNode<"float", number>; constructor(geometry: BufferGeometry, options: WaterMeshOptions); } diff --git a/types/three/examples/jsm/postprocessing/EffectComposer.d.ts b/types/three/examples/jsm/postprocessing/EffectComposer.d.ts index ae300491a0c6bb..3ad41398b34f59 100644 --- a/types/three/examples/jsm/postprocessing/EffectComposer.d.ts +++ b/types/three/examples/jsm/postprocessing/EffectComposer.d.ts @@ -1,22 +1,19 @@ -import { Clock, WebGLRenderer, WebGLRenderTarget } from "three"; - -import { FullScreenQuad, Pass } from "./Pass.js"; +import { Timer, WebGLRenderer, WebGLRenderTarget } from "three"; +import { Pass } from "./Pass.js"; import { ShaderPass } from "./ShaderPass.js"; -export { FullScreenQuad } from "./Pass.js"; -export { Pass }; - -export class EffectComposer { - constructor(renderer: WebGLRenderer, renderTarget?: WebGLRenderTarget); +declare class EffectComposer { renderer: WebGLRenderer; renderTarget1: WebGLRenderTarget; renderTarget2: WebGLRenderTarget; writeBuffer: WebGLRenderTarget; readBuffer: WebGLRenderTarget; + renderToScreen: boolean; passes: Pass[]; copyPass: ShaderPass; - clock: Clock; - renderToScreen: boolean; + timer: Timer; + + constructor(renderer: WebGLRenderer, renderTarget?: WebGLRenderTarget); swapBuffers(): void; addPass(pass: Pass): void; @@ -29,3 +26,5 @@ export class EffectComposer { setPixelRatio(pixelRatio: number): void; dispose(): void; } + +export { EffectComposer }; diff --git a/types/three/examples/jsm/postprocessing/UnrealBloomPass.d.ts b/types/three/examples/jsm/postprocessing/UnrealBloomPass.d.ts index 5123441343ca25..bf1575b4bcb39a 100644 --- a/types/three/examples/jsm/postprocessing/UnrealBloomPass.d.ts +++ b/types/three/examples/jsm/postprocessing/UnrealBloomPass.d.ts @@ -3,12 +3,13 @@ import { Color, MeshBasicMaterial, ShaderMaterial, Vector2, Vector3, WebGLRender import { FullScreenQuad, Pass } from "./Pass.js"; export class UnrealBloomPass extends Pass { - constructor(resolution: Vector2, strength: number, radius: number, threshold: number); - resolution: Vector2; strength: number; radius: number; threshold: number; + resolution: Vector2; clearColor: Color; + needsUpdate: boolean; + renderTargetsHorizontal: WebGLRenderTarget[]; renderTargetsVertical: WebGLRenderTarget[]; nMips: number; @@ -20,12 +21,6 @@ export class UnrealBloomPass extends Pass { bloomTintColors: Vector3[]; copyUniforms: object; blendMaterial: ShaderMaterial; - oldClearColor: Color; - oldClearAlpha: number; - basic: MeshBasicMaterial; - fsQuad: FullScreenQuad; - dispose(): void; - getSeparableBlurMaterial(): ShaderMaterial; - getCompositeMaterial(): ShaderMaterial; + constructor(resolution: Vector2, strength: number, radius: number, threshold: number); } diff --git a/types/three/examples/jsm/shaders/GodRaysShader.d.ts b/types/three/examples/jsm/shaders/GodRaysShader.d.ts deleted file mode 100644 index 31b3b6c770a986..00000000000000 --- a/types/three/examples/jsm/shaders/GodRaysShader.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { IUniform } from "three"; - -export const GodRaysDepthMaskShader: { - name: string; - uniforms: { - tInput: IUniform; - }; - vertexShader: string; - fragmentShader: string; -}; - -export const GodRaysGenerateShader: { - name: string; - uniforms: { - tInput: IUniform; - fStepSize: IUniform; - vSunPositionScreenSpace: IUniform; - }; - vertexShader: string; - fragmentShader: string; -}; - -export const GodRaysCombineShader: { - name: string; - uniforms: { - tColors: IUniform; - tGodRays: IUniform; - fGodRayIntensity: IUniform; - }; - vertexShader: string; - fragmentShader: string; -}; - -export const GodRaysFakeSunShader: { - name: string; - uniforms: { - vSunPositionScreenSpace: IUniform; - fAspect: IUniform; - sunColor: IUniform; - bgColor: IUniform; - }; - vertexShader: string; - fragmentShader: string; -}; diff --git a/types/three/examples/jsm/tsl/display/AnaglyphPassNode.d.ts b/types/three/examples/jsm/tsl/display/AnaglyphPassNode.d.ts index 72cb8c7e3a4672..144f6b61db209f 100644 --- a/types/three/examples/jsm/tsl/display/AnaglyphPassNode.d.ts +++ b/types/three/examples/jsm/tsl/display/AnaglyphPassNode.d.ts @@ -1,12 +1,42 @@ import { Camera, Scene } from "three/webgpu"; import StereoCompositePassNode from "./StereoCompositePassNode.js"; +declare const AnaglyphAlgorithm: { + TRUE: "true"; + GREY: "grey"; + COLOUR: "colour"; + HALF_COLOUR: "halfColour"; + DUBOIS: "dubois"; + OPTIMISED: "optimised"; + COMPROMISE: "compromise"; +}; +type AnaglyphAlgorithm = (typeof AnaglyphAlgorithm)[keyof typeof AnaglyphAlgorithm]; + +declare const AnaglyphColorMode: { + RED_CYAN: "redCyan"; + MAGENTA_CYAN: "magentaCyan"; + MAGENTA_GREEN: "magentaGreen"; +}; +type AnaglyphColorMode = (typeof AnaglyphColorMode)[keyof typeof AnaglyphColorMode]; + declare class AnaglyphPassNode extends StereoCompositePassNode { readonly isAnaglyphPassNode: true; + eyeSep: number; + + planeDistance: number; + constructor(scene: Scene, camera: Camera); + + get algorithm(): AnaglyphAlgorithm; + set algorithm(algorithm: AnaglyphAlgorithm); + + get colorMode(): AnaglyphColorMode; + set colorMode(color: AnaglyphColorMode); } export default AnaglyphPassNode; +export { AnaglyphAlgorithm, AnaglyphColorMode }; + export const anaglyphPass: (scene: Scene, camera: Camera) => AnaglyphPassNode; diff --git a/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts b/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts index 6f45988983b7de..38f2fae2f3247a 100644 --- a/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts +++ b/types/three/examples/jsm/tsl/display/AnamorphicNode.d.ts @@ -1,6 +1,6 @@ import { Node, TempNode, Vector2 } from "three/webgpu"; -export default class AnamorphicNode extends TempNode { +export default class AnamorphicNode extends TempNode<"vec4"> { textureNode: Node; thresholdNode: Node; scaleNode: Node; diff --git a/types/three/examples/jsm/tsl/display/BilateralBlurNode.d.ts b/types/three/examples/jsm/tsl/display/BilateralBlurNode.d.ts new file mode 100644 index 00000000000000..7f908e9f669572 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/BilateralBlurNode.d.ts @@ -0,0 +1,27 @@ +import { Node, TempNode, TextureNode } from "three/webgpu"; + +declare class BilateralBlurNode extends TempNode<"vec4"> { + textureNode: TextureNode; + directionNode: Node<"vec2"> | Node<"float"> | null; + sigma: number; + sigmaColor: number; + + constructor( + textureNode: TextureNode, + directionNode?: Node<"vec2"> | Node<"float"> | null, + sigma?: number, + sigmaColor?: number, + ); + + setSize(width: number, height: number): void; + getTextureNode(): TextureNode; +} + +export default BilateralBlurNode; + +export const bilateralBlur: ( + node: Node<"vec4">, + directionNode?: Node<"vec2"> | Node<"float">, + sigma?: number, + sigmaColor?: number, +) => BilateralBlurNode; diff --git a/types/three/examples/jsm/tsl/display/BloomNode.d.ts b/types/three/examples/jsm/tsl/display/BloomNode.d.ts index b2bd8135d7fb96..291e697a37b1f3 100644 --- a/types/three/examples/jsm/tsl/display/BloomNode.d.ts +++ b/types/three/examples/jsm/tsl/display/BloomNode.d.ts @@ -1,12 +1,12 @@ import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class BloomNode extends TempNode { +declare class BloomNode extends TempNode<"vec4"> { inputNode: Node; - strength: UniformNode; - radius: UniformNode; - threshold: UniformNode; + strength: UniformNode<"float", number>; + radius: UniformNode<"float", number>; + threshold: UniformNode<"float", number>; - smoothWidth: UniformNode; + smoothWidth: UniformNode<"float", number>; constructor(inputNode: Node, strength?: number, radius?: number, threshold?: number); diff --git a/types/three/examples/jsm/tsl/display/CRT.d.ts b/types/three/examples/jsm/tsl/display/CRT.d.ts new file mode 100644 index 00000000000000..d5f2702ae0f315 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/CRT.d.ts @@ -0,0 +1,22 @@ +import { Node } from "three/webgpu"; + +export const barrelUV: (curvature?: Node<"float">, coord?: Node<"vec2">) => Node<"vec2">; + +export const barrelMast: (coord: Node<"vec2">) => Node<"float">; + +export const colorBleeding: (color: Node, amount?: Node<"float">) => Node<"vec3">; + +export const scanlines: ( + color: Node<"vec3">, + intensity?: Node<"float">, + count?: Node<"float">, + speed?: Node<"float">, + coord?: Node<"vec2">, +) => Node<"vec3">; + +export const vignette: ( + color: Node<"vec3">, + intensity?: Node<"float">, + smoothness?: Node<"float"> | number, + coord?: Node<"vec2">, +) => Node<"vec3">; diff --git a/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts b/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts index b2689fad2554cd..ec1000829ed2f3 100644 --- a/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts +++ b/types/three/examples/jsm/tsl/display/DenoiseNode.d.ts @@ -7,11 +7,11 @@ declare class DenoiseNode extends TempNode { noiseNode: Node; - lumaPhi: UniformNode; - depthPhi: UniformNode; - normalPhi: UniformNode; - radius: UniformNode; - index: UniformNode; + lumaPhi: UniformNode<"float", number>; + depthPhi: UniformNode<"float", number>; + normalPhi: UniformNode<"float", number>; + radius: UniformNode<"float", number>; + index: UniformNode<"float", number>; constructor(textureNode: Node, depthNode: Node, normalNode: Node, noiseNode: Node, camera: Camera); } diff --git a/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts b/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts index 26f43564e8fced..bee7ffe002f6ed 100644 --- a/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts +++ b/types/three/examples/jsm/tsl/display/DotScreenNode.d.ts @@ -1,19 +1,17 @@ -import { Node, TempNode, UniformNode, Vector2 } from "three/webgpu"; +import { Node, TempNode, UniformNode } from "three/webgpu"; declare class DotScreenNode extends TempNode { inputNode: Node; - center: UniformNode; - angle: UniformNode; - scale: UniformNode; + angle: UniformNode<"float", number>; + scale: UniformNode<"float", number>; - constructor(inputNode: Node, center?: Vector2, angle?: number, scale?: number); + constructor(inputNode: Node, angle?: number, scale?: number); } export default DotScreenNode; export const dotScreen: ( node: Node, - center?: Vector2, angle?: number, scale?: number, ) => DotScreenNode; diff --git a/types/three/examples/jsm/tsl/display/GTAONode.d.ts b/types/three/examples/jsm/tsl/display/GTAONode.d.ts index 8fd6fad03d48e4..2ec5689b87a687 100644 --- a/types/three/examples/jsm/tsl/display/GTAONode.d.ts +++ b/types/three/examples/jsm/tsl/display/GTAONode.d.ts @@ -1,18 +1,18 @@ import { Camera, Node, TempNode, TextureNode, UniformNode, Vector2 } from "three/webgpu"; -declare class GTAONode extends TempNode { +declare class GTAONode extends TempNode<"float"> { depthNode: Node; normalNode: Node; resolutionScale: number; - radius: UniformNode; - resolution: UniformNode; - thickness: UniformNode; - distanceExponent: UniformNode; - distanceFallOff: UniformNode; - scale: UniformNode; - samples: UniformNode; + radius: UniformNode<"float", number>; + resolution: UniformNode<"vec2", Vector2>; + thickness: UniformNode<"float", number>; + distanceExponent: UniformNode<"float", number>; + distanceFallOff: UniformNode<"float", number>; + scale: UniformNode<"float", number>; + samples: UniformNode<"float", number>; useTemporalFiltering: boolean; diff --git a/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts b/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts index 88493f2c50ddb3..94b131ef99179d 100644 --- a/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts +++ b/types/three/examples/jsm/tsl/display/GaussianBlurNode.d.ts @@ -2,10 +2,10 @@ import { Node, TempNode, TextureNode, Vector2 } from "three/webgpu"; export interface GaussianBlurNodeOptions { premultipliedAlpha?: boolean | undefined; - resolution?: Vector2 | undefined; + resolutionScale?: number | undefined; } -declare class GaussianBlurNode extends TempNode { +declare class GaussianBlurNode extends TempNode<"vec4"> { textureNode: TextureNode; directionNode: Node | null; sigma: number; @@ -14,6 +14,8 @@ declare class GaussianBlurNode extends TempNode { premultipliedAlpha: boolean; + readonly isGaussianBlurNode: boolean; + constructor( textureNode: TextureNode, directionNode?: Node | null, diff --git a/types/three/examples/jsm/tsl/display/GodraysNode.d.ts b/types/three/examples/jsm/tsl/display/GodraysNode.d.ts new file mode 100644 index 00000000000000..58e12e10a9e7ec --- /dev/null +++ b/types/three/examples/jsm/tsl/display/GodraysNode.d.ts @@ -0,0 +1,20 @@ +import { Camera, DirectionalLight, PointLight, TempNode, TextureNode, UniformNode } from "three/webgpu"; + +declare class GodraysNode extends TempNode<"vec4"> { + depthNode: TextureNode; + + raymarchSteps: UniformNode<"uint", number>; + density: UniformNode<"float", number>; + maxDensity: UniformNode<"float", number>; + distanceAttenuation: UniformNode<"float", number>; + resolutionScale: number; + + constructor(depthNode: TextureNode, camera: Camera, light: DirectionalLight | PointLight); + + getTextureNode(): TextureNode; + setSize(width: number, height: number): void; +} + +export default GodraysNode; + +export const godrays: (depthNode: TextureNode, camera: Camera, light: DirectionalLight | PointLight) => GodraysNode; diff --git a/types/three/examples/jsm/tsl/display/LensflareNode.d.ts b/types/three/examples/jsm/tsl/display/LensflareNode.d.ts index b2bd8018cca384..adf71ed3feba38 100644 --- a/types/three/examples/jsm/tsl/display/LensflareNode.d.ts +++ b/types/three/examples/jsm/tsl/display/LensflareNode.d.ts @@ -1,4 +1,4 @@ -import { Node, TempNode, TextureNode, UniformNode, Vector3 } from "three/webgpu"; +import { Node, TempNode, TextureNode } from "three/webgpu"; interface LensflareNodeParams { ghostTint?: Node | undefined; @@ -12,11 +12,11 @@ interface LensflareNodeParams { declare class LensflareNode extends TempNode { textureNode: TextureNode; - ghostTintNode: UniformNode; - thresholdNode: UniformNode; - ghostSamplesNode: UniformNode; - ghostSpacingNode: UniformNode; - ghostAttenuationFactorNode: UniformNode; + ghostTintNode: Node<"vec3">; + thresholdNode: Node<"float">; + ghostSamplesNode: Node<"float">; + ghostSpacingNode: Node<"float">; + ghostAttenuationFactorNode: Node<"float">; downSampleRatio: number; constructor(textureNode: TextureNode, params?: LensflareNodeParams); diff --git a/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts b/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts index 3b292e76446a36..c4be4e1395838d 100644 --- a/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts +++ b/types/three/examples/jsm/tsl/display/Lut3DNode.d.ts @@ -1,12 +1,12 @@ -import { Data3DTexture, Node, TempNode, Texture3DNode, UniformNode } from "three/webgpu"; +import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; declare class Lut3DNode extends TempNode { inputNode: Node; - lutNode: Texture3DNode; - size: UniformNode; - intensityNode: UniformNode; + lutNode: TextureNode; + size: UniformNode<"float", number>; + intensityNode: Node<"float">; - constructor(inputNode: Node, lutNode: UniformNode, size: number, intensityNode: UniformNode); + constructor(inputNode: Node, lutNode: TextureNode, size: number, intensityNode: Node); } export default Lut3DNode; diff --git a/types/three/examples/jsm/tsl/display/MotionBlur.d.ts b/types/three/examples/jsm/tsl/display/MotionBlur.d.ts index e2c720ad83df71..b4daaf8ee92f63 100644 --- a/types/three/examples/jsm/tsl/display/MotionBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/MotionBlur.d.ts @@ -4,4 +4,4 @@ export const motionBlur: ( inputNode: Node, velocity: Node, numSamples?: Node, -) => Node; +) => Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/display/OutlineNode.d.ts b/types/three/examples/jsm/tsl/display/OutlineNode.d.ts index 479bc345e9f795..37753dd49ab518 100644 --- a/types/three/examples/jsm/tsl/display/OutlineNode.d.ts +++ b/types/three/examples/jsm/tsl/display/OutlineNode.d.ts @@ -1,4 +1,4 @@ -import { Camera, Node, Object3D, Scene, TempNode, TextureNode, UniformNode } from "three/webgpu"; +import { Camera, Node, Object3D, Scene, TempNode, TextureNode } from "three/webgpu"; export interface OutlineNodeParams { selectedObjects?: Object3D[] | undefined; @@ -7,19 +7,19 @@ export interface OutlineNodeParams { downSampleRatio?: number | undefined; } -declare class OutlineNode extends TempNode { +declare class OutlineNode extends TempNode<"vec4"> { scene: Scene; camera: Camera; selectedObjects: Object3D[]; - edgeThicknessNode: UniformNode; - edgeGlowNode: UniformNode; + edgeThicknessNode: Node<"float">; + edgeGlowNode: Node<"float">; downSampleRatio: number; constructor(scene: Scene, camera: Camera, params?: OutlineNodeParams); - get visibleEdge(): Node; + get visibleEdge(): Node<"float">; - get hiddenEdge(): Node; + get hiddenEdge(): Node<"float">; getTextureNode(): TextureNode; diff --git a/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts b/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts index 6c4223e479fd01..d3523e28eb4a4f 100644 --- a/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts +++ b/types/three/examples/jsm/tsl/display/PixelationPassNode.d.ts @@ -1,27 +1,27 @@ -import { Camera, PassNode, Scene, UniformNode } from "three/webgpu"; +import { Camera, Node, PassNode, Scene } from "three/webgpu"; declare class PixelationPassNode extends PassNode { - pixelSize: UniformNode; - normalEdgeStrength: UniformNode; - depthEdgeStrength: UniformNode; + pixelSize: Node<"float">; + normalEdgeStrength: Node<"float">; + depthEdgeStrength: Node<"float">; readonly isPixelationPassNode: true; constructor( scene: Scene, camera: Camera, - pixelSize: number, - normalEdgeStrength: number, - depthEdgeStrength: number, + pixelSize: Node, + normalEdgeStrength: Node, + depthEdgeStrength: Node, ); } export const pixelationPass: ( scene: Scene, camera: Camera, - pixelSize: UniformNode, - normalEdgeStrength: UniformNode, - depthEdgeStrength: UniformNode, + pixelSize: Node | number, + normalEdgeStrength: Node | number, + depthEdgeStrength: Node | number, ) => PixelationPassNode; export default PixelationPassNode; diff --git a/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts b/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts index e368898288ef90..2171a3b33495c6 100644 --- a/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts +++ b/types/three/examples/jsm/tsl/display/RGBShiftNode.d.ts @@ -2,8 +2,8 @@ import { Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; export default class RGBShiftNode extends TempNode { textureNode: TextureNode; - amount: UniformNode; - angle: UniformNode; + amount: UniformNode<"float", number>; + angle: UniformNode<"float", number>; constructor(textureNode: TextureNode, amount?: number, angle?: number); diff --git a/types/three/examples/jsm/tsl/display/RetroPassNode.d.ts b/types/three/examples/jsm/tsl/display/RetroPassNode.d.ts new file mode 100644 index 00000000000000..0f7b3998aedd22 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/RetroPassNode.d.ts @@ -0,0 +1,17 @@ +import { Camera, Node, PassNode, Scene } from "three/webgpu"; + +export interface RetroPassNodeOptions { + affineDistortion?: Node | null | undefined; + filterTextures?: boolean | undefined; +} + +declare class RetroPassNode extends PassNode { + affineDistortionNode: Node | null; + filterTextures: boolean; + + constructor(scene: Scene, camera: Camera, options?: RetroPassNodeOptions); +} + +export default RetroPassNode; + +export const retroPass: (scene: Scene, camera: Camera, options?: RetroPassNodeOptions) => RetroPassNode; diff --git a/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts b/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts index 3a0760f17a705b..4f53e31abd2d6c 100644 --- a/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSAAPassNode.d.ts @@ -8,7 +8,7 @@ declare class SSAAPassNode extends PassNode { clearColor: Color; clearAlpha: number; - sampleWeight: UniformNode; + sampleWeight: UniformNode<"float", number>; sampleRenderTarget: RenderTarget | null; diff --git a/types/three/examples/jsm/tsl/display/SSGINode.d.ts b/types/three/examples/jsm/tsl/display/SSGINode.d.ts index f2479fa8d1ef42..6a3df43dfbfc31 100644 --- a/types/three/examples/jsm/tsl/display/SSGINode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSGINode.d.ts @@ -1,20 +1,20 @@ import { Node, PerspectiveCamera, TempNode, UniformNode } from "three/webgpu"; -declare class SSGINode extends TempNode { +declare class SSGINode extends TempNode<"vec4"> { beautyNode: Node; depthNode: Node; normalNode: Node; - sliceCount: UniformNode; - stepCount: UniformNode; - aoIntensity: UniformNode; - giIntensity: UniformNode; - radius: UniformNode; - useScreenSpaceSampling: UniformNode; - expFactor: UniformNode; - thickness: UniformNode; - useLinearThickness: UniformNode; - backfaceLighting: UniformNode; + sliceCount: UniformNode<"uint", number>; + stepCount: UniformNode<"uint", number>; + aoIntensity: UniformNode<"float", number>; + giIntensity: UniformNode<"float", number>; + radius: UniformNode<"float", number>; + useScreenSpaceSampling: UniformNode<"bool", boolean>; + expFactor: UniformNode<"float", number>; + thickness: UniformNode<"float", number>; + useLinearThickness: UniformNode<"bool", boolean>; + backfaceLighting: UniformNode<"float", number>; useTemporalFiltering: boolean; constructor(beautyNode: Node, depthNode: Node, normalNode: Node, camera: PerspectiveCamera); diff --git a/types/three/examples/jsm/tsl/display/SSRNode.d.ts b/types/three/examples/jsm/tsl/display/SSRNode.d.ts index 4cad8929a7a338..b892ec18f87bc7 100644 --- a/types/three/examples/jsm/tsl/display/SSRNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSRNode.d.ts @@ -1,6 +1,6 @@ import { Camera, Node, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class SSRNode extends TempNode { +declare class SSRNode extends TempNode<"vec4"> { colorNode: Node; depthNode: Node; normalNode: Node; @@ -10,11 +10,11 @@ declare class SSRNode extends TempNode { resolutionScale: number; - maxDistance: UniformNode; - thickness: UniformNode; - opacity: UniformNode; - quality: UniformNode; - blurQuality: UniformNode; + maxDistance: UniformNode<"float", number>; + thickness: UniformNode<"float", number>; + opacity: UniformNode<"float", number>; + quality: UniformNode<"float", number>; + blurQuality: UniformNode<"float", number>; constructor( colorNode: Node, diff --git a/types/three/examples/jsm/tsl/display/SSSNode.d.ts b/types/three/examples/jsm/tsl/display/SSSNode.d.ts index 08944535835b27..16653990ebe729 100644 --- a/types/three/examples/jsm/tsl/display/SSSNode.d.ts +++ b/types/three/examples/jsm/tsl/display/SSSNode.d.ts @@ -1,12 +1,12 @@ import { Camera, DirectionalLight, TempNode, TextureNode, UniformNode } from "three/webgpu"; -declare class SSSNode extends TempNode { +declare class SSSNode extends TempNode<"float"> { depthNode: TextureNode; - maxDistance: UniformNode; - thickness: UniformNode; - shadowIntensity: UniformNode; - quality: UniformNode; + maxDistance: UniformNode<"float", number>; + thickness: UniformNode<"float", number>; + shadowIntensity: UniformNode<"float", number>; + quality: UniformNode<"float", number>; resolutionScale: number; useTemporalFiltering: boolean; diff --git a/types/three/examples/jsm/tsl/display/Shape.d.ts b/types/three/examples/jsm/tsl/display/Shape.d.ts new file mode 100644 index 00000000000000..93589103bbb917 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/Shape.d.ts @@ -0,0 +1,3 @@ +import { Node } from "three/webgpu"; + +export const circle: (scale?: Node<"float">, softness?: Node<"float"> | number, coord?: Node<"vec2">) => Node<"float">; diff --git a/types/three/examples/jsm/tsl/display/TransitionNode.d.ts b/types/three/examples/jsm/tsl/display/TransitionNode.d.ts index 2a0b55e2d15a76..619e63786f9527 100644 --- a/types/three/examples/jsm/tsl/display/TransitionNode.d.ts +++ b/types/three/examples/jsm/tsl/display/TransitionNode.d.ts @@ -25,7 +25,7 @@ export const transition: ( node: Node, nodeB: Node, mixTexture: Node, - mixRatio: UniformNode, - threshold: UniformNode, - useTexture: UniformNode, + mixRatio: Node | number, + threshold: Node | number, + useTexture: Node | number, ) => TransitionNode; diff --git a/types/three/examples/jsm/tsl/display/boxBlur.d.ts b/types/three/examples/jsm/tsl/display/boxBlur.d.ts index a42f9720c62900..a38a052ccb28a1 100644 --- a/types/three/examples/jsm/tsl/display/boxBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/boxBlur.d.ts @@ -7,4 +7,4 @@ export interface BoxBlurOptions { premultipliedAlpha?: boolean | undefined; } -export const boxBlur: (textureNode: Node, options?: BoxBlurOptions) => Node; +export const boxBlur: (textureNode: Node, options?: BoxBlurOptions) => Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/display/depthAwareBlend.d.ts b/types/three/examples/jsm/tsl/display/depthAwareBlend.d.ts new file mode 100644 index 00000000000000..fb21cfd8b432e1 --- /dev/null +++ b/types/three/examples/jsm/tsl/display/depthAwareBlend.d.ts @@ -0,0 +1,15 @@ +import { Camera, Color, Node } from "three/webgpu"; + +export interface DepthAwareBlendOptions { + blendColor?: Node | Color; + edgeRadius?: Node<"int"> | number; + edgeStrength?: Node<"float"> | number; +} + +export const depthAwareBlend: ( + baseNode: Node, + blendNode: Node, + depthNode: Node, + camera: Camera, + options?: DepthAwareBlendOptions, +) => Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/display/hashBlur.d.ts b/types/three/examples/jsm/tsl/display/hashBlur.d.ts index e591cbcd104c9b..f17f8a36cb3942 100644 --- a/types/three/examples/jsm/tsl/display/hashBlur.d.ts +++ b/types/three/examples/jsm/tsl/display/hashBlur.d.ts @@ -10,4 +10,4 @@ export const hashBlur: ( textureNode: Node, bluramount?: Node | number, options?: HashBlurOptions, -) => Node; +) => Node<"vec4">; diff --git a/types/three/examples/jsm/tsl/math/Bayer.d.ts b/types/three/examples/jsm/tsl/math/Bayer.d.ts index f261abbe006fd0..1b95d35633d5fc 100644 --- a/types/three/examples/jsm/tsl/math/Bayer.d.ts +++ b/types/three/examples/jsm/tsl/math/Bayer.d.ts @@ -1,3 +1,5 @@ import { Node } from "three/webgpu"; export const bayer16: (uv: Node) => Node; + +export const bayerDither: (color: Node<"vec3">, steps?: Node<"float">) => Node<"vec3">; diff --git a/types/three/examples/jsm/tsl/utils/Raymarching.d.ts b/types/three/examples/jsm/tsl/utils/Raymarching.d.ts index f42fdc16469723..664df29d623bdb 100644 --- a/types/three/examples/jsm/tsl/utils/Raymarching.d.ts +++ b/types/three/examples/jsm/tsl/utils/Raymarching.d.ts @@ -3,6 +3,6 @@ import { FunctionNode, Node } from "three/webgpu"; export const RaymarchingBox: ( steps: number | Node, callback: - | ((params: { positionRay: Node }) => void) - | FunctionNode<{ positionRay: Node }>, + | ((params: { positionRay: Node<"vec3"> }) => void) + | FunctionNode<{ positionRay: Node<"vec3"> }>, ) => void; diff --git a/types/three/package.json b/types/three/package.json index 8bfc91140eb717..51f09c34d04ec9 100644 --- a/types/three/package.json +++ b/types/three/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/three", - "version": "0.182.9999", + "version": "0.183.9999", "projects": [ "https://threejs.org/" ], @@ -26,7 +26,7 @@ "@types/webxr": ">=0.5.17", "@webgpu/types": "*", "fflate": "~0.8.2", - "meshoptimizer": "~0.22.0" + "meshoptimizer": "~1.0.1" }, "devDependencies": { "@types/three": "workspace:." diff --git a/types/three/src/Three.Core.d.ts b/types/three/src/Three.Core.d.ts index 07a66c051b5504..07c40f4b79ad54 100644 --- a/types/three/src/Three.Core.d.ts +++ b/types/three/src/Three.Core.d.ts @@ -105,6 +105,7 @@ export * from "./math/Euler.js"; export * from "./math/Frustum.js"; export * from "./math/FrustumArray.js"; export * from "./math/Interpolant.js"; +export * from "./math/interpolants/BezierInterpolant.js"; export * from "./math/interpolants/CubicInterpolant.js"; export * from "./math/interpolants/DiscreteInterpolant.js"; export * from "./math/interpolants/LinearInterpolant.js"; @@ -139,7 +140,6 @@ export * from "./objects/SkinnedMesh.js"; export * from "./objects/Sprite.js"; export * from "./renderers/WebGL3DRenderTarget.js"; export * from "./renderers/WebGLArrayRenderTarget.js"; -export * from "./renderers/WebGLCubeRenderTarget.js"; export * from "./renderers/WebGLRenderTarget.js"; export * from "./renderers/webxr/WebXRController.js"; export * from "./scenes/Fog.js"; diff --git a/types/three/src/Three.TSL.d.ts b/types/three/src/Three.TSL.d.ts index 73d3d34b8154f7..454c8b9ad11e19 100644 --- a/types/three/src/Three.TSL.d.ts +++ b/types/three/src/Three.TSL.d.ts @@ -29,7 +29,6 @@ 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; -export const ScriptableNodeResources: typeof TSL.ScriptableNodeResources; export const ShaderNode: typeof TSL.ShaderNode; export const Stack: typeof TSL.Stack; export const Switch: typeof TSL.Switch; @@ -58,7 +57,6 @@ export const arrayBuffer: typeof TSL.arrayBuffer; export const asin: typeof TSL.asin; export const assign: typeof TSL.assign; export const atan: typeof TSL.atan; -export const atan2: typeof TSL.atan2; export const atomicAdd: typeof TSL.atomicAdd; export const atomicAnd: typeof TSL.atomicAnd; export const atomicFunc: typeof TSL.atomicFunc; @@ -98,7 +96,6 @@ 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 burn: typeof TSL.burn; export const builtin: typeof TSL.builtin; export const builtinAOContext: typeof TSL.builtinAOContext; export const builtinShadowContext: typeof TSL.builtinShadowContext; @@ -127,6 +124,7 @@ export const clamp: typeof TSL.clamp; 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 code: typeof TSL.code; export const color: typeof TSL.color; export const colorSpaceToWorking: typeof TSL.colorSpaceToWorking; @@ -169,17 +167,16 @@ export const directionToFaceDirection: typeof TSL.directionToFaceDirection; export const dispersion: typeof TSL.dispersion; export const distance: typeof TSL.distance; export const div: typeof TSL.div; -export const dodge: typeof TSL.dodge; export const dot: typeof TSL.dot; export const drawIndex: typeof TSL.drawIndex; export const dynamicBufferAttribute: typeof TSL.dynamicBufferAttribute; export const element: typeof TSL.element; export const emissive: typeof TSL.emissive; export const equal: typeof TSL.equal; -export const equals: typeof TSL.equals; export const equirectUV: typeof TSL.equirectUV; export const exp: typeof TSL.exp; export const exp2: typeof TSL.exp2; +export const exponentialHeightFogFactor: typeof TSL.exponentialHeightFogFactor; export const expression: typeof TSL.expression; export const faceDirection: typeof TSL.faceDirection; export const faceForward: typeof TSL.faceForward; @@ -417,7 +414,6 @@ export const oscSquare: typeof TSL.oscSquare; export const oscTriangle: typeof TSL.oscTriangle; export const output: typeof TSL.output; export const outputStruct: typeof TSL.outputStruct; -export const overlay: typeof TSL.overlay; export const overloadingFn: typeof TSL.overloadingFn; export const packHalf2x16: typeof TSL.packHalf2x16; export const packSnorm2x16: typeof TSL.packSnorm2x16; @@ -482,13 +478,10 @@ export const sampler: typeof TSL.sampler; export const samplerComparison: typeof TSL.samplerComparison; export const saturate: typeof TSL.saturate; export const saturation: typeof TSL.saturation; -export const screen: typeof TSL.screen; export const screenCoordinate: typeof TSL.screenCoordinate; export const screenDPR: typeof TSL.screenDPR; export const screenSize: typeof TSL.screenSize; export const screenUV: typeof TSL.screenUV; -export const scriptable: typeof TSL.scriptable; -export const scriptableValue: typeof TSL.scriptableValue; export const select: typeof TSL.select; export const setCurrentStack: typeof TSL.setCurrentStack; export const setName: typeof TSL.setName; @@ -519,7 +512,6 @@ 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 storageObject: typeof TSL.storageObject; export const storageTexture: typeof TSL.storageTexture; export const string: typeof TSL.string; export const struct: typeof TSL.struct; @@ -611,11 +603,14 @@ export const vibrance: typeof TSL.vibrance; export const viewZToLogarithmicDepth: typeof TSL.viewZToLogarithmicDepth; export const viewZToOrthographicDepth: typeof TSL.viewZToOrthographicDepth; export const viewZToPerspectiveDepth: typeof TSL.viewZToPerspectiveDepth; +export const viewZToReversedOrthographicDepth: typeof TSL.viewZToReversedOrthographicDepth; +export const viewZToReversedPerspectiveDepth: typeof TSL.viewZToReversedPerspectiveDepth; export const viewport: typeof TSL.viewport; export const viewportCoordinate: typeof TSL.viewportCoordinate; 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; @@ -630,4 +625,4 @@ export const workgroupId: typeof TSL.workgroupId; export const workingToColorSpace: typeof TSL.workingToColorSpace; export const xor: typeof TSL.xor; -export type { ProxiedObject, Swizzable } from "./nodes/TSL.js"; +export type { ProxiedObject } from "./nodes/TSL.js"; diff --git a/types/three/src/Three.WebGPU.Nodes.d.ts b/types/three/src/Three.WebGPU.Nodes.d.ts index d7c18ce9bb20f8..e3288943b5b5ce 100644 --- a/types/three/src/Three.WebGPU.Nodes.d.ts +++ b/types/three/src/Three.WebGPU.Nodes.d.ts @@ -7,6 +7,7 @@ export { default as Lighting } from "./renderers/common/Lighting.js"; export { default as PostProcessing } from "./renderers/common/PostProcessing.js"; export { default as QuadMesh } from "./renderers/common/QuadMesh.js"; export type { default as Renderer } from "./renderers/common/Renderer.js"; +export { default as RenderPipeline } from "./renderers/common/RenderPipeline.js"; export { default as WebGPURenderer } from "./renderers/webgpu/WebGPURenderer.Nodes.js"; import * as RendererUtils from "./renderers/common/RendererUtils.js"; export { RendererUtils }; @@ -16,6 +17,7 @@ export { default as NodeLoader } from "./loaders/nodes/NodeLoader.js"; export { default as NodeMaterialLoader } from "./loaders/nodes/NodeMaterialLoader.js"; export { default as NodeObjectLoader } from "./loaders/nodes/NodeObjectLoader.js"; export * from "./nodes/Nodes.js"; +export { default as BlendMode } from "./renderers/common/BlendMode.js"; export { default as CanvasTarget } from "./renderers/common/CanvasTarget.js"; export { default as InspectorBase } from "./renderers/common/InspectorBase.js"; import * as TSL from "./nodes/TSL.js"; diff --git a/types/three/src/Three.WebGPU.d.ts b/types/three/src/Three.WebGPU.d.ts index 24ec94d4c5994c..01dda72539d092 100644 --- a/types/three/src/Three.WebGPU.d.ts +++ b/types/three/src/Three.WebGPU.d.ts @@ -7,6 +7,7 @@ export { default as Lighting } from "./renderers/common/Lighting.js"; export { default as PostProcessing } from "./renderers/common/PostProcessing.js"; export { default as QuadMesh } from "./renderers/common/QuadMesh.js"; export type { default as Renderer } from "./renderers/common/Renderer.js"; +export { default as RenderPipeline } from "./renderers/common/RenderPipeline.js"; export { default as WebGPURenderer } from "./renderers/webgpu/WebGPURenderer.js"; import * as RendererUtils from "./renderers/common/RendererUtils.js"; export { RendererUtils }; @@ -16,7 +17,9 @@ export { default as NodeLoader } from "./loaders/nodes/NodeLoader.js"; export { default as NodeMaterialLoader } from "./loaders/nodes/NodeMaterialLoader.js"; export { default as NodeObjectLoader } from "./loaders/nodes/NodeObjectLoader.js"; export * from "./nodes/Nodes.js"; +export { default as BlendMode } from "./renderers/common/BlendMode.js"; export { default as CanvasTarget } from "./renderers/common/CanvasTarget.js"; +export { default as CubeRenderTarget } from "./renderers/common/CubeRenderTarget.js"; export { default as InspectorBase } from "./renderers/common/InspectorBase.js"; import * as TSL from "./nodes/TSL.js"; export { TSL }; diff --git a/types/three/src/Three.d.ts b/types/three/src/Three.d.ts index ac68a78bee168b..63c81747080620 100644 --- a/types/three/src/Three.d.ts +++ b/types/three/src/Three.d.ts @@ -10,8 +10,7 @@ export type { WebGLBindingStates } from "./renderers/webgl/WebGLBindingStates.js export type { WebGLBufferRenderer } from "./renderers/webgl/WebGLBufferRenderer.js"; export type { WebGLCapabilities, WebGLCapabilitiesParameters } from "./renderers/webgl/WebGLCapabilities.js"; export type { WebGLClipping } from "./renderers/webgl/WebGLClipping.js"; -export type { WebGLCubeMaps } from "./renderers/webgl/WebGLCubeMaps.js"; -export type { WebGLCubeUVMaps } from "./renderers/webgl/WebGLCubeUVMaps.js"; +export type { WebGLEnvironments } from "./renderers/webgl/WebGLEnvironments.js"; export type { WebGLExtensions } from "./renderers/webgl/WebGLExtensions.js"; export type { WebGLGeometries } from "./renderers/webgl/WebGLGeometries.js"; export type { WebGLIndexedBufferRenderer } from "./renderers/webgl/WebGLIndexedBufferRenderer.js"; @@ -37,6 +36,7 @@ export type { export type { WebGLTextures } from "./renderers/webgl/WebGLTextures.js"; export type { WebGLUniforms } from "./renderers/webgl/WebGLUniforms.js"; export * from "./renderers/webgl/WebGLUtils.js"; +export * from "./renderers/WebGLCubeRenderTarget.js"; export * from "./renderers/WebGLRenderer.js"; export type { WebXRController, diff --git a/types/three/src/animation/AnimationClip.d.ts b/types/three/src/animation/AnimationClip.d.ts index 2f019fb0eb760d..859483c29eb11f 100644 --- a/types/three/src/animation/AnimationClip.d.ts +++ b/types/three/src/animation/AnimationClip.d.ts @@ -92,7 +92,7 @@ export class AnimationClip { * @static * @deprecated since r175. * @param {Object} animation - A serialized animation clip as JSON. - * @param {Array} bones - An array of bones. + * @param {Array} bones - An array of bones. * @return {?AnimationClip} The new animation clip. */ static parseAnimation(animation: AnimationClipJSON, bones: Array): AnimationClip | null; diff --git a/types/three/src/animation/KeyframeTrack.d.ts b/types/three/src/animation/KeyframeTrack.d.ts index 28a4b822e7be13..f9697d86cdc250 100644 --- a/types/three/src/animation/KeyframeTrack.d.ts +++ b/types/three/src/animation/KeyframeTrack.d.ts @@ -1,5 +1,6 @@ import { InterpolationModes } from "../constants.js"; import { TypedArray, TypedArrayConstructor } from "../core/BufferAttribute.js"; +import { BezierInterpolant } from "../math/interpolants/BezierInterpolant.js"; import { CubicInterpolant } from "../math/interpolants/CubicInterpolant.js"; import { DiscreteInterpolant } from "../math/interpolants/DiscreteInterpolant.js"; import { LinearInterpolant } from "../math/interpolants/LinearInterpolant.js"; @@ -13,7 +14,7 @@ export interface KeyframeTrackJSON { } /** - * Represents s a timed sequence of keyframes, which are composed of lists of + * Represents a timed sequence of keyframes, which are composed of lists of * times and related values, and which are used to animate a specific property * of an object. */ @@ -32,7 +33,7 @@ export class KeyframeTrack { * @param {string} name - The keyframe track's name. * @param {Array} times - A list of keyframe times. * @param {Array} values - A list of keyframe values. - * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type. + * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth|InterpolateBezier)} [interpolation] - The interpolation type. */ constructor( name: string, @@ -78,17 +79,30 @@ export class KeyframeTrack { * @return {CubicInterpolant} The new interpolant. */ InterpolantFactoryMethodSmooth(result?: TypedArray): CubicInterpolant; + /** + * Factory method for creating a new Bezier interpolant. + * + * The Bezier interpolant requires tangent data to be set via the `settings` property + * on the track before creating the interpolant. The settings should contain: + * - `inTangents`: Float32Array with [time, value] pairs per keyframe per component + * - `outTangents`: Float32Array with [time, value] pairs per keyframe per component + * + * @static + * @param {TypedArray} [result] - The result buffer. + * @return {BezierInterpolant} The new interpolant. + */ + InterpolantFactoryMethodBezier(result?: TypedArray): BezierInterpolant; /** * Defines the interpolation factor method for this keyframe track. * - * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} interpolation - The interpolation type. + * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth|InterpolateBezier)} interpolation - The interpolation type. * @return {KeyframeTrack} A reference to this keyframe track. */ setInterpolation(interpolation: InterpolationModes): KeyframeTrack; /** * Returns the current interpolation type. * - * @return {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} The interpolation type. + * @return {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth|InterpolateBezier)} The interpolation type. */ getInterpolation(): InterpolationModes; /** @@ -133,7 +147,7 @@ export class KeyframeTrack { * Optimizes this keyframe track by removing equivalent sequential keys (which are * common in morph target sequences). * - * @return {AnimationClip} A reference to this animation clip. + * @return {KeyframeTrack} A reference to this keyframe track. */ optimize(): this; /** diff --git a/types/three/src/animation/PropertyMixer.d.ts b/types/three/src/animation/PropertyMixer.d.ts index 806b9d16231043..535b70ccdf6440 100644 --- a/types/three/src/animation/PropertyMixer.d.ts +++ b/types/three/src/animation/PropertyMixer.d.ts @@ -20,26 +20,27 @@ export class PropertyMixer { * The keyframe track value size. */ valueSize: number; + buffer: Float64Array | unknown[]; /** - * TODO + * Accumulated weight of the property binding. * * @default 0 */ cumulativeWeight: number; /** - * TODO + * Accumulated additive weight of the property binding. * * @default 0 */ cumulativeWeightAdditive: number; /** - * TODO + * Number of active keyframe tracks currently using this property binding. * * @default 0 */ useCount: number; /** - * TODO + * Number of keyframe tracks referencing this property binding. * * @default 0 */ diff --git a/types/three/src/audio/Audio.d.ts b/types/three/src/audio/Audio.d.ts index 63a944b5e78ae7..57437fcfaf2334 100644 --- a/types/three/src/audio/Audio.d.ts +++ b/types/three/src/audio/Audio.d.ts @@ -1,273 +1,340 @@ import { Object3D } from "../core/Object3D.js"; -import { AudioContext } from "./AudioContext.js"; import { AudioListener } from "./AudioListener.js"; -// Extras / Audio ///////////////////////////////////////////////////////////////////// - /** - * Create a non-positional ( global ) {@link Audio} object. - * This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web {@link Audio} API}. - * @example - * ```typescript + * Represents a non-positional ( global ) audio object. + * + * This and related audio modules make use of the [Web Audio API](https://www.w3.org/TR/webaudio-1.1/). + * + * ```js * // create an AudioListener and add it to the camera * const listener = new THREE.AudioListener(); - * camera.add(listener); - * // create a global {@link Audio} source - * const sound = new THREE.Audio(listener); - * // load a sound and set it as the {@link Audio} object's buffer + * camera.add( listener ); + * + * // create a global audio source + * const sound = new THREE.Audio( listener ); + * + * // load a sound and set it as the Audio object's buffer * const audioLoader = new THREE.AudioLoader(); - * audioLoader.load('sounds/ambient.ogg', function (buffer) { - * sound.setBuffer(buffer); - * sound.setLoop(true); - * sound.setVolume(0.5); - * sound.play(); + * audioLoader.load( 'sounds/ambient.ogg', function( buffer ) { + * sound.setBuffer( buffer ); + * sound.setLoop( true ); + * sound.setVolume( 0.5 ); + * sound.play(); * }); * ``` - * @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox } - * @see Example: {@link https://threejs.org/examples/#webaudio_visualizer | webaudio / visualizer } - * @see {@link https://threejs.org/docs/index.html#api/en/audio/Audio | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/Audio.js | Source} */ -export class Audio extends Object3D { +export class Audio extends Object3D { /** - * Create a new instance of {@link Audio} - * @param listener (required) {@link AudioListener | AudioListener} instance. + * Constructs a new audio. + * + * @param {AudioListener} listener - The global audio listener. */ constructor(listener: AudioListener); - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `Audio` + * The global audio listener. */ - readonly type: string | "Audio"; - + readonly listener: AudioListener; /** - * A reference to the listener object of this audio. + * The audio context. */ - listener: AudioListener; - + readonly context: AudioContext; /** - * The {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext} of the {@link AudioListener | listener} given in the constructor. + * The gain node used for volume control. */ - context: AudioContext; - + readonly gain: GainNode; /** - * A {@link https://developer.mozilla.org/en-US/docs/Web/API/GainNode | GainNode} created using - * {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain | AudioContext.createGain}(). + * Whether to start playback automatically or not. */ - gain: GainNode; - + autoplay: boolean; /** - * Whether to start playback automatically. - * @defaultValue `false` + * A reference to an audio buffer. + * + * Defined via {@link Audio#setBuffer}. + * + * @default null */ - autoplay: boolean; - - buffer: AudioBuffer | null; - + readonly buffer: AudioBuffer | null; /** - * Modify pitch, measured in cents. +/- 100 is a semitone. +/- 1200 is an octave. - * @defaultValue `0` + * Modify pitch, measured in cents. +/- 100 is a semitone. + * +/- 1200 is an octave. + * + * Defined via {@link Audio#setDetune}. + * + * @default 0 */ - detune: number; - + readonly detune: number; /** + * Whether the audio should loop or not. + * + * Defined via {@link Audio#setLoop}. + * * @default false */ - loop: boolean; - + readonly loop: boolean; /** + * Defines where in the audio buffer the replay should + * start, in seconds. + * * @default 0 */ loopStart: number; - /** + * Defines where in the audio buffer the replay should + * stop, in seconds. + * * @default 0 */ loopEnd: number; - /** - * An offset to the time within the {@link Audio} buffer that playback should begin. - * Same as the {@link Audio.offset | offset} parameter of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start | AudioBufferSourceNode.start()}. - * @defaultValue `0` + * An offset to the time within the audio buffer the playback + * should begin, in seconds. + * + * @default 0 */ offset: number; - /** - * Overrides the duration of the audio. Same as the {@link Audio.duration | duration} parameter of - * {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start | AudioBufferSourceNode.start()}. - * @defaultValue `undefined` _to play the whole buffer_. + * Overrides the default duration of the audio. + * + * @default undefined */ duration: number | undefined; - /** - * Speed of playback. - * @defaultValue `1` + * The playback speed. + * + * Defined via {@link Audio#setPlaybackRate}. + * + * @default 1 */ - playbackRate: number; - + readonly playbackRate: number; /** - * Whether the {@link Audio} is currently playing. - * @defaultValue `false` + * Indicates whether the audio is playing or not. + * + * This flag will be automatically set when using {@link Audio#play}, + * {@link Audio#pause}, {@link Audio#stop}. + * + * @default false */ - isPlaying: boolean; - + readonly isPlaying: boolean; /** - * Whether playback can be controlled using the {@link Audio.play | play}(), {@link Audio.pause | pause}() etc. methods. - * @defaultValue `true` + * Indicates whether the audio playback can be controlled + * with method like {@link Audio#play} or {@link Audio#pause}. + * + * This flag will be automatically set when audio sources are + * defined. + * + * @default true */ - hasPlaybackControl: boolean; - + readonly hasPlaybackControl: boolean; /** - * Type of the {@link Audio} source. - * @defaultValue 'empty'. + * Holds a reference to the current audio source. + * + * The property is automatically by one of the `set*()` methods. + * + * @default null */ - sourceType: string; - + readonly source: AudioNode | null; /** - * An {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode | AudioBufferSourceNode} created using - * {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource | AudioContext.createBufferSource()}. + * Defines the source type. + * + * The property is automatically set by one of the `set*()` methods. + * + * @default 'empty' */ - source: AudioScheduledSourceNode | null; - + readonly sourceType: "empty" | "audioNode" | "mediaNode" | "mediaStreamNode" | "buffer"; /** - * Represents an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioNode | AudioNodes}. - * Can be used to apply a variety of low-order filters to create more complex sound effects. - * In most cases, the array contains instances of {@link https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode | BiquadFilterNodes}. - * Filters are set via {@link THREE.Audio.setFilter | Audio.setFilter} or {@link THREE.Audio.setFilters | Audio.setFilters}. - * @defaultValue `[]` + * Can be used to apply a variety of low-order filters to create + * more complex sound effects e.g. via `BiquadFilterNode`. + * + * The property is automatically set by {@link Audio#setFilters}. */ - filters: AudioNode[]; - + readonly filters: AudioNode[]; /** - * Return the {@link Audio.gain | gainNode}. + * Returns the output audio node. + * + * @return {GainNode} The output node. */ - getOutput(): NodeType; - + getOutput(): TNode; /** - * Setup the {@link Audio.source | source} to the audioBuffer, and sets {@link Audio.sourceType | sourceType} to 'audioNode'. - * @remarks Also sets {@link Audio.hasPlaybackControl | hasPlaybackControl} to false. + * Sets the given audio node as the source of this instance. + * + * {@link Audio#sourceType} is set to `audioNode` and {@link Audio#hasPlaybackControl} to `false`. + * + * @param {AudioNode} audioNode - The audio node like an instance of `OscillatorNode`. + * @return {Audio} A reference to this instance. */ - setNodeSource(audioNode: AudioScheduledSourceNode): this; - + setNodeSource(audioNode: AudioNode): this; /** - * Applies the given object of type {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement | HTMLMediaElement} as the source of this audio. - * @remarks Also sets {@link Audio.hasPlaybackControl | hasPlaybackControl} to false. + * Sets the given media element as the source of this instance. + * + * {@link Audio#sourceType} is set to `mediaNode` and {@link Audio#hasPlaybackControl} to `false`. + * + * @param {HTMLMediaElement} mediaElement - The media element. + * @return {Audio} A reference to this instance. */ setMediaElementSource(mediaElement: HTMLMediaElement): this; - /** - * Applies the given object of type {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStream | MediaStream} as the source of this audio. - * @remarks Also sets {@link Audio.hasPlaybackControl | hasPlaybackControl} to false. + * Sets the given media stream as the source of this instance. + * + * {@link Audio#sourceType} is set to `mediaStreamNode` and {@link Audio#hasPlaybackControl} to `false`. + * + * @param {MediaStream} mediaStream - The media stream. + * @return {Audio} A reference to this instance. */ setMediaStreamSource(mediaStream: MediaStream): this; - /** - * Setup the {@link Audio.source | source} to the audioBuffer, and sets {@link Audio.sourceType | sourceType} to 'buffer'. - * @remarks If {@link Audio.autoplay | autoplay}, also starts playback. + * Sets the given audio buffer as the source of this instance. + * + * {@link Audio#sourceType} is set to `buffer` and {@link Audio#hasPlaybackControl} to `true`. + * + * @param {AudioBuffer} audioBuffer - The audio buffer. + * @return {Audio} A reference to this instance. */ setBuffer(audioBuffer: AudioBuffer): this; - /** - * If {@link Audio.hasPlaybackControl | hasPlaybackControl} is true, starts playback. + * Starts the playback of the audio. + * + * Can only be used with compatible audio sources that allow playback control. + * + * @param {number} [delay=0] - The delay, in seconds, at which the audio should start playing. + * @return {Audio|undefined} A reference to this instance. */ - play(delay?: number): this; - + play(delay?: number): this | undefined; /** - * If {@link Audio.hasPlaybackControl | hasPlaybackControl} is true, pauses playback. + * Pauses the playback of the audio. + * + * Can only be used with compatible audio sources that allow playback control. + * + * @return {Audio|undefined} A reference to this instance. */ - pause(): this; - + pause(): this | undefined; /** - * If {@link Audio.hasPlaybackControl | hasPlaybackControl} is enabled, stops playback. - * @param delay (optional) - The delay, in seconds, at which the audio should start playing. + * Stops the playback of the audio. + * + * Can only be used with compatible audio sources that allow playback control. + * + * @param {number} [delay=0] - The delay, in seconds, at which the audio should stop playing. + * @return {Audio|undefined} A reference to this instance. */ - stop(delay?: number): this; - + stop(delay?: number): this | undefined; /** - * Called automatically when playback finished. + * Connects to the audio source. This is used internally on + * initialisation and when setting / removing filters. + * + * @return {Audio} A reference to this instance. */ - onEnded(): void; - + connect(): this; /** - * Connect to the {@link THREE.Audio.source | Audio.source} - * @remarks This is used internally on initialisation and when setting / removing filters. + * Disconnects to the audio source. This is used internally on + * initialisation and when setting / removing filters. + * + * @return {Audio|undefined} A reference to this instance. */ - connect(): this; + disconnect(): this | undefined; /** - * Disconnect from the {@link THREE.Audio.source | Audio.source} - * @remarks This is used internally when setting / removing filters. + * Returns the current set filters. + * + * @return {Array} The list of filters. */ - disconnect(): this; - + getFilters(): AudioNode[]; /** - * Returns the detuning of oscillation in cents. + * Sets an array of filters and connects them with the audio source. + * + * @param {Array} [value] - A list of filters. + * @return {Audio} A reference to this instance. */ - getDetune(): number; + setFilters(value?: AudioNode[]): this; /** * Defines the detuning of oscillation in cents. - * @param value Expects a `Float` + * + * @param {number} value - The detuning of oscillation in cents. + * @return {Audio} A reference to this instance. */ setDetune(value: number): this; - /** - * Returns the first element of the {@link Audio.filters | filters} array. + * Returns the detuning of oscillation in cents. + * + * @return {number} The detuning of oscillation in cents. */ - getFilter(): AudioNode; + getDetune(): number; /** - * Applies a single filter node to the audio. + * Returns the first filter in the list of filters. + * + * @return {AudioNode|undefined} The first filter in the list of filters. */ - setFilter(filter: AudioNode): this; - + getFilter(): AudioNode | undefined; /** - * Returns the {@link Audio.filters | filters} array. + * Applies a single filter node to the audio. + * + * @param {AudioNode} [filter] - The filter to set. + * @return {Audio} A reference to this instance. */ - getFilters(): AudioNode[]; + setFilter(filter?: AudioNode): this; /** - * Applies an array of filter nodes to the audio. - * @param value Arrays of filters. + * Sets the playback rate. + * + * Can only be used with compatible audio sources that allow playback control. + * + * @param {number} [value] - The playback rate to set. + * @return {Audio|undefined} A reference to this instance. */ - setFilters(value: AudioNode[]): this; - + setPlaybackRate(value?: number): this | undefined; /** - * Return the value of {@link Audio.playbackRate | playbackRate}. + * Returns the current playback rate. + + * @return {number} The playback rate. */ getPlaybackRate(): number; /** - * If {@link Audio.hasPlaybackControl | hasPlaybackControl} is enabled, set the {@link Audio.playbackRate | playbackRate} to `value`. - * @param value Expects a `Float` + * Automatically called when playback finished. */ - setPlaybackRate(value: number): this; - + onEnded(): void; /** - * Return the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop | source.loop} (whether playback should loop). + * Returns the loop flag. + * + * Can only be used with compatible audio sources that allow playback control. + * + * @return {boolean} Whether the audio should loop or not. */ getLoop(): boolean; /** - * Set {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loop | source.loop} to `value` (whether playback should loop). - * @param value + * Sets the loop flag. + * + * Can only be used with compatible audio sources that allow playback control. + * + * @param {boolean} value - Whether the audio should loop or not. + * @return {Audio|undefined} A reference to this instance. */ - setLoop(value: boolean): this; - + setLoop(value: boolean): this | undefined; /** - * Set {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loopStart | source.loopStart} to `value`. - * @param value Expects a `Float` + * Sets the loop start value which defines where in the audio buffer the replay should + * start, in seconds. + * + * @param {number} value - The loop start value. + * @return {Audio} A reference to this instance. */ setLoopStart(value: number): this; /** - * Set {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/loopEnd | source.loopEnd} to `value`. - * @param value Expects a `Float` + * Sets the loop end value which defines where in the audio buffer the replay should + * stop, in seconds. + * + * @param {number} value - The loop end value. + * @return {Audio} A reference to this instance. */ setLoopEnd(value: number): this; - /** - * Return the current volume. + * Returns the volume. + * + * @return {number} The volume. */ getVolume(): number; /** - * Set the volume. - * @param value Expects a `Float` + * Sets the volume. + * + * @param {number} value - The volume to set. + * @return {Audio} A reference to this instance. */ setVolume(value: number): this; + copy(source: Audio, recursive?: boolean): this; + clone(recursive?: boolean): this; } diff --git a/types/three/src/audio/AudioAnalyser.d.ts b/types/three/src/audio/AudioAnalyser.d.ts index 474583ec782a86..b59d6b9161843c 100644 --- a/types/three/src/audio/AudioAnalyser.d.ts +++ b/types/three/src/audio/AudioAnalyser.d.ts @@ -1,58 +1,63 @@ import { Audio } from "./Audio.js"; /** - * Create a {@link AudioAnalyser} object, which uses an {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode | AnalyserNode} to analyse audio data. - * This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web Audio API}. - * @example - * ```typescript + * This class can be used to analyse audio data. + * + * ```js * // create an AudioListener and add it to the camera * const listener = new THREE.AudioListener(); - * camera.add(listener); + * camera.add( listener ); + * * // create an Audio source - * const sound = new THREE.Audio(listener); + * const sound = new THREE.Audio( listener ); + * * // load a sound and set it as the Audio object's buffer * const audioLoader = new THREE.AudioLoader(); - * audioLoader.load('sounds/ambient.ogg', function (buffer) { - * sound.setBuffer(buffer); - * sound.setLoop(true); - * sound.setVolume(0.5); - * sound.play(); + * audioLoader.load( 'sounds/ambient.ogg', function( buffer ) { + * sound.setBuffer( buffer ); + * sound.setLoop(true); + * sound.setVolume(0.5); + * sound.play(); * }); + * * // create an AudioAnalyser, passing in the sound and desired fftSize - * const analyser = new THREE.AudioAnalyser(sound, 32); + * const analyser = new THREE.AudioAnalyser( sound, 32 ); + * * // get the average frequency of the sound * const data = analyser.getAverageFrequency(); * ``` - * @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox } - * @see Example: {@link https://threejs.org/examples/#webaudio_visualizer | webaudio / visualizer } - * @see {@link https://threejs.org/docs/index.html#api/en/audio/AudioAnalyser | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/AudioAnalyser.js | Source} */ export class AudioAnalyser { /** - * Create a new {@link {@link AudioAnalyser} | AudioAnalyser}. - * @param audio - * @param fftSize See {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize | AnalyserNode.fftSize }. Expects a `unsigned integer`. Default `2048`. + * Constructs a new audio analyzer. + * + * @param {Audio} audio - The audio to analyze. + * @param {number} [fftSize=2048] - The window size in samples that is used when performing a Fast Fourier Transform (FFT) to get frequency domain data. */ constructor(audio: Audio, fftSize?: number); - /** - * An {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode | AnalyserNode} used to analyze audio. + * The global audio listener. */ analyser: AnalyserNode; - /** - * A Uint8Array with size determined by {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount | analyser.frequencyBinCount} used to hold analysis data. + * Holds the analyzed data. */ data: Uint8Array; - /** - * Uses the Web Audio's {@link https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData | getByteFrequencyData} method + * Returns an array with frequency data of the audio. + * + * Each item in the array represents the decibel value for a specific frequency. + * The frequencies are spread linearly from 0 to 1/2 of the sample rate. + * For example, for 48000 sample rate, the last item of the array will represent + * the decibel value for 24000 Hz. + * + * @return {Uint8Array} The frequency data. */ getFrequencyData(): Uint8Array; - /** - * Get the average of the frequencies returned by the {@link AudioAnalyser.getFrequencyData | getFrequencyData} method. + * Returns the average of the frequencies returned by {@link AudioAnalyser#getFrequencyData}. + * + * @return {number} The average frequency. */ getAverageFrequency(): number; } diff --git a/types/three/src/audio/AudioContext.d.ts b/types/three/src/audio/AudioContext.d.ts index 50a7f3d6e8c234..32fe4f168516ab 100644 --- a/types/three/src/audio/AudioContext.d.ts +++ b/types/three/src/audio/AudioContext.d.ts @@ -1,19 +1,19 @@ /** - * This contains methods for setting up an {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext}. - * Used internally by the {@link AudioListener | AudioListener} and {@link AudioLoader | AudioLoader} classes. - * This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web Audio API}. - * @see {@link https://threejs.org/docs/index.html#api/en/audio/AudioContext | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/AudioContext.js | Source} + * Manages the global audio context in the engine. + * + * @hideconstructor */ -export namespace AudioContext { +export class AudioContext { /** - * Return the value of the variable `context` in the outer scope, if defined, otherwise set it to a new {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext}. + * Returns the global native audio context. + * + * @return {AudioContext} The native audio context. */ - function getContext(): AudioContext; - + static getContext(): AudioContext; /** - * Set the variable `context` in the outer scope to `value`. - * @param value + * Allows to set the global native audio context from outside. + * + * @param {AudioContext} value - The native context to set. */ - function setContext(context: AudioContext): void; + static setContext(value: AudioContext): void; } diff --git a/types/three/src/audio/AudioListener.d.ts b/types/three/src/audio/AudioListener.d.ts index 743d67ea2f3373..cef5078898bfed 100644 --- a/types/three/src/audio/AudioListener.d.ts +++ b/types/three/src/audio/AudioListener.d.ts @@ -1,96 +1,75 @@ import { Object3D } from "../core/Object3D.js"; -import { AudioContext } from "./AudioContext.js"; /** - * The {@link AudioListener} represents a virtual {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioListener | listener} of the all positional and non-positional audio effects in the scene. - * A three.js application usually creates a single instance of {@link AudioListener} * @remarks - * It is a mandatory constructor parameter for audios entities like {@link Audio | Audio} and {@link PositionalAudio | PositionalAudio}. - * In most cases, the listener object is a child of the camera - * So the 3D transformation of the camera represents the 3D transformation of the listener. - * @example - * ```typescript - * // create an {@link AudioListener} and add it to the camera - * const listener = new THREE.AudioListener(); - * camera.add(listener); - * // create a global audio source - * const sound = new THREE.Audio(listener); - * // load a sound and set it as the Audio object's buffer - * const audioLoader = new THREE.AudioLoader(); - * audioLoader.load('sounds/ambient.ogg', function (buffer) { - * sound.setBuffer(buffer); - * sound.setLoop(true); - * sound.setVolume(0.5); - * sound.play(); - * }); - * ``` - * @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox } - * @see Example: {@link https://threejs.org/examples/#webaudio_timing | webaudio / timing } - * @see Example: {@link https://threejs.org/examples/#webaudio_visualizer | webaudio / visualizer } - * @see {@link https://threejs.org/docs/index.html#api/en/audio/AudioListener | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/AudioListener.js | Source} + * The class represents a virtual listener of the all positional and non-positional audio effects + * in the scene. A three.js application usually creates a single listener. It is a mandatory + * constructor parameter for audios entities like {@link Audio} and {@link PositionalAudio}. + * + * In most cases, the listener object is a child of the camera. So the 3D transformation of the + * camera represents the 3D transformation of the listener. */ export class AudioListener extends Object3D { /** - * Create a new AudioListener. + * The native audio context. */ - constructor(); - + readonly context: AudioContext; /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `AudioListener` + * The gain node used for volume control. */ - readonly type: string | "AudioListener"; - + readonly gain: GainNode; /** - * The {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext | AudioContext} of the {@link {@link AudioListener} | listener} given in the constructor. + * An optional filter. + * + * Defined via {@link AudioListener#setFilter}. + * + * @default null */ - context: AudioContext; - + readonly filter: AudioNode | null; /** - * A {@link https://developer.mozilla.org/en-US/docs/Web/API/GainNode | GainNode} created using - * {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain | AudioContext.createGain()}. + * Time delta values required for `linearRampToValueAtTime()` usage. + * + * @default 0 */ - gain: GainNode; - - /** - * @defaultValue `null` - */ - filter: AudioNode; - + readonly timeDelta: number; /** - * Time delta value for audio entities. Use in context of {@link https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/linearRampToValueAtTime | AudioParam.linearRampToValueAtTimeDefault()}. - * @defaultValue `0` - */ - timeDelta: number; - - /** - * Return the {@link AudioListener.gain | gainNode}. + * Returns the listener's input node. + * + * This method is used by other audio nodes to connect to this listener. + * + * @return {GainNode} The input node. */ getInput(): GainNode; /** - * Set the {@link AudioListener.filter | filter} property to `null`. + * Removes the current filter from this listener. + * + * @return {AudioListener} A reference to this listener. */ removeFilter(): this; - /** - * Returns the value of the {@link AudioListener.filter | filter} property. + * Returns the current set filter. + * + * @return {?AudioNode} The filter. */ - getFilter(): AudioNode; + getFilter(): AudioNode | null; /** - * Set the {@link AudioListener.filter | filter} property to `value`. - * @param value + * Sets the given filter to this listener. + * + * @param {AudioNode} value - The filter to set. + * @return {AudioListener} A reference to this listener. */ setFilter(value: AudioNode): this; - /** - * Return the volume. + * Returns the applications master volume. + * + * @return {number} The master volume. */ getMasterVolume(): number; - /** - * Set the volume. - * @param value + * Sets the applications master volume. This volume setting affects + * all audio nodes in the scene. + * + * @param {number} value - The master volume to set. + * @return {AudioListener} A reference to this listener. */ setMasterVolume(value: number): this; } diff --git a/types/three/src/audio/PositionalAudio.d.ts b/types/three/src/audio/PositionalAudio.d.ts index d72d106746cf1b..35dafbecb8572a 100644 --- a/types/three/src/audio/PositionalAudio.d.ts +++ b/types/three/src/audio/PositionalAudio.d.ts @@ -1,101 +1,108 @@ import { Audio } from "./Audio.js"; -import { AudioListener } from "./AudioListener.js"; /** - * Create a positional audio object. - * This uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API | Web Audio API}. - * @example - * ```typescript + * Represents a positional audio object. + * + * ```js * // create an AudioListener and add it to the camera * const listener = new THREE.AudioListener(); - * camera.add(listener); - * // create the {@link PositionalAudio} object (passing in the listener) - * const sound = new THREE.PositionalAudio(listener); - * // load a sound and set it as the {@link PositionalAudio} object's buffer + * camera.add( listener ); + * + * // create the PositionalAudio object (passing in the listener) + * const sound = new THREE.PositionalAudio( listener ); + * + * // load a sound and set it as the PositionalAudio object's buffer * const audioLoader = new THREE.AudioLoader(); - * audioLoader.load('sounds/song.ogg', function (buffer) { - * sound.setBuffer(buffer); - * sound.setRefDistance(20); - * sound.play(); + * audioLoader.load( 'sounds/song.ogg', function( buffer ) { + * sound.setBuffer( buffer ); + * sound.setRefDistance( 20 ); + * sound.play(); * }); + * * // create an object for the sound to play from - * const sphere = new THREE.SphereGeometry(20, 32, 16); - * const material = new THREE.MeshPhongMaterial({ - * color: 0xff2200 - * }); - * const mesh = new THREE.Mesh(sphere, material); - * scene.add(mesh); + * const sphere = new THREE.SphereGeometry( 20, 32, 16 ); + * const material = new THREE.MeshPhongMaterial( { color: 0xff2200 } ); + * const mesh = new THREE.Mesh( sphere, material ); + * scene.add( mesh ); + * * // finally add the sound to the mesh - * mesh.add(sound); - * ``` - * @see Example: {@link https://threejs.org/examples/#webaudio_orientation | webaudio / orientation } - * @see Example: {@link https://threejs.org/examples/#webaudio_sandbox | webaudio / sandbox } - * @see Example: {@link https://threejs.org/examples/#webaudio_timing | webaudio / timing } - * @see {@link https://threejs.org/docs/index.html#api/en/audio/PositionalAudio | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/PositionalAudio.js | Source} + * mesh.add( sound ); */ export class PositionalAudio extends Audio { /** - * Create a new instance of {@link PositionalAudio} - * @param listener (required) {@link AudioListener | AudioListener} instance. - */ - constructor(listener: AudioListener); - - /** - * The PositionalAudio's {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode | PannerNode}. - */ - panner: PannerNode; - - /** - * Returns the {@link PositionalAudio.panner | panner}. + * The panner node represents the location, direction, and behavior of an audio + * source in 3D space. */ - getOutput(): PannerNode; - + readonly panner: PannerNode; + disconnect(): this; /** - * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance | panner.refDistance}. + * Returns the current reference distance. + * + * @return {number} The reference distance. */ getRefDistance(): number; /** - * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance | panner.refDistance}. - * @param value Expects a `Float` + * Defines the reference distance for reducing volume as the audio source moves + * further from the listener – i.e. the distance at which the volume reduction + * starts taking effect. + * + * @param {number} value - The reference distance to set. + * @return {PositionalAudio} A reference to this instance. */ setRefDistance(value: number): this; - /** - * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor | panner.rolloffFactor}. + * Returns the current rolloff factor. + * + * @return {number} The rolloff factor. */ getRolloffFactor(): number; /** - * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor | panner.rolloffFactor}. - * @param value Expects a `Float` + * Defines how quickly the volume is reduced as the source moves away from the listener. + * + * @param {number} value - The rolloff factor. + * @return {PositionalAudio} A reference to this instance. */ setRolloffFactor(value: number): this; - /** - * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel | panner.distanceModel}. + * Returns the current distance model. + * + * @return {('linear'|'inverse'|'exponential')} The distance model. */ - getDistanceModel(): string; + getDistanceModel(): "linear" | "inverse" | "exponential"; /** - * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel | panner.distanceModel}. - * @param value + * Defines which algorithm to use to reduce the volume of the audio source + * as it moves away from the listener. + * + * Read [the spec](https://www.w3.org/TR/webaudio-1.1/#enumdef-distancemodeltype) + * for more details. + * + * @param {('linear'|'inverse'|'exponential')} value - The distance model to set. + * @return {PositionalAudio} A reference to this instance. */ - setDistanceModel(value: string): this; - + setDistanceModel(value: "linear" | "inverse" | "exponential"): this; /** - * Returns the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance | panner.maxDistance}. + * Returns the current max distance. + * + * @return {number} The max distance. */ getMaxDistance(): number; /** - * Sets the value of {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance | panner.maxDistance}. - * @param value Expects a `Float` + * Defines the maximum distance between the audio source and the listener, + * after which the volume is not reduced any further. + * + * This value is used only by the `linear` distance model. + * + * @param {number} value - The max distance. + * @return {PositionalAudio} A reference to this instance. */ setMaxDistance(value: number): this; - /** - * This method can be used in order to transform an omnidirectional sound into a {@link https://developer.mozilla.org/en-US/docs/Web/API/PannerNode | directional sound}. - * @param coneInnerAngle Expects a `Float` - * @param coneOuterAngle Expects a `Float` - * @param coneOuterGain Expects a `Float` + * Sets the directional cone in which the audio can be listened. + * + * @param {number} coneInnerAngle - An angle, in degrees, of a cone inside of which there will be no volume reduction. + * @param {number} coneOuterAngle - An angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by the `coneOuterGain` parameter. + * @param {number} coneOuterGain - The amount of volume reduction outside the cone defined by the `coneOuterAngle`. When set to `0`, no sound can be heard. + * @return {PositionalAudio} A reference to this instance. */ setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): this; } diff --git a/types/three/src/cameras/ArrayCamera.d.ts b/types/three/src/cameras/ArrayCamera.d.ts index 314e6342fad86d..d78e0b97585ce2 100644 --- a/types/three/src/cameras/ArrayCamera.d.ts +++ b/types/three/src/cameras/ArrayCamera.d.ts @@ -1,38 +1,35 @@ import { PerspectiveCamera } from "./PerspectiveCamera.js"; /** - * {@link ArrayCamera} can be used in order to efficiently render a scene with a predefined set of cameras - * @remarks - * This is an important performance aspect for rendering VR scenes. - * An instance of {@link ArrayCamera} always has an array of sub cameras - * It's mandatory to define for each sub camera the `viewport` property which determines the part of the viewport that is rendered with this camera. - * @see Example: {@link https://threejs.org/examples/#webgl_camera_array | camera / array } - * @see {@link https://threejs.org/docs/index.html#api/en/cameras/ArrayCamera | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/ArrayCamera.js | Source} + * This type of camera can be used in order to efficiently render a scene with a + * predefined set of cameras. This is an important performance aspect for + * rendering VR scenes. + * + * An instance of `ArrayCamera` always has an array of sub cameras. It's mandatory + * to define for each sub camera the `viewport` property which determines the + * part of the viewport that is rendered with this camera. */ export class ArrayCamera extends PerspectiveCamera { /** - * Read-only flag to check if a given object is of type {@link ArrayCamera}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * Constructs a new array camera. + * + * @param {Array} [array=[]] - An array of perspective sub cameras. */ - readonly isArrayCamera: true; - + constructor(array?: PerspectiveCamera[]); /** - * Whether this camera is used with multiview rendering or not. + * This flag can be used for type testing. + * + * @default true */ - isMultiViewCamera: boolean; - + readonly isArrayCamera: boolean; /** - * An array of cameras. - * @defaultValue `[]` + * Whether this camera is used with multiview rendering or not. + * + * @default false */ - cameras: PerspectiveCamera[]; - - index: number; - + readonly isMultiViewCamera: boolean; /** - * An array of cameras. + * An array of perspective sub cameras. */ - constructor(cameras?: PerspectiveCamera[]); + cameras: PerspectiveCamera[]; } diff --git a/types/three/src/cameras/Camera.d.ts b/types/three/src/cameras/Camera.d.ts index 0384a91d87e1e2..1015d405641150 100644 --- a/types/three/src/cameras/Camera.d.ts +++ b/types/three/src/cameras/Camera.d.ts @@ -1,81 +1,42 @@ import { CoordinateSystem } from "../constants.js"; -import { Layers } from "../core/Layers.js"; import { Object3D } from "../core/Object3D.js"; import { Matrix4 } from "../math/Matrix4.js"; -import { Vector3 } from "../math/Vector3.js"; import { Vector4 } from "../math/Vector4.js"; /** - * Abstract base class for cameras - * @remarks - * This class should always be inherited when you build a new camera. - * @see {@link https://threejs.org/docs/index.html#api/en/cameras/Camera | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/Camera.js | Source} + * Abstract base class for cameras. This class should always be inherited + * when you build a new camera. */ export class Camera extends Object3D { /** - * Read-only flag to check if a given object is of type {@link Camera}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isCamera: true; - - /** - * @override - * @defaultValue `Camera` - */ - override readonly type: string | "Camera"; - - /** - * @override - * The {@link Layers | layers} that the {@link Camera} is a member of. - * @remarks Objects must share at least one layer with the {@link Camera} to be n when the camera's viewpoint is rendered. - * @defaultValue `new THREE.Layers()` + * This flag can be used for type testing. + * + * @default true */ - override layers: Layers; - + readonly isCamera: boolean; /** - * This is the inverse of matrixWorld. - * @remarks MatrixWorld contains the Matrix which has the world transform of the {@link Camera} . - * @defaultValue {@link Matrix4 | `new THREE.Matrix4()`} + * The inverse of the camera's world matrix. */ matrixWorldInverse: Matrix4; - /** - * This is the matrix which contains the projection. - * @defaultValue {@link Matrix4 | `new THREE.Matrix4()`} + * The camera's projection matrix. */ projectionMatrix: Matrix4; - /** - * This is the inverse of projectionMatrix. - * @defaultValue {@link Matrix4 | `new THREE.Matrix4()`} + * The inverse of the camera's projection matrix. */ projectionMatrixInverse: Matrix4; - - coordinateSystem: CoordinateSystem; - - viewport?: Vector4; - /** - * @remarks - * Note that this class is not intended to be called directly; you probably want a - * {@link PerspectiveCamera | PerspectiveCamera} or - * {@link OrthographicCamera | OrthographicCamera} instead. + * The coordinate system in which the camera is used. */ - constructor(); - + coordinateSystem: CoordinateSystem; + viewport?: Vector4; /** * The flag that indicates whether the camera uses a reversed depth buffer. * * @default false */ get reversedDepth(): boolean; - - /** - * Returns a {@link Vector3 | Vector3} representing the world space direction in which the {@link Camera} is looking. - * @remarks Note: A {@link Camera} looks down its local, negative z-axis. - * @param target The result will be copied into this Vector3. - */ - getWorldDirection(target: Vector3): Vector3; + copy(source: Camera, recursive?: boolean): this; + clone(): this; } diff --git a/types/three/src/cameras/CubeCamera.d.ts b/types/three/src/cameras/CubeCamera.d.ts index 9d9aae0a058980..2b80c720e3359b 100644 --- a/types/three/src/cameras/CubeCamera.d.ts +++ b/types/three/src/cameras/CubeCamera.d.ts @@ -1,6 +1,7 @@ import { CoordinateSystem } from "../constants.js"; import { Object3D } from "../core/Object3D.js"; import { RenderTarget } from "../core/RenderTarget.js"; +import CubeRenderTarget from "../renderers/common/CubeRenderTarget.js"; import { WebGLCubeRenderTarget } from "../renderers/WebGLCubeRenderTarget.js"; import { Camera } from "./Camera.js"; @@ -21,12 +22,13 @@ export interface CubeCameraRenderer { } /** - * Creates **6** {@link THREE.PerspectiveCamera | cameras} that render to a {@link THREE.WebGLCubeRenderTarget | WebGLCubeRenderTarget}. - * @remarks The cameras are added to the {@link children} array. - * @example - * ```typescript + * A special type of camera that is positioned in 3D space to render its surroundings into a + * cube render target. The render target can then be used as an environment map for rendering + * realtime reflections in your scene. + * + * ```js * // Create cube render target - * const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 128, { generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } ); + * const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 256, { generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } ); * * // Create cube camera * const cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget ); @@ -46,40 +48,42 @@ export interface CubeCameraRenderer { * car.visible = true; * renderer.render( scene, camera ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_materials_cubemap_dynamic | materials / cubemap / dynamic } - * @see {@link https://threejs.org/docs/index.html#api/en/cameras/CubeCamera | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/CubeCamera.js | Source} */ export class CubeCamera extends Object3D { /** - * Constructs a {@link CubeCamera} that contains 6 {@link PerspectiveCamera | PerspectiveCameras} that render to a {@link THREE.WebGLCubeRenderTarget | WebGLCubeRenderTarget}. - * @param near The near clipping distance. - * @param far The far clipping distance. - * @param renderTarget The destination cube render target. + * Constructs a new cube camera. + * + * @param {number} near - The camera's near plane. + * @param {number} far - The camera's far plane. + * @param {WebGLCubeRenderTarget} renderTarget - The cube render target. */ - constructor(near: number, far: number, renderTarget: WebGLCubeRenderTarget); - + constructor(near: number, far: number, renderTarget: WebGLCubeRenderTarget | CubeRenderTarget); /** - * @override - * @defaultValue `CubeCamera` + * A reference to the cube render target. */ - override readonly type: string | "CubeCamera"; - + renderTarget: WebGLCubeRenderTarget; /** - * The destination cube render target. + * The current active coordinate system. + * + * @default null + */ + coordinateSystem: CoordinateSystem | null; + /** + * The current active mipmap level + * + * @default 0 */ - renderTarget: WebGLCubeRenderTarget; - - coordinateSystem: CoordinateSystem; - activeMipmapLevel: number; - + /** + * Must be called when the coordinate system of the cube camera is changed. + */ updateCoordinateSystem(): void; - /** - * Call this to update the {@link CubeCamera.renderTarget | renderTarget}. - * @param renderer The current WebGL renderer - * @param scene The current scene + * Calling this method will render the given scene with the given renderer + * into the cube render target of the camera. + * + * @param {(Renderer|WebGLRenderer)} renderer - The renderer. + * @param {Scene} scene - The scene to render. */ update(renderer: CubeCameraRenderer, scene: Object3D): void; } diff --git a/types/three/src/cameras/OrthographicCamera.d.ts b/types/three/src/cameras/OrthographicCamera.d.ts index 745d114164d332..dc2aee6db4de58 100644 --- a/types/three/src/cameras/OrthographicCamera.d.ts +++ b/types/three/src/cameras/OrthographicCamera.d.ts @@ -26,63 +26,48 @@ export interface OrthographicCameraJSON extends Object3DJSON { } /** - * Camera that uses {@link https://en.wikipedia.org/wiki/Orthographic_projection | orthographic projection}. - * In this projection mode, an object's size in the rendered image stays constant regardless of its distance from the camera. - * This can be useful for rendering 2D scenes and UI elements, amongst other things. - * @example - * ```typescript - * const camera = new THREE.OrthographicCamera(width / -2, width / 2, height / 2, height / -2, 1, 1000); - * scene.add(camera); + * Camera that uses [orthographic projection](https://en.wikipedia.org/wiki/Orthographic_projection). + * + * In this projection mode, an object's size in the rendered image stays + * constant regardless of its distance from the camera. This can be useful + * for rendering 2D scenes and UI elements, amongst other things. + * + * ```js + * const camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + * scene.add( camera ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_camera | camera } - * @see Example: {@link https://threejs.org/examples/#webgl_interactive_cubes_ortho | interactive / cubes / ortho } - * @see Example: {@link https://threejs.org/examples/#webgl_materials_cubemap_dynamic | materials / cubemap / dynamic } - * @see Example: {@link https://threejs.org/examples/#webgl_postprocessing_advanced | postprocessing / advanced } - * @see Example: {@link https://threejs.org/examples/#webgl_postprocessing_dof2 | postprocessing / dof2 } - * @see Example: {@link https://threejs.org/examples/#webgl_postprocessing_godrays | postprocessing / godrays } - * @see Example: {@link https://threejs.org/examples/#webgl_rtt | rtt } - * @see Example: {@link https://threejs.org/examples/#webgl_shaders_tonemapping | shaders / tonemapping } - * @see Example: {@link https://threejs.org/examples/#webgl_shadowmap | shadowmap } - * @see {@link https://threejs.org/docs/index.html#api/en/cameras/OrthographicCamera | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/OrthographicCamera.js | Source} */ export class OrthographicCamera extends Camera { /** - * Creates a new {@link OrthographicCamera}. - * @remarks Together these define the camera's {@link https://en.wikipedia.org/wiki/Viewing_frustum | viewing frustum}. - * @param left Camera frustum left plane. Default `-1`. - * @param right Camera frustum right plane. Default `1`. - * @param top Camera frustum top plane. Default `1`. - * @param bottom Camera frustum bottom plane. Default `-1`. - * @param near Camera frustum near plane. Default `0.1`. - * @param far Camera frustum far plane. Default `2000`. + * Constructs a new orthographic camera. + * + * @param {number} [left=-1] - The left plane of the camera's frustum. + * @param {number} [right=1] - The right plane of the camera's frustum. + * @param {number} [top=1] - The top plane of the camera's frustum. + * @param {number} [bottom=-1] - The bottom plane of the camera's frustum. + * @param {number} [near=0.1] - The camera's near plane. + * @param {number} [far=2000] - The camera's far plane. */ constructor(left?: number, right?: number, top?: number, bottom?: number, near?: number, far?: number); - - /** - * Read-only flag to check if a given object is of type {@link OrthographicCamera}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isOrthographicCamera: true; - /** - * @override - * @defaultValue `OrthographicCamera` + * This flag can be used for type testing. + * + * @default true */ - override readonly type: string | "OrthographicCamera"; - + readonly isOrthographicCamera: boolean; /** - * Gets or sets the zoom factor of the camera. - * @defaultValue `1` + * The zoom factor of the camera. + * + * @default 1 */ zoom: number; - /** - * Set by {@link setViewOffset | .setViewOffset()}. - * @defaultValue `null` + * Represents the frustum window specification. This property should not be edited + * directly but via {@link PerspectiveCamera#setViewOffset} and {@link PerspectiveCamera#clearViewOffset}. + * + * @default null */ - view: null | { + view: { enabled: boolean; fullWidth: number; fullHeight: number; @@ -90,85 +75,70 @@ export class OrthographicCamera extends Camera { offsetY: number; width: number; height: number; - }; - + } | null; /** - * Camera frustum left plane. - * @remarks Expects a `Float` - * @defaultValue `-1` + * The left plane of the camera's frustum. + * + * @default -1 */ left: number; - /** - * Camera frustum right plane. - * @remarks Expects a `Float` - * @defaultValue `1` + * The right plane of the camera's frustum. + * + * @default 1 */ right: number; - /** - * Camera frustum top plane. - * @remarks Expects a `Float` - * @defaultValue `1` + * The top plane of the camera's frustum. + * + * @default 1 */ top: number; - /** - * Camera frustum bottom plane. - * @remarks Expects a `Float`. - * @defaultValue `-1` + * The bottom plane of the camera's frustum. + * + * @default -1 */ bottom: number; - /** - * Camera frustum near plane.`. - * @remarks The valid range is between `0` and the current value of the {@link far | .far} plane. - * @remarks Note that, unlike for the {@link THREE.PerspectiveCamera | PerspectiveCamera}, `0` is a valid value for an {@link THREE.OrthographicCamera | OrthographicCamera's} near plane. - * @remarks Expects a `Float` - * @defaultValue `0.1` + * The camera's near plane. The valid range is greater than `0` + * and less than the current value of {@link OrthographicCamera#far}. + * + * Note that, unlike for the {@link PerspectiveCamera}, `0` is a + * valid value for an orthographic camera's near plane. + * + * @default 0.1 */ near: number; - /** - * Camera frustum far plane. - * @remarks Must be greater than the current value of {@link near | .near} plane. - * @remarks Expects a `Float` - * @defaultValue `2000` + * The camera's far plane. Must be greater than the + * current value of {@link OrthographicCamera#near}. + * + * @default 2000 */ far: number; - + copy(source: OrthographicCamera, recursive?: boolean): this; /** - * Updates the camera projection matrix - * @remarks Must be called after any change of parameters. + * Sets an offset in a larger frustum. This is useful for multi-window or + * multi-monitor/multi-machine setups. + * + * @param {number} fullWidth - The full width of multiview setup. + * @param {number} fullHeight - The full height of multiview setup. + * @param {number} x - The horizontal offset of the subcamera. + * @param {number} y - The vertical offset of the subcamera. + * @param {number} width - The width of subcamera. + * @param {number} height - The height of subcamera. + * @see {@link PerspectiveCamera#setViewOffset} */ - updateProjectionMatrix(): void; - + setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void; /** - * Sets an offset in a larger {@link https://en.wikipedia.org/wiki/Viewing_frustum | viewing frustum} - * @remarks - * This is useful for multi-window or multi-monitor/multi-machine setups - * For an example on how to use it see {@link PerspectiveCamera.setViewOffset | PerspectiveCamera}. - * @see {@link THREE.PerspectiveCamera.setViewOffset | PerspectiveCamera}. - * @param fullWidth Full width of multiview setup Expects a `Float`. - * @param fullHeight Full height of multiview setup Expects a `Float`. - * @param x Horizontal offset of subcamera Expects a `Float`. - * @param y Vertical offset of subcamera Expects a `Float`. - * @param width Width of subcamera Expects a `Float`. - * @param height Height of subcamera Expects a `Float`. + * Removes the view offset from the projection matrix. */ - setViewOffset( - fullWidth: number, - fullHeight: number, - offsetX: number, - offsetY: number, - width: number, - height: number, - ): void; - + clearViewOffset(): void; /** - * Removes any offset set by the {@link setViewOffset | .setViewOffset} method. + * Updates the camera's projection matrix. Must be called after any change of + * camera properties. */ - clearViewOffset(): void; - + updateProjectionMatrix(): void; toJSON(meta?: JSONMeta): OrthographicCameraJSON; } diff --git a/types/three/src/cameras/PerspectiveCamera.d.ts b/types/three/src/cameras/PerspectiveCamera.d.ts index 60567105f33db2..dfdc717c031888 100644 --- a/types/three/src/cameras/PerspectiveCamera.d.ts +++ b/types/three/src/cameras/PerspectiveCamera.d.ts @@ -31,98 +31,83 @@ export interface PerspectiveCameraJSON extends Object3DJSON { } /** - * Camera that uses {@link https://en.wikipedia.org/wiki/Perspective_(graphical) | perspective projection}. - * This projection mode is designed to mimic the way the human eye sees - * @remarks - * It is the most common projection mode used for rendering a 3D scene. - * @example - * ```typescript - * const camera = new THREE.PerspectiveCamera(45, width / height, 1, 1000); - * scene.add(camera); + * Camera that uses [perspective projection](https://en.wikipedia.org/wiki/Perspective_(graphical)). + * + * This projection mode is designed to mimic the way the human eye sees. It + * is the most common projection mode used for rendering a 3D scene. + * + * ```js + * const camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); + * scene.add( camera ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_blending | animation / skinning / blending } - * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_morph | animation / skinning / morph } - * @see Example: {@link https://threejs.org/examples/#webgl_effects_stereo | effects / stereo } - * @see Example: {@link https://threejs.org/examples/#webgl_interactive_cubes | interactive / cubes } - * @see Example: {@link https://threejs.org/examples/#webgl_loader_collada_skinning | loader / collada / skinning } - * @see {@link https://threejs.org/docs/index.html#api/en/cameras/PerspectiveCamera | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js | Source} */ export class PerspectiveCamera extends Camera { /** - * Creates a new {@link PerspectiveCamera}. - * @remarks Together these define the camera's {@link https://en.wikipedia.org/wiki/Viewing_frustum | viewing frustum}. - * @param fov Camera frustum vertical field of view. Default `50`. - * @param aspect Camera frustum aspect ratio. Default `1`. - * @param near Camera frustum near plane. Default `0.1`. - * @param far Camera frustum far plane. Default `2000`. + * Constructs a new perspective camera. + * + * @param {number} [fov=50] - The vertical field of view. + * @param {number} [aspect=1] - The aspect ratio. + * @param {number} [near=0.1] - The camera's near plane. + * @param {number} [far=2000] - The camera's far plane. */ constructor(fov?: number, aspect?: number, near?: number, far?: number); - - /** - * Read-only flag to check if a given object is of type {@link Camera}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isPerspectiveCamera: true; - - /** - * @override - * @defaultValue `PerspectiveCamera` - */ - override readonly type: string | "PerspectiveCamera"; - /** - * Gets or sets the zoom factor of the camera. - * @defaultValue `1` + * This flag can be used for type testing. + * + * @default true */ - zoom: number; - + readonly isPerspectiveCamera: boolean; /** - * Camera frustum vertical field of view, from bottom to top of view, in degrees. - * @remarks Expects a `Float` - * @defaultValue `50` + * The vertical field of view, from bottom to top of view, + * in degrees. + * + * @default 50 */ fov: number; - /** - * Camera frustum aspect ratio, usually the canvas width / canvas height. - * @remarks Expects a `Float` - * @defaultValue `1`, _(square canvas)_. + * The zoom factor of the camera. + * + * @default 1 */ - aspect: number; - + zoom: number; /** - * Camera frustum near plane. - * @remarks The valid range is greater than `0` and less than the current value of the {@link far | .far} plane. - * @remarks Note that, unlike for the {@link THREE.OrthographicCamera | OrthographicCamera}, `0` is **not** a valid value for a {@link PerspectiveCamera |PerspectiveCamera's}. near plane. - * @defaultValue `0.1` - * @remarks Expects a `Float` + * The camera's near plane. The valid range is greater than `0` + * and less than the current value of {@link PerspectiveCamera#far}. + * + * Note that, unlike for the {@link OrthographicCamera}, `0` is not a + * valid value for a perspective camera's near plane. + * + * @default 0.1 */ near: number; - /** - * Camera frustum far plane. - * @remarks Must be greater than the current value of {@link near | .near} plane. - * @remarks Expects a `Float` - * @defaultValue `2000` + * The camera's far plane. Must be greater than the + * current value of {@link PerspectiveCamera#near}. + * + * @default 2000 */ far: number; - /** - * Object distance used for stereoscopy and depth-of-field effects. - * @remarks This parameter does not influence the projection matrix unless a {@link THREE.StereoCamera | StereoCamera} is being used. - * @remarks Expects a `Float` - * @defaultValue `10` + * Object distance used for stereoscopy and depth-of-field effects. This + * parameter does not influence the projection matrix unless a + * {@link StereoCamera} is being used. + * + * @default 10 */ focus: number; - /** - * Frustum window specification or null. - * This is set using the {@link setViewOffset | .setViewOffset} method and cleared using {@link clearViewOffset | .clearViewOffset}. - * @defaultValue `null` + * The aspect ratio, usually the canvas width / canvas height. + * + * @default 1 + */ + aspect: number; + /** + * Represents the frustum window specification. This property should not be edited + * directly but via {@link PerspectiveCamera#setViewOffset} and {@link PerspectiveCamera#clearViewOffset}. + * + * @default null */ - view: null | { + view: { enabled: boolean; fullWidth: number; fullHeight: number; @@ -130,125 +115,127 @@ export class PerspectiveCamera extends Camera { offsetY: number; width: number; height: number; - }; - + } | null; /** - * Film size used for the larger axis. - * This parameter does not influence the projection matrix unless {@link filmOffset | .filmOffset} is set to a nonzero value. - * @remarks Expects a `Float` - * @defaultValue `35`, _millimeters_. + * Film size used for the larger axis. Default is `35` (millimeters). This + * parameter does not influence the projection matrix unless {@link PerspectiveCamera#filmOffset} + * is set to a nonzero value. + * + * @default 35 */ filmGauge: number; - /** - * Horizontal off-center offset in the same unit as {@link filmGauge | .filmGauge}. - * @remarks Expects a `Float` - * @defaultValue `0` + * Horizontal off-center offset in the same unit as {@link PerspectiveCamera#filmGauge}. + * + * @default 0 */ filmOffset: number; - + copy(source: PerspectiveCamera, recursive?: boolean): this; /** - * Returns the focal length of the current {@link .fov | fov} in respect to {@link filmGauge | .filmGauge}. + * Sets the FOV by focal length in respect to the current {@link PerspectiveCamera#filmGauge}. + * + * The default film gauge is 35, so that the focal length can be specified for + * a 35mm (full frame) camera. + * + * @param {number} focalLength - Values for focal length and film gauge must have the same unit. */ - getFocalLength(): number; - + setFocalLength(focalLength: number): void; /** - * Sets the FOV by focal length in respect to the current {@link filmGauge | .filmGauge}. - * @remarks By default, the focal length is specified for a `35mm` (full frame) camera. - * @param focalLength Expects a `Float` + * Returns the focal length from the current {@link PerspectiveCamera#fov} and + * {@link PerspectiveCamera#filmGauge}. + * + * @return {number} The computed focal length. */ - setFocalLength(focalLength: number): void; - + getFocalLength(): number; /** - * Returns the current vertical field of view angle in degrees considering {@link zoom | .zoom}. + * Returns the current vertical field of view angle in degrees considering {@link PerspectiveCamera#zoom}. + * + * @return {number} The effective FOV. */ getEffectiveFOV(): number; - /** - * Returns the width of the image on the film - * @remarks - * If {@link aspect | .aspect}. is greater than or equal to one (landscape format), the result equals {@link filmGauge | .filmGauge}. + * Returns the width of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or + * equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}. + * + * @return {number} The film width. */ getFilmWidth(): number; - /** - * Returns the height of the image on the film - * @remarks - * If {@link aspect | .aspect}. is less than or equal to one (portrait format), the result equals {@link filmGauge | .filmGauge}. + * Returns the height of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or + * equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}. + * + * @return {number} The film width. */ getFilmHeight(): number; - /** * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction. - * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle. + * Sets `minTarget` and `maxTarget` to the coordinates of the lower-left and upper-right corners of the view rectangle. + * + * @param {number} distance - The viewing distance. + * @param {Vector2} minTarget - The lower-left corner of the view rectangle is written into this vector. + * @param {Vector2} maxTarget - The upper-right corner of the view rectangle is written into this vector. */ getViewBounds(distance: number, minTarget: Vector2, maxTarget: Vector2): void; - /** * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction. - * Copies the result into the target Vector2, where x is width and y is height. + * + * @param {number} distance - The viewing distance. + * @param {Vector2} target - The target vector that is used to store result where x is width and y is height. + * @returns {Vector2} The view size. */ getViewSize(distance: number, target: Vector2): Vector2; - /** - * Sets an offset in a larger frustum. - * @remarks - * This is useful for multi-window or multi-monitor/multi-machine setups. + * Sets an offset in a larger frustum. This is useful for multi-window or + * multi-monitor/multi-machine setups. * - * For example, if you have 3x2 monitors and each monitor is _1920x1080_ and + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and * the monitors are in grid like this * ``` - * ┌───┬───┬───┐ - * │ A │ B │ C │ - * ├───┼───┼───┤ - * │ D │ E │ F │ - * └───┴───┴───┘ + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ * ``` - * then for each monitor you would call it like this - * ```typescript - * const w = 1920; - * const h = 1080; - * const fullWidth = w * 3; - * const fullHeight = h * 2; - * - * // Monitor - A - * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); - * // Monitor - B - * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); - * // Monitor - C - * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); - * // Monitor - D - * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); - * // Monitor - E - * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); - * // Monitor - F - * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); + * then for each monitor you would call it like this: + * ```js + * const w = 1920; + * const h = 1080; + * const fullWidth = w * 3; + * const fullHeight = h * 2; + * + * // --A-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * // --B-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * // --C-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * // --D-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * // --E-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * // --F-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); * ``` + * * Note there is no reason monitors have to be the same size or in a grid. - * @param fullWidth Full width of multiview setup Expects a `Float`. - * @param fullHeight Full height of multiview setup Expects a `Float`. - * @param x Horizontal offset of subcamera Expects a `Float`. - * @param y Vertical offset of subcamera Expects a `Float`. - * @param width Width of subcamera Expects a `Float`. - * @param height Height of subcamera Expects a `Float`. + * + * @param {number} fullWidth - The full width of multiview setup. + * @param {number} fullHeight - The full height of multiview setup. + * @param {number} x - The horizontal offset of the subcamera. + * @param {number} y - The vertical offset of the subcamera. + * @param {number} width - The width of subcamera. + * @param {number} height - The height of subcamera. */ setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void; - /** - * Removes any offset set by the {@link setViewOffset | .setViewOffset} method. + * Removes the view offset from the projection matrix. */ clearViewOffset(): void; - /** - * Updates the camera projection matrix - * @remarks Must be called after any change of parameters. + * Updates the camera's projection matrix. Must be called after any change of + * camera properties. */ updateProjectionMatrix(): void; - - /** - * @deprecated Use {@link PerspectiveCamera.setFocalLength | .setFocalLength()} and {@link PerspectiveCamera.filmGauge | .filmGauge} instead. - */ - setLens(focalLength: number, frameHeight?: number): void; - toJSON(meta?: JSONMeta): PerspectiveCameraJSON; } diff --git a/types/three/src/cameras/StereoCamera.d.ts b/types/three/src/cameras/StereoCamera.d.ts index 3f359e3e0c8b5d..bc0a15999d6d06 100644 --- a/types/three/src/cameras/StereoCamera.d.ts +++ b/types/three/src/cameras/StereoCamera.d.ts @@ -1,50 +1,44 @@ -import { Camera } from "./Camera.js"; import { PerspectiveCamera } from "./PerspectiveCamera.js"; /** - * Dual {@link PerspectiveCamera | PerspectiveCamera}s used for effects such as - * {@link https://en.wikipedia.org/wiki/Anaglyph_3D | 3D Anaglyph} or - * {@link https://en.wikipedia.org/wiki/parallax_barrier | Parallax Barrier}. - * @see Example: {@link https://threejs.org/examples/#webgl_effects_anaglyph | effects / anaglyph } - * @see Example: {@link https://threejs.org/examples/#webgl_effects_parallaxbarrier | effects / parallaxbarrier } - * @see Example: {@link https://threejs.org/examples/#webgl_effects_stereo | effects / stereo } - * @see {@link https://threejs.org/docs/index.html#api/en/cameras/StereoCamera | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/StereoCamera.js | Source} + * A special type of camera that uses two perspective cameras with + * stereoscopic projection. Can be used for rendering stereo effects + * like [3D Anaglyph](https://en.wikipedia.org/wiki/Anaglyph_3D) or + * [Parallax Barrier](https://en.wikipedia.org/wiki/parallax_barrier). */ -export class StereoCamera extends Camera { - constructor(); - - type: "StereoCamera"; - +export class StereoCamera { + /** + * The type property is used for detecting the object type + * in context of serialization/deserialization. + */ + readonly type: string; /** - * @remarks Expects a `Float` - * @defaultValue `1` + * The aspect. + * + * @default 1 */ aspect: number; - /** - * @remarks Expects a `Float` - * @defaultValue `0.064` + * The eye separation which represents the distance + * between the left and right camera. + * + * @default 0.064 */ eyeSep: number; - /** - * The Left camera. - * A {@link PerspectiveCamera } added to {@link THREE.PerspectiveCamera.layers | layer 1} - * @remarks Objects to be rendered by the **left** camera must also be added to this layer. + * The camera representing the left eye. This is added to layer `1` so objects to be + * rendered by the left camera must also be added to this layer. */ cameraL: PerspectiveCamera; - /** - * The Right camera. - * A {@link PerspectiveCamera } added to {@link THREE.PerspectiveCamera.layers | layer 2} - * @remarks Objects to be rendered by the **right** camera must also be added to this layer. + * The camera representing the right eye. This is added to layer `2` so objects to be + * rendered by the right camera must also be added to this layer. */ cameraR: PerspectiveCamera; - /** - * Update the stereo cameras based on the camera passed in. - * @param camera + * Updates the stereo camera based on the given perspective camera. + * + * @param {PerspectiveCamera} camera - The perspective camera. */ update(camera: PerspectiveCamera): void; } diff --git a/types/three/src/constants.d.ts b/types/three/src/constants.d.ts index d1ce5c543382ce..7ea818f27f5d96 100644 --- a/types/three/src/constants.d.ts +++ b/types/three/src/constants.d.ts @@ -50,13 +50,15 @@ export const AdditiveBlending: 2; export const SubtractiveBlending: 3; export const MultiplyBlending: 4; export const CustomBlending: 5; +export const MaterialBlending: 6; export type Blending = | typeof NoBlending | typeof NormalBlending | typeof AdditiveBlending | typeof SubtractiveBlending | typeof MultiplyBlending - | typeof CustomBlending; + | typeof CustomBlending + | typeof MaterialBlending; // custom blending equations // (numbers start from 100 not to clash with other @@ -651,7 +653,12 @@ export type AnimationActionLoopStyles = typeof LoopOnce | typeof LoopRepeat | ty export const InterpolateDiscrete: 2300; export const InterpolateLinear: 2301; export const InterpolateSmooth: 2302; -export type InterpolationModes = typeof InterpolateDiscrete | typeof InterpolateLinear | typeof InterpolateSmooth; +export const InterpolateBezier: 2303; +export type InterpolationModes = + | typeof InterpolateDiscrete + | typeof InterpolateLinear + | typeof InterpolateSmooth + | typeof InterpolateBezier; // Interpolant ending modes export const ZeroCurvatureEnding: 2400; @@ -824,6 +831,11 @@ export type InterpolationSamplingMode = | typeof InterpolationSamplingMode.FIRST | typeof InterpolationSamplingMode.EITHER; +export const Compatibility: { + TEXTURE_COMPARE: "depthTextureCompare"; +}; +export type Compatibility = typeof Compatibility.TEXTURE_COMPARE; + /////////////////////////////////////////////////////////////////////////////// // Texture - Internal Pixel Formats diff --git a/types/three/src/core/Clock.d.ts b/types/three/src/core/Clock.d.ts index be39e97c2ded21..7185bcfb5c77c6 100644 --- a/types/three/src/core/Clock.d.ts +++ b/types/three/src/core/Clock.d.ts @@ -3,10 +3,13 @@ * [performance.now]{@link https://developer.mozilla.org/en-US/docs/Web/API/Performance/now}. * @see [Official Documentation]{@link https://threejs.org/docs/index.html#api/en/core/Clock} * @see [Source]{@link https://github.com/mrdoob/three.js/blob/master/src/core/Clock.js} + * + * @deprecated Please use THREE.Timer instead. */ export class Clock { /** * Create a new instance of {@link THREE.Clock | Clock} + * @deprecated Please use THREE.Timer instead. * @param autoStart - Whether to automatically start the clock when {@link getDelta | .getDelta()} is called for the first time. Default `true` */ constructor(autoStart?: boolean); diff --git a/types/three/src/core/Object3D.d.ts b/types/three/src/core/Object3D.d.ts index 20bba57ce67bd9..7f7abdc9927f67 100644 --- a/types/three/src/core/Object3D.d.ts +++ b/types/three/src/core/Object3D.d.ts @@ -28,12 +28,15 @@ export interface Object3DJSONObject { visible?: boolean; frustumCulled?: boolean; renderOrder?: number; + static?: boolean; userData?: Record; layers: number; matrix: Matrix4Tuple; up: Vector3Tuple; + pivot?: Vector3Tuple; + matrixAutoUpdate?: boolean; material?: string | string[]; @@ -265,13 +268,6 @@ export class Object3D ext */ animations: AnimationClip[]; - /** - * An object that can be used to store custom data about the {@link Object3D}. - * @remarks It should not hold references to _functions_ as these **will not** be cloned. - * @default `{}` - */ - userData: Record; - /** * Custom depth material to be used when rendering to the depth map. * @remarks Can only be used in context of meshes. @@ -287,6 +283,34 @@ export class Object3D ext */ customDistanceMaterial?: Material | undefined; + /** + * Whether the 3D object is supposed to be static or not. If set to `true`, it means + * the 3D object is not going to be changed after the initial renderer. This includes + * geometry and material settings. A static 3D object can be processed by the renderer + * slightly faster since certain state checks can be bypassed. + * + * Only relevant in context of {@link WebGPURenderer}. + * + * @default false + */ + static: boolean; + + /** + * An object that can be used to store custom data about the {@link Object3D}. + * @remarks It should not hold references to _functions_ as these **will not** be cloned. + * @default `{}` + */ + userData: Record; + + /** + * The pivot point for rotation and scale transformations. + * When set, rotation and scale are applied around this point + * instead of the object's origin. + * + * @default null + */ + pivot: Vector3 | null; + /** * An optional callback that is executed immediately before a 3D object is rendered to a shadow map. * @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry, diff --git a/types/three/src/geometries/TorusGeometry.d.ts b/types/three/src/geometries/TorusGeometry.d.ts index 3f5e0e8698d44b..291f8cfbfdb35b 100644 --- a/types/three/src/geometries/TorusGeometry.d.ts +++ b/types/three/src/geometries/TorusGeometry.d.ts @@ -1,5 +1,13 @@ import { BufferGeometry } from "../core/BufferGeometry.js"; +export interface TorusGeometryJSON { + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + arc: number; +} + /** * A class for generating torus geometries. * @example @@ -21,8 +29,18 @@ export class TorusGeometry extends BufferGeometry { * @param radialSegments Default is `12`. * @param tubularSegments Default is `48`. * @param arc Central angle. Default is Math.PI * 2. + * @param {number} [thetaStart=0] - Start of the tubular sweep in radians. + * @param {number} [thetaLength=Math.PI times 2] - Length of the tubular sweep in radians. */ - constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number); + constructor( + radius?: number, + tube?: number, + radialSegments?: number, + tubularSegments?: number, + arc?: number, + thetaStart?: number, + thetaLength?: number, + ); /** * A Read-only _string_ to check if `this` object type. @@ -41,8 +59,9 @@ export class TorusGeometry extends BufferGeometry { readonly radialSegments: number; readonly tubularSegments: number; readonly arc: number; + readonly thetaStart: number; + readonly thetaLength: number; }; - /** @internal */ - static fromJSON(data: any): TorusGeometry; + static fromJSON(data: TorusGeometryJSON): TorusGeometry; } diff --git a/types/three/src/helpers/ArrowHelper.d.ts b/types/three/src/helpers/ArrowHelper.d.ts index 94896123cfcb86..3123106dc0853f 100644 --- a/types/three/src/helpers/ArrowHelper.d.ts +++ b/types/three/src/helpers/ArrowHelper.d.ts @@ -6,30 +6,31 @@ import { Mesh } from "../objects/Mesh.js"; /** * An 3D arrow object for visualizing directions. - * @example - * ```typescript - * const dir = new THREE.Vector3(1, 2, 0); + * + * ```js + * const dir = new THREE.Vector3( 1, 2, 0 ); + * * //normalize the direction vector (convert to vector of length 1) * dir.normalize(); - * const origin = new THREE.Vector3(0, 0, 0); + * + * const origin = new THREE.Vector3( 0, 0, 0 ); * const length = 1; * const hex = 0xffff00; - * const {@link ArrowHelper} = new THREE.ArrowHelper(dir, origin, length, hex); - * scene.add(arrowHelper); + * + * const arrowHelper = new THREE.ArrowHelper( dir, origin, length, hex ); + * scene.add( arrowHelper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_shadowmesh | WebGL / shadowmesh} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/ArrowHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/ArrowHelper.js | Source} */ export class ArrowHelper extends Object3D { /** - * Create a new instance of {@link ArrowHelper} - * @param dir Direction from origin. Must be a unit vector. Default `new THREE.Vector3(0, 0, 1)` - * @param origin Point at which the arrow starts. Default `new THREE.Vector3(0, 0, 0)` - * @param length Length of the arrow. Default `1` - * @param hex Hexadecimal value to define color. Default `0xffff00` - * @param headLength The length of the head of the arrow. Default `0.2 * length` - * @param headWidth The width of the head of the arrow. Default `0.2 * headLength` + * Constructs a new arrow helper. + * + * @param {Vector3} [dir=(0, 0, 1)] - The (normalized) direction vector. + * @param {Vector3} [origin=(0, 0, 0)] - Point at which the arrow starts. + * @param {number} [length=1] - Length of the arrow in world units. + * @param {(number|Color|string)} [color=0xffff00] - Color of the arrow. + * @param {number} [headLength=length times 0.2] - The length of the head of the arrow. + * @param {number} [headWidth=headLength times 0.2] - The width of the head of the arrow. */ constructor( dir?: Vector3, @@ -39,55 +40,38 @@ export class ArrowHelper extends Object3D { headLength?: number, headWidth?: number, ); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `ArrowHelper` - */ - override readonly type: string | "ArrowHelper"; - /** - * Contains the line part of the arrowHelper. + * The line part of the arrow helper. */ line: Line; - /** - * Contains the cone part of the arrowHelper. + * The cone part of the arrow helper. */ cone: Mesh; - - /** - * Sets the color of the arrowHelper. - * @param color The desired color. - */ - setColor(color: ColorRepresentation): void; - /** - * @param dir The desired direction. Must be a unit vector. + * Sets the direction of the helper. + * + * @param {Vector3} dir - The normalized direction vector. */ setDirection(dir: Vector3): void; - /** - * Sets the length of the arrowhelper. - * @param length The desired length. - * @param headLength The length of the head of the arrow. Default `0.2 * length` - * @param headWidth The width of the head of the arrow. Default `0.2 * headLength` + * Sets the length of the helper. + * + * @param {number} length - Length of the arrow in world units. + * @param {number} [headLength=length times 0.2] - The length of the head of the arrow. + * @param {number} [headWidth=headLength times 0.2] - The width of the head of the arrow. */ setLength(length: number, headLength?: number, headWidth?: number): void; - /** - * Copy the given object into this object - * @remarks Note: event listeners and user-defined callbacks ({@link onAfterRender | .onAfterRender} and {@link onBeforeRender | .onBeforeRender}) are not copied. - * @param source + * Sets the color of the helper. + * + * @param {number|Color|string} color - The color to set. */ - override copy(source: this): this; - + setColor(color: ColorRepresentation): void; + copy(source: ArrowHelper): this; /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 8a0d13200fc4d3..725a0fb9b7f426 100644 --- a/types/three/src/helpers/AxesHelper.d.ts +++ b/types/three/src/helpers/AxesHelper.d.ts @@ -1,52 +1,38 @@ -import { BufferGeometry } from "../core/BufferGeometry.js"; -import { LineBasicMaterial } from "../materials/LineBasicMaterial.js"; import { ColorRepresentation } from "../math/Color.js"; import { LineSegments } from "../objects/LineSegments.js"; /** * An axis object to visualize the 3 axes in a simple way. - * @remarks - * The X axis is red - * The Y axis is green - * The Z axis is blue. - * @example - * ```typescript - * const {@link AxesHelper} = new THREE.AxesHelper(5); - * scene.add(axesHelper); + * The X axis is red. The Y axis is green. The Z axis is blue. + * + * ```js + * const axesHelper = new THREE.AxesHelper( 5 ); + * scene.add( axesHelper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_compression | WebGL / buffergeometry / compression} - * @see Example: {@link https://threejs.org/examples/#webgl_geometry_convex | WebGL / geometry / convex} - * @see Example: {@link https://threejs.org/examples/#webgl_loader_nrrd | WebGL / loader / nrrd} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/AxesHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/AxesHelper.js | Source} */ -export class AxesHelper extends LineSegments { +export class AxesHelper extends LineSegments { /** - * Create a new instance of {@link AxesHelper} - * @param size Size of the lines representing the axes. Default `1` + * Constructs a new axes helper. + * + * @param {number} [size=1] - Size of the lines representing the axes. */ constructor(size?: number); - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `AxesHelper` + * Defines the colors of the axes helper. + * + * @param {number|Color|string} xAxisColor - The color for the x axis. + * @param {number|Color|string} yAxisColor - The color for the y axis. + * @param {number|Color|string} zAxisColor - The color for the z axis. + * @return {AxesHelper} A reference to this axes helper. */ - override readonly type: string | "AxesHelper"; - - /** - * Sets the axes colors to {@link Color | xAxisColor}, {@link Color | yAxisColor}, {@link Color | zAxisColor}. - * @param xAxisColor - * @param yAxisColor - * @param zAxisColor - */ - setColors(xAxisColor: ColorRepresentation, yAxisColor: ColorRepresentation, zAxisColor: ColorRepresentation): this; - + setColors( + xAxisColor: ColorRepresentation, + yAxisColor: ColorRepresentation, + zAxisColor: ColorRepresentation, + ): AxesHelper; /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 78e1c6f8210a25..b19984bf4c169b 100644 --- a/types/three/src/helpers/Box3Helper.d.ts +++ b/types/three/src/helpers/Box3Helper.d.ts @@ -3,42 +3,31 @@ import { ColorRepresentation } from "../math/Color.js"; import { LineSegments } from "../objects/LineSegments.js"; /** - * Helper object to visualize a {@link THREE.Box3 | Box3}. - * @example - * ```typescript + * A helper object to visualize an instance of {@link Box3}. + * + * ```js * const box = new THREE.Box3(); - * box.setFromCenterAndSize(new THREE.Vector3(1, 1, 1), new THREE.Vector3(2, 1, 3)); - * const helper = new THREE.Box3Helper(box, 0xffff00); - * scene.add(helper); + * box.setFromCenterAndSize( new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 2, 1, 3 ) ); + * + * const helper = new THREE.Box3Helper( box, 0xffff00 ); + * scene.add( helper ) * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/Box3Helper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/Box3Helper.js | Source} */ export class Box3Helper extends LineSegments { /** - * Creates a new wireframe box that represents the passed Box3. - * @param box The Box3 to show. - * @param color The box's color. Default `0xffff00` + * Constructs a new box3 helper. + * + * @param {Box3} box - The box to visualize. + * @param {number|Color|string} [color=0xffff00] - The box's color. */ constructor(box: Box3, color?: ColorRepresentation); - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `Box3Helper` - */ - override readonly type: string | "Box3Helper"; - - /** - * The Box3 being visualized. + * The box being visualized. */ box: Box3; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 d049a5b728d57f..91b857e1338211 100644 --- a/types/three/src/helpers/BoxHelper.d.ts +++ b/types/three/src/helpers/BoxHelper.d.ts @@ -1,64 +1,53 @@ import { BufferGeometry } from "../core/BufferGeometry.js"; import { Object3D } from "../core/Object3D.js"; import { LineBasicMaterial } from "../materials/LineBasicMaterial.js"; +import { Box3 } from "../math/Box3.js"; import { ColorRepresentation } from "../math/Color.js"; import { LineSegments } from "../objects/LineSegments.js"; /** - * Helper object to graphically show the world-axis-aligned bounding box around an object - * @remarks - * The actual bounding box is handled with {@link THREE.Box3 | Box3}, this is just a visual helper for debugging - * It can be automatically resized with the {@link THREE.BoxHelper.update | BoxHelper.update} method when the object it's created from is transformed - * Note that the object must have a {@link THREE.BufferGeometry | BufferGeometry} for this to work, so it won't work with {@link Sprite | Sprites}. - * @example - * ```typescript + * Helper object to graphically show the world-axis-aligned bounding box + * around an object. The actual bounding box is handled with {@link Box3}, + * this is just a visual helper for debugging. It can be automatically + * resized with {@link BoxHelper#update} when the object it's created from + * is transformed. Note that the object must have a geometry for this to work, + * so it won't work with sprites. + * + * ```js * const sphere = new THREE.SphereGeometry(); - * const object = new THREE.Mesh(sphere, new THREE.MeshBasicMaterial(0xff0000)); - * const box = new THREE.BoxHelper(object, 0xffff00); - * scene.add(box); + * const object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) ); + * const box = new THREE.BoxHelper( object, 0xffff00 ); + * scene.add( box ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_helpers | WebGL / helpers} - * @see Example: {@link https://threejs.org/examples/#webgl_loader_nrrd | WebGL / loader / nrrd} - * @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_drawrange | WebGL / buffergeometry / drawrange} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/BoxHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/BoxHelper.js | Source} */ export class BoxHelper extends LineSegments { /** - * Creates a new wireframe box that bounds the passed object - * @remarks - * Internally this uses {@link THREE.Box3.setFromObject | Box3.setFromObject} to calculate the dimensions - * Note that this includes any children. - * @param object The object3D to show the world-axis-aligned bounding box. - * @param color Hexadecimal value that defines the box's color. Default `0xffff00` + * Constructs a new box helper. + * + * @param {Object3D} [object] - The 3D object to show the world-axis-aligned bounding box. + * @param {number|Color|string} [color=0xffff00] - The box's color. */ constructor(object: Object3D, color?: ColorRepresentation); - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `BoxHelper` + * The 3D object being visualized. */ - override readonly type: string | "BoxHelper"; - + object: Object3D; /** - * Updates the helper's geometry to match the dimensions of the object, including any children - * @remarks - * See {@link THREE.Box3.setFromObject | Box3.setFromObject}. + * Updates the helper's geometry to match the dimensions of the object, + * including any children. */ - update(object?: Object3D): void; - + update(): void; /** * Updates the wireframe box for the passed object. - * @param object {@link THREE.Object3D | Object3D} to create the helper of. + * + * @param {Object3D} object - The 3D object to create the helper for. + * @return {BoxHelper} A reference to this instance. */ - setFromObject(object: Object3D): this; - + setFromObject(object: Object3D): BoxHelper; + copy(source: BoxHelper, 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. + * 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 469dcaa0d3bf51..bb331f5781f11f 100644 --- a/types/three/src/helpers/CameraHelper.d.ts +++ b/types/three/src/helpers/CameraHelper.d.ts @@ -1,80 +1,59 @@ import { Camera } from "../cameras/Camera.js"; import { Color } from "../math/Color.js"; -import { Matrix4 } from "../math/Matrix4.js"; import { LineSegments } from "../objects/LineSegments.js"; /** - * This helps with visualizing what a camera contains in its frustum - * @remarks - * It visualizes the frustum of a camera using a {@link THREE.LineSegments | LineSegments}. - * @remarks {@link CameraHelper} must be a child of the scene. - * @example - * ```typescript - * const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); - * const helper = new THREE.CameraHelper(camera); - * scene.add(helper); + * This helps with visualizing what a camera contains in its frustum. It + * visualizes the frustum of a camera using a line segments. + * + * Based on frustum visualization in [lightgl.js shadowmap example](https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html). + * + * `CameraHelper` must be a child of the scene. + * + * When the camera is transformed or its projection matrix is changed, it's necessary + * to call the `update()` method of the respective helper. + * + * ```js + * const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); + * const helper = new THREE.CameraHelper( camera ); + * scene.add( helper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_camera | WebGL / camera} - * @see Example: {@link https://threejs.org/examples/#webgl_geometry_extrude_splines | WebGL / extrude / splines} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/CameraHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/CameraHelper.js | Source} */ export class CameraHelper extends LineSegments { /** - * This create a new {@link CameraHelper} for the specified camera. - * @param camera The camera to visualize. + * Constructs a new arrow helper. + * + * @param {Camera} camera - The camera to visualize. */ constructor(camera: Camera); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `CameraHelper` - */ - override readonly type: string | "CameraHelper"; - /** * The camera being visualized. */ camera: Camera; - /** * This contains the points used to visualize the camera. */ - pointMap: { [id: string]: number[] }; - - /** - * Reference to the {@link THREE.Camera.matrixWorld | camera.matrixWorld}. - */ - matrix: Matrix4; - - /** - * Is set to `false`, as the helper is using the {@link THREE.Camera.matrixWorld | camera.matrixWorld}. - * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}. - * @defaultValue `false`. - */ - override matrixAutoUpdate: boolean; - + pointMap: { + [x: string]: number[]; + }; /** * Defines the colors of the helper. - * @param frustum - * @param cone - * @param up - * @param target - * @param cross + * + * @param {Color} frustum - The frustum line color. + * @param {Color} cone - The cone line color. + * @param {Color} up - The up line color. + * @param {Color} target - The target line color. + * @param {Color} cross - The cross line color. + * @return {CameraHelper} A reference to this helper. */ - setColors(frustum: Color, cone: Color, up: Color, target: Color, cross: Color): this; - + setColors(frustum: Color, cone: Color, up: Color, target: Color, cross: Color): CameraHelper; /** - * Updates the helper based on the projectionMatrix of the camera. + * Updates the helper based on the projection matrix of the camera. */ update(): void; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 729eccedd7ae1f..e80d1711c34a86 100644 --- a/types/three/src/helpers/DirectionalLightHelper.d.ts +++ b/types/three/src/helpers/DirectionalLightHelper.d.ts @@ -5,77 +5,56 @@ import { Matrix4 } from "../math/Matrix4.js"; import { Line } from "../objects/Line.js"; /** - * Helper object to assist with visualizing a {@link THREE.DirectionalLight | DirectionalLight}'s effect on the scene - * @remarks - * This consists of plane and a line representing the light's position and direction. - * @example - * ```typescript - * const light = new THREE.DirectionalLight(0xFFFFFF); - * scene.add(light); + * Helper object to assist with visualizing a {@link DirectionalLight}'s + * effect on the scene. This consists of a plane and a line representing the + * light's position and direction. * - * const helper = new THREE.DirectionalLightHelper(light, 5); - * scene.add(helper); + * When the directional light or its target are transformed or light properties + * are changed, it's necessary to call the `update()` method of the respective helper. + * + * ```js + * const light = new THREE.DirectionalLight( 0xFFFFFF ); + * scene.add( light ); + * + * const helper = new THREE.DirectionalLightHelper( light, 5 ); + * scene.add( helper ); * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/DirectionalLightHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/DirectionalLightHelper.js | Source} */ export class DirectionalLightHelper extends Object3D { /** - * Create a new instance of {@link DirectionalLightHelper} - * @param light The light to be visualized. - * @param size Dimensions of the plane. Default `1` - * @param color If this is not the set the helper will take the color of the light. Default `light.color` + * Constructs a new directional light helper. + * + * @param {DirectionalLight} light - The light to be visualized. + * @param {number} [size=1] - The dimensions of the plane. + * @param {number|Color|string} [color] - The helper's color. If not set, the helper will take + * the color of the light. */ constructor(light: DirectionalLight, size?: number, color?: ColorRepresentation); - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `DirectionalLightHelper` - */ - override readonly type: string | "DirectionalLightHelper"; - - /** - * Contains the line mesh showing the location of the directional light. - */ - lightPlane: Line; - - /** - * Reference to the {@link THREE.DirectionalLight | directionalLight} being visualized. + * The light being visualized. */ light: DirectionalLight; - /** - * Reference to the {@link THREE.DirectionalLight.matrixWorld | light.matrixWorld}. + * The color parameter passed in the constructor. + * If not set, the helper will take the color of the light. */ - matrix: Matrix4; - + color: ColorRepresentation | undefined; /** - * Is set to `false`, as the helper is using the {@link THREE.DirectionalLight.matrixWorld | light.matrixWorld}. - * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}. - * @defaultValue `false`. + * Contains the line showing the location of the directional light. */ - override matrixAutoUpdate: boolean; - + lightPlane: Line; /** - * The color parameter passed in the constructor. - * @remarks If this is changed, the helper's color will update the next time {@link update} is called. - * @defaultValue `undefined` + * Represents the target line of the directional light. */ - color: ColorRepresentation | undefined; - - targetLine: Line; // TODO: Double check if this need to be exposed or not. - + targetLine: Line; /** - * Updates the helper to match the position and direction of the {@link light | DirectionalLight} being visualized. + * Frees the GPU-related resources allocated by this instance. Call this + * method whenever this instance is no longer used in your app. */ - update(): void; - + dispose(): void; /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * Updates the helper to match the position and direction of the + * light being visualized. */ - dispose(): void; + update(): void; } diff --git a/types/three/src/helpers/GridHelper.d.ts b/types/three/src/helpers/GridHelper.d.ts index 0b786b9926278b..380fc43cc87665 100644 --- a/types/three/src/helpers/GridHelper.d.ts +++ b/types/three/src/helpers/GridHelper.d.ts @@ -4,44 +4,30 @@ import { ColorRepresentation } from "../math/Color.js"; import { LineSegments } from "../objects/LineSegments.js"; /** - * The {@link GridHelper} is an object to define grids - * @remarks - * Grids are two-dimensional arrays of lines. - * @example - * ```typescript + * The helper is an object to define grids. Grids are two-dimensional + * arrays of lines. + * + * ```js * const size = 10; * const divisions = 10; - * const {@link GridHelper} = new THREE.GridHelper(size, divisions); - * scene.add(gridHelper); + * + * const gridHelper = new THREE.GridHelper( size, divisions ); + * scene.add( gridHelper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_helpers | WebGL / helpers} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/GridHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/GridHelper.js | Source} */ export class GridHelper extends LineSegments { /** - * Creates a new {@link GridHelper} of size 'size' and divided into 'divisions' segments per side - * @remarks - * Colors are optional. - * @param size The size of the grid. Default `10` - * @param divisions The number of divisions across the grid. Default `10` - * @param colorCenterLine The color of the centerline. This can be a {@link THREE.Color | Color}, a hexadecimal value and an CSS-Color name. Default `0x444444` - * @param colorGrid The color of the lines of the grid. This can be a {@link THREE.Color | Color}, a hexadecimal value and an CSS-Color name. Default `0x888888` + * Constructs a new grid helper. + * + * @param {number} [size=10] - The size of the grid. + * @param {number} [divisions=10] - The number of divisions across the grid. + * @param {number|Color|string} [color1=0x444444] - The color of the center line. + * @param {number|Color|string} [color2=0x888888] - The color of the lines of the grid. */ constructor(size?: number, divisions?: number, color1?: ColorRepresentation, color2?: ColorRepresentation); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `GridHelper` - */ - override readonly type: string | "GridHelper"; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 80366b63b10e39..35c26eb6abb173 100644 --- a/types/three/src/helpers/HemisphereLightHelper.d.ts +++ b/types/three/src/helpers/HemisphereLightHelper.d.ts @@ -2,71 +2,48 @@ import { Object3D } from "../core/Object3D.js"; import { HemisphereLight } from "../lights/HemisphereLight.js"; import { MeshBasicMaterial } from "../materials/MeshBasicMaterial.js"; import { ColorRepresentation } from "../math/Color.js"; -import { Matrix4 } from "../math/Matrix4.js"; /** - * Creates a visual aid consisting of a spherical {@link THREE.Mesh | Mesh} for a {@link THREE.HemisphereLight | HemisphereLight}. - * @example - * ```typescript - * const light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1); - * const helper = new THREE.HemisphereLightHelper(light, 5); - * scene.add(helper); + * Creates a visual aid consisting of a spherical mesh for a + * given {@link HemisphereLight}. + * + * When the hemisphere light is transformed or its light properties are changed, + * it's necessary to call the `update()` method of the respective helper. + * + * ```js + * const light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + * const helper = new THREE.HemisphereLightHelper( light, 5 ); + * scene.add( helper ); * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/HemisphereLightHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/HemisphereLightHelper.js | Source} */ export class HemisphereLightHelper extends Object3D { /** - * Create a new instance of {@link HemisphereLightHelper} - * @param light The light being visualized. - * @param size Thr sphere size - * @param color If this is not the set the helper will take the color of the light. + * Constructs a new hemisphere light helper. + * + * @param {HemisphereLight} light - The light to be visualized. + * @param {number} [size=1] - The size of the mesh used to visualize the light. + * @param {number|Color|string} [color] - The helper's color. If not set, the helper will take + * the color of the light. */ - constructor(light: HemisphereLight, size: number, color?: ColorRepresentation); - + constructor(light: HemisphereLight, size?: number, color?: ColorRepresentation); /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `HemisphereLightHelper` - */ - override readonly type: string | "HemisphereLightHelper"; - - /** - * Reference to the HemisphereLight being visualized. + * The light being visualized. */ light: HemisphereLight; - - /** - * Reference to the {@link THREE.HemisphereLight.matrixWorld | light.matrixWorld}. - */ - matrix: Matrix4; - - /** - * Is set to `false`, as the helper is using the {@link THREE.HemisphereLight.matrixWorld | light.matrixWorld}. - * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}. - * @defaultValue `false`. - */ - override matrixAutoUpdate: boolean; - - material: MeshBasicMaterial; // TODO: Double check if this need to be exposed or not. - /** * The color parameter passed in the constructor. - * @remarks If this is changed, the helper's color will update the next time {@link update} is called. - * @defaultValue `undefined` + * If not set, the helper will take the color of the light. */ color: ColorRepresentation | undefined; - + material: MeshBasicMaterial; /** - * Updates the helper to match the position and direction of the {@link .light | HemisphereLight}. + * Frees the GPU-related resources allocated by this instance. Call this + * method whenever this instance is no longer used in your app. */ - update(): void; - + dispose(): void; /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * Updates the helper to match the position and direction of the + * light being visualized. */ - dispose(): void; + update(): void; } diff --git a/types/three/src/helpers/PlaneHelper.d.ts b/types/three/src/helpers/PlaneHelper.d.ts index 43c9821cbc5301..73d2a85592f626 100644 --- a/types/three/src/helpers/PlaneHelper.d.ts +++ b/types/three/src/helpers/PlaneHelper.d.ts @@ -1,50 +1,38 @@ +import { ColorRepresentation } from "../math/Color.js"; import { Plane } from "../math/Plane.js"; -import { LineSegments } from "../objects/LineSegments.js"; +import { Line } from "../objects/Line.js"; /** - * Helper object to visualize a {@link THREE.Plane | Plane}. - * @example - * ```typescript - * const plane = new THREE.Plane(new THREE.Vector3(1, 1, 0.2), 3); - * const helper = new THREE.PlaneHelper(plane, 1, 0xffff00); - * scene.add(helper); + * A helper object to visualize an instance of {@link Plane}. + * + * ```js + * const plane = new THREE.Plane( new THREE.Vector3( 1, 1, 0.2 ), 3 ); + * const helper = new THREE.PlaneHelper( plane, 1, 0xffff00 ); + * scene.add( helper ); * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/PlaneHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/PlaneHelper.js | Source} */ -export class PlaneHelper extends LineSegments { +export class PlaneHelper extends Line { /** - * Creates a new wireframe representation of the passed plane. - * @param plane The plane to visualize. - * @param size Side length of plane helper. Expects a `Float`. Default `1` - * @param hex Color. Default `0xffff00` + * Constructs a new plane helper. + * + * @param {Plane} plane - The plane to be visualized. + * @param {number} [size=1] - The side length of plane helper. + * @param {number|Color|string} [hex=0xffff00] - The helper's color. */ - constructor(plane: Plane, size?: number, hex?: number); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `PlaneHelper` - */ - override readonly type: string | "PlaneHelper"; - + constructor(plane: Plane, size?: number, hex?: ColorRepresentation); /** - * The {@link Plane | plane} being visualized. + * The plane being visualized. */ plane: Plane; - /** - * The side lengths of plane helper. - * @remarks Expects a `Float` - * @defaultValue `1` + * The side length of plane helper. + * + * @default 1 */ size: number; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 7d61da5e3e6191..cb419f061a2206 100644 --- a/types/three/src/helpers/PointLightHelper.d.ts +++ b/types/three/src/helpers/PointLightHelper.d.ts @@ -1,73 +1,48 @@ -import { Object3D } from "../core/Object3D.js"; import { PointLight } from "../lights/PointLight.js"; import { ColorRepresentation } from "../math/Color.js"; -import { Matrix4 } from "../math/Matrix4.js"; +import { Mesh } from "../objects/Mesh.js"; /** - * This displays a helper object consisting of a spherical {@link THREE.Mesh | Mesh} for visualizing a {@link THREE.PointLight | PointLight}. - * @example - * ```typescript - * const pointLight = new THREE.PointLight(0xff0000, 1, 100); - * pointLight.position.set(10, 10, 10); - * scene.add(pointLight); + * This displays a helper object consisting of a spherical mesh for + * visualizing an instance of {@link PointLight}. + * + * ```js + * const pointLight = new THREE.PointLight( 0xff0000, 1, 100 ); + * pointLight.position.set( 10, 10, 10 ); + * scene.add( pointLight ); + * * const sphereSize = 1; - * const {@link PointLightHelper} = new THREE.PointLightHelper(pointLight, sphereSize); - * scene.add(pointLightHelper); + * const pointLightHelper = new THREE.PointLightHelper( pointLight, sphereSize ); + * scene.add( pointLightHelper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_helpers | WebGL / helpers} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/PointLightHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/PointLightHelper.js | Source} */ -export class PointLightHelper extends Object3D { +export class PointLightHelper extends Mesh { /** - * Create a new instance of {@link PointLightHelper} - * @param light The light to be visualized. - * @param sphereSize The size of the sphere helper. Expects a `Float`. Default `1` - * @param color If this is not the set the helper will take the color of the light. + * Constructs a new point light helper. + * + * @param {PointLight} light - The light to be visualized. + * @param {number} [sphereSize=1] - The size of the sphere helper. + * @param {number|Color|string} [color] - The helper's color. If not set, the helper will take + * the color of the light. */ constructor(light: PointLight, sphereSize?: number, color?: ColorRepresentation); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `PointLightHelper` - */ - override readonly type: string | "PointLightHelper"; - /** - * The {@link THREE.PointLight | PointLight} that is being visualized. + * The light being visualized. */ light: PointLight; - - /** - * Reference to the {@link THREE.PointLight.matrixWorld | light.matrixWorld}. - */ - matrix: Matrix4; - /** * The color parameter passed in the constructor. - * @remarks If this is changed, the helper's color will update the next time {@link update} is called. - * @defaultValue `undefined` + * If not set, the helper will take the color of the light. */ color: ColorRepresentation | undefined; - /** - * Is set to `false`, as the helper is using the {@link THREE.PointLight.matrixWorld | light.matrixWorld}. - * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}. - * @defaultValue `false`. + * Frees the GPU-related resources allocated by this instance. Call this + * method whenever this instance is no longer used in your app. */ - override matrixAutoUpdate: boolean; - + dispose(): void; /** - * Updates the helper to match the position of the {@link THREE..light | .light}. + * Updates the helper to match the position of the + * light being visualized. */ update(): void; - - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/helpers/PolarGridHelper.d.ts b/types/three/src/helpers/PolarGridHelper.d.ts index 994d71c940686b..62b26685063ea5 100644 --- a/types/three/src/helpers/PolarGridHelper.d.ts +++ b/types/three/src/helpers/PolarGridHelper.d.ts @@ -2,54 +2,41 @@ import { ColorRepresentation } from "../math/Color.js"; import { LineSegments } from "../objects/LineSegments.js"; /** - * The {@link PolarGridHelper} is an object to define polar grids - * @remarks - * Grids are two-dimensional arrays of lines. - * @example - * ```typescript + * This helper is an object to define polar grids. Grids are + * two-dimensional arrays of lines. + * + * ```js * const radius = 10; * const sectors = 16; * const rings = 8; * const divisions = 64; - * const helper = new THREE.PolarGridHelper(radius, sectors, rings, divisions); - * scene.add(helper); + * + * const helper = new THREE.PolarGridHelper( radius, sectors, rings, divisions ); + * scene.add( helper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_helpers | WebGL / helpers} - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/PolarGridHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/PolarGridHelper.js | Source} */ export class PolarGridHelper extends LineSegments { /** - * Creates a new {@link PolarGridHelper} of radius 'radius' with 'sectors' number of sectors and 'rings' number of rings, where each circle is smoothed into 'divisions' number of line segments. - * @remarks Colors are optional. - * @param radius The radius of the polar grid. This can be any positive number. Default `10`. - * @param sectors The number of sectors the grid will be divided into. This can be any positive integer. Default `16`. - * @param rings The number of rings. This can be any positive integer. Default `8`. - * @param divisions The number of line segments used for each circle. This can be any positive integer that is 3 or greater. Default `64`. - * @param color1 The first color used for grid elements. This can be a {@link THREE.Color | Color}, a hexadecimal value and an CSS-Color name. Default `0x444444`. - * @param color2 The second color used for grid elements. This can be a {@link THREE.Color | Color}, a hexadecimal value and an CSS-Color name. Default `0x888888`. + * Constructs a new polar grid helper. + * + * @param {number} [radius=10] - The radius of the polar grid. This can be any positive number. + * @param {number} [sectors=16] - The number of sectors the grid will be divided into. This can be any positive integer. + * @param {number} [rings=16] - The number of rings. This can be any positive integer. + * @param {number} [divisions=64] - The number of line segments used for each circle. This can be any positive integer. + * @param {number|Color|string} [color1=0x444444] - The first color used for grid elements. + * @param {number|Color|string} [color2=0x888888] - The second color used for grid elements. */ constructor( radius?: number, - radials?: number, - circles?: number, + sectors?: number, + rings?: number, divisions?: number, color1?: ColorRepresentation, color2?: ColorRepresentation, ); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `PolarGridHelper` - */ - override readonly type: string | "PolarGridHelper"; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * 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 ae0f35e4f1c788..b8f9814299392a 100644 --- a/types/three/src/helpers/SkeletonHelper.d.ts +++ b/types/three/src/helpers/SkeletonHelper.d.ts @@ -1,73 +1,49 @@ import { Object3D } from "../core/Object3D.js"; import { Color } from "../math/Color.js"; -import { Matrix4 } from "../math/Matrix4.js"; import { Bone } from "../objects/Bone.js"; import { LineSegments } from "../objects/LineSegments.js"; -import { SkinnedMesh } from "../objects/SkinnedMesh.js"; /** - * A helper object to assist with visualizing a {@link Skeleton | Skeleton} - * @remarks - * The helper is rendered using a {@link LineBasicMaterial | LineBasicMaterial}. - * @example - * ```typescript - * const helper = new THREE.SkeletonHelper(skinnedMesh); - * scene.add(helper); + * A helper object to assist with visualizing a {@link Skeleton}. + * + * ```js + * const helper = new THREE.SkeletonHelper( skinnedMesh ); + * scene.add( helper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_blending | WebGL / animation / skinning / blending} - * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_morph | WebGL / animation / skinning / morph} - * @see Example: {@link https://threejs.org/examples/#webgl_loader_bvh | WebGL / loader / bvh } - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/SkeletonHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/SkeletonHelper.js | Source} */ -declare class SkeletonHelper extends LineSegments { +export class SkeletonHelper extends LineSegments { /** - * Create a new instance of {@link SkeletonHelper} - * @param object Usually an instance of {@link THREE.SkinnedMesh | SkinnedMesh}. - * However, any instance of {@link THREE.Object3D | Object3D} can be used if it represents a hierarchy of {@link Bone | Bone}s (via {@link THREE.Object3D.children | Object3D.children}). + * Constructs a new skeleton helper. + * + * @param {Object3D} object - Usually an instance of {@link SkinnedMesh}. However, any 3D object + * can be used if it represents a hierarchy of bones (see {@link Bone}). */ - constructor(object: SkinnedMesh | Object3D); - + constructor(object: Object3D); /** - * Read-only flag to check if a given object is of type {@link SkeletonHelper}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * This flag can be used for type testing. + * + * @default true */ - readonly isSkeletonHelper = true; - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `SkeletonHelper` - */ - override readonly type: string | "SkeletonHelper"; - + readonly isSkeletonHelper: boolean; /** - * The object passed in the constructor. + * The object being visualized. */ - root: SkinnedMesh | Object3D; - + root: Object3D; /** - * The list of bones that the helper renders as {@link Line | Lines}. + * The list of bones that the helper visualizes. */ bones: Bone[]; - /** - * Is set to `false`, as the helper is using the {@link THREE.Object3D.matrixWorld | root.matrixWorld}. - * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}. - * @defaultValue `false`. + * Defines the colors of the helper. + * + * @param {Color} color1 - The first line color for each bone. + * @param {Color} color2 - The second line color for each bone. + * @return {SkeletonHelper} A reference to this helper. */ - override matrixAutoUpdate: boolean; - - setColors(color1: Color, color2: Color): this; - + setColors(color1: Color, color2: Color): SkeletonHelper; /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * Frees the GPU-related resources allocated by this instance. Call this + * method whenever this instance is no longer used in your app. */ dispose(): void; } - -export { SkeletonHelper }; diff --git a/types/three/src/helpers/SpotLightHelper.d.ts b/types/three/src/helpers/SpotLightHelper.d.ts index f620ed990be271..0c56b5ed1626f7 100644 --- a/types/three/src/helpers/SpotLightHelper.d.ts +++ b/types/three/src/helpers/SpotLightHelper.d.ts @@ -1,77 +1,50 @@ import { Object3D } from "../core/Object3D.js"; -import { Light } from "../lights/Light.js"; +import { SpotLight } from "../lights/SpotLight.js"; import { ColorRepresentation } from "../math/Color.js"; -import { Matrix4 } from "../math/Matrix4.js"; import { LineSegments } from "../objects/LineSegments.js"; /** - * This displays a cone shaped helper object for a {@link THREE.SpotLight | SpotLight}. - * @example - * ```typescript - * const spotLight = new THREE.SpotLight(0xffffff); - * spotLight.position.set(10, 10, 10); - * scene.add(spotLight); - * const {@link SpotLightHelper} = new THREE.SpotLightHelper(spotLight); - * scene.add(spotLightHelper); + * This displays a cone shaped helper object for a {@link SpotLight}. + * + * When the spot light or its target are transformed or light properties are + * changed, it's necessary to call the `update()` method of the respective helper. + * + * ```js + * const spotLight = new THREE.SpotLight( 0xffffff ); + * spotLight.position.set( 10, 10, 10 ); + * scene.add( spotLight ); + * + * const spotLightHelper = new THREE.SpotLightHelper( spotLight ); + * scene.add( spotLightHelper ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_lights_spotlights | WebGL/ lights / spotlights } - * @see {@link https://threejs.org/docs/index.html#api/en/helpers/SpotLightHelper | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/SpotLightHelper.js | Source} */ export class SpotLightHelper extends Object3D { /** - * Create a new instance of {@link SpotLightHelper} - * @param light The {@link THREE.SpotLight | SpotLight} to be visualized. - * @param color If this is not the set the helper will take the color of the light. Default `light.color` + * Constructs a new spot light helper. + * + * @param {HemisphereLight} light - The light to be visualized. + * @param {number|Color|string} [color] - The helper's color. If not set, the helper will take + * the color of the light. */ - constructor(light: Light, color?: ColorRepresentation); - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @override - * @defaultValue `SpotLightHelper` - */ - override readonly type: string | "SpotLightHelper"; - - /** - * {@link THREE.LineSegments | LineSegments} used to visualize the light. - */ - cone: LineSegments; - - /** - * Reference to the {@link THREE.SpotLight | SpotLight} being visualized. - */ - light: Light; - + constructor(light: SpotLight, color?: ColorRepresentation); /** - * Reference to the spotLight's {@link Object3D.matrixWorld | matrixWorld}. + * The light being visualized. */ - matrix: Matrix4; - + light: SpotLight; /** * The color parameter passed in the constructor. - * If this is changed, the helper's color will update the next time {@link SpotLightHelper.update | update} is called. - * @defaultValue `undefined` + * If not set, the helper will take the color of the light. */ color: ColorRepresentation | undefined; - + cone: LineSegments; /** - * Is set to `false`, as the helper is using the {@link THREE.Light.matrixWorld | light.matrixWorld}. - * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}. - * @defaultValue `false`. + * Frees the GPU-related resources allocated by this instance. Call this + * method whenever this instance is no longer used in your app. */ - override matrixAutoUpdate: boolean; - + dispose(): void; /** - * Updates the light helper. + * Updates the helper to match the position and direction of the + * light being visualized. */ update(): void; - - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. - */ - dispose(): void; } diff --git a/types/three/src/lights/AmbientLight.d.ts b/types/three/src/lights/AmbientLight.d.ts index 7000a37e76535e..8b26e0b8044ce6 100644 --- a/types/three/src/lights/AmbientLight.d.ts +++ b/types/three/src/lights/AmbientLight.d.ts @@ -3,34 +3,26 @@ import { Light } from "./Light.js"; /** * This light globally illuminates all objects in the scene equally. - * @remarks This light cannot be used to cast shadows as it does not have a direction. - * @example - * ```typescript - * const light = new THREE.AmbientLight(0x404040); // soft white light - * scene.add(light); + * + * It cannot be used to cast shadows as it does not have a direction. + * + * ```js + * const light = new THREE.AmbientLight( 0x404040 ); // soft white light + * scene.add( light ); * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/lights/AmbientLight | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js | Source} */ -export class AmbientLight extends Light { +export class AmbientLight extends Light { /** - * Creates a new {@link AmbientLight}. - * @param color Numeric value of the RGB component of the color. Default `0xffffff` - * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1` + * Constructs a new ambient 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); - - /** - * Read-only flag to check if a given object is of type {@link AmbientLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isAmbientLight: true; - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `AmbientLight` + * This flag can be used for type testing. + * + * @default true */ - override readonly type: string | "AmbientLight"; + readonly isAmbientLight: boolean; } diff --git a/types/three/src/lights/DirectionalLight.d.ts b/types/three/src/lights/DirectionalLight.d.ts index 8a8e2d4c2f6092..911634caee8923 100644 --- a/types/three/src/lights/DirectionalLight.d.ts +++ b/types/three/src/lights/DirectionalLight.d.ts @@ -1,6 +1,5 @@ import { JSONMeta, Object3D } from "../core/Object3D.js"; import { ColorRepresentation } from "../math/Color.js"; -import { Vector3 } from "../math/Vector3.js"; import { DirectionalLightShadow } from "./DirectionalLightShadow.js"; import { Light, LightJSON } from "./Light.js"; import { LightShadowJSON } from "./LightShadow.js"; @@ -11,100 +10,59 @@ export interface DirectionalLightJSON extends LightJSON { } /** - * A light that gets emitted in a specific direction - * @remarks - * This light will behave as though it is infinitely far away and the rays produced from it are all parallel - * The common use case for this is to simulate daylight; the sun is far enough away that its position can be considered to be infinite, and all light rays coming from it are parallel. - * A common point of confusion for directional lights is that setting the rotation has no effect - * This is because three.js's {@link DirectionalLight} is the equivalent to what is often called a 'Target Direct Light' in other applications. - * This means that its direction is calculated as pointing from the light's {@link THREE.Object3D.position | position} to the {@link THREE.DirectionalLight.target | target}'s - * position (as opposed to a 'Free Direct Light' that just has a rotation component). - * See the {@link THREE.DirectionalLight.target | target} property below for details on updating the target. - * @example - * ```typescript + * A light that gets emitted in a specific direction. This light will behave + * as though it is infinitely far away and the rays produced from it are all + * parallel. The common use case for this is to simulate daylight; the sun is + * far enough away that its position can be considered to be infinite, and + * all light rays coming from it are parallel. + * + * A common point of confusion for directional lights is that setting the + * rotation has no effect. This is because three.js's DirectionalLight is the + * equivalent to what is often called a 'Target Direct Light' in other + * applications. + * + * This means that its direction is calculated as pointing from the light's + * {@link Object3D#position} to the {@link DirectionalLight#target} position + * (as opposed to a 'Free Direct Light' that just has a rotation + * component). + * + * This light can cast shadows - see the {@link DirectionalLightShadow} for details. + * + * ```js * // White directional light at half intensity shining from the top. - * const {@link DirectionalLight} = new THREE.DirectionalLight(0xffffff, 0.5); - * scene.add(directionalLight); + * const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + * scene.add( directionalLight ); * ``` - * @see Example: {@link https://threejs.org/examples/#misc_controls_fly | controls / fly } - * @see Example: {@link https://threejs.org/examples/#webgl_effects_parallaxbarrier | effects / parallaxbarrier } - * @see Example: {@link https://threejs.org/examples/#webgl_effects_stereo | effects / stereo } - * @see Example: {@link https://threejs.org/examples/#webgl_geometry_extrude_splines | geometry / extrude / splines } - * @see Example: {@link https://threejs.org/examples/#webgl_materials_bumpmap | materials / bumpmap } - * @see {@link https://threejs.org/docs/index.html#api/en/lights/DirectionalLight | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/DirectionalLight.js | Source} */ -export class DirectionalLight extends Light { +export class DirectionalLight extends Light { /** - * Creates a new {@link DirectionalLight}. - * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_. - * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1` + * Constructs a new directional 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); - - /** - * Read-only flag to check if a given object is of type {@link DirectionalLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isDirectionalLight: true; - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `DirectionalLight` - */ - override readonly type: string | "DirectionalLight"; - - /** - * Whether the object gets rendered into shadow map. - * @remarks - * If set to `true` light will cast dynamic shadows. - * **Warning**: This is expensive and requires tweaking to get shadows looking right. - * @see {@link THREE.DirectionalLightShadow | DirectionalLightShadow} for details. - * @defaultValue `false` - */ - override castShadow: boolean; - /** - * This is set equal to {@link THREE.Object3D.DEFAULT_UP}, so that the light shines from the top down. - * @defaultValue {@link Object3D.DEFAULT_UP} _(0, 1, 0)_ - */ - override readonly position: Vector3; - - /** - * A {@link THREE.DirectionalLightShadow | DirectionalLightShadow} used to calculate shadows for this light. - * @defaultValue `new THREE.DirectionalLightShadow()` + * This flag can be used for type testing. + * + * @default true */ - shadow: DirectionalLightShadow; - + readonly isDirectionalLight: boolean; /** - * The {@link DirectionalLight} points from its {@link DirectionalLight.position | position} to target.position. - * @remarks **Note**: For the target's position to be changed to anything other than the default, - * it must be added to the {@link THREE.Scene | scene} using - * ```typescript - * Scene.add( light.target ); - * ``` - * This is so that the target's {@link THREE.Object3D.matrixWorld | matrixWorld} gets automatically updated each frame. + * The directional light points from its position to the + * target's position. + * + * For the target's position to be changed to anything other + * than the default, it must be added to the scene. * - * It is also possible to set the target to be another object in the scene (anything with a {@link THREE.Object3D.position | position} property), - * like so: - * ```typescript - * const targetObject = new THREE.Object3D(); - * scene.add(targetObject); - * light.target = targetObject; - * ``` - * The {@link DirectionalLight} will now track the target object. - * @defaultValue `new THREE.Object3D()` at _(0, 0, 0)_ + * It is also possible to set the target to be another 3D object + * in the scene. The light will now track the target object. */ target: Object3D; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * This property holds the light's shadow configuration. */ - dispose(): void; - + shadow: DirectionalLightShadow; + copy(source: DirectionalLight): this; toJSON(meta?: JSONMeta): DirectionalLightJSON; } diff --git a/types/three/src/lights/DirectionalLightShadow.d.ts b/types/three/src/lights/DirectionalLightShadow.d.ts index 805e4fa0bbec38..d9643d9b7ea21c 100644 --- a/types/three/src/lights/DirectionalLightShadow.d.ts +++ b/types/three/src/lights/DirectionalLightShadow.d.ts @@ -2,72 +2,17 @@ import { OrthographicCamera } from "../cameras/OrthographicCamera.js"; import { LightShadow } from "./LightShadow.js"; /** - * This is used internally by {@link DirectionalLight | DirectionalLights} for calculating shadows. - * Unlike the other shadow classes, this uses an {@link THREE.OrthographicCamera | OrthographicCamera} to calculate the shadows, - * rather than a {@link THREE.PerspectiveCamera | PerspectiveCamera} - * @remarks - * This is because light rays from a {@link THREE.DirectionalLight | DirectionalLight} are parallel. - * @example - * ```typescript - * //Create a WebGLRenderer and turn on shadows in the renderer - * const renderer = new THREE.WebGLRenderer(); - * renderer.shadowMap.enabled = true; - * renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - * //Create a DirectionalLight and turn on shadows for the light - * const light = new THREE.DirectionalLight(0xffffff, 1); - * light.position.set(0, 1, 0); //default; light shining from top - * light.castShadow = true; // default false - * scene.add(light); - * //Set up shadow properties for the light - * light.shadow.mapSize.width = 512; // default - * light.shadow.mapSize.height = 512; // default - * light.shadow.camera.near = 0.5; // default - * light.shadow.camera.far = 500; // default - * //Create a sphere that cast shadows (but does not receive them) - * const sphereGeometry = new THREE.SphereGeometry(5, 32, 32); - * const sphereMaterial = new THREE.MeshStandardMaterial({ - * color: 0xff0000 - * }); - * const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial); - * sphere.castShadow = true; //default is false - * sphere.receiveShadow = false; //default - * scene.add(sphere); - * //Create a plane that receives shadows (but does not cast them) - * const planeGeometry = new THREE.PlaneGeometry(20, 20, 32, 32); - * const planeMaterial = new THREE.MeshStandardMaterial({ - * color: 0x00ff00 - * }) - * const plane = new THREE.Mesh(planeGeometry, planeMaterial); - * plane.receiveShadow = true; - * scene.add(plane); - * //Create a helper for the shadow camera (optional) - * const helper = new THREE.CameraHelper(light.shadow.camera); - * scene.add(helper); - * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/lights/shadows/DirectionalLightShadow | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/DirectionalLightShadow.js | Source} + * Represents the shadow configuration of directional lights. */ export class DirectionalLightShadow extends LightShadow { /** - * Create a new instance of {@link DirectionalLightShadow} + * Constructs a new directional light shadow. */ constructor(); - - /** - * Read-only flag to check if a given object is of type {@link DirectionalLightShadow}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isDirectionalLightShadow: true; - /** - * The light's view of the world. - * @remarks This is used to generate a depth map of the scene; objects behind other objects from the light's perspective will be in shadow. - * @defaultValue is an {@link THREE.OrthographicCamera | OrthographicCamera} with - * {@link OrthographicCamera.left | left} and {@link OrthographicCamera.bottom | bottom} set to -5, - * {@link OrthographicCamera.right | right} and {@link OrthographicCamera.top | top} set to 5, - * the {@link OrthographicCamera.near | near} clipping plane at 0.5 and - * the {@link OrthographicCamera.far | far} clipping plane at 500. + * This flag can be used for type testing. + * + * @default true */ - camera: OrthographicCamera; + readonly isDirectionalLightShadow: boolean; } diff --git a/types/three/src/lights/HemisphereLight.d.ts b/types/three/src/lights/HemisphereLight.d.ts index 08dad563175184..51ec53c404ab55 100644 --- a/types/three/src/lights/HemisphereLight.d.ts +++ b/types/three/src/lights/HemisphereLight.d.ts @@ -1,6 +1,5 @@ import { JSONMeta } from "../core/Object3D.js"; import { Color, ColorRepresentation } from "../math/Color.js"; -import { Vector3 } from "../math/Vector3.js"; import { Light, LightJSON } from "./Light.js"; export interface HemisphereLightJSON extends LightJSON { @@ -8,61 +7,35 @@ export interface HemisphereLightJSON extends LightJSON { } /** - * A light source positioned directly above the scene, with color fading from the sky color to the ground color. - * @remarks This light cannot be used to cast shadows. - * @example - * ```typescript - * const light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1); - * scene.add(light); + * A light source positioned directly above the scene, with color fading from + * the sky color to the ground color. + * + * This light cannot be used to cast shadows. + * + * ```js + * const light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + * scene.add( light ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_blending | animation / skinning / blending } - * @see Example: {@link https://threejs.org/examples/#webgl_lights_hemisphere | lights / hemisphere } - * @see Example: {@link https://threejs.org/examples/#misc_controls_pointerlock | controls / pointerlock } - * @see Example: {@link https://threejs.org/examples/#webgl_loader_collada_kinematics | loader / collada / kinematics } - * @see Example: {@link https://threejs.org/examples/#webgl_loader_stl | loader / stl } - * @see {@link https://threejs.org/docs/index.html#api/en/lights/HemisphereLight | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/HemisphereLight.js | Source} */ -export class HemisphereLight extends Light { +export class HemisphereLight extends Light { /** - * Creates a new {@link HemisphereLight}. - * @param skyColor Hexadecimal color of the sky. Expects a `Integer`. Default `0xffffff` _(white)_. - * @param groundColor Hexadecimal color of the ground. Expects a `Integer`. Default `0xffffff` _(white)_. - * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1`. + * Constructs a new hemisphere light. + * + * @param {(number|Color|string)} [skyColor=0xffffff] - The light's sky color. + * @param {(number|Color|string)} [groundColor=0xffffff] - The light's ground color. + * @param {number} [intensity=1] - The light's strength/intensity. */ constructor(skyColor?: ColorRepresentation, groundColor?: ColorRepresentation, intensity?: number); - - /** - * Read-only flag to check if a given object is of type {@link HemisphereLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isHemisphereLight: true; - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `HemisphereLight` - */ - override readonly type: string | "HemisphereLight"; - - /** - * This is set equal to {@link THREE.Object3D.DEFAULT_UP}, so that the light shines from the top down. - * @defaultValue {@link Object3D.DEFAULT_UP} _(0, 1, 0)_ - */ - override readonly position: Vector3; - /** - * The light's sky color, as passed in the constructor. - * @defaultValue `new THREE.Color()` set to white _(0xffffff)_. + * This flag can be used for type testing. + * + * @default true */ - override color: Color; - + readonly isHemisphereLight: boolean; /** - * The light's ground color, as passed in the constructor. - * @defaultValue `new THREE.Color()` set to white _(0xffffff)_. + * The light's ground color. */ groundColor: Color; - + copy(source: HemisphereLight, recursive?: boolean): this; toJSON(meta?: JSONMeta): HemisphereLightJSON; } diff --git a/types/three/src/lights/Light.d.ts b/types/three/src/lights/Light.d.ts index b64dd051c386ed..785754da572903 100644 --- a/types/three/src/lights/Light.d.ts +++ b/types/three/src/lights/Light.d.ts @@ -1,6 +1,5 @@ import { JSONMeta, Object3D, Object3DEventMap, Object3DJSON } from "../core/Object3D.js"; import { Color, ColorRepresentation } from "../math/Color.js"; -import { LightShadow } from "./LightShadow.js"; export interface LightJSON extends Object3DJSON { color: number; @@ -12,67 +11,38 @@ export interface LightEventMap extends Object3DEventMap { } /** - * Abstract base class for lights. - * @remarks All other light types inherit the properties and methods described here. + * 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 { /** - * Creates a new {@link Light} - * @remarks - * **Note** that this is not intended to be called directly (use one of derived classes instead). - * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_. - * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1`. + * Constructs a new 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); - /** - * Read-only flag to check if a given object is of type {@link HemisphereLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * This flag can be used for type testing. + * + * @default true */ - readonly isLight: true; - + readonly isLight: boolean; /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `Light` - */ - override readonly type: string | "Light"; - - /** - * Color of the light. \ - * @defaultValue `new THREE.Color(0xffffff)` _(white)_. + * The light's color. */ color: Color; - /** - * The light's intensity, or strength. - * The units of intensity depend on the type of light. - * @defaultValue `1` + * The light's intensity. + * + * @default 1 */ intensity: number; - /** - * A {@link THREE.LightShadow | LightShadow} used to calculate shadows for this light. - * @remarks Available only on Light's that support shadows. - */ - shadow: TShadowSupport; - - /** - * Copies value of all the properties from the {@link Light | source} to this instance. - * @param source - * @param recursive - */ - copy(source: this, 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. + * 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/LightProbe.d.ts b/types/three/src/lights/LightProbe.d.ts index 1b930a87b2b601..989d4796c348df 100644 --- a/types/three/src/lights/LightProbe.d.ts +++ b/types/three/src/lights/LightProbe.d.ts @@ -7,45 +7,40 @@ export interface LightProbeJSON extends LightJSON { } /** - * Light probes are an alternative way of adding light to a 3D scene. - * @remarks - * Unlike classical light sources (e.g - * directional, point or spot lights), light probes do not emit light - * Instead they store information about light passing through 3D space - * During rendering, the light that hits a 3D object is approximated by using the data from the light probe. - * Light probes are usually created from (radiance) environment maps - * The class {@link THREE.LightProbeGenerator | LightProbeGenerator} can be used to create light probes from - * instances of {@link THREE.CubeTexture | CubeTexture} or {@link THREE.WebGLCubeRenderTarget | WebGLCubeRenderTarget} - * However, light estimation data could also be provided in other forms e.g - * by WebXR - * This enables the rendering of augmented reality content that reacts to real world lighting. - * The current probe implementation in three.js supports so-called diffuse light probes - * This type of light probe is functionally equivalent to an irradiance environment map. - * @see Example: {@link https://threejs.org/examples/#webgl_lightprobe | WebGL / light probe } - * @see Example: {@link https://threejs.org/examples/#webgl_lightprobe_cubecamera | WebGL / light probe / cube camera } - * @see {@link https://threejs.org/docs/index.html#api/en/lights/LightProbe | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/LightProbe.js | Source} + * Light probes are an alternative way of adding light to a 3D scene. Unlike + * classical light sources (e.g. directional, point or spot lights), light + * probes do not emit light. Instead they store information about light + * passing through 3D space. During rendering, the light that hits a 3D + * object is approximated by using the data from the light probe. + * + * Light probes are usually created from (radiance) environment maps. The + * class {@link LightProbeGenerator} can be used to create light probes from + * cube textures or render targets. However, light estimation data could also + * be provided in other forms e.g. by WebXR. This enables the rendering of + * augmented reality content that reacts to real world lighting. + * + * The current probe implementation in three.js supports so-called diffuse + * light probes. This type of light probe is functionally equivalent to an + * irradiance environment map. */ export class LightProbe extends Light { /** - * Creates a new LightProbe. - * @param sh An instance of {@link THREE.SphericalHarmonics3 | SphericalHarmonics3}. Default `new THREE.SphericalHarmonics3()``. - * @param intensity Numeric value of the light probe's intensity. Expects a `Float`. Default `1`. + * Constructs a new light probe. + * + * @param {SphericalHarmonics3} sh - The spherical harmonics which represents encoded lighting information. + * @param {number} [intensity=1] - The light's strength/intensity. */ constructor(sh?: SphericalHarmonics3, intensity?: number); - /** - * Read-only flag to check if a given object is of type {@link DirectionalLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * This flag can be used for type testing. + * + * @default true */ - readonly isLightProbe: true; - + readonly isLightProbe: boolean; /** * A light probe uses spherical harmonics to encode lighting information. - * @defaultValue `new THREE.SphericalHarmonics3()` */ sh: SphericalHarmonics3; - + copy(source: LightProbe): this; toJSON(meta?: JSONMeta): LightProbeJSON; } diff --git a/types/three/src/lights/LightShadow.d.ts b/types/three/src/lights/LightShadow.d.ts index a2b02513dcfd11..534a4124c471dc 100644 --- a/types/three/src/lights/LightShadow.d.ts +++ b/types/three/src/lights/LightShadow.d.ts @@ -1,11 +1,12 @@ import { Camera } from "../cameras/Camera.js"; import { TextureDataType } from "../constants.js"; import { Object3DJSONObject } from "../core/Object3D.js"; +import { RenderTarget } from "../core/RenderTarget.js"; import { Frustum } from "../math/Frustum.js"; import { Matrix4 } from "../math/Matrix4.js"; import { Vector2, Vector2Tuple } from "../math/Vector2.js"; import { Vector4 } from "../math/Vector4.js"; -import { WebGLRenderTarget } from "../renderers/WebGLRenderTarget.js"; +import Node from "../nodes/core/Node.js"; import { Light } from "./Light.js"; export interface LightShadowJSON { @@ -19,159 +20,174 @@ export interface LightShadowJSON { } /** - * Serves as a base class for the other shadow classes. - * @see {@link https://threejs.org/docs/index.html#api/en/lights/shadows/LightShadow | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/LightShadow.js | Source} + * Abstract base class for light shadow classes. These classes + * represent the shadow configuration for different light types. */ -export class LightShadow { +export abstract class LightShadow { /** - * Create a new instance of {@link LightShadow} - * @param camera The light's view of the world. + * Constructs a new light shadow. + * + * @param {Camera} camera - The light's view of the world. */ constructor(camera: TCamera); - /** * The light's view of the world. - * @remark This is used to generate a depth map of the scene; objects behind other objects from the light's perspective will be in shadow. */ camera: TCamera; - /** - * The intensity of the shadow. The default is `1`. Valid values are in the range `[0, 1]`. + * The intensity of the shadow. The default is `1`. + * Valid values are in the range `[0, 1]`. + * + * @default 1 */ intensity: number; - /** - * Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow. - * @remark The Very tiny adjustments here (in the order of 0.0001) may help reduce artifacts in shadows. - * @remarks Expects a `Float` - * @defaultValue `0` + * Shadow map bias, how much to add or subtract from the normalized depth + * when deciding whether a surface is in shadow. + * + * The default is `0`. Very tiny adjustments here (in the order of `0.0001`) + * may help reduce artifacts in shadows. + * + * @default 0 */ bias: number; - /** - * Defines how much the position used to query the shadow map is offset along the object normal. - * @remark The Increasing this value can be used to reduce shadow acne especially in large scenes where light shines onto geometry at a shallow angle. - * @remark The cost is that shadows may appear distorted. - * @remarks Expects a `Float` - * @defaultValue `0` + * A node version of `bias`. Only supported with `WebGPURenderer`. + * + * If a bias node is defined, `bias` has no effect. + * + * @default null + */ + biasNode: Node<"float"> | null; + /** + * Defines how much the position used to query the shadow map is offset along + * the object normal. The default is `0`. Increasing this value can be used to + * reduce shadow acne especially in large scenes where light shines onto + * geometry at a shallow angle. The cost is that shadows may appear distorted. + * + * @default 0 */ normalBias: number; - /** - * Setting this to values greater than 1 will blur the edges of the shadow.toi - * @remark High values will cause unwanted banding effects in the shadows - a greater {@link LightShadow.mapSize | mapSize - * will allow for a higher value to be used here before these effects become visible. - * @remark If {@link THREE.WebGLRenderer.shadowMap.type | WebGLRenderer.shadowMap.type} is set to {@link Renderer | PCFSoftShadowMap}, - * radius has no effect and it is recommended to increase softness by decreasing {@link LightShadow.mapSize | mapSize} instead. - * @remark Note that this has no effect if the {@link THREE.WebGLRenderer.shadowMap | WebGLRenderer.shadowMap}.{@link THREE.WebGLShadowMap.type | type} - * is set to {@link THREE.BasicShadowMap | BasicShadowMap}. - * @remarks Expects a `Float` - * @defaultValue `1` + * Setting this to values greater than 1 will blur the edges of the shadow. + * High values will cause unwanted banding effects in the shadows - a greater + * map size will allow for a higher value to be used here before these effects + * become visible. + * + * The property has no effect when the shadow map type is `BasicShadowMap`. + * + * @default 1 */ radius: number; - /** * The amount of samples to use when blurring a VSM shadow map. - * @remarks Expects a `Integer` - * @defaultValue `8` + * + * @default 8 */ blurSamples: number; - /** - * A {@link THREE.Vector2 | Vector2} defining the width and height of the shadow map. - * @remarks Higher values give better quality shadows at the cost of computation time. - * @remarks Values must be powers of 2, up to the {@link THREE.WebGLRenderer.capabilities | WebGLRenderer.capabilities}.maxTextureSize for a given device, - * although the width and height don't have to be the same (so, for example, (512, 1024) is valid). - * @defaultValue `new THREE.Vector2(512, 512)` + * Defines the width and height of the shadow map. Higher values give better quality + * shadows at the cost of computation time. Values must be powers of two. + * + * @default (512,512) */ mapSize: Vector2; - /** * The type of shadow texture. The default is `UnsignedByteType`. * * @default UnsignedByteType */ mapType: TextureDataType; - /** - * The depth map generated using the internal camera; a location beyond a pixel's depth is in shadow. Computed internally during rendering. - * @defaultValue null + * The depth map generated using the internal camera; a location beyond a + * pixel's depth is in shadow. Computed internally during rendering. + * + * @default null */ - map: WebGLRenderTarget | null; - + map: RenderTarget | null; /** - * The distribution map generated using the internal camera; an occlusion is calculated based on the distribution of depths. Computed internally during rendering. - * @defaultValue null + * The distribution map generated using the internal camera; an occlusion is + * calculated based on the distribution of depths. Computed internally during + * rendering. + * + * @default null */ - mapPass: WebGLRenderTarget | null; - + mapPass: RenderTarget | null; /** * Model to shadow camera space, to compute location and depth in shadow map. - * Stored in a {@link Matrix4 | Matrix4}. - * @remarks This is computed internally during rendering. - * @defaultValue new THREE.Matrix4() + * This is computed internally during rendering. */ matrix: Matrix4; - /** - * Enables automatic updates of the light's shadow. If you do not require dynamic lighting / shadows, you may set this to `false`. - * @defaultValue `true` + * Enables automatic updates of the light's shadow. If you do not require dynamic + * lighting / shadows, you may set this to `false`. + * + * @default true */ autoUpdate: boolean; - /** * When set to `true`, shadow maps will be updated in the next `render` call. - * If you have set {@link autoUpdate} to `false`, you will need to set this property to `true` and then make a render call to update the light's shadow. - * @defaultValue `false` + * If you have set {@link LightShadow#autoUpdate} to `false`, you will need to + * set this property to `true` and then make a render call to update the light's shadow. + * + * @default false */ needsUpdate: boolean; - /** - * Used internally by the renderer to get the number of viewports that need to be rendered for this shadow. + * Used internally by the renderer to get the number of viewports that need + * to be rendered for this shadow. + * + * @return {number} The viewport count. */ getViewportCount(): number; - /** - * Copies value of all the properties from the {@link {@link LightShadow} | source} to this Light. - * @param source - */ - copy(source: LightShadow): this; - - /** - * Creates a new {@link LightShadow} with the same properties as this one. - */ - clone(recursive?: boolean): this; - - /** - * Serialize this LightShadow. - */ - toJSON(): LightShadowJSON; - - /** - * Gets the shadow cameras frustum - * @remarks - * Used internally by the renderer to cull objects. + * Gets the shadow cameras frustum. Used internally by the renderer to cull objects. + * + * @return {Frustum} The shadow camera frustum. */ getFrustum(): Frustum; - /** * Update the matrices for the camera and shadow, used internally by the renderer. - * @param light The light for which the shadow is being rendered. + * + * @param {Light} light - The light for which the shadow is being rendered. */ updateMatrices(light: Light): void; - + /** + * Returns a viewport definition for the given viewport index. + * + * @param {number} viewportIndex - The viewport index. + * @return {Vector4} The viewport. + */ getViewport(viewportIndex: number): Vector4; - /** - * Used internally by the renderer to extend the shadow map to contain all viewports + * Returns the frame extends. + * + * @return {Vector2} The frame extends. */ getFrameExtents(): Vector2; - /** - * Frees the GPU-related resources allocated by this instance - * @remarks - * Call this method whenever this instance is no longer used in your app. + * Frees the GPU-related resources allocated by this instance. Call this + * method whenever this instance is no longer used in your app. */ dispose(): void; + /** + * Copies the values of the given light shadow instance to this instance. + * + * @param {LightShadow} source - The light shadow to copy. + * @return {LightShadow} A reference to this light shadow instance. + */ + copy(source: LightShadow): this; + /** + * Returns a new light shadow instance with copied values from this instance. + * + * @return {LightShadow} A clone of this instance. + */ + clone(): this; + /** + * Serializes the light shadow into JSON. + * + * @return {Object} A JSON object representing the serialized light shadow. + * @see {@link ObjectLoader#parse} + */ + toJSON(): LightShadowJSON; } diff --git a/types/three/src/lights/PointLight.d.ts b/types/three/src/lights/PointLight.d.ts index 70d22bf7044996..09a9a006d0df24 100644 --- a/types/three/src/lights/PointLight.d.ts +++ b/types/three/src/lights/PointLight.d.ts @@ -12,102 +12,61 @@ export interface PointLightJSON extends LightJSON { } /** - * A light that gets emitted from a single point in all directions - * @remarks - * A common use case for this is to replicate the light emitted from a bare lightbulb. - * @example - * ```typescript - * const light = new THREE.PointLight(0xff0000, 1, 100); - * light.position.set(50, 50, 50); - * scene.add(light); + * A light that gets emitted from a single point in all directions. A common + * use case for this is to replicate the light emitted from a bare + * lightbulb. + * + * This light can cast shadows - see the {@link PointLightShadow} for details. + * + * ```js + * const light = new THREE.PointLight( 0xff0000, 1, 100 ); + * light.position.set( 50, 50, 50 ); + * scene.add( light ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_lights_pointlights | lights / pointlights } - * @see Example: {@link https://threejs.org/examples/#webgl_effects_anaglyph | effects / anaglyph } - * @see Example: {@link https://threejs.org/examples/#webgl_geometry_text | geometry / text } - * @see Example: {@link https://threejs.org/examples/#webgl_lensflares | lensflares } - * @see {@link https://threejs.org/docs/index.html#api/en/lights/PointLight | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/PointLight.js | Source} */ -export class PointLight extends Light { +export class PointLight extends Light { /** - * Creates a new PointLight. - * @param color Hexadecimal color of the light. Default is 0xffffff (white). Expects an `Integer` - * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1` - * @param distance Maximum range of the light. Default is 0 (no limit). - * @param decay The amount the light dims along the distance of the light. Expects a `Float`. Default `2` + * Constructs a new point light. + * + * @param {(number|Color|string)} [color=0xffffff] - The light's color. + * @param {number} [intensity=1] - The light's strength/intensity measured in candela (cd). + * @param {number} [distance=0] - Maximum range of the light. `0` means no limit. + * @param {number} [decay=2] - The amount the light dims along the distance of the light. */ constructor(color?: ColorRepresentation, intensity?: number, distance?: number, decay?: number); - - /** - * Read-only flag to check if a given object is of type {@link PointLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isPointLight: true; - /** - * @default 'PointLight' - */ - type: string; - - /** - * The light's intensity. + * This flag can be used for type testing. * - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — intensity is the luminous intensity of the light measured in candela (cd). - * @remarks Changing the intensity will also change the light's power. - * @remarks Expects a `Float` - * @defaultValue `1` + * @default true */ - intensity: number; - + readonly isPointLight: boolean; /** - * When **Default mode** — When distance is zero, light does not attenuate. When distance is non-zero, - * light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light. + * When distance is zero, light will attenuate according to inverse-square + * law to infinite distance. When distance is non-zero, light will attenuate + * according to inverse-square law until near the distance cutoff, where it + * will then attenuate quickly and smoothly to 0. Inherently, cutoffs are not + * physically correct. * - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — When distance is zero, - * light will attenuate according to inverse-square law to infinite distance. - * When distance is non-zero, light will attenuate according to inverse-square law until near the distance cutoff, - * where it will then attenuate quickly and smoothly to 0. Inherently, cutoffs are not physically correct. - * - * @defaultValue `0.0` - * @remarks Expects a `Float` + * @default 0 */ distance: number; - - /** - * If set to `true` light will cast dynamic shadows. - * **Warning**: This is expensive and requires tweaking to get shadows looking right. - * @see {@link THREE.PointLightShadow | PointLightShadow} for details. - * @defaultValue `false` - */ - castShadow: boolean; - /** - * The amount the light dims along the distance of the light. - * In context of physically-correct rendering the default value should not be changed. - * @remarks Expects a `Float` - * @defaultValue `2` + * The amount the light dims along the distance of the light. In context of + * physically-correct rendering the default value should not be changed. + * + * @default 2 */ decay: number; - /** - * A {@link THREE.PointLightShadow | PointLightShadow} used to calculate shadows for this light. - * The lightShadow's {@link LightShadow.camera | camera} is set to - * a {@link THREE.PerspectiveCamera | PerspectiveCamera} with {@link PerspectiveCamera.fov | fov} of 90, - * {@link PerspectiveCamera.aspect | aspect} of 1, - * {@link PerspectiveCamera.near | near} clipping plane at 0.5 - * and {@link PerspectiveCamera.far | far} clipping plane at 500. - * @defaultValue new THREE.PointLightShadow() + * This property holds the light's shadow configuration. */ shadow: PointLightShadow; - + set power(power: number); /** - * The light's power. - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — power is the luminous power of the light measured in lumens (lm). - * @remarks Changing the power will also change the light's intensity. - * @remarks Expects a `Float` + * The light's power. Power is the luminous power of the light measured in lumens (lm). + * Changing the power will also change the light's intensity. */ - power: number; - + get power(): number; + copy(source: PointLight, recursive?: boolean): this; toJSON(meta?: JSONMeta): PointLightJSON; } diff --git a/types/three/src/lights/PointLightShadow.d.ts b/types/three/src/lights/PointLightShadow.d.ts index cccd795dfc8f00..810057aa71a12a 100644 --- a/types/three/src/lights/PointLightShadow.d.ts +++ b/types/three/src/lights/PointLightShadow.d.ts @@ -2,14 +2,17 @@ import { PerspectiveCamera } from "../cameras/PerspectiveCamera.js"; import { LightShadow } from "./LightShadow.js"; /** - * Shadow for {@link THREE.PointLight | PointLight} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/PointLightShadow.js | Source} + * Represents the shadow configuration of point lights. */ export class PointLightShadow extends LightShadow { /** - * Read-only flag to check if a given object is of type {@link PointLightShadow}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * Constructs a new point light shadow. */ - readonly isPointLightShadow: true; + constructor(); + /** + * This flag can be used for type testing. + * + * @default true + */ + readonly isPointLightShadow: boolean; } diff --git a/types/three/src/lights/RectAreaLight.d.ts b/types/three/src/lights/RectAreaLight.d.ts index 2861e97940baf1..a4821d6d657ce1 100644 --- a/types/three/src/lights/RectAreaLight.d.ts +++ b/types/three/src/lights/RectAreaLight.d.ts @@ -2,81 +2,61 @@ import { ColorRepresentation } from "../math/Color.js"; import { Light } from "./Light.js"; /** - * {@link RectAreaLight} emits light uniformly across the face a rectangular plane - * @remarks - * This light type can be used to simulate light sources such as bright windows or strip lighting. + * This class emits light uniformly across the face a rectangular plane. + * This light type can be used to simulate light sources such as bright + * windows or strip lighting. + * * Important Notes: - * - There is no shadow support. - * - Only {@link MeshStandardMaterial | MeshStandardMaterial} and {@link MeshPhysicalMaterial | MeshPhysicalMaterial} are supported. - * - You have to include {@link https://threejs.org/examples/jsm/lights/RectAreaLightUniformsLib.js | RectAreaLightUniformsLib} into your scene and call `init()`. - * @example - * ```typescript - * const width = 10; - * const height = 10; - * const intensity = 1; - * const rectLight = new THREE.RectAreaLight(0xffffff, intensity, width, height); - * rectLight.position.set(5, 5, 0); - * rectLight.lookAt(0, 0, 0); - * scene.add(rectLight) - * const rectLightHelper = new RectAreaLightHelper(rectLight); - * rectLight.add(rectLightHelper); + * + * - There is no shadow support. + * - Only PBR materials are supported. + * - You have to include `RectAreaLightUniformsLib` (`WebGLRenderer`) or `RectAreaLightTexturesLib` (`WebGPURenderer`) + * into your app and init the uniforms/textures. + * + * ```js + * RectAreaLightUniformsLib.init(); // only relevant for WebGLRenderer + * THREE.RectAreaLightNode.setLTC( RectAreaLightTexturesLib.init() ); // only relevant for WebGPURenderer + * + * const intensity = 1; const width = 10; const height = 10; + * const rectLight = new THREE.RectAreaLight( 0xffffff, intensity, width, height ); + * rectLight.position.set( 5, 5, 0 ); + * rectLight.lookAt( 0, 0, 0 ); + * scene.add( rectLight ) * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_lights_rectarealight | WebGL / {@link RectAreaLight} } - * @see {@link https://threejs.org/docs/index.html#api/en/lights/RectAreaLight | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/RectAreaLight.js | Source} */ -export class RectAreaLight extends Light { +export class RectAreaLight extends Light { /** - * Creates a new {@link RectAreaLight}. - * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_. - * @param intensity The light's intensity, or brightness. Expects a `Float`. Default `1` - * @param width Width of the light. Expects a `Float`. Default `10` - * @param height Height of the light. Expects a `Float`. Default `10` + * Constructs a new area light. + * + * @param {(number|Color|string)} [color=0xffffff] - The light's color. + * @param {number} [intensity=1] - The light's strength/intensity. + * @param {number} [width=10] - The width of the light. + * @param {number} [height=10] - The height of the light. */ constructor(color?: ColorRepresentation, intensity?: number, width?: number, height?: number); - /** - * Read-only flag to check if a given object is of type {@link RectAreaLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * This flag can be used for type testing. + * + * @default true */ - readonly isRectAreaLight: true; - - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `RectAreaLight` - */ - override readonly type: string | "RectAreaLight"; - + readonly isRectAreaLight: boolean; /** * The width of the light. - * @remarks Expects a `Float` - * @defaultValue `10` + * + * @default 10 */ width: number; - /** * The height of the light. - * @remarks Expects a `Float` - * @defaultValue `10` + * + * @default 10 */ height: number; - - /** - * The light's intensity. - * @remarks Changing the intensity will also change the light's power. - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — intensity is the luminance (brightness) of the light measured in nits (cd/m^2). - * @remarks Expects a `Float` - * @defaultValue `1` - */ - intensity: number; - + set power(power: number); /** - * The light's power. - * @remarks Changing the power will also change the light's intensity. - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — power is the luminous power of the light measured in lumens (lm). - * @remarks Expects a `Float` + * The light's power. Power is the luminous power of the light measured in lumens (lm). + * Changing the power will also change the light's intensity. */ - power: number; + get power(): number; + copy(source: RectAreaLight): this; } diff --git a/types/three/src/lights/SpotLight.d.ts b/types/three/src/lights/SpotLight.d.ts index 73a0e5af199709..2b1e77c58275f5 100644 --- a/types/three/src/lights/SpotLight.d.ts +++ b/types/three/src/lights/SpotLight.d.ts @@ -1,6 +1,5 @@ import { JSONMeta, Object3D } from "../core/Object3D.js"; import { ColorRepresentation } from "../math/Color.js"; -import { Vector3 } from "../math/Vector3.js"; import { Texture } from "../textures/Texture.js"; import { Light, LightJSON } from "./Light.js"; import { LightShadowJSON } from "./LightShadow.js"; @@ -19,35 +18,35 @@ export interface SpotLightJSON extends LightJSON { } /** - * This light gets emitted from a single point in one direction, along a cone that increases in size the further from the light it gets. - * @example - * ```typescript - * // white {@link SpotLight} shining from the side, modulated by a texture, casting a shadow - * const {@link SpotLight} = new THREE.SpotLight(0xffffff); - * spotLight.position.set(100, 1000, 100); - * spotLight.map = new THREE.TextureLoader().load(url); + * This light gets emitted from a single point in one direction, along a cone + * that increases in size the further from the light it gets. + * + * This light can cast shadows - see the {@link SpotLightShadow} for details. + * + * ```js + * // white spotlight shining from the side, modulated by a texture + * const spotLight = new THREE.SpotLight( 0xffffff ); + * spotLight.position.set( 100, 1000, 100 ); + * spotLight.map = new THREE.TextureLoader().load( url ); + * * spotLight.castShadow = true; * spotLight.shadow.mapSize.width = 1024; * spotLight.shadow.mapSize.height = 1024; * spotLight.shadow.camera.near = 500; * spotLight.shadow.camera.far = 4000; - * spotLight.shadow.camera.fov = 30; - * scene.add(spotLight); + * spotLight.shadow.camera.fov = 30;s * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_lights_spotlight | lights / {@link SpotLight} } - * @see Example: {@link https://threejs.org/examples/#webgl_lights_spotlights | lights / spotlights } - * @see {@link https://threejs.org/docs/index.html#api/en/lights/SpotLight | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/SpotLight.js | Source} */ -export class SpotLight extends Light { +export class SpotLight extends Light { /** - * Creates a new SpotLight. - * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_. - * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1`. - * @param distance Maximum range of the light. Default is 0 (no limit). Expects a `Float`. - * @param angle Maximum angle of light dispersion from its direction whose upper bound is Math.PI/2. - * @param penumbra Percent of the {@link SpotLight} cone that is attenuated due to penumbra. Takes values between zero and 1. Expects a `Float`. Default `0`. - * @param decay The amount the light dims along the distance of the light. Expects a `Float`. Default `2`. + * Constructs a new spot light. + * + * @param {(number|Color|string)} [color=0xffffff] - The light's color. + * @param {number} [intensity=1] - The light's strength/intensity measured in candela (cd). + * @param {number} [distance=0] - Maximum range of the light. `0` means no limit. + * @param {number} [angle=Math.PI/3] - Maximum angle of light dispersion from its direction whose upper bound is `Math.PI/2`. + * @param {number} [penumbra=0] - Percent of the spotlight cone that is attenuated due to penumbra. Value range is `[0,1]`. + * @param {number} [decay=2] - The amount the light dims along the distance of the light. */ constructor( color?: ColorRepresentation, @@ -57,123 +56,70 @@ export class SpotLight extends Light { penumbra?: number, decay?: number, ); - - /** - * Read-only flag to check if a given object is of type {@link SpotLight}. - * @remarks This is a _constant_ value - * @defaultValue `true` - */ - readonly isSpotLight: true; - /** - * A Read-only _string_ to check if `this` object type. - * @remarks Sub-classes will update this value. - * @defaultValue `SpotLight` - */ - override readonly type: string | "SpotLight"; - - /** - * This is set equal to {@link THREE.Object3D.DEFAULT_UP | Object3D.DEFAULT_UP} (0, 1, 0), so that the light shines from the top down. - * @defaultValue `{@link Object3D.DEFAULT_UP}` + * This flag can be used for type testing. + * + * @default true */ - readonly position: Vector3; - + readonly isSpotLight: boolean; /** - * The {@link SpotLight} points from its {@link SpotLight.position | position} to target.position. - * @remarks - * **Note**: For the target's position to be changed to anything other than the default, - * it must be added to the {@link Scene | scene} using + * The spot light points from its position to the + * target's position. * - * ```typescript - * scene.add( light.target ); - * ``` + * For the target's position to be changed to anything other + * than the default, it must be added to the scene. * - * This is so that the target's {@link Object3D.matrixWorld | matrixWorld} gets automatically updated each frame. - * It is also possible to set the target to be another object in the scene (anything with a {@link THREE.Object3D.position | position} property), like so: - * ```typescript - * const targetObject = new THREE.Object3D(); - * scene.add(targetObject); - * light.target = targetObject; - * ``` - * The {@link SpotLight} will now track the target object. - * @defaultValue `new THREE.Object3D()` _The default position of the target is *(0, 0, 0)*._ + * It is also possible to set the target to be another 3D object + * in the scene. The light will now track the target object. */ target: Object3D; - /** - * If set to `true` light will cast dynamic shadows. - * @remarks **Warning**: This is expensive and requires tweaking to get shadows looking right. the {@link THREE.SpotLightShadow | SpotLightShadow} for details. - * @defaultValue `false` - */ - override castShadow: boolean; - - /** - * The light's intensity. - * @remarks Changing the intensity will also change the light's power. - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — intensity is the luminous intensity of the light measured in candela (cd). - * @remarks Expects a `Float` - * @defaultValue `1` - */ - intensity: number; - - /** - * When **Default mode** — When distance is zero, light does not attenuate. When distance is non-zero, - * light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light. + * Maximum range of the light. `0` means no limit. * - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — When distance is zero, - * light will attenuate according to inverse-square law to infinite distance. - * When distance is non-zero, light will attenuate according to inverse-square law until near the distance cutoff, - * where it will then attenuate quickly and smoothly to `0`. Inherently, cutoffs are not physically correct. - * @remarks Expects a `Float` - * @defaultValue `0.0` + * @default 0 */ distance: number; - /** - * Maximum extent of the spotlight, in radians, from its direction. - * @remarks Should be no more than `Math.PI/2`. - * @remarks Expects a `Float` - * @defaultValue `Math.PI / 3` + * Maximum angle of light dispersion from its direction whose upper bound is `Math.PI/2`. + * + * @default Math.PI/3 */ angle: number; - /** - * The amount the light dims along the distance of the light. - * In context of physically-correct rendering the default value should not be changed. - * @remarks Expects a `Float` - * @defaultValue `2` + * Percent of the spotlight cone that is attenuated due to penumbra. + * Value range is `[0,1]`. + * + * @default 0 */ - decay: number; - + penumbra: number; /** - * A {@link THREE.SpotLightShadow | SpotLightShadow} used to calculate shadows for this light. - * @defaultValue `new THREE.SpotLightShadow()` + * The amount the light dims along the distance of the light. In context of + * physically-correct rendering the default value should not be changed. + * + * @default 2 */ - shadow: SpotLightShadow; - + decay: number; /** - * The light's power. - * @remarks Changing the power will also change the light's intensity. - * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — power is the luminous power of the light measured in lumens (lm). - * @remarks Expects a `Float` + * A texture used to modulate the color of the light. The spot light + * color is mixed with the RGB value of this texture, with a ratio + * corresponding to its alpha value. The cookie-like masking effect is + * reproduced using pixel values (0, 0, 0, 1-cookie_value). + * + * *Warning*: This property is disabled if {@link Object3D#castShadow} is set to `false`. + * + * @default null */ - power: number; - + map: Texture | null; /** - * Percent of the {@link SpotLight} cone that is attenuated due to penumbra. - * @remarks Takes values between zero and 1. - * @remarks Expects a `Float` - * @defaultValue `0.0` + * This property holds the light's shadow configuration. */ - penumbra: number; - + shadow: SpotLightShadow; + set power(power: number); /** - * A {@link THREE.Texture | Texture} used to modulate the color of the light. - * The spot light color is mixed with the _RGB_ value of this texture, with a ratio corresponding to its alpha value. - * The cookie-like masking effect is reproduced using pixel values (0, 0, 0, 1-cookie_value). - * @remarks **Warning**: {@link SpotLight.map} is disabled if {@link SpotLight.castShadow} is `false`. + * The light's power. Power is the luminous power of the light measured in lumens (lm). + * Changing the power will also change the light's intensity. */ - map: Texture | null; - + get power(): number; + copy(source: SpotLight, recursive?: boolean): this; toJSON(meta?: JSONMeta): SpotLightJSON; } diff --git a/types/three/src/lights/SpotLightShadow.d.ts b/types/three/src/lights/SpotLightShadow.d.ts index 2cb3c62eedd4b0..8eab600c403579 100644 --- a/types/three/src/lights/SpotLightShadow.d.ts +++ b/types/three/src/lights/SpotLightShadow.d.ts @@ -2,73 +2,31 @@ import { PerspectiveCamera } from "../cameras/PerspectiveCamera.js"; import { LightShadow } from "./LightShadow.js"; /** - * This is used internally by {@link SpotLight | SpotLights} for calculating shadows. - * @example - * ```typescript - * //Create a WebGLRenderer and turn on shadows in the renderer - * const renderer = new THREE.WebGLRenderer(); - * renderer.shadowMap.enabled = true; - * renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - * //Create a SpotLight and turn on shadows for the light - * const light = new THREE.SpotLight(0xffffff); - * light.castShadow = true; // default false - * scene.add(light); - * //Set up shadow properties for the light - * light.shadow.mapSize.width = 512; // default - * light.shadow.mapSize.height = 512; // default - * light.shadow.camera.near = 0.5; // default - * light.shadow.camera.far = 500; // default - * light.shadow.focus = 1; // default - * //Create a sphere that cast shadows (but does not receive them) - * const sphereGeometry = new THREE.SphereGeometry(5, 32, 32); - * const sphereMaterial = new THREE.MeshStandardMaterial({ - * color: 0xff0000 - * }); - * const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial); - * sphere.castShadow = true; //default is false - * sphere.receiveShadow = false; //default - * scene.add(sphere); - * //Create a plane that receives shadows (but does not cast them) - * const planeGeometry = new THREE.PlaneGeometry(20, 20, 32, 32); - * const planeMaterial = new THREE.MeshStandardMaterial({ - * color: 0x00ff00 - * }) - * const plane = new THREE.Mesh(planeGeometry, planeMaterial); - * plane.receiveShadow = true; - * scene.add(plane); - * //Create a helper for the shadow camera (optional) - * const helper = new THREE.CameraHelper(light.shadow.camera); - * scene.add(helper); - * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/lights/shadows/SpotLightShadow | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/SpotLightShadow.js | Source} + * Represents the shadow configuration of directional lights. */ export class SpotLightShadow extends LightShadow { /** - * Read-only flag to check if a given object is of type {@link SpotLightShadow}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * Constructs a new spot light shadow. */ - readonly isSpotLightShadow: true; - + constructor(); /** - * The light's view of the world. - * @remarks This is used to generate a depth map of the scene; objects behind other objects from the light's perspective will be in shadow. - * @remarks - * The {@link THREE.PerspectiveCamera.fov | fov} will track the {@link THREE.SpotLight.angle | angle} property - * of the owning {@link SpotLight | SpotLight} via the {@link SpotLightShadow.update | update} method. - * Similarly, the {@link THREE.PerspectiveCamera.aspect | aspect} property will track the aspect of the {@link LightShadow.mapSize | mapSize}. - * If the {@link SpotLight.distance | distance} property of the light is set, the {@link THREE.PerspectiveCamera.far | far} clipping plane will track that, otherwise it defaults to `500`. - * @defaultValue is a {@link THREE.PerspectiveCamera | PerspectiveCamera} with {@link THREE.PerspectiveCamera.near | near} clipping plane at `0.5`. + * This flag can be used for type testing. + * + * @default true */ - camera: PerspectiveCamera; - + readonly isSpotLightShadow: boolean; /** - * Used to focus the shadow camera. - * @remarks The camera's field of view is set as a percentage of the spotlight's field-of-view. Range is `[0, 1]`. 0`. - * @defaultValue `1` + * Used to focus the shadow camera. The camera's field of view is set as a + * percentage of the spotlight's field-of-view. Range is `[0, 1]`. + * + * @default 1 */ focus: number; - + /** + * Texture aspect ratio. + * + * @default 1 + */ aspect: number; + copy(source: SpotLightShadow): this; } diff --git a/types/three/src/lights/webgpu/IESSpotLight.d.ts b/types/three/src/lights/webgpu/IESSpotLight.d.ts index bf1b660061d3ed..8882642476ddb0 100644 --- a/types/three/src/lights/webgpu/IESSpotLight.d.ts +++ b/types/three/src/lights/webgpu/IESSpotLight.d.ts @@ -1,6 +1,18 @@ import { Texture } from "../../textures/Texture.js"; import { SpotLight } from "../SpotLight.js"; -export default class IESSpotLight extends SpotLight { +/** + * A IES version of {@link SpotLight}. Can only be used with {@link WebGPURenderer}. + */ +declare class IESSpotLight extends SpotLight { + /** + * The IES map. It's a lookup table that stores normalized attenuation factors + * (0.0 to 1.0) that represent the light's intensity at a specific angle. + * + * @default null + */ iesMap: Texture | null; + copy(source: IESSpotLight, recursive?: boolean): this; } + +export default IESSpotLight; diff --git a/types/three/src/lights/webgpu/ProjectorLight.d.ts b/types/three/src/lights/webgpu/ProjectorLight.d.ts index 32a217daef0273..834c8732f98607 100644 --- a/types/three/src/lights/webgpu/ProjectorLight.d.ts +++ b/types/three/src/lights/webgpu/ProjectorLight.d.ts @@ -1,17 +1,16 @@ -import { ColorRepresentation } from "../../math/Color.js"; import { SpotLight } from "../SpotLight.js"; +/** + * A projector light version of {@link SpotLight}. Can only be used with {@link WebGPURenderer}. + */ declare class ProjectorLight extends SpotLight { + /** + * Aspect ratio of the light. Set to `null` to use the texture aspect ratio. + * + * @default null + */ aspect: number | null; - - constructor( - color?: ColorRepresentation, - intensity?: number, - distance?: number, - angle?: number, - penumbra?: number, - decay?: number, - ); + copy(source: ProjectorLight, recursive?: boolean): this; } export default ProjectorLight; diff --git a/types/three/src/materials/MeshLambertMaterial.d.ts b/types/three/src/materials/MeshLambertMaterial.d.ts index cf42f76bea8a91..fb4fc9625c7562 100644 --- a/types/three/src/materials/MeshLambertMaterial.d.ts +++ b/types/three/src/materials/MeshLambertMaterial.d.ts @@ -180,6 +180,12 @@ export interface MeshLambertMaterialProperties extends MaterialProperties { * @default 1 */ reflectivity: number; + /** + * Scales the effect of the environment map by multiplying its color. + * + * @default 1 + */ + envMapIntensity: number; /** * The index of refraction (IOR) of air (approximately 1) divided by the * index of refraction of the material. It is used with environment mapping diff --git a/types/three/src/materials/MeshPhongMaterial.d.ts b/types/three/src/materials/MeshPhongMaterial.d.ts index c1cc686c20a339..20a882b8d7cf94 100644 --- a/types/three/src/materials/MeshPhongMaterial.d.ts +++ b/types/three/src/materials/MeshPhongMaterial.d.ts @@ -194,6 +194,12 @@ export interface MeshPhongMaterialProperties extends MaterialProperties { * @default 1 */ reflectivity: number; + /** + * Scales the effect of the environment map by multiplying its color. + * + * @default 1 + */ + envMapIntensity: number; /** * The index of refraction (IOR) of air (approximately 1) divided by the * index of refraction of the material. It is used with environment mapping diff --git a/types/three/src/materials/nodes/Line2NodeMaterial.d.ts b/types/three/src/materials/nodes/Line2NodeMaterial.d.ts index 9d4234166dec40..1766a71e30e24c 100644 --- a/types/three/src/materials/nodes/Line2NodeMaterial.d.ts +++ b/types/three/src/materials/nodes/Line2NodeMaterial.d.ts @@ -4,12 +4,6 @@ import { MapColorPropertiesToColorRepresentations } from "../Material.js"; import NodeMaterial, { NodeMaterialNodeProperties } from "./NodeMaterial.js"; export interface Line2NodeMaterialNodeProperties extends NodeMaterialNodeProperties { - /** - * Whether vertex colors should be used or not. - * - * @default false - */ - useColor: boolean; /** * The dash offset. * diff --git a/types/three/src/materials/nodes/LineBasicNodeMaterial.d.ts b/types/three/src/materials/nodes/LineBasicNodeMaterial.d.ts index fe6b177a83e8a3..62d2970aa1c91c 100644 --- a/types/three/src/materials/nodes/LineBasicNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/LineBasicNodeMaterial.d.ts @@ -15,8 +15,6 @@ export interface LineBasicNodeMaterialParameters /** * Node material version of {@link LineBasicMaterial}. - * - * @augments NodeMaterial */ declare class LineBasicNodeMaterial extends NodeMaterial { /** @@ -28,8 +26,6 @@ declare class LineBasicNodeMaterial extends NodeMaterial { /** * This flag can be used for type testing. * - * @type {boolean} - * @readonly * @default true */ readonly isLineBasicNodeMaterial: boolean; diff --git a/types/three/src/materials/nodes/MeshBasicNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshBasicNodeMaterial.d.ts index a42ef14f1d9398..5c7e59a6a6213d 100644 --- a/types/three/src/materials/nodes/MeshBasicNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshBasicNodeMaterial.d.ts @@ -5,6 +5,7 @@ import { MapColorPropertiesToColorRepresentations } from "../Material.js"; import { MeshBasicMaterialParameters, MeshBasicMaterialProperties } from "../MeshBasicMaterial.js"; import NodeMaterial, { NodeMaterialNodeProperties } from "./NodeMaterial.js"; +// eslint-disable-next-line @typescript-eslint/no-empty-interface export interface MeshBasicNodeMaterialNodeProperties extends NodeMaterialNodeProperties { } @@ -28,8 +29,6 @@ declare class MeshBasicNodeMaterial extends NodeMaterial { /** * This flag can be used for type testing. * - * @type {boolean} - * @readonly * @default true */ readonly isMeshBasicNodeMaterial: boolean; diff --git a/types/three/src/materials/nodes/MeshLambertNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshLambertNodeMaterial.d.ts index 88dd57330a75c5..45c653567b4560 100644 --- a/types/three/src/materials/nodes/MeshLambertNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshLambertNodeMaterial.d.ts @@ -29,8 +29,6 @@ declare class MeshLambertNodeMaterial extends NodeMaterial { /** * This flag can be used for type testing. * - * @type {boolean} - * @readonly * @default true */ readonly isMeshLambertNodeMaterial: boolean; diff --git a/types/three/src/materials/nodes/MeshNormalNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshNormalNodeMaterial.d.ts index ce18f998329be3..05c89c81b11283 100644 --- a/types/three/src/materials/nodes/MeshNormalNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshNormalNodeMaterial.d.ts @@ -25,8 +25,6 @@ declare class MeshNormalNodeMaterial extends NodeMaterial { constructor(parameters?: MeshNormalNodeMaterialParameters); /** * This flag can be used for type testing. - * - * @type {boolean} */ readonly isMeshNormalNodeMaterial: boolean; setValues(values?: MeshNormalNodeMaterialParameters): void; diff --git a/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts index 0fd2fe66b1ce62..5ad95d202b7e95 100644 --- a/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshSSSNodeMaterial.d.ts @@ -1,4 +1,3 @@ -import InputNode from "../../nodes/core/InputNode.js"; import { LightingModelDirectInput } from "../../nodes/core/LightingModel.js"; import Node from "../../nodes/core/Node.js"; import NodeBuilder from "../../nodes/core/NodeBuilder.js"; @@ -58,23 +57,23 @@ export interface MeshSSSNodeMaterialNodeProperties extends MeshPhysicalNodeMater /** * Represents the distortion factor. */ - thicknessDistortionNode: InputNode; + thicknessDistortionNode: Node<"float">; /** * Represents the thickness ambient factor. */ - thicknessAmbientNode: InputNode; + thicknessAmbientNode: Node<"float">; /** * Represents the thickness attenuation. */ - thicknessAttenuationNode: InputNode; + thicknessAttenuationNode: Node<"float">; /** * Represents the thickness power. */ - thicknessPowerNode: InputNode; + thicknessPowerNode: Node<"float">; /** * Represents the thickness scale. */ - thicknessScaleNode: InputNode; + thicknessScaleNode: Node<"float">; } // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -87,8 +86,6 @@ export interface MeshSSSNodeMaterialParameters /** * This node material is an experimental extension of {@link MeshPhysicalNodeMaterial} * that implements a Subsurface scattering (SSS) term. - * - * @augments MeshPhysicalNodeMaterial */ declare class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial { constructor(parameters?: MeshSSSNodeMaterialParameters); diff --git a/types/three/src/materials/nodes/MeshToonNodeMaterial.d.ts b/types/three/src/materials/nodes/MeshToonNodeMaterial.d.ts index c5c013981af7cf..b6189d9e409ca0 100644 --- a/types/three/src/materials/nodes/MeshToonNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/MeshToonNodeMaterial.d.ts @@ -16,8 +16,6 @@ export interface MeshToonNodeMaterialParameters /** * Node material version of {@link MeshToonMaterial}. - * - * @augments NodeMaterial */ declare class MeshToonNodeMaterial extends NodeMaterial { /** @@ -29,8 +27,6 @@ declare class MeshToonNodeMaterial extends NodeMaterial { /** * This flag can be used for type testing. * - * @type {boolean} - * @readonly * @default true */ readonly isMeshToonNodeMaterial: boolean; diff --git a/types/three/src/materials/nodes/NodeMaterial.d.ts b/types/three/src/materials/nodes/NodeMaterial.d.ts index b941010e7aa27a..ee26ad9e902b14 100644 --- a/types/three/src/materials/nodes/NodeMaterial.d.ts +++ b/types/three/src/materials/nodes/NodeMaterial.d.ts @@ -88,7 +88,7 @@ export interface NodeMaterialNodeProperties { * * @default null */ - colorNode: Node | null; + colorNode: Node<"float"> | Node<"vec2"> | Node<"vec3"> | Node<"vec4"> | Node<"color"> | null; /** * The normals of node materials are by default inferred from the `normalMap`/`normalScale` * or `bumpMap`/`bumpScale` properties. This node property allows to overwrite the default @@ -153,6 +153,12 @@ export interface NodeMaterialNodeProperties { * @default null */ maskNode: Node | null; + /** + * This node can be used to implement a shadow mask for the material. + * + * @default null + */ + maskShadowNode: Node | null; /** * The local vertex positions are computed based on multiple factors like the * attribute data, morphing or skinning. This node property allows to overwrite @@ -181,7 +187,7 @@ export interface NodeMaterialNodeProperties { * * @default null */ - geometryNode: (() => Node) | null; + geometryNode: Node | null; /** * Allows to overwrite depth values in the fragment shader. * @@ -278,7 +284,7 @@ export interface NodeMaterialNodeProperties { * * @default null */ - contextNode: ContextNode | null; + contextNode: ContextNode | null; } // eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/types/three/src/materials/nodes/SpriteNodeMaterial.d.ts b/types/three/src/materials/nodes/SpriteNodeMaterial.d.ts index 5e1543b3c6c851..acb44a3ee07fae 100644 --- a/types/three/src/materials/nodes/SpriteNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/SpriteNodeMaterial.d.ts @@ -28,7 +28,6 @@ export interface SpriteNodeMaterialNodeProperties extends NodeMaterialNodeProper /** * Whether to use size attenuation or not. * - * @type {boolean} * @default true */ get sizeAttenuation(): boolean; @@ -55,8 +54,6 @@ declare class SpriteNodeMaterial extends NodeMaterial { /** * This flag can be used for type testing. * - * @type {boolean} - * @readonly * @default true */ readonly isSpriteNodeMaterial: boolean; diff --git a/types/three/src/materials/nodes/VolumeNodeMaterial.d.ts b/types/three/src/materials/nodes/VolumeNodeMaterial.d.ts index cafd4db985d649..b60b252b19eb94 100644 --- a/types/three/src/materials/nodes/VolumeNodeMaterial.d.ts +++ b/types/three/src/materials/nodes/VolumeNodeMaterial.d.ts @@ -32,8 +32,6 @@ export interface VolumeNodeMaterialParameters /** * Volume node material. - * - * @augments NodeMaterial */ declare class VolumeNodeMaterial extends NodeMaterial { /** diff --git a/types/three/src/materials/nodes/manager/NodeMaterialObserver.d.ts b/types/three/src/materials/nodes/manager/NodeMaterialObserver.d.ts index e95b24b215139a..c58e0df704716a 100644 --- a/types/three/src/materials/nodes/manager/NodeMaterialObserver.d.ts +++ b/types/three/src/materials/nodes/manager/NodeMaterialObserver.d.ts @@ -1,111 +1,56 @@ import { BufferAttribute } from "../../../core/BufferAttribute.js"; import { Light } from "../../../lights/Light.js"; -import { Matrix4 } from "../../../math/Matrix4.js"; import NodeBuilder from "../../../nodes/core/NodeBuilder.js"; import NodeFrame from "../../../nodes/core/NodeFrame.js"; import LightsNode from "../../../nodes/lighting/LightsNode.js"; import Renderer from "../../../renderers/common/Renderer.js"; import RenderObject from "../../../renderers/common/RenderObject.js"; import { Material } from "../../Material.js"; -declare const refreshUniforms: readonly [ - "alphaMap", - "alphaTest", - "anisotropy", - "anisotropyMap", - "anisotropyRotation", - "aoMap", - "aoMapIntensity", - "attenuationColor", - "attenuationDistance", - "bumpMap", - "clearcoat", - "clearcoatMap", - "clearcoatNormalMap", - "clearcoatNormalScale", - "clearcoatRoughness", - "color", - "dispersion", - "displacementMap", - "emissive", - "emissiveIntensity", - "emissiveMap", - "envMap", - "envMapIntensity", - "gradientMap", - "ior", - "iridescence", - "iridescenceIOR", - "iridescenceMap", - "iridescenceThicknessMap", - "lightMap", - "lightMapIntensity", - "map", - "matcap", - "metalness", - "metalnessMap", - "normalMap", - "normalScale", - "opacity", - "roughness", - "roughnessMap", - "sheen", - "sheenColor", - "sheenColorMap", - "sheenRoughnessMap", - "shininess", - "specular", - "specularColor", - "specularColorMap", - "specularIntensity", - "specularIntensityMap", - "specularMap", - "thickness", - "transmission", - "transmissionMap", -]; -type RefreshUniform = (typeof refreshUniforms)[number]; -type MaterialData = { - [K in RefreshUniform]?: unknown; -}; -interface AttributesData { - [name: string]: { - version: number; - }; -} -interface RenderObjectData { - material: MaterialData; - geometry: { - id: number; - attributes: AttributesData; - indexVersion: number | null; - drawRange: { - start: number; - count: number; - }; - }; - worldMatrix: Matrix4; - version?: number; -} -interface LightData { - map: number; -} + /** * This class is used by {@link WebGPURenderer} as management component. * It's primary purpose is to determine whether render objects require a * refresh right before they are going to be rendered or not. */ declare class NodeMaterialObserver { - renderObjects: WeakMap; - hasNode: boolean; - hasAnimation: boolean; - refreshUniforms: readonly RefreshUniform[]; - renderId: number; /** * Constructs a new node material observer. * * @param {NodeBuilder} builder - The node builder. */ constructor(builder: NodeBuilder); + /** + * A node material can be used by more than one render object so the + * monitor must maintain a list of render objects. + * + * @type {WeakMap} + */ + renderObjects: WeakMap; + /** + * Whether the material uses node objects or not. + * + * @type {boolean} + */ + hasNode: boolean; + /** + * Whether the node builder's 3D object is animated or not. + * + * @type {boolean} + */ + hasAnimation: boolean; + /** + * A list of all possible material uniforms + * + * @type {Array} + */ + refreshUniforms: string[]; + /** + * Holds the current render ID from the node frame. + * + * @type {number} + * @default 0 + */ + renderId: number; /** * Returns `true` if the given render object is verified for the first time of this observer. * @@ -126,7 +71,7 @@ declare class NodeMaterialObserver { * @param {RenderObject} renderObject - The render object. * @return {Object} The monitoring data. */ - getRenderObjectData(renderObject: RenderObject): RenderObjectData; + getRenderObjectData(renderObject: RenderObject): unknown; /** * Returns an attribute data structure holding the attributes versions for * monitoring. @@ -134,7 +79,7 @@ declare class NodeMaterialObserver { * @param {Object} attributes - The geometry attributes. * @return {Object} An object for monitoring the versions of attributes. */ - getAttributesData(attributes: Record): AttributesData; + getAttributesData(attributes: Record): unknown; /** * Returns `true` if the node builder's material uses * node properties. @@ -150,7 +95,7 @@ declare class NodeMaterialObserver { * @param {Material} material - The material. * @return {Object} An object for monitoring material properties. */ - getMaterialData(material: Material): MaterialData; + getMaterialData(material: Material): unknown; /** * Returns `true` if the given render object has not changed its state. * @@ -165,7 +110,7 @@ declare class NodeMaterialObserver { * @param {Array} materialLights - The material lights. * @return {Array} The lights data for the given material lights. */ - getLightsData(materialLights: Light[]): LightData[]; + getLightsData(materialLights: Light[]): unknown[]; /** * Returns the lights for the given lights node and render ID. * @@ -173,7 +118,7 @@ declare class NodeMaterialObserver { * @param {number} renderId - The render ID. * @return {Array} The lights for the given lights node and render ID. */ - getLights(lightsNode: LightsNode, renderId: number): LightData[]; + getLights(lightsNode: LightsNode, renderId: number): unknown[]; /** * Checks if the given render object requires a refresh. * @@ -183,4 +128,5 @@ declare class NodeMaterialObserver { */ needsRefresh(renderObject: RenderObject, nodeFrame: NodeFrame): boolean; } + export default NodeMaterialObserver; diff --git a/types/three/src/math/Color.d.ts b/types/three/src/math/Color.d.ts index dadc976bd397e0..eb40c9aaba30bf 100644 --- a/types/three/src/math/Color.d.ts +++ b/types/three/src/math/Color.d.ts @@ -221,6 +221,7 @@ export class Color { */ b: number; + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type set(...args: [color: ColorRepresentation] | [r: number, g: number, b: number]): this; /** diff --git a/types/three/src/math/Vector3.d.ts b/types/three/src/math/Vector3.d.ts index 4f14967d1865be..43dc5629b55127 100644 --- a/types/three/src/math/Vector3.d.ts +++ b/types/three/src/math/Vector3.d.ts @@ -98,7 +98,7 @@ export class Vector3 { */ addVectors(a: Vector3Like, b: Vector3Like): this; - addScaledVector(v: Vector3, s: number): this; + addScaledVector(v: Vector3Like, s: number): this; /** * Subtracts v from this vector. @@ -123,7 +123,7 @@ export class Vector3 { applyEuler(euler: Euler): this; - applyAxisAngle(axis: Vector3, angle: number): this; + applyAxisAngle(axis: Vector3Like, angle: number): this; applyMatrix3(m: Matrix3): this; diff --git a/types/three/src/math/interpolants/BezierInterpolant.d.ts b/types/three/src/math/interpolants/BezierInterpolant.d.ts new file mode 100644 index 00000000000000..f1d9cac02ff0f5 --- /dev/null +++ b/types/three/src/math/interpolants/BezierInterpolant.d.ts @@ -0,0 +1,7 @@ +import { Interpolant } from "../Interpolant.js"; + +export class BezierInterpolant extends Interpolant { + constructor(parameterPositions: any, samplesValues: any, sampleSize: number, resultBuffer?: any); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/types/three/src/nodes/Nodes.d.ts b/types/three/src/nodes/Nodes.d.ts index 9fc53df5fb9631..544fe185fe452f 100644 --- a/types/three/src/nodes/Nodes.d.ts +++ b/types/three/src/nodes/Nodes.d.ts @@ -9,6 +9,8 @@ export { default as BypassNode } from "./core/BypassNode.js"; export { default as ConstNode } from "./core/ConstNode.js"; export { default as ContextNode } from "./core/ContextNode.js"; export { default as IndexNode, IndexNodeScope } from "./core/IndexNode.js"; +export { default as InputNode } from "./core/InputNode.js"; +export { default as InspectorNode } from "./core/InspectorNode.js"; export { default as IsolateNode } from "./core/IsolateNode.js"; export { default as LightingModel, @@ -26,8 +28,9 @@ export { NodeBuilderContext, NodeData, } from "./core/NodeBuilder.js"; -export { default as NodeCache, ShaderStageNodeData } from "./core/NodeCache.js"; +export { default as NodeCache } from "./core/NodeCache.js"; export { default as NodeCode } from "./core/NodeCode.js"; +export { default as NodeError } from "./core/NodeError.js"; export { default as NodeFrame } from "./core/NodeFrame.js"; export { default as NodeFunctionInput } from "./core/NodeFunctionInput.js"; export { default as NodeUniform } from "./core/NodeUniform.js"; @@ -37,6 +40,7 @@ export { default as OutputStructNode } from "./core/OutputStructNode.js"; export { default as ParameterNode } from "./core/ParameterNode.js"; export { default as PropertyNode } from "./core/PropertyNode.js"; export { default as StackNode } from "./core/StackNode.js"; +export { default as StackTrace } from "./core/StackTrace.js"; export { default as StructNode } from "./core/StructNode.js"; export { default as StructTypeNode } from "./core/StructTypeNode.js"; export { default as SubBuildNode } from "./core/SubBuildNode.js"; @@ -49,32 +53,12 @@ export { default as VaryingNode } from "./core/VaryingNode.js"; import * as NodeUtils from "./core/NodeUtils.js"; export { NodeUtils }; -// utils -export { default as ArrayElementNode } from "./utils/ArrayElementNode.js"; -export { default as ConvertNode } from "./utils/ConvertNode.js"; -export { default as DebugNode } from "./utils/DebugNode.js"; -export { default as EventNode } from "./utils/EventNode.js"; -export { default as FunctionOverloadingNode } from "./utils/FunctionOverloadingNode.js"; -export { default as JoinNode } from "./utils/JoinNode.js"; -export { default as LoopNode } from "./utils/LoopNode.js"; -export { default as MaxMipLevelNode } from "./utils/MaxMipLevelNode.js"; -export { default as MemberNode } from "./utils/MemberNode.js"; -export { default as ReflectorNode, ReflectorNodeParameters } from "./utils/ReflectorNode.js"; -export { default as RemapNode } from "./utils/RemapNode.js"; -export { default as RotateNode } from "./utils/RotateNode.js"; -export { default as RTTNode, RTTNodeOptions } from "./utils/RTTNode.js"; -export { default as SetNode } from "./utils/SetNode.js"; -export { default as SplitNode } from "./utils/SplitNode.js"; -export { default as SpriteSheetUVNode } from "./utils/SpriteSheetUVNode.js"; -export { default as StorageArrayElementNode } from "./utils/StorageArrayElementNode.js"; - -// math -export { default as BitcastNode } from "./math/BitcastNode.js"; - // accessors export { default as BatchNode } from "./accessors/BatchNode.js"; export { default as BufferAttributeNode } from "./accessors/BufferAttributeNode.js"; export { default as BufferNode } from "./accessors/BufferNode.js"; +export { default as BuiltinNode } from "./accessors/BuiltinNode.js"; +export { default as ClippingNode } from "./accessors/ClippingNode.js"; export { default as CubeTextureNode } from "./accessors/CubeTextureNode.js"; export { default as InstancedMeshNode } from "./accessors/InstancedMeshNode.js"; export { default as InstanceNode } from "./accessors/InstanceNode.js"; @@ -84,9 +68,9 @@ export { default as ModelNode } from "./accessors/ModelNode.js"; export { default as MorphNode } from "./accessors/MorphNode.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 ReferenceNode } from "./accessors/ReferenceNode.js"; export { default as RendererReferenceNode } from "./accessors/RendererReferenceNode.js"; -export { default as SceneNode, SceneNodeScope } from "./accessors/SceneNode.js"; export { default as SkinningNode } from "./accessors/SkinningNode.js"; export { default as StorageBufferNode } from "./accessors/StorageBufferNode.js"; export { default as StorageTextureNode } from "./accessors/StorageTextureNode.js"; @@ -95,42 +79,47 @@ export { default as TextureNode } from "./accessors/TextureNode.js"; export { default as TextureSizeNode } from "./accessors/TextureSizeNode.js"; export { default as UniformArrayNode } from "./accessors/UniformArrayNode.js"; export { default as UserDataNode, NodeUserData } from "./accessors/UserDataNode.js"; +export { default as VelocityNode } from "./accessors/VelocityNode.js"; export { default as VertexColorNode } from "./accessors/VertexColorNode.js"; +// code +export { CodeNodeInclude, default as CodeNode } from "./code/CodeNode.js"; +export { default as ExpressionNode } from "./code/ExpressionNode.js"; +export { default as FunctionCallNode } from "./code/FunctionCallNode.js"; +export { default as FunctionNode } from "./code/FunctionNode.js"; + // display 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 PosterizeNode } from "./display/PosterizeNode.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"; +export { default as ToonOutlinePassNode } from "./display/ToonOutlinePassNode.js"; export { default as ViewportDepthNode, ViewportDepthNodeScope } from "./display/ViewportDepthNode.js"; export { default as ViewportDepthTextureNode } from "./display/ViewportDepthTextureNode.js"; export { default as ViewportSharedTextureNode } from "./display/ViewportSharedTextureNode.js"; export { default as ViewportTextureNode } from "./display/ViewportTextureNode.js"; -// code -export { CodeNodeInclude, default as CodeNode } from "./code/CodeNode.js"; -export { default as ExpressionNode } from "./code/ExpressionNode.js"; -export { default as FunctionCallNode } from "./code/FunctionCallNode.js"; -export { default as FunctionNode } from "./code/FunctionNode.js"; -export { default as ScriptableNode } from "./code/ScriptableNode.js"; -export { default as ScriptableValueNode } from "./code/ScriptableValueNode.js"; - // geometry export { default as RangeNode } from "./geometry/RangeNode.js"; // gpgpu +export { default as AtomicFunctionNode } from "./gpgpu/AtomicFunctionNode.js"; +export { default as BarrierNode } from "./gpgpu/BarrierNode.js"; +export { default as ComputeBuiltinNode } from "./gpgpu/ComputeBuiltinNode.js"; export { default as ComputeNode } from "./gpgpu/ComputeNode.js"; +export { default as SubgroupFunctionNode } from "./gpgpu/SubgroupFunctionNode.js"; +export { default as WorkgroupInfoNode } from "./gpgpu/WorkgroupInfoNode.js"; // lighting export { default as AmbientLightNode } from "./lighting/AmbientLightNode.js"; export { default as AnalyticLightNode } from "./lighting/AnalyticLightNode.js"; export { default as AONode } from "./lighting/AONode.js"; export { default as BasicEnvironmentNode } from "./lighting/BasicEnvironmentNode.js"; +export { default as BasicLightMapNode } from "./lighting/BasicLightMapNode.js"; export { default as DirectionalLightNode } from "./lighting/DirectionalLightNode.js"; export { default as EnvironmentNode } from "./lighting/EnvironmentNode.js"; export { default as HemisphereLightNode } from "./lighting/HemisphereLightNode.js"; @@ -141,18 +130,49 @@ export { default as LightingNode } from "./lighting/LightingNode.js"; export { default as LightProbeNode } from "./lighting/LightProbeNode.js"; export { default as LightsNode } from "./lighting/LightsNode.js"; export { default as PointLightNode } from "./lighting/PointLightNode.js"; +export { default as PointShadowNode } from "./lighting/PointShadowNode.js"; export { default as ProjectorLightNode } from "./lighting/ProjectorLightNode.js"; export { default as RectAreaLightNode, RectAreaLightTexturesLib } from "./lighting/RectAreaLightNode.js"; export { default as ShadowBaseNode } from "./lighting/ShadowBaseNode.js"; export { default as ShadowNode } from "./lighting/ShadowNode.js"; export { default as SpotLightNode } from "./lighting/SpotLightNode.js"; -// pmrem -export { default as PMREMNode } from "./pmrem/PMREMNode.js"; +// math +export { default as BitcastNode } from "./math/BitcastNode.js"; +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 PackFloatNode } from "./math/PackFloatNode.js"; +export { default as UnpackFloatNode } from "./math/UnpackFloatNode.js"; // parsers export { default as GLSLNodeParser } from "./parsers/GLSLNodeParser.js"; +// pmrem +export { default as PMREMNode } from "./pmrem/PMREMNode.js"; + +// utils +export { default as ArrayElementNode } from "./utils/ArrayElementNode.js"; +export { default as ConvertNode } from "./utils/ConvertNode.js"; +export { default as CubeMapNode } from "./utils/CubeMapNode.js"; +export { default as DebugNode } from "./utils/DebugNode.js"; +export { default as EventNode } from "./utils/EventNode.js"; +export { default as FlipNode } from "./utils/FlipNode.js"; +export { default as FunctionOverloadingNode } from "./utils/FunctionOverloadingNode.js"; +export { default as JoinNode } from "./utils/JoinNode.js"; +export { default as LoopNode } from "./utils/LoopNode.js"; +export { default as MaxMipLevelNode } from "./utils/MaxMipLevelNode.js"; +export { default as MemberNode } from "./utils/MemberNode.js"; +export { default as ReflectorNode, ReflectorNodeParameters } from "./utils/ReflectorNode.js"; +export { default as RemapNode } from "./utils/RemapNode.js"; +export { default as RotateNode } from "./utils/RotateNode.js"; +export { default as RTTNode, RTTNodeOptions } from "./utils/RTTNode.js"; +export { default as SampleNode } from "./utils/SampleNode.js"; +export { default as SetNode } from "./utils/SetNode.js"; +export { default as SplitNode } from "./utils/SplitNode.js"; +export { default as StorageArrayElementNode } from "./utils/StorageArrayElementNode.js"; + // lighting models export { default as PhongLightingModel } from "./functions/PhongLightingModel.js"; export { default as PhysicalLightingModel } from "./functions/PhysicalLightingModel.js"; diff --git a/types/three/src/nodes/TSL.d.ts b/types/three/src/nodes/TSL.d.ts index 2923ca9b1be3cd..2e1ea0f18d25b3 100644 --- a/types/three/src/nodes/TSL.d.ts +++ b/types/three/src/nodes/TSL.d.ts @@ -42,7 +42,7 @@ export * from "./utils/RemapNode.js"; export * from "./utils/RotateNode.js"; export * from "./utils/RTTNode.js"; export * from "./utils/SampleNode.js"; -export * from "./utils/SpriteSheetUVNode.js"; +export * from "./utils/SpriteSheetUV.js"; export * from "./utils/SpriteUtils.js"; export * from "./utils/Timer.js"; export * from "./utils/TriplanarTextures.js"; @@ -77,7 +77,7 @@ export * from "./accessors/Position.js"; export * from "./accessors/ReferenceNode.js"; export * from "./accessors/ReflectVector.js"; export * from "./accessors/RendererReferenceNode.js"; -export * from "./accessors/SceneNode.js"; +export * from "./accessors/SceneProperties.js"; export * from "./accessors/SkinningNode.js"; export * from "./accessors/StorageBufferNode.js"; export * from "./accessors/StorageTextureNode.js"; @@ -99,7 +99,6 @@ export * from "./display/ColorAdjustment.js"; export * from "./display/ColorSpaceNode.js"; export * from "./display/FrontFacingNode.js"; export * from "./display/NormalMapNode.js"; -export * from "./display/PosterizeNode.js"; export * from "./display/RenderOutputNode.js"; export * from "./display/ScreenNode.js"; export * from "./display/ToneMappingNode.js"; @@ -119,8 +118,6 @@ export * from "./code/CodeNode.js"; export * from "./code/ExpressionNode.js"; export * from "./code/FunctionCallNode.js"; export * from "./code/FunctionNode.js"; -export * from "./code/ScriptableNode.js"; -export * from "./code/ScriptableValueNode.js"; // fog export * from "./fog/Fog.js"; diff --git a/types/three/src/nodes/accessors/Arrays.d.ts b/types/three/src/nodes/accessors/Arrays.d.ts index df0a81a7b2f458..424417458da247 100644 --- a/types/three/src/nodes/accessors/Arrays.d.ts +++ b/types/three/src/nodes/accessors/Arrays.d.ts @@ -1,13 +1,22 @@ -import { TypedArray } from "../../core/BufferAttribute.js"; -import { Struct } from "../core/StructNode.js"; import StorageBufferNode from "./StorageBufferNode.js"; -export const attributeArray: ( - count: TypedArray | number, - type?: string | Struct, -) => StorageBufferNode; +interface ArrayFunction { + (count: number | Float32Array, type?: "float"): StorageBufferNode<"float">; + (count: number | Int32Array, type: "int"): StorageBufferNode<"int">; + (count: number | Uint32Array, type: "uint"): StorageBufferNode<"uint">; + (count: number | Float32Array, type: "vec2"): StorageBufferNode<"vec2">; + (count: number | Int32Array, type: "ivec2"): StorageBufferNode<"ivec2">; + (count: number | Uint32Array, type: "uvec2"): StorageBufferNode<"uvec2">; + (count: number | Float32Array, type: "vec3"): StorageBufferNode<"vec3">; + (count: number | Int32Array, type: "ivec3"): StorageBufferNode<"ivec3">; + (count: number | Uint32Array, type: "uvec3"): StorageBufferNode<"uvec3">; + (count: number | Float32Array, type: "vec4"): StorageBufferNode<"vec4">; + (count: number | Int32Array, type: "ivec4"): StorageBufferNode<"ivec4">; + (count: number | Uint32Array, type: "uvec4"): StorageBufferNode<"uvec4">; +} -export const instancedArray: ( - count: TypedArray | number, - type?: string | Struct, -) => StorageBufferNode; +export const attributeArray: ArrayFunction; + +export const instancedArray: ArrayFunction; + +export {}; diff --git a/types/three/src/nodes/accessors/BufferAttributeNode.d.ts b/types/three/src/nodes/accessors/BufferAttributeNode.d.ts index 97912d9870c352..975f7c057b9b30 100644 --- a/types/three/src/nodes/accessors/BufferAttributeNode.d.ts +++ b/types/three/src/nodes/accessors/BufferAttributeNode.d.ts @@ -5,6 +5,7 @@ import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribut import InputNode from "../core/InputNode.js"; import Node from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; + /** * In earlier `three.js` versions it was only possible to define attribute data * on geometry level. With `BufferAttributeNode`, it is also possible to do this @@ -27,15 +28,7 @@ import NodeBuilder from "../core/NodeBuilder.js"; * ``` * @augments InputNode */ -declare class BufferAttributeNode extends InputNode { - static get type(): string; - readonly isBufferNode: true; - bufferType: string | null; - bufferStride: number; - bufferOffset: number; - usage: Usage; - instanced: boolean; - attribute: BufferAttribute | InterleavedBufferAttribute | null; +declare class BufferAttributeNodeClass extends InputNode { /** * Constructs a new buffer attribute node. * @@ -45,11 +38,62 @@ declare class BufferAttributeNode extends InputNode( + value: TypedArray | InterleavedBuffer | BufferAttribute, + bufferType?: string | null, + bufferStride?: number, + bufferOffset?: number, + ): BufferAttributeNode; +}; + +type BufferAttributeNode = + & InputNode + & BufferAttributeNodeClass; + export default BufferAttributeNode; + /** * TSL function for creating a buffer attribute node. * - * @tsl * @function * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data. * @param {?string} [type=null] - The buffer type (e.g. `'vec3'`). @@ -115,17 +181,17 @@ export default BufferAttributeNode; * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const bufferAttribute: ( +export declare const bufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, - type?: string | null, + type?: TNodeType | null, stride?: number, offset?: number, -) => Node; +) => Node; + /** * TSL function for creating a buffer attribute node but with dynamic draw usage. * Use this function if attribute data are updated per frame. * - * @tsl * @function * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data. * @param {?string} [type=null] - The buffer type (e.g. `'vec3'`). @@ -133,16 +199,16 @@ export declare const bufferAttribute: ( * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const dynamicBufferAttribute: ( +export declare const dynamicBufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, - type?: string | null, + type?: TNodeType | null, stride?: number, offset?: number, -) => Node; +) => Node; + /** * TSL function for creating a buffer attribute node but with enabled instancing * - * @tsl * @function * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data. * @param {?string} [type=null] - The buffer type (e.g. `'vec3'`). @@ -150,16 +216,16 @@ export declare const dynamicBufferAttribute: ( * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const instancedBufferAttribute: ( +export declare const instancedBufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, - type?: string | null, + type?: TNodeType | null, stride?: number, offset?: number, -) => Node; +) => Node; + /** * TSL function for creating a buffer attribute node but with dynamic draw usage and enabled instancing * - * @tsl * @function * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data. * @param {?string} [type=null] - The buffer type (e.g. `'vec3'`). @@ -167,15 +233,15 @@ export declare const instancedBufferAttribute: ( * @param {number} [offset=0] - The buffer offset. * @returns {BufferAttributeNode|Node} */ -export declare const instancedDynamicBufferAttribute: ( +export declare const instancedDynamicBufferAttribute: ( array: BufferAttribute | InterleavedBuffer | TypedArray, - type?: string | null, + type?: TNodeType | null, stride?: number, offset?: number, -) => Node; -declare module "../Nodes.js" { - interface BufferNode { - toAttribute: () => BufferAttributeNode; - toAttributeAssign: () => this; +) => Node; + +declare module "./BufferNode.js" { + interface BufferNodeExtensions { + toAttribute: () => BufferAttributeNode; } } diff --git a/types/three/src/nodes/accessors/BufferNode.d.ts b/types/three/src/nodes/accessors/BufferNode.d.ts index 586468951fa6e8..1fe9c0528a3fcb 100644 --- a/types/three/src/nodes/accessors/BufferNode.d.ts +++ b/types/three/src/nodes/accessors/BufferNode.d.ts @@ -1,17 +1,31 @@ import UniformNode from "../core/UniformNode.js"; -import { NodeOrType } from "../tsl/TSLCore.js"; -export default class BufferNode extends UniformNode { +export interface BufferNodeInterface { isBufferNode: true; bufferType: string; bufferCount: number; +} + +declare const BufferNode: { + new(value: TValue, bufferType: TNodeType, bufferCount?: number): BufferNode; +}; - constructor(value: TValue, bufferType: string, bufferCount?: number); +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface BufferNodeExtensions { } -export const buffer: ( - value: unknown, - nodeOrType: NodeOrType, +type BufferNode = + & UniformNode + & BufferNodeInterface + & BufferNodeExtensions; + +export default BufferNode; + +export const buffer: ( + value: TValue, + type: TNodeType, count: number, -) => BufferNode; +) => BufferNode; + +export {}; diff --git a/types/three/src/nodes/accessors/Camera.d.ts b/types/three/src/nodes/accessors/Camera.d.ts index a37ce5a113b289..0eb189f07227ce 100644 --- a/types/three/src/nodes/accessors/Camera.d.ts +++ b/types/three/src/nodes/accessors/Camera.d.ts @@ -4,13 +4,13 @@ import { Vector3 } from "../../math/Vector3.js"; import { Vector4 } from "../../math/Vector4.js"; import UniformNode from "../core/UniformNode.js"; -export const cameraIndex: UniformNode; -export const cameraNear: UniformNode; -export const cameraFar: UniformNode; -export const cameraProjectionMatrix: UniformNode; -export const cameraProjectionMatrixInverse: UniformNode; -export const cameraViewMatrix: UniformNode; -export const cameraWorldMatrix: UniformNode; -export const cameraNormalMatrix: UniformNode; -export const cameraPosition: UniformNode; -export const cameraViewport: UniformNode; +export const cameraIndex: UniformNode<"uint", number>; +export const cameraNear: UniformNode<"float", number>; +export const cameraFar: UniformNode<"float", number>; +export const cameraProjectionMatrix: UniformNode<"mat4", Matrix4>; +export const cameraProjectionMatrixInverse: UniformNode<"mat4", Matrix4>; +export const cameraViewMatrix: UniformNode<"mat4", Matrix4>; +export const cameraWorldMatrix: UniformNode<"mat4", Matrix4>; +export const cameraNormalMatrix: UniformNode<"mat3", Matrix3>; +export const cameraPosition: UniformNode<"vec3", Vector3>; +export const cameraViewport: UniformNode<"vec4", Vector4>; diff --git a/types/three/src/nodes/accessors/CubeTextureNode.d.ts b/types/three/src/nodes/accessors/CubeTextureNode.d.ts index 4f40b452d1b830..b9f1c752437db3 100644 --- a/types/three/src/nodes/accessors/CubeTextureNode.d.ts +++ b/types/three/src/nodes/accessors/CubeTextureNode.d.ts @@ -4,7 +4,7 @@ import TextureNode from "./TextureNode.js"; declare class CubeTextureNode extends TextureNode { isCubeTextureNode: boolean; - uvNode: Node | null; + uvNode: Node<"vec3"> | null; levelNode: Node | null; constructor( diff --git a/types/three/src/nodes/accessors/InstanceNode.d.ts b/types/three/src/nodes/accessors/InstanceNode.d.ts index 73d36bb5dd4fe0..450e8dda226562 100644 --- a/types/three/src/nodes/accessors/InstanceNode.d.ts +++ b/types/three/src/nodes/accessors/InstanceNode.d.ts @@ -1,4 +1,5 @@ import { InstancedBufferAttribute } from "../../core/InstancedBufferAttribute.js"; +import { InstancedInterleavedBuffer } from "../../core/InstancedInterleavedBuffer.js"; import StorageInstancedBufferAttribute from "../../renderers/common/StorageInstancedBufferAttribute.js"; import Node from "../core/Node.js"; @@ -10,6 +11,11 @@ export default class InstanceNode extends Node { instanceMatrixNode: Node | null; instanceColorNode: Node | null; + buffer: InstancedInterleavedBuffer | null; + bufferColor: InstancedBufferAttribute | null; + + previousInstancedMatrixNode: Node | null; + constructor( count: number, instanceMatrix: InstancedBufferAttribute | StorageInstancedBufferAttribute, diff --git a/types/three/src/nodes/accessors/Lights.d.ts b/types/three/src/nodes/accessors/Lights.d.ts index 862422913d0b52..a35314df0f6fc3 100644 --- a/types/three/src/nodes/accessors/Lights.d.ts +++ b/types/three/src/nodes/accessors/Lights.d.ts @@ -1,14 +1,17 @@ import { Light } from "../../lights/Light.js"; +import { Matrix4 } from "../../math/Matrix4.js"; +import { Vector3 } from "../../math/Vector3.js"; import Node from "../core/Node.js"; +import UniformNode from "../core/UniformNode.js"; -export function lightShadowMatrix(light: Light): Node; +export function lightShadowMatrix(light: Light): UniformNode<"mat4", Matrix4>; -export function lightProjectionUV(light: Light, position?: Node): Node; +export function lightProjectionUV(light: Light, position?: Node): Node<"vec3">; -export function lightPosition(light: Light): Node; +export function lightPosition(light: Light): UniformNode<"vec3", Vector3>; -export function lightTargetPosition(light: Light): Node; +export function lightTargetPosition(light: Light): UniformNode<"vec3", Vector3>; -export function lightViewPosition(light: Light): Node; +export function lightViewPosition(light: Light): UniformNode<"vec3", Vector3>; -export const lightTargetDirection: (light: Light) => Node; +export const lightTargetDirection: (light: Light) => Node<"vec3">; diff --git a/types/three/src/nodes/accessors/MaterialNode.d.ts b/types/three/src/nodes/accessors/MaterialNode.d.ts index 2a2aa75ce43b53..d008ae55ebb6a8 100644 --- a/types/three/src/nodes/accessors/MaterialNode.d.ts +++ b/types/three/src/nodes/accessors/MaterialNode.d.ts @@ -1,6 +1,4 @@ -import { Vector2 } from "../../math/Vector2.js"; import Node from "../core/Node.js"; -import UniformNode from "../core/UniformNode.js"; export type MaterialNodeScope = | typeof MaterialNode.ALPHA_TEST @@ -125,4 +123,4 @@ export const materialPointSize: MaterialNode; export const materialDispersion: MaterialNode; export const materialLightMap: MaterialNode; export const materialAO: MaterialNode; -export const materialAnisotropyVector: UniformNode; +export const materialAnisotropyVector: MaterialNode; diff --git a/types/three/src/nodes/accessors/MaterialProperties.d.ts b/types/three/src/nodes/accessors/MaterialProperties.d.ts index b97bf137a60770..45f70023773cbf 100644 --- a/types/three/src/nodes/accessors/MaterialProperties.d.ts +++ b/types/three/src/nodes/accessors/MaterialProperties.d.ts @@ -1,8 +1,8 @@ -import { Matrix4 } from "../../math/Matrix4.js"; +import Node from "../core/Node.js"; import UniformNode from "../core/UniformNode.js"; -export const materialRefractionRatio: UniformNode; +export const materialRefractionRatio: UniformNode<"float", number>; -export const materialEnvIntensity: UniformNode; +export const materialEnvIntensity: Node<"float">; -export const materialEnvRotation: UniformNode; +export const materialEnvRotation: Node<"mat4">; diff --git a/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts b/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts index 34fd8550dd21af..cdcd6aa5106a2f 100644 --- a/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts +++ b/types/three/src/nodes/accessors/MaterialReferenceNode.d.ts @@ -2,7 +2,7 @@ import { Material } from "../../materials/Material.js"; import { NodeOrType } from "../tsl/TSLCore.js"; import ReferenceNode from "./ReferenceNode.js"; -export default class MaterialReferenceNode extends ReferenceNode { +export default class MaterialReferenceNode extends ReferenceNode { readonly isMaterialReferenceNode: true; constructor(property: string, inputType: string, material?: Material | null); diff --git a/types/three/src/nodes/accessors/ModelNode.d.ts b/types/three/src/nodes/accessors/ModelNode.d.ts index 3545af20c403fd..c2eba24485ab9b 100644 --- a/types/three/src/nodes/accessors/ModelNode.d.ts +++ b/types/three/src/nodes/accessors/ModelNode.d.ts @@ -1,3 +1,4 @@ +import { Matrix3 } from "../../math/Matrix3.js"; import { Matrix4 } from "../../math/Matrix4.js"; import Node from "../core/Node.js"; import { UniformNode } from "../Nodes.js"; @@ -6,27 +7,43 @@ import Object3DNode from "./Object3DNode.js"; /** * Similar to {@link Object3DNode} but the object comes from {@link NodeFrame} */ -export default class ModelNode extends Object3DNode { - constructor(scope: string); -} - -export const modelDirection: ModelNode; -export const modelWorldMatrix: ModelNode; -export const modelPosition: ModelNode; -export const modelScale: ModelNode; -export const modelViewPosition: ModelNode; -export const modelRadius: ModelNode; -export const modelNormalMatrix: Node; -export const modelWorldMatrixInverse: UniformNode; - -export const modelViewMatrix: ModelNode; +declare const ModelNode: { + new(scope: typeof ModelNode.WORLD_MATRIX): ModelNode<"mat4">; + new(scope: typeof ModelNode.POSITION): ModelNode<"vec3">; + new(scope: typeof ModelNode.SCALE): ModelNode<"vec3">; + new(scope: typeof ModelNode.VIEW_POSITION): ModelNode<"vec3">; + new(scope: typeof ModelNode.DIRECTION): ModelNode<"vec3">; + new(scope: typeof ModelNode.RADIUS): ModelNode<"float">; + + WORLD_MATRIX: "worldMatrix"; + POSITION: "position"; + SCALE: "scale"; + VIEW_POSITION: "viewPosition"; + DIRECTION: "direction"; + RADIUS: "radius"; +}; + +type ModelNode = Object3DNode; + +export default Object3DNode; + +export const modelDirection: ModelNode<"vec3">; +export const modelWorldMatrix: ModelNode<"mat4">; +export const modelPosition: ModelNode<"vec3">; +export const modelScale: ModelNode<"vec3">; +export const modelViewPosition: ModelNode<"vec3">; +export const modelRadius: ModelNode<"float">; +export const modelNormalMatrix: UniformNode<"mat3", Matrix3>; +export const modelWorldMatrixInverse: UniformNode<"mat4", Matrix4>; + +export const modelViewMatrix: Node<"mat4">; // GPU Precision -export const mediumpModelViewMatrix: Node; +export const mediumpModelViewMatrix: Node<"mat4">; // CPU Precision -export const highpModelViewMatrix: Node; +export const highpModelViewMatrix: Node<"mat4">; -export const highpModelNormalViewMatrix: Node; +export const highpModelNormalViewMatrix: Node<"mat3">; diff --git a/types/three/src/nodes/accessors/MorphNode.d.ts b/types/three/src/nodes/accessors/MorphNode.d.ts index 32f8f53b27505f..7fcf9729da13e6 100644 --- a/types/three/src/nodes/accessors/MorphNode.d.ts +++ b/types/three/src/nodes/accessors/MorphNode.d.ts @@ -4,7 +4,7 @@ import UniformNode from "../core/UniformNode.js"; declare class MorphNode extends Node { mesh: Mesh; - morphBaseInfluence: UniformNode; + morphBaseInfluence: UniformNode<"float", number>; constructor(mesh: Mesh); } diff --git a/types/three/src/nodes/accessors/Normal.d.ts b/types/three/src/nodes/accessors/Normal.d.ts index bdc76a815e4747..5937460b71d4fc 100644 --- a/types/three/src/nodes/accessors/Normal.d.ts +++ b/types/three/src/nodes/accessors/Normal.d.ts @@ -1,38 +1,36 @@ -import AttributeNode from "../core/AttributeNode.js"; import Node from "../core/Node.js"; -import VarNode from "../core/VarNode.js"; -export const normalGeometry: AttributeNode; +export const normalGeometry: Node<"vec3">; -export const normalLocal: VarNode; +export const normalLocal: Node<"vec3">; -export const normalFlat: VarNode; +export const normalFlat: Node<"vec3">; -export const normalViewGeometry: VarNode; +export const normalViewGeometry: Node<"vec3">; -export const normalWorldGeometry: VarNode; +export const normalWorldGeometry: Node<"vec3">; -export const normalView: VarNode; +export const normalView: Node<"vec3">; -export const normalWorld: VarNode; +export const normalWorld: Node<"vec3">; -export const clearcoatNormalView: VarNode; +export const clearcoatNormalView: Node<"vec3">; -export const transformNormal: (normal: Node, matrix?: Node) => Node; +export const transformNormal: (normal: Node, matrix?: Node) => Node<"vec3">; -export const transformNormalToView: (normal: Node) => Node; +export const transformNormalToView: (normal: Node) => Node<"vec3">; /** * @deprecated since r178. Use `normalView` instead. */ -export const transformedNormalView: VarNode; +export const transformedNormalView: Node<"vec3">; /** * @deprecated since r178. Use `normalWorld` instead. */ -export const transformedNormalWorld: VarNode; +export const transformedNormalWorld: Node<"vec3">; /** * @deprecated since r178. Use `clearcoatNormalView` instead. */ -export const transformedClearcoatNormalView: VarNode; +export const transformedClearcoatNormalView: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/Object3DNode.d.ts b/types/three/src/nodes/accessors/Object3DNode.d.ts index 568869585e656b..edeab21c260aad 100644 --- a/types/three/src/nodes/accessors/Object3DNode.d.ts +++ b/types/three/src/nodes/accessors/Object3DNode.d.ts @@ -1,23 +1,42 @@ import { Object3D } from "../../core/Object3D.js"; import Node from "../core/Node.js"; -export default class Object3DNode extends Node { - scope: string; +export type Object3DNodeScope = + | typeof Object3DNode.WORLD_MATRIX + | typeof Object3DNode.POSITION + | typeof Object3DNode.SCALE + | typeof Object3DNode.VIEW_POSITION + | typeof Object3DNode.DIRECTION + | typeof Object3DNode.RADIUS; + +interface Object3DNodeInterface { + scope: Object3DNodeScope; object3d: Object3D | null; +} - constructor(scope: string, object3d?: Object3D | null); +declare const Object3DNode: { + new(scope: typeof Object3DNode.WORLD_MATRIX, object3d?: Object3D | null): Object3DNode<"mat4">; + new(scope: typeof Object3DNode.POSITION, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.SCALE, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.VIEW_POSITION, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.DIRECTION, object3d?: Object3D | null): Object3DNode<"vec3">; + new(scope: typeof Object3DNode.RADIUS, object3d?: Object3D | null): Object3DNode<"float">; - static WORLD_MATRIX: "worldMatrix"; - static POSITION: "position"; - static SCALE: "scale"; - static VIEW_POSITION: "viewPosition"; - static DIRECTION: "direction"; - static RADIUS: "radius"; -} + WORLD_MATRIX: "worldMatrix"; + POSITION: "position"; + SCALE: "scale"; + VIEW_POSITION: "viewPosition"; + DIRECTION: "direction"; + RADIUS: "radius"; +}; + +type Object3DNode = Node & Object3DNodeInterface; + +export default Object3DNode; -export const objectDirection: (object3d: Object3D | null) => Object3DNode; -export const objectWorldMatrix: (object3d: Object3D | null) => Object3DNode; -export const objectPosition: (object3d: Object3D | null) => Object3DNode; -export const objectScale: (object3d: Object3D | null) => Object3DNode; -export const objectViewPosition: (object3d: Object3D | null) => Object3DNode; -export const objectRadius: (object3d: Object3D | null) => Object3DNode; +export const objectDirection: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectWorldMatrix: (object3d: Object3D | null) => Object3DNode<"mat4">; +export const objectPosition: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectScale: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectViewPosition: (object3d: Object3D | null) => Object3DNode<"vec3">; +export const objectRadius: (object3d: Object3D | null) => Object3DNode<"float">; diff --git a/types/three/src/nodes/accessors/Position.d.ts b/types/three/src/nodes/accessors/Position.d.ts index cbe99d876bf558..c57ac3384ac984 100644 --- a/types/three/src/nodes/accessors/Position.d.ts +++ b/types/three/src/nodes/accessors/Position.d.ts @@ -1,9 +1,11 @@ +import AttributeNode from "../core/AttributeNode.js"; import Node from "../core/Node.js"; -export const positionGeometry: Node; -export const positionLocal: Node; -export const positionPrevious: Node; -export const positionWorld: Node; -export const positionWorldDirection: Node; -export const positionView: Node; -export const positionViewDirection: Node; +export const clipSpace: Node<"vec4">; +export const positionGeometry: AttributeNode<"vec3">; +export const positionLocal: AttributeNode<"vec3">; +export const positionPrevious: AttributeNode<"vec3">; +export const positionWorld: Node<"vec3">; +export const positionWorldDirection: Node<"vec3">; +export const positionView: Node<"vec3">; +export const positionViewDirection: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/ReferenceNode.d.ts b/types/three/src/nodes/accessors/ReferenceNode.d.ts index f5e72dbc2b3123..e238f053c94167 100644 --- a/types/three/src/nodes/accessors/ReferenceNode.d.ts +++ b/types/three/src/nodes/accessors/ReferenceNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -declare class ReferenceNode extends Node { +interface ReferenceNodeInterface extends Node { property: string; uniformType: string; @@ -12,17 +12,26 @@ declare class ReferenceNode extends Node { reference: T | null; node: Node | null; - constructor(property: string, uniformType: string, object?: T | null, count?: number | null); - setNodeType(uniformType: string): void; } +declare const ReferenceNode: { + new( + property: string, + uniformType: TNodeType, + object?: T | null, + count?: number | null, + ): ReferenceNode; +}; + +type ReferenceNode = ReferenceNodeInterface & Node; + export default ReferenceNode; -export const reference: (name: string, type: string, object: T) => ReferenceNode; -export const referenceBuffer: ( +export const reference: (name: string, type: TNodeType, object: T) => ReferenceNode; +export const referenceBuffer: ( name: string, - type: string, + type: TNodeType, count: number, object: T, -) => ReferenceNode; +) => ReferenceNode; diff --git a/types/three/src/nodes/accessors/ReflectVector.d.ts b/types/three/src/nodes/accessors/ReflectVector.d.ts index 32f149bf3394ab..53db54bbfc7f1d 100644 --- a/types/three/src/nodes/accessors/ReflectVector.d.ts +++ b/types/three/src/nodes/accessors/ReflectVector.d.ts @@ -1,8 +1,7 @@ import Node from "../core/Node.js"; -import VarNode from "../core/VarNode.js"; -export const reflectView: Node; -export const refractView: Node; +export const reflectView: Node<"vec3">; +export const refractView: Node<"vec3">; -export const reflectVector: VarNode; -export const refractVector: VarNode; +export const reflectVector: Node<"vec3">; +export const refractVector: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/RendererReferenceNode.d.ts b/types/three/src/nodes/accessors/RendererReferenceNode.d.ts index 7bf48604c67257..c3bc488ecde8ed 100644 --- a/types/three/src/nodes/accessors/RendererReferenceNode.d.ts +++ b/types/three/src/nodes/accessors/RendererReferenceNode.d.ts @@ -1,7 +1,7 @@ import Renderer from "../../renderers/common/Renderer.js"; import ReferenceNode from "./ReferenceNode.js"; -export default class RendererReferenceNode extends ReferenceNode { +export default class RendererReferenceNode extends ReferenceNode { renderer: Renderer | null; constructor(property: string, inputType: string, renderer?: Renderer | null); diff --git a/types/three/src/nodes/accessors/SceneNode.d.ts b/types/three/src/nodes/accessors/SceneNode.d.ts deleted file mode 100644 index 3eac5bb4ba47eb..00000000000000 --- a/types/three/src/nodes/accessors/SceneNode.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Scene } from "../../scenes/Scene.js"; -import Node from "../core/Node.js"; - -export type SceneNodeScope = typeof SceneNode.BACKGROUND_BLURRINESS | typeof SceneNode.BACKGROUND_INTENSITY; - -declare class SceneNode extends Node { - scope: SceneNodeScope; - scene: Scene | null; - - constructor(scope?: SceneNodeScope, scene?: Scene | null); - - static BACKGROUND_BLURRINESS: "backgroundBlurriness"; - static BACKGROUND_INTENSITY: "backgroundIntensity"; - static BACKGROUND_ROTATION: "backgroundRotation"; -} - -export default SceneNode; - -export const backgroundBlurriness: SceneNode; -export const backgroundIntensity: SceneNode; -export const backgroundRotation: SceneNode; diff --git a/types/three/src/nodes/accessors/SceneProperties.d.ts b/types/three/src/nodes/accessors/SceneProperties.d.ts new file mode 100644 index 00000000000000..8605e1070dbcc4 --- /dev/null +++ b/types/three/src/nodes/accessors/SceneProperties.d.ts @@ -0,0 +1,5 @@ +import Node from "../core/Node.js"; + +export const backgroundBlurriness: Node<"float">; +export const backgroundIntensity: Node<"float">; +export const backgroundRotation: Node<"mat4">; diff --git a/types/three/src/nodes/accessors/SkinningNode.d.ts b/types/three/src/nodes/accessors/SkinningNode.d.ts index 61c05f52dd5c67..57a22e986261e6 100644 --- a/types/three/src/nodes/accessors/SkinningNode.d.ts +++ b/types/three/src/nodes/accessors/SkinningNode.d.ts @@ -19,11 +19,13 @@ export default class SkinningNode extends Node { getSkinnedPosition(boneMatrices?: Node, position?: Node): Node; - getSkinnedNormal(boneMatrices?: Node, normal?: Node): Node; + getSkinnedNormalAndTangent( + boneMatrices?: Node, + normal?: Node, + tangent?: Node, + ): { skinNormal: Node; skinTangent: Node }; getPreviousSkinnedPosition(builder: NodeBuilder): Node; - - needsPreviousBoneMatrices(builder: NodeBuilder): boolean; } export const skinning: (skinnedMesh: SkinnedMesh) => SkinningNode; diff --git a/types/three/src/nodes/accessors/StorageBufferNode.d.ts b/types/three/src/nodes/accessors/StorageBufferNode.d.ts index 7045ca722b716a..f819d249b09ad5 100644 --- a/types/three/src/nodes/accessors/StorageBufferNode.d.ts +++ b/types/three/src/nodes/accessors/StorageBufferNode.d.ts @@ -8,7 +8,7 @@ import StructTypeNode from "../core/StructTypeNode.js"; import StorageArrayElementNode from "../utils/StorageArrayElementNode.js"; import BufferNode from "./BufferNode.js"; -export default class StorageBufferNode extends BufferNode { +interface StorageBufferNodeInterface { readonly isStorageBufferNode: true; structTypeNode: StructTypeNode | null; @@ -19,13 +19,7 @@ export default class StorageBufferNode extends BufferNode StorageArrayElementNode; + element: (indexNode: Node | number) => StorageArrayElementNode; setPBO(value: boolean): this; @@ -39,18 +33,51 @@ export default class StorageBufferNode extends BufferNode( + value: StorageBufferAttribute | StorageInstancedBufferAttribute, + bufferType?: string | Struct | null, + bufferCount?: number, + ): StorageBufferNode; +}; + +type StorageBufferNode = + & StorageBufferNodeInterface + & BufferNode; + +export default StorageBufferNode; + +interface Storage { + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "float", + count: number, + ): StorageBufferNode<"float">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "uint", + count: number, + ): StorageBufferNode<"uint">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "vec2", + count: number, + ): StorageBufferNode<"vec2">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "vec3", + count: number, + ): StorageBufferNode<"vec3">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: "vec4", + count: number, + ): StorageBufferNode<"vec4">; + ( + value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, + type: Struct, + count: number, + ): StorageBufferNode<"struct">; +} -export const storage: ( - value: StorageBufferAttribute | StorageInstancedBufferAttribute | BufferAttribute, - type?: string | Struct | null, - count?: number, -) => StorageBufferNode; - -/** - * @deprecated - */ -export const storageObject: ( - value: StorageBufferAttribute | StorageInstancedBufferAttribute, - type?: string | Struct | null, - count?: number, -) => StorageBufferNode; +export const storage: Storage; diff --git a/types/three/src/nodes/accessors/StorageTextureNode.d.ts b/types/three/src/nodes/accessors/StorageTextureNode.d.ts index 9eef343b990e97..98c1ad33116f7b 100644 --- a/types/three/src/nodes/accessors/StorageTextureNode.d.ts +++ b/types/three/src/nodes/accessors/StorageTextureNode.d.ts @@ -39,7 +39,7 @@ export const storageTexture: ( ) => StorageTextureNode; export const textureStore: ( - value: Texture, + value: Texture | StorageTextureNode, uvNode?: Node | null, storeNode?: Node, ) => StorageTextureNode; diff --git a/types/three/src/nodes/accessors/Tangent.d.ts b/types/three/src/nodes/accessors/Tangent.d.ts index bad61533a90677..5832d8ae073dc1 100644 --- a/types/three/src/nodes/accessors/Tangent.d.ts +++ b/types/three/src/nodes/accessors/Tangent.d.ts @@ -1,8 +1,6 @@ -import AttributeNode from "../core/AttributeNode.js"; -import VaryingNode from "../core/VaryingNode.js"; -import MathNode from "../math/MathNode.js"; +import Node from "../core/Node.js"; -export const tangentGeometry: AttributeNode; -export const tangentLocal: VaryingNode; -export const tangentView: MathNode; -export const tangentWorld: MathNode; +export const tangentGeometry: Node<"vec4">; +export const tangentLocal: Node<"vec3">; +export const tangentView: Node<"vec3">; +export const tangentWorld: Node<"vec3">; diff --git a/types/three/src/nodes/accessors/Texture3DNode.d.ts b/types/three/src/nodes/accessors/Texture3DNode.d.ts index d984915b50df33..b6ff4af9a5c30b 100644 --- a/types/three/src/nodes/accessors/Texture3DNode.d.ts +++ b/types/three/src/nodes/accessors/Texture3DNode.d.ts @@ -7,7 +7,7 @@ export default class Texture3DNode extends TextureNode { constructor(value: Texture, uvNode?: Node | null, levelNode?: Node | null); - normal(uvNode: Node): Node; + normal(uvNode: Node): Node<"vec3">; } export const texture3D: ( diff --git a/types/three/src/nodes/accessors/TextureBicubic.d.ts b/types/three/src/nodes/accessors/TextureBicubic.d.ts index 4d0740e5e3a6ce..121eaa8356b5ba 100644 --- a/types/three/src/nodes/accessors/TextureBicubic.d.ts +++ b/types/three/src/nodes/accessors/TextureBicubic.d.ts @@ -1,5 +1,6 @@ import Node from "../core/Node.js"; +import TextureNode from "./TextureNode.js"; -export const textureBicubicLevel: (textureNode: Node, lodNode: Node) => Node; +export const textureBicubicLevel: (textureNode: Node, lodNode: Node) => TextureNode; -export const textureBicubic: (textureNode: Node, strength: Node) => Node; +export const textureBicubic: (textureNode: Node, strength: Node) => TextureNode; diff --git a/types/three/src/nodes/accessors/TextureNode.d.ts b/types/three/src/nodes/accessors/TextureNode.d.ts index e619bf69968ba3..1fbe8efe828616 100644 --- a/types/three/src/nodes/accessors/TextureNode.d.ts +++ b/types/three/src/nodes/accessors/TextureNode.d.ts @@ -2,10 +2,10 @@ import { Texture } from "../../textures/Texture.js"; import Node from "../core/Node.js"; import UniformNode from "../core/UniformNode.js"; -export default class TextureNode extends UniformNode { +interface TextureNodeInterface { readonly isTextureNode: true; - uvNode: Node | null; + uvNode: Node<"vec2"> | Node<"vec3"> | null; levelNode: Node | null; biasNode: Node | null; compareNode: Node | null; @@ -17,27 +17,15 @@ export default class TextureNode extends UniformNode { referenceNode: Node | null; - constructor( - value?: Texture, - uvNode?: Node | null, - levelNode?: Node | null, - biasNode?: Node | null, - ); - getDefaultUV(): Node; setSampler(value: boolean): this; getSampler(): boolean; - /** - * @deprecated - */ - uv(uvNode: Node): Node; - - sample(uvNode: Node): Node; + sample(uvNode: Node): Node; - load(uvNode: Node): Node; + load(uvNode: Node): Node; blur(amountNode: Node): Node; @@ -51,13 +39,26 @@ export default class TextureNode extends UniformNode { compare(compareNode: Node): Node; - grad(gradeNodeX: Node, gradeNodeY: Node): Node; + grad(gradeNodeX: Node, gradeNodeY: Node): TextureNode; - depth(depthNode: Node): Node; + depth(depthNode: Node): TextureNode; clone(): this; } +declare const TextureNode: { + new( + value?: Texture, + uvNode?: Node | null, + levelNode?: Node | null, + biasNode?: Node | null, + ): TextureNode; +}; + +type TextureNode = TextureNodeInterface & UniformNode; + +export default TextureNode; + export const texture: ( value?: Texture | TextureNode, uvNode?: Node | null, diff --git a/types/three/src/nodes/accessors/UV.d.ts b/types/three/src/nodes/accessors/UV.d.ts index e5e8f0a991351e..aa5beb5def8c3b 100644 --- a/types/three/src/nodes/accessors/UV.d.ts +++ b/types/three/src/nodes/accessors/UV.d.ts @@ -1,3 +1,3 @@ import AttributeNode from "../core/AttributeNode.js"; -export const uv: (index?: number) => AttributeNode; +export const uv: (index?: number) => AttributeNode<"vec2">; diff --git a/types/three/src/nodes/accessors/UniformArrayNode.d.ts b/types/three/src/nodes/accessors/UniformArrayNode.d.ts index 1f3e6dd926af5b..cd1406ad75b2ec 100644 --- a/types/three/src/nodes/accessors/UniformArrayNode.d.ts +++ b/types/three/src/nodes/accessors/UniformArrayNode.d.ts @@ -2,24 +2,26 @@ import Node from "../core/Node.js"; import ArrayElementNode from "../utils/ArrayElementNode.js"; import BufferNode from "./BufferNode.js"; -declare class UniformArrayElementNode extends ArrayElementNode { - constructor(arrayBuffer: Node, indexNode: Node); -} +type UniformArrayElementNode = ArrayElementNode; -declare class UniformArrayNode extends BufferNode { +interface UniformArrayNodeInterface { array: unknown[]; elementType: string | null; paddedType: string; readonly isArrayBufferNode: true; - constructor(value: unknown[], elementType?: string | null); - getPaddedType(): string; - element: (indexNode: Node) => UniformArrayElementNode; + element: (indexNode: Node | number) => UniformArrayElementNode; } +declare const UniformArrayNode: { + new(value: unknown[], elementType?: TNodeType | null): UniformArrayNode; +}; + +type UniformArrayNode = UniformArrayNodeInterface & BufferNode; + export default UniformArrayNode; -export const uniformArray: (values: unknown[], nodeType?: string | null) => UniformArrayNode; +export const uniformArray: (values: unknown[], nodeType?: TNodeType | null) => UniformArrayNode; diff --git a/types/three/src/nodes/accessors/UserDataNode.d.ts b/types/three/src/nodes/accessors/UserDataNode.d.ts index 0daa1d74821668..f5788670035133 100644 --- a/types/three/src/nodes/accessors/UserDataNode.d.ts +++ b/types/three/src/nodes/accessors/UserDataNode.d.ts @@ -2,7 +2,7 @@ import ReferenceNode from "./ReferenceNode.js"; export type NodeUserData = Record; -export default class UserDataNode extends ReferenceNode { +export default class UserDataNode extends ReferenceNode { userData: NodeUserData | null; constructor(property: string, inputType: string, userData?: NodeUserData | null); } diff --git a/types/three/src/nodes/accessors/VelocityNode.d.ts b/types/three/src/nodes/accessors/VelocityNode.d.ts index 4719cc7bf7c55c..153cf5a53a50ff 100644 --- a/types/three/src/nodes/accessors/VelocityNode.d.ts +++ b/types/three/src/nodes/accessors/VelocityNode.d.ts @@ -5,9 +5,9 @@ import UniformNode from "../core/UniformNode.js"; declare class VelocityNode extends TempNode { projectionMatrix: Matrix4 | null; - previousModelWorldMatrix: UniformNode; - previousProjectionMatrix: UniformNode; - previousCameraViewMatrix: UniformNode; + previousModelWorldMatrix: UniformNode<"mat4", Matrix4>; + previousProjectionMatrix: UniformNode<"mat4", Matrix4>; + previousCameraViewMatrix: UniformNode<"mat4", Matrix4>; constructor(); diff --git a/types/three/src/nodes/accessors/VertexColorNode.d.ts b/types/three/src/nodes/accessors/VertexColorNode.d.ts index e880b7b6d60e4d..5487be407634a0 100644 --- a/types/three/src/nodes/accessors/VertexColorNode.d.ts +++ b/types/three/src/nodes/accessors/VertexColorNode.d.ts @@ -1,6 +1,6 @@ import AttributeNode from "../core/AttributeNode.js"; -export default class VertexColorNode extends AttributeNode { +export default class VertexColorNode extends AttributeNode<"vec4"> { readonly isVertexColorNode: true; index: number; diff --git a/types/three/src/nodes/code/FunctionCallNode.d.ts b/types/three/src/nodes/code/FunctionCallNode.d.ts index d746ead23296bd..8919aef8156b9d 100644 --- a/types/three/src/nodes/code/FunctionCallNode.d.ts +++ b/types/three/src/nodes/code/FunctionCallNode.d.ts @@ -23,6 +23,5 @@ export const call:

( declare module "../Nodes.js" { interface FunctionNode

{ call: (parameters?: ProxiedObject

) => FunctionCallNode

; - callAssign: (parameters?: ProxiedObject

) => this; } } diff --git a/types/three/src/nodes/code/FunctionNode.d.ts b/types/three/src/nodes/code/FunctionNode.d.ts index b4cecf51cd87e1..1abf4494c79512 100644 --- a/types/three/src/nodes/code/FunctionNode.d.ts +++ b/types/three/src/nodes/code/FunctionNode.d.ts @@ -14,23 +14,27 @@ export default class FunctionNode

| { [name: stri getNodeFunction(builder: NodeBuilder): NodeFunction; } +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type type FnParameters

= P extends readonly [...unknown[]] ? ProxiedTuple

+ // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type : readonly [ProxiedObject

]; +// eslint-disable-next-line @definitelytyped/no-unnecessary-generics export const nativeFn:

( code: string, includes?: CodeNodeInclude[], language?: string, - // eslint-disable-next-line @definitelytyped/no-unnecessary-generics ) => (...params: FnParameters

) => Node; +// eslint-disable-next-line @definitelytyped/no-unnecessary-generics export const glslFn:

( code: string, includes?: CodeNodeInclude[], - // eslint-disable-next-line @definitelytyped/no-unnecessary-generics ) => (...params: FnParameters

) => Node; +// eslint-disable-next-line @definitelytyped/no-unnecessary-generics export const wgslFn:

( code: string, includes?: CodeNodeInclude[], - // eslint-disable-next-line @definitelytyped/no-unnecessary-generics ) => (...params: FnParameters

) => Node; + +export {}; diff --git a/types/three/src/nodes/code/ScriptableNode.d.ts b/types/three/src/nodes/code/ScriptableNode.d.ts deleted file mode 100644 index 1849bb228fec9a..00000000000000 --- a/types/three/src/nodes/code/ScriptableNode.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Node from "../core/Node.js"; - -declare class Resources extends Map { - get(key: string, callback?: ((...args: TArgs) => void) | null, ...params: TArgs): unknown; -} - -export const ScriptableNodeResources: Resources; - -declare class ScriptableNode extends Node { - codeNode: Node | null; - parameters: Record; - - constructor(codeNode?: Node | null, parameters?: Record); -} - -export default ScriptableNode; - -export const scriptable: ( - codeNode: Node, - parameters?: Record, -) => ScriptableNode; diff --git a/types/three/src/nodes/code/ScriptableValueNode.d.ts b/types/three/src/nodes/code/ScriptableValueNode.d.ts deleted file mode 100644 index 066b3203b338a6..00000000000000 --- a/types/three/src/nodes/code/ScriptableValueNode.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import Node from "../core/Node.js"; - -declare class ScriptableValueNode extends Node { - constructor(value: unknown); -} - -export default ScriptableValueNode; - -export const scriptableValue: (value: unknown) => ScriptableValueNode; diff --git a/types/three/src/nodes/core/ArrayNode.d.ts b/types/three/src/nodes/core/ArrayNode.d.ts index 327ac90cd30a90..cad55888430445 100644 --- a/types/three/src/nodes/core/ArrayNode.d.ts +++ b/types/three/src/nodes/core/ArrayNode.d.ts @@ -18,9 +18,8 @@ interface ArrayFunction { export const array: ArrayFunction; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { toArray: (count: number) => ArrayNode; - toArrayAssign: (count: number) => this; } } diff --git a/types/three/src/nodes/core/AttributeNode.d.ts b/types/three/src/nodes/core/AttributeNode.d.ts index c9e762a3f66fdf..c1da1a7ddf02c9 100644 --- a/types/three/src/nodes/core/AttributeNode.d.ts +++ b/types/three/src/nodes/core/AttributeNode.d.ts @@ -1,15 +1,21 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; -export default class AttributeNode extends Node { - constructor(attributeName: string, nodeType?: string | null); - +interface AttributeNodeInterface { setAttributeName(attributeName: string): this; getAttributeName(builder: NodeBuilder): string; } -export const attribute: ( +declare const AttributeNode: { + new(attributeName: string, TNodeType?: string | null): AttributeNode; +}; + +type AttributeNode = Node & AttributeNodeInterface; + +export default AttributeNode; + +export const attribute: ( name: string, - nodeType?: string | null, -) => AttributeNode; + nodeType?: TNodeType | null, +) => AttributeNode; diff --git a/types/three/src/nodes/core/BypassNode.d.ts b/types/three/src/nodes/core/BypassNode.d.ts index f39e08c2d05ba5..85c1261169889a 100644 --- a/types/three/src/nodes/core/BypassNode.d.ts +++ b/types/three/src/nodes/core/BypassNode.d.ts @@ -10,9 +10,8 @@ export default class BypassNode extends Node { export const bypass: (returnNode: Node, callNode: Node) => BypassNode; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { bypass: (callNode: Node) => BypassNode; - bypassAssign: (callNode: Node) => this; } } diff --git a/types/three/src/nodes/core/ConstNode.d.ts b/types/three/src/nodes/core/ConstNode.d.ts index f866b0c0c8b45e..c21599fd79345d 100644 --- a/types/three/src/nodes/core/ConstNode.d.ts +++ b/types/three/src/nodes/core/ConstNode.d.ts @@ -1,9 +1,16 @@ import InputNode from "./InputNode.js"; import NodeBuilder from "./NodeBuilder.js"; -export default class ConstNode extends InputNode { - isConstNode: true; - constructor(value: Value, nodeType?: string | null); +interface ConstNodeInterface { + readonly isConstNode: true; generateConst(builder: NodeBuilder): string; } + +declare const ConstNode: { + new(value: TValue, nodeType?: TNodeType | null): ConstNode; +}; + +type ConstNode = InputNode & ConstNodeInterface; + +export default ConstNode; diff --git a/types/three/src/nodes/core/ContextNode.d.ts b/types/three/src/nodes/core/ContextNode.d.ts index 2dab710d993572..bad9872febaaff 100644 --- a/types/three/src/nodes/core/ContextNode.d.ts +++ b/types/three/src/nodes/core/ContextNode.d.ts @@ -2,61 +2,56 @@ import { Light } from "../../lights/Light.js"; import Node from "./Node.js"; import { NodeBuilderContext } from "./NodeBuilder.js"; -declare class ContextNode extends Node { +declare class ContextNodeInterface extends Node { readonly isContextNode: true; - node: Node | null; + node: Node | null; value: NodeBuilderContext; - - constructor(node?: Node | null, value?: NodeBuilderContext); } +declare const ContextNode: { + new(node?: Node | null, value?: NodeBuilderContext): ContextNode; +}; + +type ContextNode = ContextNodeInterface & Node; + export default ContextNode; interface ContextFunction { - (value?: NodeBuilderContext): ContextNode; - (node: Node, value?: NodeBuilderContext): ContextNode; + (value?: NodeBuilderContext): ContextNode; + (node: Node, value?: NodeBuilderContext): ContextNode; } export const context: ContextFunction; -export const uniformFlow: (node: Node) => ContextNode; +export const uniformFlow: (node: Node) => ContextNode; -export const setName: (node: Node, label: string) => Node; +export const setName: (node: Node, label: string) => Node; -export function builtinShadowContext(shadowNode: Node, light: Light, node?: Node | null): ContextNode; +export function builtinShadowContext(shadowNode: Node, light: Light, node?: Node | null): ContextNode; -export function builtinAOContext(aoNode: Node, node?: Node | null): ContextNode; +export function builtinAOContext(aoNode: Node, node?: Node | null): ContextNode; /** * @deprecated "label()" has been deprecated. Use "setName()" instead. */ -export function label(node: Node, label: string): Node; +export function label(node: Node, label: string): Node; -declare module "../Nodes.js" { - interface Node { - context: (context?: NodeBuilderContext) => ContextNode; - contextAssign: (context?: NodeBuilderContext) => this; +declare module "./Node.js" { + interface NodeExtensions { + context: (context?: NodeBuilderContext) => ContextNode; /** * @deprecated "label()" has been deprecated. Use "setName()" instead. */ - label: (label: string) => Node; - /** - * @deprecated "label()" has been deprecated. Use "setName()" instead. - */ - labelAssign: (label: string) => this; + label: (label: string) => Node; - uniformFlow: () => ContextNode; - uniformFlowAssign: () => this; + uniformFlow: () => ContextNode; - setName: (label: string) => Node; - setNameAssign: (label: string) => this; + setName: (label: string) => Node; - builtinShadowContext: (shadowNode: Node, light: Light) => ContextNode; - builtinShadowContextAssign: (shadowNode: Node, light: Light) => this; + builtinShadowContext: (shadowNode: Node, light: Light) => ContextNode; - builtinAOContext: (aoValue: Node) => ContextNode; - builtinAOContextAssign: (aoValue: Node) => this; + builtinAOContext: (aoValue: Node) => ContextNode; } } diff --git a/types/three/src/nodes/core/IndexNode.d.ts b/types/three/src/nodes/core/IndexNode.d.ts index c60fd7bbcdae4c..c491ec22ae09e0 100644 --- a/types/three/src/nodes/core/IndexNode.d.ts +++ b/types/three/src/nodes/core/IndexNode.d.ts @@ -8,7 +8,7 @@ export type IndexNodeScope = | typeof IndexNode.INVOCATION_SUBGROUP | typeof IndexNode.DRAW; -declare class IndexNode extends Node { +declare class IndexNode extends Node<"uint"> { scope: IndexNodeScope; readonly isInstanceNode: true; diff --git a/types/three/src/nodes/core/InputNode.d.ts b/types/three/src/nodes/core/InputNode.d.ts index e5b3ca1b2b4992..e58345af549534 100644 --- a/types/three/src/nodes/core/InputNode.d.ts +++ b/types/three/src/nodes/core/InputNode.d.ts @@ -3,13 +3,21 @@ import NodeBuilder from "./NodeBuilder.js"; export type Precision = "low" | "medium" | "high"; -export default abstract class InputNode extends Node { +interface InputNodeInterface { isInputNode: true; - value: Value; + value: TValue; precision: Precision | null; - constructor(value: Value, nodeType?: string | null); - getInputType(builder: NodeBuilder): string | null; setPrecision(precision: Precision): this; } + +declare const InputNode: { + new(value: TValue, nodeType?: TNodeType | null): InputNode; +}; + +type InputNode = Node & InputNodeInterface; + +export default InputNode; + +export type { InputNode }; diff --git a/types/three/src/nodes/core/InspectorNode.d.ts b/types/three/src/nodes/core/InspectorNode.d.ts index 93ec3d69f0a8c4..f6b38084453cb1 100644 --- a/types/three/src/nodes/core/InspectorNode.d.ts +++ b/types/three/src/nodes/core/InspectorNode.d.ts @@ -8,9 +8,8 @@ export default InspectorNode; export function inspector(node: T, name?: string, callback?: (node: T) => Node): T; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { toInspector: (name?: string, callback?: (node: this) => Node) => this; - toInspectorAssign: (name?: string, callback?: (node: this) => Node) => this; } } diff --git a/types/three/src/nodes/core/IsolateNode.d.ts b/types/three/src/nodes/core/IsolateNode.d.ts index d466d2a8bcc560..3d921bdb98f79d 100644 --- a/types/three/src/nodes/core/IsolateNode.d.ts +++ b/types/three/src/nodes/core/IsolateNode.d.ts @@ -19,18 +19,13 @@ export const isolate: (node: Node) => IsolateNode; */ export const cache: (node: Node, cache?: NodeCache) => IsolateNode; -declare module "../Nodes.js" { - interface Node { +declare module "./Node.js" { + interface NodeElements { /** * @deprecated "cache()" has been deprecated. Use "isolate()" instead. */ cache: (cache?: NodeCache) => IsolateNode; - /** - * @deprecated "cache()" has been deprecated. Use "isolate()" instead. - */ - cacheAssign: (cache?: NodeCache) => this; isolate: () => IsolateNode; - isolateAssign: () => this; } } diff --git a/types/three/src/nodes/core/MRTNode.d.ts b/types/three/src/nodes/core/MRTNode.d.ts index 76bd089f76b089..d203c07ce1f79c 100644 --- a/types/three/src/nodes/core/MRTNode.d.ts +++ b/types/three/src/nodes/core/MRTNode.d.ts @@ -1,3 +1,4 @@ +import BlendMode from "../../renderers/common/BlendMode.js"; import { Texture } from "../../textures/Texture.js"; import { Node } from "../Nodes.js"; import OutputStructNode from "./OutputStructNode.js"; @@ -7,10 +8,16 @@ export function getTextureIndex(textures: ReadonlyArray, name: string): declare class MRTNode extends OutputStructNode { outputNodes: { [name: string]: Node }; + blendModes: { [name: string]: BlendMode }; + readonly isMRTNode: true; constructor(outputNodes: { [name: string]: Node }); + setBlendMode(name: string, blend: BlendMode): this; + + getBlendMode(name: string): BlendMode; + 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 ab64d6332de653..9b22c11ba515e1 100644 --- a/types/three/src/nodes/core/Node.d.ts +++ b/types/three/src/nodes/core/Node.d.ts @@ -2,6 +2,7 @@ import { EventDispatcher } from "../../core/EventDispatcher.js"; import { NodeUpdateType } from "./constants.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeFrame from "./NodeFrame.js"; + interface NodeJSONMeta { textures: { [key: string]: unknown; @@ -13,11 +14,13 @@ interface NodeJSONMeta { [key: string]: NodeJSONIntermediateOutputData; }; } + interface NodeJSONMetadata { version: number; type: "Node"; generator: "Node.toJSON"; } + interface NodeJSONInputNodes { [property: string]: | string[] @@ -27,6 +30,7 @@ interface NodeJSONInputNodes { | string | undefined; } + export interface NodeJSONInputData { inputNodes?: NodeJSONInputNodes | undefined; meta: { @@ -38,6 +42,7 @@ export interface NodeJSONInputData { }; }; } + export interface NodeJSONIntermediateOutputData { uuid: string; type: string | undefined; @@ -48,6 +53,7 @@ export interface NodeJSONIntermediateOutputData { images?: unknown[]; nodes?: NodeJSONIntermediateOutputData[]; } + interface NodeJSONOutputData { uuid: string; type: string | undefined; @@ -57,40 +63,123 @@ interface NodeJSONOutputData { images?: unknown[]; nodes?: NodeJSONOutputData[]; } + export interface NodeChild { property: string; index?: number | string; childNode: Node; } + /** * Base class for all nodes. * * @augments EventDispatcher */ -declare class Node extends EventDispatcher<{ - dispose: {}; -}> { +declare class NodeClass extends EventDispatcher<{ dispose: {} }> { static get type(): string; + /** + * Constructs a new node. + * + * @param {?string} nodeType - The node type. + */ + constructor(nodeType?: string | null); + /** + * The node type. This represents the result type of the node (e.g. `float` or `vec3`). + * + * @type {?string} + * @default null + */ nodeType: string | null; + /** + * The update type of the node's {@link Node#update} method. Possible values are listed in {@link NodeUpdateType}. + * + * @type {string} + * @default 'none' + */ updateType: NodeUpdateType; + /** + * The update type of the node's {@link Node#updateBefore} method. Possible values are listed in {@link NodeUpdateType}. + * + * @type {string} + * @default 'none' + */ updateBeforeType: NodeUpdateType; + /** + * The update type of the node's {@link Node#updateAfter} method. Possible values are listed in {@link NodeUpdateType}. + * + * @type {string} + * @default 'none' + */ updateAfterType: NodeUpdateType; - uuid: string; - version: number; - name: string | null; - _cacheKey: number | null; - _cacheKeyVersion: number; + /** + * The UUID of the node. + * + * @type {string} + * @readonly + */ + readonly uuid: string; + /** + * The version of the node. The version automatically is increased when {@link Node#needsUpdate} is set to `true`. + * + * @type {number} + * @readonly + * @default 0 + */ + readonly version: number; + /** + * The name of the node. + * + * @type {string} + * @default '' + */ + name: string; + /** + * Whether this node is global or not. This property is relevant for the internal + * node caching system. All nodes which should be declared just once should + * set this flag to `true` (a typical example is {@link AttributeNode}). + * + * @type {boolean} + * @default false + */ global: boolean; + /** + * Create a list of parents for this node during the build process. + * + * @type {boolean} + * @default false + */ parents: boolean; - readonly isNode: true; - readonly id: number; - self?: this; /** - * Constructs a new node. + * This flag can be used for type testing. * - * @param {?string} nodeType - The node type. + * @type {boolean} + * @readonly + * @default true */ - constructor(nodeType?: string | null); + readonly isNode: boolean; + /** + * The cache key of this node. + * + * @private + * @type {?number} + * @default null + */ + private _cacheKey; + /** + * The cache key's version. + * + * @private + * @type {number} + * @default 0 + */ + private _cacheKeyVersion; + /** + * The stack trace of the node for debugging purposes. + * + * @type {?string} + * @default null + */ + stackTrace: string | null; /** * Set this property to `true` when the node should be regenerated. * @@ -105,7 +194,7 @@ declare class Node extends EventDispatcher<{ * @type {string} * @readonly */ - get type(): string | undefined; + get type(): string; /** * Convenient method for defining {@link Node#update}. * @@ -114,6 +203,15 @@ declare class Node extends EventDispatcher<{ * @return {Node} A reference to this node. */ onUpdate(callback: (this: this, frame: NodeFrame) => unknown, updateType: NodeUpdateType): this; + /** + * The method can be implemented to update the node's internal state when it is used to render an object. + * The {@link Node#updateType} property defines how often the update is executed. + * + * @abstract + * @param {NodeFrame} frame - A reference to the current node frame. + * @return {?boolean} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching). + */ + update(frame: NodeFrame): boolean | undefined; /** * Convenient method for defining {@link Node#update}. Similar to {@link Node#onUpdate}, but * this method automatically sets the update type to `FRAME`. @@ -168,18 +266,12 @@ declare class Node extends EventDispatcher<{ * @generator * @yields {Node} A child node. */ - getChildren(): Generator; + getChildren(): Generator, void, unknown>; /** * Calling this method dispatches the `dispose` event. This event can be used * to register event listeners for clean up tasks. */ dispose(): void; - /** - * Callback for {@link Node#traverse}. - * - * @callback traverseCallback - * @param {Node} node - The current node. - */ /** * Can be used to traverse through the node's hierarchy. * @@ -193,7 +285,7 @@ declare class Node extends EventDispatcher<{ * @param {Set} [ignores=new Set()] - A set of nodes to ignore during the search to avoid circular references. * @returns {Array} An array of objects describing the child nodes. */ - _getChildren(ignores?: Set): NodeChild[]; + private _getChildren; /** * Returns the cache key for this node. * @@ -201,7 +293,7 @@ declare class Node extends EventDispatcher<{ * @param {Set} [ignores=null] - A set of nodes to ignore during the computation of the cache key. * @return {number} The cache key of the node. */ - getCacheKey(force?: boolean, ignores?: Set | null): number; + getCacheKey(force?: boolean, ignores?: Set): number; /** * Generate a custom cache key for this node. * @@ -249,7 +341,7 @@ declare class Node extends EventDispatcher<{ * @param {NodeBuilder} builder - The current node builder. * @return {string} The type of the node. */ - getElementType(builder: NodeBuilder): "bool" | "int" | "float" | "vec2" | "vec3" | "vec4" | "uint" | null; + getElementType(builder: NodeBuilder): string; /** * Returns the node member type for the given name. * @@ -264,7 +356,7 @@ declare class Node extends EventDispatcher<{ * @param {NodeBuilder} builder - The current node builder. * @return {string} The type of the node. */ - getNodeType(builder: NodeBuilder): string | null; + getNodeType(builder: NodeBuilder): string; /** * This method is used during the build process of a node and ensures * equal nodes are not built multiple times but just once. For example if @@ -290,7 +382,7 @@ declare class Node extends EventDispatcher<{ * @param {NodeBuilder} builder - The current node builder. * @return {?Node} The output node. */ - setup(builder: NodeBuilder): unknown; + setup(builder: NodeBuilder): Node | null | undefined; /** * Represents the analyze stage which is the second step of the build process, see {@link Node#build} method. * This stage analyzes the node hierarchy and ensures descendent nodes are built. @@ -316,7 +408,7 @@ declare class Node extends EventDispatcher<{ * @param {NodeFrame} frame - A reference to the current node frame. * @return {?boolean} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching). */ - updateBefore(frame: NodeFrame): void; + updateBefore(frame: NodeFrame): boolean | undefined; /** * The method can be implemented to update the node's internal state after it was used to render an object. * The {@link Node#updateAfterType} property defines how often the update is executed. @@ -325,16 +417,7 @@ declare class Node extends EventDispatcher<{ * @param {NodeFrame} frame - A reference to the current node frame. * @return {?boolean} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching). */ - updateAfter(frame: NodeFrame): void; - /** - * The method can be implemented to update the node's internal state when it is used to render an object. - * The {@link Node#updateType} property defines how often the update is executed. - * - * @abstract - * @param {NodeFrame} frame - A reference to the current node frame. - * @return {?boolean} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching). - */ - update(frame: NodeFrame): void; + updateAfter(frame: NodeFrame): boolean | undefined; before(node: Node): this; /** * This method performs the build of a node. The behavior and return value depend on the current build stage: @@ -346,7 +429,7 @@ declare class Node extends EventDispatcher<{ * @param {?(string|Node)} [output=null] - Can be used to define the output type. * @return {?(Node|string)} The result of the build process, depending on the build stage. */ - build(builder: NodeBuilder, output?: string | Node | null): Node | string | null; + build(builder: NodeBuilder, output?: (string | Node) | null): (Node | string) | null; /** * Returns the child nodes as a JSON object. * @@ -373,4 +456,140 @@ declare class Node extends EventDispatcher<{ */ toJSON(meta?: NodeJSONMeta | string): NodeJSONOutputData; } + +declare const Node: { + new(nodeType?: TNodeType | null): Node; + new(nodeType?: string | null): Node; + /** + * Enables or disables the automatic capturing of stack traces for nodes. + * + * @type {boolean} + * @default false + */ + captureStackTrace: boolean; +}; + +export interface NodeElements { +} + +export interface NodeExtensions { +} + +export type NumType = "float" | "int" | "uint"; +export type IntegerType = "int" | "uint"; +export type NumOrBoolType = NumType | "bool"; +export type FloatVecType = "vec2" | "vec3" | "vec4"; +export type MatType = "mat2" | "mat3" | "mat4"; + +export interface FloatExtensions { +} + +export interface IntExtensions { +} + +export interface UintExtensions { +} + +export interface BoolExtensions { +} + +export interface NumExtensions { +} + +export interface IntegerExtensions { +} + +export interface NumOrBoolExtensions { +} + +export interface NumVec2Extensions { +} + +export interface NumVec3Extensions { +} + +export interface NumVec4Extensions { +} + +export interface NumOrBoolVec2Extensions { +} + +export interface NumOrBoolVec3Extensions { +} + +export interface NumOrBoolVec4Extensions { +} + +export interface Vec2Extensions { +} + +export interface Vec3Extensions { +} + +export interface Vec4Extensions { +} + +export interface ColorExtensions { +} + +export interface FloatVecExtensions { +} + +export interface Mat2Extensions { +} + +export interface Mat3Extensions { +} + +export interface Mat4Extensions { +} + +export interface MatExtensions { +} + +type Node = + & NodeClass + & NodeElements + & (unknown extends TNodeType ? {} : NodeExtensions) + & (TNodeType extends "float" ? NumOrBoolExtensions<"float"> & FloatExtensions & NumExtensions<"float"> + : TNodeType extends "int" + ? NumOrBoolExtensions<"int"> & IntExtensions & NumExtensions<"int"> & IntegerExtensions<"int"> + : TNodeType extends "uint" + ? NumOrBoolExtensions<"uint"> & UintExtensions & NumExtensions<"uint"> & IntegerExtensions<"uint"> + : TNodeType extends "bool" ? NumOrBoolExtensions<"bool"> & BoolExtensions + : TNodeType extends "vec2" ? + & NumOrBoolVec2Extensions<"float"> + & Vec2Extensions + & NumVec2Extensions<"float"> + & FloatVecExtensions<"vec2"> + : TNodeType extends "ivec2" ? NumOrBoolVec2Extensions<"int"> & NumVec2Extensions<"int"> + : TNodeType extends "uvec2" ? NumOrBoolVec2Extensions<"uint"> & NumVec2Extensions<"uint"> + : TNodeType extends "bvec2" ? NumOrBoolVec2Extensions<"bool"> + : TNodeType extends "vec3" ? + & NumOrBoolVec3Extensions<"float"> + & Vec3Extensions + & NumVec3Extensions<"float"> + & FloatVecExtensions<"vec3"> + : TNodeType extends "ivec3" ? NumOrBoolVec3Extensions<"int"> & NumVec3Extensions<"int"> + : TNodeType extends "uvec3" ? NumOrBoolVec3Extensions<"uint"> & NumVec3Extensions<"uint"> + : TNodeType extends "bvec3" ? NumOrBoolVec3Extensions<"bool"> + : TNodeType extends "vec4" ? + & NumOrBoolVec4Extensions<"float"> + & Vec4Extensions + & NumVec4Extensions<"float"> + & FloatVecExtensions<"vec4"> + : TNodeType extends "ivec4" ? NumOrBoolVec4Extensions<"int"> & NumVec4Extensions<"int"> + : TNodeType extends "uvec4" ? NumOrBoolVec4Extensions<"uint"> & NumVec4Extensions<"uint"> + : TNodeType extends "bvec4" ? NumOrBoolVec4Extensions<"bool"> + : TNodeType extends "color" ? ColorExtensions + : TNodeType extends "mat2" ? Mat2Extensions & MatExtensions<"mat2"> + : TNodeType extends "mat3" ? Mat3Extensions & MatExtensions<"mat3"> + : TNodeType extends "mat4" ? Mat4Extensions & MatExtensions<"mat4"> + : {}) + & { + __TypeScript_NODE_TYPE__: TNodeType; + }; + export default Node; + +export {}; diff --git a/types/three/src/nodes/core/NodeAttribute.d.ts b/types/three/src/nodes/core/NodeAttribute.d.ts index b8cd78d6ff3495..71ad2eab762342 100644 --- a/types/three/src/nodes/core/NodeAttribute.d.ts +++ b/types/three/src/nodes/core/NodeAttribute.d.ts @@ -1,4 +1,5 @@ import Node from "./Node.js"; + /** * {@link NodeBuilder} is going to create instances of this class during the build process * of nodes. They represent the final shader attributes that are going to be generated @@ -6,10 +7,6 @@ import Node from "./Node.js"; * and {@link NodeBuilder#bufferAttributes} for this purpose. */ declare class NodeAttribute { - readonly isNodeAttribute: true; - name: string; - type: string | null; - node: Node | null; /** * Constructs a new node attribute. * @@ -17,6 +14,34 @@ declare class NodeAttribute { * @param {string} type - The type of the attribute. * @param {?Node} node - An optional reference to the node. */ - constructor(name: string, type: string | null, node?: Node | null); + constructor(name: string, type: string, node?: Node | null); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isNodeAttribute: boolean; + /** + * The name of the attribute. + * + * @type {string} + */ + name: string; + /** + * The type of the attribute. + * + * @type {string} + */ + type: string; + /** + * An optional reference to the node. + * + * @type {?Node} + * @default null + */ + node: Node | null; } + export default NodeAttribute; diff --git a/types/three/src/nodes/core/NodeBuilder.d.ts b/types/three/src/nodes/core/NodeBuilder.d.ts index eb477e39e05c5e..ca5c836a47772d 100644 --- a/types/three/src/nodes/core/NodeBuilder.d.ts +++ b/types/three/src/nodes/core/NodeBuilder.d.ts @@ -26,7 +26,9 @@ export interface NodeData { compute: { [key: string]: unknown }; } -export type NodeBuilderContext = { [key: string]: unknown }; +export interface NodeBuilderContext { + [key: string]: unknown; +} export default abstract class NodeBuilder { object: Object3D; @@ -92,7 +94,7 @@ export default abstract class NodeBuilder { getAttribute(name: string, type: string): NodeAttribute; - getPropertyName(node: NodeVar | NodeUniform, shaderStage: NodeShaderStage): string; + getPropertyName(node: NodeVar | NodeUniform, shaderStage: NodeShaderStage): string; isVector(type: string): boolean; isMatrix(type: string): boolean; @@ -110,7 +112,7 @@ export default abstract class NodeBuilder { type: string, shaderStage?: NodeShaderStage, name?: string | null, - ): NodeUniform; + ): NodeUniform; getVarFromNode(node: Node, type: string, shaderStage?: NodeShaderStage): NodeVar; getVaryFromNode(node: Node, type: string): NodeVarying; getCodeFromNode(node: Node, type: string, shaderStage?: NodeShaderStage): string; diff --git a/types/three/src/nodes/core/NodeCache.d.ts b/types/three/src/nodes/core/NodeCache.d.ts index a9272f47b41b88..645e3a8c338ad9 100644 --- a/types/three/src/nodes/core/NodeCache.d.ts +++ b/types/three/src/nodes/core/NodeCache.d.ts @@ -1,74 +1,50 @@ -import { BufferAttribute, TypedArray } from "../../core/BufferAttribute.js"; -import { InterleavedBuffer } from "../../core/InterleavedBuffer.js"; -import BufferAttributeNode from "../accessors/BufferAttributeNode.js"; import Node from "./Node.js"; -import NodeAttribute from "./NodeAttribute.js"; -import NodeCode from "./NodeCode.js"; -import NodeUniform from "./NodeUniform.js"; -import NodeVar from "./NodeVar.js"; -import NodeVarying from "./NodeVarying.js"; -import StructType from "./StructType.js"; -export interface ShaderStageNodeData { - properties?: - | ( - & { - outputNode: Node | null; - initialized?: boolean | undefined; - } - & { - [K in `node${string}`]?: Node | undefined; - } - ) - | undefined; - bufferAttribute?: NodeAttribute | undefined; - structType?: StructType | undefined; - uniform?: NodeUniform | undefined; - variable?: NodeVar | undefined; - varying?: NodeVarying | undefined; - code?: NodeCode | undefined; - usageCount?: number | undefined; - snippet?: string | undefined; - propertyName?: string | undefined; - propertySizeName?: string | undefined; -} -interface NodeData { - vertex?: ShaderStageNodeData | undefined; - fragment?: ShaderStageNodeData | undefined; - compute?: ShaderStageNodeData | undefined; - any?: ShaderStageNodeData | undefined; -} -interface BufferAttributeData { - node: BufferAttributeNode; -} + /** * This utility class is used in {@link NodeBuilder} as an internal * cache data structure for node data. */ declare class NodeCache { - id: number; - nodesData: WeakMap; - parent: NodeCache | null; /** * Constructs a new node cache. * * @param {?NodeCache} parent - A reference to a parent cache. */ constructor(parent?: NodeCache | null); + /** + * The id of the cache. + * + * @type {number} + * @readonly + */ + readonly id: number; + /** + * A weak map for managing node data. + * + * @type {WeakMap} + */ + nodesData: WeakMap; + /** + * Reference to a parent node cache. + * + * @type {?NodeCache} + * @default null + */ + parent: NodeCache | null; /** * Returns the data for the given node. * * @param {Node} node - The node. * @return {?Object} The data for the node. */ - getData(node: Node): NodeData | undefined; - getData(node: TypedArray | InterleavedBuffer | BufferAttribute): BufferAttributeData | undefined; + getData(node: Node): unknown; /** * Sets the data for a given node. * * @param {Node} node - The node. * @param {Object} data - The data that should be cached. */ - setData(node: Node, data: NodeData): void; - setData(node: TypedArray | InterleavedBuffer | BufferAttribute, data: BufferAttributeData): void; + setData(node: Node, data: unknown): void; } + export default NodeCache; diff --git a/types/three/src/nodes/core/NodeError.d.ts b/types/three/src/nodes/core/NodeError.d.ts new file mode 100644 index 00000000000000..c1d4220ea2b19f --- /dev/null +++ b/types/three/src/nodes/core/NodeError.d.ts @@ -0,0 +1,9 @@ +import StackTrace from "./StackTrace.js"; + +declare class NodeError extends Error { + stackTrace: StackTrace | null; + + constructor(message?: string, stackTrace?: StackTrace | null); +} + +export default NodeError; diff --git a/types/three/src/nodes/core/NodeParser.d.ts b/types/three/src/nodes/core/NodeParser.d.ts index d204c375c93636..7a476515ec9622 100644 --- a/types/three/src/nodes/core/NodeParser.d.ts +++ b/types/three/src/nodes/core/NodeParser.d.ts @@ -1,4 +1,5 @@ import NodeFunction from "./NodeFunction.js"; + /** * Base class for node parsers. A derived parser must be implemented * for each supported native shader language. @@ -13,4 +14,5 @@ declare abstract class NodeParser { */ abstract parseFunction(source: string): NodeFunction; } + export default NodeParser; diff --git a/types/three/src/nodes/core/NodeUniform.d.ts b/types/three/src/nodes/core/NodeUniform.d.ts index 81804abef0d97a..b025cada05d1d7 100644 --- a/types/three/src/nodes/core/NodeUniform.d.ts +++ b/types/three/src/nodes/core/NodeUniform.d.ts @@ -1,16 +1,13 @@ +import UniformGroupNode from "./UniformGroupNode.js"; import UniformNode from "./UniformNode.js"; + /** * {@link NodeBuilder} is going to create instances of this class during the build process * of nodes. They represent the final shader uniforms that are going to be generated * by the builder. A dictionary of node uniforms is maintained in {@link NodeBuilder#uniforms} * for this purpose. */ -declare class NodeUniform { - readonly isNodeUniform: true; - name: string; - type: string | null; - node: UniformNode; - needsUpdate: boolean | undefined; +declare class NodeUniform { /** * Constructs a new node uniform. * @@ -18,14 +15,40 @@ declare class NodeUniform { * @param {string} type - The type of the uniform. * @param {UniformNode} node - An reference to the node. */ - constructor(name: string, type: string | null, node: UniformNode); + constructor(name: string, type: string, node: UniformNode); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isNodeUniform: boolean; + /** + * The name of the uniform. + * + * @type {string} + */ + name: string; + /** + * The type of the uniform. + * + * @type {string} + */ + type: string; + /** + * An reference to the node. + * + * @type {UniformNode} + */ + node: UniformNode; + set value(val: TValue); /** * The value of the uniform node. * * @type {any} */ get value(): TValue; - set value(val: TValue); /** * The id of the uniform node. * @@ -37,6 +60,7 @@ declare class NodeUniform { * * @type {UniformGroupNode} */ - get groupNode(): import("./UniformGroupNode.js").default; + get groupNode(): UniformGroupNode; } + export default NodeUniform; diff --git a/types/three/src/nodes/core/NodeVar.d.ts b/types/three/src/nodes/core/NodeVar.d.ts index aa58f8ebf83aa6..6d1d888619f6fe 100644 --- a/types/three/src/nodes/core/NodeVar.d.ts +++ b/types/three/src/nodes/core/NodeVar.d.ts @@ -5,11 +5,6 @@ * this purpose. */ declare class NodeVar { - readonly isNodeVar: true; - name: string; - type: string; - readOnly: boolean; - count: number | null; /** * Constructs a new node variable. * @@ -19,5 +14,38 @@ declare class NodeVar { * @param {?number} [count=null] - The size. */ constructor(name: string, type: string, readOnly?: boolean, count?: number | null); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isNodeVar: boolean; + /** + * The name of the variable. + * + * @type {string} + */ + name: string; + /** + * The type of the variable. + * + * @type {string} + */ + type: string; + /** + * The read-only flag. + * + * @type {boolean} + */ + readOnly: boolean; + /** + * The size. + * + * @type {?number} + */ + count: number | null; } + export default NodeVar; diff --git a/types/three/src/nodes/core/NodeVarying.d.ts b/types/three/src/nodes/core/NodeVarying.d.ts index df9d152b9f7443..4956e9d4133b9b 100644 --- a/types/three/src/nodes/core/NodeVarying.d.ts +++ b/types/three/src/nodes/core/NodeVarying.d.ts @@ -1,5 +1,6 @@ import { InterpolationSamplingMode, InterpolationSamplingType } from "../../constants.js"; import NodeVar from "./NodeVar.js"; + /** * {@link NodeBuilder} is going to create instances of this class during the build process * of nodes. They represent the final shader varyings that are going to be generated @@ -9,10 +10,6 @@ import NodeVar from "./NodeVar.js"; * @augments NodeVar */ declare class NodeVarying extends NodeVar { - needsInterpolation: boolean; - readonly isNodeVarying: true; - interpolationType: InterpolationSamplingType | null; - interpolationSampling: InterpolationSamplingMode | null; /** * Constructs a new node varying. * @@ -27,5 +24,36 @@ declare class NodeVarying extends NodeVar { interpolationType?: InterpolationSamplingType | null, interpolationSampling?: InterpolationSamplingMode | null, ); + /** + * Whether this varying requires interpolation or not. This property can be used + * to check if the varying can be optimized for a variable. + * + * @type {boolean} + * @default false + */ + needsInterpolation: boolean; + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isNodeVarying: boolean; + /** + * The interpolation type of the varying data. + * + * @type {?string} + * @default null + */ + interpolationType: InterpolationSamplingType | null; + /** + * The interpolation sampling type of varying data. + * + * @type {?string} + * @default null + */ + interpolationSampling: InterpolationSamplingMode | null; } + export default NodeVarying; diff --git a/types/three/src/nodes/core/ParameterNode.d.ts b/types/three/src/nodes/core/ParameterNode.d.ts index d00ab02af0753a..fe6412e1455087 100644 --- a/types/three/src/nodes/core/ParameterNode.d.ts +++ b/types/three/src/nodes/core/ParameterNode.d.ts @@ -1,11 +1,18 @@ import PropertyNode from "./PropertyNode.js"; -declare class ParameterNode extends PropertyNode { +interface ParameterNodeInterface { readonly isParameterNode: true; - - constructor(nodeType: string, name?: string | null); } +declare const ParameterNode: { + new( + nodeType: TNodeType, + name?: string | null, + ): ParameterNode; +}; + +type ParameterNode = PropertyNode & ParameterNodeInterface; + export default ParameterNode; -export const parameter: (type: string, name?: string | null) => ParameterNode; +export const parameter: (type: TNodeType, name?: string | null) => ParameterNode; diff --git a/types/three/src/nodes/core/PropertyNode.d.ts b/types/three/src/nodes/core/PropertyNode.d.ts index de00f157a80ce6..2dbdb817c8f7c5 100644 --- a/types/three/src/nodes/core/PropertyNode.d.ts +++ b/types/three/src/nodes/core/PropertyNode.d.ts @@ -1,44 +1,54 @@ import Node from "./Node.js"; -export default class PropertyNode extends Node { +interface PropertyNodeInterface { name: string | null; varying: boolean; readonly isPropertyNode: true; - - constructor(nodeType?: string | null, name?: string | null, varying?: boolean); } -export const property: (type?: string | null, name?: string | null) => PropertyNode; -export const varyingProperty: (type?: string | null, name?: string | null) => PropertyNode; +declare const PropertyNode: { + new( + nodeType: TNodeType, + name?: string | null, + varying?: boolean, + ): PropertyNode; +}; + +type PropertyNode = Node & PropertyNodeInterface; + +export default PropertyNode; + +export const property: (type: TNodeType, name?: string | null) => PropertyNode; +export const varyingProperty: (type: TNodeType, name?: string | null) => PropertyNode; -export const diffuseColor: PropertyNode; -export const diffuseContribution: PropertyNode; -export const emissive: PropertyNode; -export const roughness: PropertyNode; -export const metalness: PropertyNode; -export const clearcoat: PropertyNode; -export const clearcoatRoughness: PropertyNode; -export const sheen: PropertyNode; -export const sheenRoughness: PropertyNode; -export const iridescence: PropertyNode; -export const iridescenceIOR: PropertyNode; -export const iridescenceThickness: PropertyNode; -export const alphaT: PropertyNode; -export const anisotropy: PropertyNode; -export const anisotropyT: PropertyNode; -export const anisotropyB: PropertyNode; -export const specularColor: PropertyNode; -export const specularColorBlended: PropertyNode; -export const specularF90: PropertyNode; -export const shininess: PropertyNode; -export const output: PropertyNode; -export const dashSize: PropertyNode; -export const gapSize: PropertyNode; -export const pointWidth: PropertyNode; -export const ior: PropertyNode; -export const transmission: PropertyNode; -export const thickness: PropertyNode; -export const attenuationDistance: PropertyNode; -export const attenuationColor: PropertyNode; -export const dispersion: PropertyNode; +export const diffuseColor: PropertyNode<"vec4">; +export const diffuseContribution: PropertyNode<"vec3">; +export const emissive: PropertyNode<"vec3">; +export const roughness: PropertyNode<"float">; +export const metalness: PropertyNode<"float">; +export const clearcoat: PropertyNode<"float">; +export const clearcoatRoughness: PropertyNode<"float">; +export const sheen: PropertyNode<"vec3">; +export const sheenRoughness: PropertyNode<"float">; +export const iridescence: PropertyNode<"float">; +export const iridescenceIOR: PropertyNode<"float">; +export const iridescenceThickness: PropertyNode<"float">; +export const alphaT: PropertyNode<"float">; +export const anisotropy: PropertyNode<"float">; +export const anisotropyT: PropertyNode<"vec3">; +export const anisotropyB: PropertyNode<"vec3">; +export const specularColor: PropertyNode<"color">; +export const specularColorBlended: PropertyNode<"color">; +export const specularF90: PropertyNode<"float">; +export const shininess: PropertyNode<"float">; +export const output: PropertyNode<"vec4">; +export const dashSize: PropertyNode<"float">; +export const gapSize: PropertyNode<"float">; +export const pointWidth: PropertyNode<"float">; +export const ior: PropertyNode<"float">; +export const transmission: PropertyNode<"float">; +export const thickness: PropertyNode<"float">; +export const attenuationDistance: PropertyNode<"float">; +export const attenuationColor: PropertyNode<"color">; +export const dispersion: PropertyNode<"float">; diff --git a/types/three/src/nodes/core/StackTrace.d.ts b/types/three/src/nodes/core/StackTrace.d.ts new file mode 100644 index 00000000000000..81a2b649c38ede --- /dev/null +++ b/types/three/src/nodes/core/StackTrace.d.ts @@ -0,0 +1,9 @@ +declare class StackTrace { + readonly isStackTrace: true; + + stack: Array<{ fn: string; file: string; line: number; column: number }>; + + constructor(stackMessage?: Error | string | null); +} + +export default StackTrace; diff --git a/types/three/src/nodes/core/StructType.d.ts b/types/three/src/nodes/core/StructType.d.ts index 82cec49ebefaf4..0190410e1fc885 100644 --- a/types/three/src/nodes/core/StructType.d.ts +++ b/types/three/src/nodes/core/StructType.d.ts @@ -1,8 +1,10 @@ import { MemberLayout } from "./StructTypeNode.js"; + declare class StructType { + constructor(name: string, members: MemberLayout[]); name: string; members: MemberLayout[]; output: boolean; - constructor(name: string, members: MemberLayout[]); } + export default StructType; diff --git a/types/three/src/nodes/core/StructTypeNode.d.ts b/types/three/src/nodes/core/StructTypeNode.d.ts index dad72157fb05b2..460b97d726360d 100644 --- a/types/three/src/nodes/core/StructTypeNode.d.ts +++ b/types/three/src/nodes/core/StructTypeNode.d.ts @@ -1,16 +1,19 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; + export interface MembersLayout { [name: string]: string | { type: string; atomic?: boolean; }; } + export interface MemberLayout { name: string; type: string; atomic: boolean; } + /** * Represents a struct type node in the node-based system. * This class is used to define and manage the layout and types of struct members. @@ -20,10 +23,6 @@ export interface MemberLayout { * @augments Node */ declare class StructTypeNode extends Node { - static get type(): string; - membersLayout: MemberLayout[]; - name: string | null; - readonly isStructLayoutNode: true; /** * Creates an instance of StructTypeNode. * @@ -31,6 +30,20 @@ declare class StructTypeNode extends Node { * @param {?string} [name=null] - The optional name of the struct. */ constructor(membersLayout: MembersLayout, name?: string | null); + /** + * The layout of the members for the struct + * + * @type {Array.<{name: string, type: string, atomic: boolean}>} + */ + membersLayout: Array; + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isStructLayoutNode: boolean; /** * Returns the length of the struct. * The length is calculated by summing the lengths of the struct's members. @@ -40,7 +53,8 @@ declare class StructTypeNode extends Node { getLength(): number; getMemberType(builder: NodeBuilder, name: string): string; getNodeType(builder: NodeBuilder): string; - setup(builder: NodeBuilder): void; + setup(builder: NodeBuilder): undefined; generate(builder: NodeBuilder): string; } + export default StructTypeNode; diff --git a/types/three/src/nodes/core/TempNode.d.ts b/types/three/src/nodes/core/TempNode.d.ts index 367f5ade12db7d..a3f5cbd4a59ce9 100644 --- a/types/three/src/nodes/core/TempNode.d.ts +++ b/types/three/src/nodes/core/TempNode.d.ts @@ -1,10 +1,16 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; -export default class TempNode extends Node { +interface TempNodeInterface { isTempNode: true; - constructor(type: string | null); - hasDependencies(builder: NodeBuilder): boolean; } + +declare const TempNode: { + new(type?: TNodeType | null): TempNode; +}; + +type TempNode = Node & TempNodeInterface; + +export default TempNode; diff --git a/types/three/src/nodes/core/UniformNode.d.ts b/types/three/src/nodes/core/UniformNode.d.ts index 4d6a41738def7a..9614789f574a89 100644 --- a/types/three/src/nodes/core/UniformNode.d.ts +++ b/types/three/src/nodes/core/UniformNode.d.ts @@ -1,33 +1,45 @@ +import { Color } from "../../math/Color.js"; +import { Matrix2 } from "../../math/Matrix2.js"; +import { Matrix3 } from "../../math/Matrix3.js"; +import { Matrix4 } from "../../math/Matrix4.js"; +import { Vector2 } from "../../math/Vector2.js"; +import { Vector3 } from "../../math/Vector3.js"; +import { Vector4 } from "../../math/Vector4.js"; import { NodeUpdateType } from "./constants.js"; import InputNode from "./InputNode.js"; -import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeFrame from "./NodeFrame.js"; import UniformGroupNode from "./UniformGroupNode.js"; + /** * Class for representing a uniform. * * @augments InputNode */ -declare class UniformNode extends InputNode { - static get type(): string; - readonly isUniformNode: true; - name: string; - groupNode: UniformGroupNode; +declare class UniformNodeClass extends InputNode { /** - * Constructs a new uniform node. + * This flag can be used for type testing. * - * @param {any} value - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture). - * @param {?string} nodeType - The node type. If no explicit type is defined, the node tries to derive the type from its value. + * @type {boolean} + * @readonly + * @default true */ - constructor(value: TValue, nodeType?: string | null); + readonly isUniformNode: boolean; + /** + * The uniform group of this uniform. By default, uniforms are + * managed per object but they might belong to a shared group + * which is updated per frame or render call. + * + * @type {UniformGroupNode} + */ + groupNode: UniformGroupNode; /** * Sets the {@link UniformNode#name} property. * * @param {string} name - The name of the uniform. * @return {UniformNode} A reference to this node. */ - setName: (name: string) => this; + setName(name: string): this; /** * Sets the {@link UniformNode#name} property. * @@ -35,7 +47,7 @@ declare class UniformNode extends InputNode { * @param {string} name - The name of the uniform. * @return {UniformNode} A reference to this node. */ - label: (name: string) => this; + label(name: string): this; /** * Sets the {@link UniformNode#groupNode} property. * @@ -58,17 +70,43 @@ declare class UniformNode extends InputNode { */ getUniformHash(builder: NodeBuilder): string; onUpdate(callback: (frame: NodeFrame, self: this) => TValue | undefined, updateType: NodeUpdateType): this; - getInputType(builder: NodeBuilder): string | null; + getInputType(builder: NodeBuilder): string; generate(builder: NodeBuilder, output: string | null): string; } + +declare const UniformNode: { + /** + * Constructs a new uniform node. + * + * @param {any} value - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture). + * @param {?string} nodeType - The node type. If no explicit type is defined, the node tries to derive the type from its value. + */ + new(value: TValue, nodeType?: string | null): UniformNode; +}; + +type UniformNode = UniformNodeClass & InputNode; + export default UniformNode; + +interface Uniform { + (value: number, type?: "float"): UniformNode<"float", number>; + (value: boolean): UniformNode<"bool", boolean>; + (value: Vector2): UniformNode<"vec2", Vector2>; + (value: Vector3): UniformNode<"vec3", Vector3>; + (value: Vector4): UniformNode<"vec4", Vector4>; + (value: Matrix2): UniformNode<"mat2", Matrix2>; + (value: Matrix3): UniformNode<"mat3", Matrix3>; + (value: Matrix4): UniformNode<"mat4", Matrix4>; + (value: Color): UniformNode<"color", Color>; + (value: InputNode): UniformNode; +} + /** * TSL function for creating a uniform node. * - * @tsl * @function * @param {any|string} value - The value of this uniform or your type. Usually a JS primitive or three.js object (vector, matrix, color, texture). * @param {string} [type] - The node type. If no explicit type is defined, the node tries to derive the type from its value. * @returns {UniformNode} */ -export declare const uniform: (value: InputNode | TValue, type?: Node | string) => UniformNode; +export declare const uniform: Uniform; diff --git a/types/three/src/nodes/core/VarNode.d.ts b/types/three/src/nodes/core/VarNode.d.ts index 55fe3c46bcc694..c676eeeaf6b230 100644 --- a/types/three/src/nodes/core/VarNode.d.ts +++ b/types/three/src/nodes/core/VarNode.d.ts @@ -1,6 +1,6 @@ import Node from "./Node.js"; -declare class VarNode extends Node { +interface VarNodeInterface { node: Node; name: string | null; @@ -10,29 +10,30 @@ declare class VarNode extends Node { intent: boolean; - constructor(node: Node, name?: string | null, readOnly?: boolean); - setIntent(value: boolean): this; getIntent(): boolean; } +declare const VarNode: { + new(node: Node, name?: string | null, readOnly?: boolean): VarNode; +}; + +type VarNode = Node & VarNodeInterface; + export default VarNode; -export const Var: (node: Node, name?: string | null) => VarNode; +export const Var: (node: Node, name?: string | null) => VarNode; -export const Const: (node: Node, name?: string | null) => VarNode; +export const Const: (node: Node, name?: string | null) => VarNode; -export const VarIntent: (node: Node) => Node; +export const VarIntent: (node: Node) => Node; -declare module "../Nodes.js" { - interface Node { - toVar: (name?: string | null) => VarNode; - toVarAssign: (name?: string | null) => this; +declare module "./Node.js" { + interface NodeExtensions { + toVar: (name?: string | null) => VarNode; - toConst: (name?: string | null) => VarNode; - toConstAssign: (name?: string | null) => this; + toConst: (name?: string | null) => VarNode; - toVarIntent: () => Node; - toVarIntentAssign: () => this; + toVarIntent: () => Node; } } diff --git a/types/three/src/nodes/core/VaryingNode.d.ts b/types/three/src/nodes/core/VaryingNode.d.ts index 218cfcedddebeb..6194882fca64ba 100644 --- a/types/three/src/nodes/core/VaryingNode.d.ts +++ b/types/three/src/nodes/core/VaryingNode.d.ts @@ -3,39 +3,34 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeVarying from "./NodeVarying.js"; -export default class VaryingNode extends Node { +interface VaryingNodeInterface { node: Node; name: string | null; readonly isVaryingNode: true; interpolationType: InterpolationSamplingType | null; interpolationSampling: InterpolationSamplingMode | null; - constructor(node: Node, name?: string | null); - setInterpolation(type: InterpolationSamplingType | null, sampling?: InterpolationSamplingMode | null): this; setupVarying(builder: NodeBuilder): NodeVarying; } -export const varying: (node: Node, name?: string) => VaryingNode; +declare const VaryingNode: { + new(node: Node, name?: string | null): VaryingNode; +}; + +type VaryingNode = VaryingNodeInterface & Node; + +export default VaryingNode; -export const vertexStage: (node: Node) => VaryingNode; +export const varying: (node: Node, name?: string) => VaryingNode; -declare module "../Nodes.js" { - interface Node { - toVarying: (name?: string) => VaryingNode; - toVaryingAssign: (name?: string) => this; +export const vertexStage: (node: Node) => VaryingNode; - toVertexStage: () => VaryingNode; - toVertexStageAssign: () => this; +declare module "./Node.js" { + interface NodeExtensions { + toVarying: (name?: string) => VaryingNode; - /** - * @deprecated .vertexStage() has been renamed to .toVertexStage(). - */ - vertexStage: () => VaryingNode; - /** - * @deprecated .vertexStage() has been renamed to .toVertexStage(). - */ - vertexStageAssign: () => this; + toVertexStage: () => VaryingNode; } } diff --git a/types/three/src/nodes/core/constants.d.ts b/types/three/src/nodes/core/constants.d.ts index 72c280b6fbddeb..7ac71b49bf54e8 100644 --- a/types/three/src/nodes/core/constants.d.ts +++ b/types/three/src/nodes/core/constants.d.ts @@ -4,10 +4,11 @@ * @property {string} VERTEX The vertex shader stage. * @property {string} FRAGMENT The fragment shader stage. */ -export declare const NodeShaderStage: { +export const NodeShaderStage: { readonly VERTEX: "vertex"; readonly FRAGMENT: "fragment"; }; + /** * Update types of a node. * @@ -16,12 +17,13 @@ export declare const NodeShaderStage: { * @property {string} RENDER The update method is executed per render. A frame might be produced by multiple render calls so this value allows more detailed updates than FRAME. * @property {string} OBJECT The update method is executed per {@link Object3D} that uses the node for rendering. */ -export declare const NodeUpdateType: { +export const NodeUpdateType: { readonly NONE: "none"; readonly FRAME: "frame"; readonly RENDER: "render"; readonly OBJECT: "object"; }; + /** * Data types of a node. * @@ -35,7 +37,7 @@ export declare const NodeUpdateType: { * @property {string} MATRIX3 3x3 matrix type. * @property {string} MATRIX4 4x4 matrix type. */ -export declare const NodeType: { +export const NodeType: { readonly BOOLEAN: "bool"; readonly INTEGER: "int"; readonly FLOAT: "float"; @@ -46,6 +48,7 @@ export declare const NodeType: { readonly MATRIX3: "mat3"; readonly MATRIX4: "mat4"; }; + /** * Access types of a node. These are relevant for compute and storage usage. * @@ -53,14 +56,16 @@ export declare const NodeType: { * @property {string} WRITE_ONLY Write-only access. * @property {string} READ_WRITE Read and write access. */ -export declare const NodeAccess: { +export const NodeAccess: { readonly READ_ONLY: "readOnly"; readonly WRITE_ONLY: "writeOnly"; readonly READ_WRITE: "readWrite"; }; + export type NodeShaderStage = "vertex" | "fragment" | "compute"; export type NodeUpdateType = "none" | "frame" | "render" | "object"; export type NodeAccess = "readOnly" | "writeOnly" | "readWrite"; + export declare const defaultShaderStages: NodeShaderStage[]; export declare const defaultBuildStages: string[]; export declare const shaderStages: NodeShaderStage[]; diff --git a/types/three/src/nodes/display/BlendModes.d.ts b/types/three/src/nodes/display/BlendModes.d.ts index e0a56b78a937ef..ddd05ed4836378 100644 --- a/types/three/src/nodes/display/BlendModes.d.ts +++ b/types/three/src/nodes/display/BlendModes.d.ts @@ -1,35 +1,15 @@ import Node from "../core/Node.js"; -export const blendBurn: (base: Node, blend: Node) => Node; +export const blendBurn: (base: Node, blend: Node) => Node<"vec3">; -export const blendDodge: (base: Node, blend: Node) => Node; +export const blendDodge: (base: Node, blend: Node) => Node<"vec3">; -export const blendScreen: (base: Node, blend: Node) => Node; +export const blendScreen: (base: Node, blend: Node) => Node<"vec3">; -export const blendOverlay: (base: Node, blend: Node) => Node; +export const blendOverlay: (base: Node, blend: Node) => Node<"vec3">; -export const blendColor: (base: Node, blend: Node) => Node; +export const blendColor: (base: Node, blend: Node) => Node<"vec4">; -export const premultiplyAlpha: (color: Node) => Node; +export const premultiplyAlpha: (color: Node) => Node<"vec4">; -export const unpremultiplyAlpha: (color: Node) => Node; - -/** - * @deprecated - */ -export const burn: (base: Node, blend: Node) => Node; - -/** - * @deprecated - */ -export const dodge: (base: Node, blend: Node) => Node; - -/** - * @deprecated - */ -export const screen: (base: Node, blend: Node) => Node; - -/** - * @deprecated - */ -export const overlay: (base: Node, blend: Node) => Node; +export const unpremultiplyAlpha: (color: Node) => Node<"vec4">; diff --git a/types/three/src/nodes/display/ColorAdjustment.d.ts b/types/three/src/nodes/display/ColorAdjustment.d.ts index 612ffb0c22b899..96ca775c643a51 100644 --- a/types/three/src/nodes/display/ColorAdjustment.d.ts +++ b/types/three/src/nodes/display/ColorAdjustment.d.ts @@ -1,29 +1,26 @@ import Node from "../core/Node.js"; -import MathNode from "../math/MathNode.js"; -export const grayscale: (color: Node) => Node; +export const grayscale: (color: Node) => Node<"vec3">; export const saturation: ( color: Node, adjustment?: Node | number, -) => Node; +) => Node<"vec3">; export const vibrance: ( color: Node, adjustment?: Node | number, -) => Node; +) => Node<"vec3">; export const hue: ( color: Node, adjustment?: Node | number, -) => Node; +) => Node<"vec3">; export const luminance: ( color: Node, luminanceCoefficients?: Node, -) => MathNode; - -export const threshold: (color: Node, thershold: Node) => MathNode; +) => Node<"float">; /** * Color Decision List (CDL) v1.2 @@ -52,4 +49,6 @@ export const cdl: ( power?: Node, saturation?: Node, luminanceCoefficients?: Node, -) => Node; +) => Node<"vec4">; + +export const posterize: (sourceNode: Node, stepsNode: Node | number) => Node; diff --git a/types/three/src/nodes/display/ColorSpaceNode.d.ts b/types/three/src/nodes/display/ColorSpaceNode.d.ts index b193155616d5c6..3fe8eacf6c3d6e 100644 --- a/types/three/src/nodes/display/ColorSpaceNode.d.ts +++ b/types/three/src/nodes/display/ColorSpaceNode.d.ts @@ -41,20 +41,14 @@ export const convertColorSpace: ( targetColorSpace: string, ) => ColorSpaceNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { workingToColorSpace: ( targetColorSpace: string, ) => ColorSpaceNode; - workingToColorSpaceAssign: ( - targetColorSpace: string, - ) => this; colorSpaceToWorking: ( sourceColorSpace: string, ) => ColorSpaceNode; - colorSpaceToWorkingAssign: ( - sourceColorSpace: string, - ) => this; } } diff --git a/types/three/src/nodes/display/FrontFacingNode.d.ts b/types/three/src/nodes/display/FrontFacingNode.d.ts index b4398515e4b97a..39238ce68b79a9 100644 --- a/types/three/src/nodes/display/FrontFacingNode.d.ts +++ b/types/three/src/nodes/display/FrontFacingNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -declare class FrontFacingNode extends Node { +declare class FrontFacingNode extends Node<"bool"> { isFrontFacingNode: true; constructor(); } diff --git a/types/three/src/nodes/display/PassNode.d.ts b/types/three/src/nodes/display/PassNode.d.ts index 370bdbf3e32e80..2d35bcce45dcd5 100644 --- a/types/three/src/nodes/display/PassNode.d.ts +++ b/types/three/src/nodes/display/PassNode.d.ts @@ -15,6 +15,8 @@ import TempNode from "../core/TempNode.js"; declare class PassTextureNode extends TextureNode { passNode: PassNode; + readonly isPassTextureNode: boolean; + constructor(passNode: PassNode, texture: Texture); } @@ -22,12 +24,14 @@ declare class PassMultipleTextureNode extends PassTextureNode { textureName: string; previousTexture: boolean; + readonly isPassMultipleTextureNode: boolean; + constructor(passNode: PassNode, textureName: string, previousTexture?: boolean); updateTexture(): void; } -declare class PassNode extends TempNode { +declare class PassNode extends TempNode<"vec4"> { scope: PassNodeScope; scene: Object3D; camera: Camera; @@ -38,7 +42,7 @@ declare class PassNode extends TempNode { transparent: boolean; opaque: boolean; - contextNode: ContextNode | null; + contextNode: ContextNode | null; readonly isPassNode: true; @@ -74,11 +78,11 @@ declare class PassNode extends TempNode { getTextureNode(name?: string): TextureNode; - getPreviousTextureNode(name?: string): Node; + getPreviousTextureNode(name?: string): TextureNode; - getViewZNode(name?: string): Node; + getViewZNode(name?: string): Node<"float">; - getLinearDepthNode(name?: string): Node; + getLinearDepthNode(name?: string): Node<"float">; compileAsync(renderer: Renderer): Promise; diff --git a/types/three/src/nodes/display/PosterizeNode.d.ts b/types/three/src/nodes/display/PosterizeNode.d.ts deleted file mode 100644 index 9c3dd1bce4676f..00000000000000 --- a/types/three/src/nodes/display/PosterizeNode.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Node from "../core/Node.js"; - -export default class PosterizeNode extends Node { - sourceNode: Node; - stepsNode: Node; - - constructor(sourceNode: Node, stepsNode: Node); -} - -export const posterize: ( - sourceNode: Node, - stepsNode: Node | number, -) => PosterizeNode; diff --git a/types/three/src/nodes/display/RenderOutputNode.d.ts b/types/three/src/nodes/display/RenderOutputNode.d.ts index 5762c657d103c4..100a8a39494548 100644 --- a/types/three/src/nodes/display/RenderOutputNode.d.ts +++ b/types/three/src/nodes/display/RenderOutputNode.d.ts @@ -2,7 +2,7 @@ import { ToneMapping } from "../../constants.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class RenderOutputNode extends TempNode { +declare class RenderOutputNode extends TempNode<"vec4"> { colorNode: Node; outputColorSpace: string | null; @@ -19,15 +19,11 @@ export const renderOutput: ( outputColorSpace?: string | null, ) => RenderOutputNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { renderOutput: ( toneMapping?: ToneMapping | null, outputColorSpace?: string | null, ) => RenderOutputNode; - renderOutputAssign: ( - toneMapping?: ToneMapping | null, - outputColorSpace?: string | null, - ) => this; } } diff --git a/types/three/src/nodes/display/ScreenNode.d.ts b/types/three/src/nodes/display/ScreenNode.d.ts index 4bd121ea22f019..fd03907a1c53b3 100644 --- a/types/three/src/nodes/display/ScreenNode.d.ts +++ b/types/three/src/nodes/display/ScreenNode.d.ts @@ -7,39 +7,47 @@ export type ScreenNodeScope = | typeof ScreenNode.UV | typeof ScreenNode.DPR; -declare class ScreenNode extends Node { +interface ScreenNodeInterface { scope: ScreenNodeScope; readonly isViewportNode: true; +} - constructor(scope: ScreenNodeScope); +declare const ScreenNode: { + new(scope: typeof ScreenNode.COORDINATE): ScreenNode<"vec2">; + new(scope: typeof ScreenNode.VIEWPORT): ScreenNode<"vec4">; + new(scope: typeof ScreenNode.SIZE): ScreenNode<"vec2">; + new(scope: typeof ScreenNode.UV): ScreenNode<"vec2">; + new(scope: typeof ScreenNode.DPR): ScreenNode<"float">; - static COORDINATE: "coordinate"; - static VIEWPORT: "viewport"; - static SIZE: "size"; - static UV: "uv"; - static DPR: "dpr"; -} + COORDINATE: "coordinate"; + VIEWPORT: "viewport"; + SIZE: "size"; + UV: "uv"; + DPR: "dpr"; +}; + +type ScreenNode = Node & ScreenNodeInterface; export default ScreenNode; // Screen -export const screenDPR: ScreenNode; -export const screenUV: ScreenNode; -export const screenSize: ScreenNode; -export const screenCoordinate: ScreenNode; +export const screenDPR: ScreenNode<"float">; +export const screenUV: ScreenNode<"vec2">; +export const screenSize: ScreenNode<"vec2">; +export const screenCoordinate: ScreenNode<"vec2">; // Viewport -export const viewport: ScreenNode; -export const viewportSize: Node; -export const viewportCoordinate: Node; -export const viewportUV: Node; +export const viewport: ScreenNode<"vec4">; +export const viewportSize: Node<"vec2">; +export const viewportCoordinate: Node<"vec2">; +export const viewportUV: Node<"vec2">; // Deprecated /** * @deprecated "viewportResolution" is deprecated. Use "screenSize" instead. */ -export const viewportResolution: ScreenNode; +export const viewportResolution: Node<"vec2">; diff --git a/types/three/src/nodes/display/ToneMappingNode.d.ts b/types/three/src/nodes/display/ToneMappingNode.d.ts index d8ae7fda350d7e..0da32f5eb74739 100644 --- a/types/three/src/nodes/display/ToneMappingNode.d.ts +++ b/types/three/src/nodes/display/ToneMappingNode.d.ts @@ -3,7 +3,7 @@ import RendererReferenceNode from "../accessors/RendererReferenceNode.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class ToneMappingNode extends TempNode { +declare class ToneMappingNode extends TempNode<"vec3"> { exposureNode: Node; colorNode: Node | null; @@ -19,15 +19,11 @@ export const toneMapping: ( ) => ToneMappingNode; export const toneMappingExposure: RendererReferenceNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { toneMapping: ( mapping?: ToneMapping, exposure?: Node | number, ) => ToneMappingNode; - toneMappingAssign: ( - mapping?: ToneMapping, - exposure?: Node | number, - ) => this; } } diff --git a/types/three/src/nodes/display/ViewportDepthNode.d.ts b/types/three/src/nodes/display/ViewportDepthNode.d.ts index fe601cd5aafcf5..0546947fb1f794 100644 --- a/types/three/src/nodes/display/ViewportDepthNode.d.ts +++ b/types/three/src/nodes/display/ViewportDepthNode.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -declare class ViewportDepthNode extends Node { +declare class ViewportDepthNode extends Node<"float"> { scope: ViewportDepthNodeScope; valueNode: Node; @@ -20,17 +20,21 @@ export type ViewportDepthNodeScope = export default ViewportDepthNode; -export const viewZToOrthographicDepth: (viewZ: Node, near: Node, far: Node) => Node; +export const viewZToOrthographicDepth: (viewZ: Node, near: Node, far: Node) => Node<"float">; -export const orthographicDepthToViewZ: (depth: Node, near: Node, far: Node) => Node; +export const viewZToReversedOrthographicDepth: (viewZ: Node, near: Node, far: Node) => Node<"float">; -export const viewZToPerspectiveDepth: (viewZ: Node, near: Node, far: Node) => Node; +export const orthographicDepthToViewZ: (depth: Node, near: Node, far: Node) => Node<"float">; -export const perspectiveDepthToViewZ: (depth: Node, near: Node, far: Node) => Node; +export const viewZToPerspectiveDepth: (viewZ: Node, near: Node, far: Node) => Node<"float">; -export const viewZToLogarithmicDepth: (viewZ: Node, near: Node, far: Node) => Node; +export const viewZToReversedPerspectiveDepth: (viewZ: Node, near: Node, far: Node) => Node<"float">; -export const logarithmicDepthToViewZ: (depth: Node, near: Node, far: Node) => Node; +export const perspectiveDepthToViewZ: (depth: Node, near: Node, far: Node) => Node<"float">; + +export const viewZToLogarithmicDepth: (viewZ: Node, near: Node, far: Node) => Node<"float">; + +export const logarithmicDepthToViewZ: (depth: Node, near: Node, far: Node) => Node<"float">; export const depth: ViewportDepthNode; export const linearDepth: (valueNode?: Node | null) => ViewportDepthNode; diff --git a/types/three/src/nodes/display/ViewportTextureNode.d.ts b/types/three/src/nodes/display/ViewportTextureNode.d.ts index 02625fc0f3c3e3..74a35a228ad664 100644 --- a/types/three/src/nodes/display/ViewportTextureNode.d.ts +++ b/types/three/src/nodes/display/ViewportTextureNode.d.ts @@ -29,3 +29,5 @@ export const viewportMipTexture: ( levelNode?: Node | null, framebufferTexture?: FramebufferTexture | null, ) => Node; + +export const viewportOpaqueMipTexture: (uv?: Node, level?: Node | null) => Node; diff --git a/types/three/src/nodes/fog/Fog.d.ts b/types/three/src/nodes/fog/Fog.d.ts index 4424e72b4abb9d..6977302729cc81 100644 --- a/types/three/src/nodes/fog/Fog.d.ts +++ b/types/three/src/nodes/fog/Fog.d.ts @@ -1,10 +1,12 @@ import Node from "../core/Node.js"; -export const rangeFogFactor: (near: Node | number, far: Node | number) => Node; +export const rangeFogFactor: (near: Node | number, far: Node | number) => Node<"float">; -export const densityFogFactor: (density: Node) => Node; +export const densityFogFactor: (density: Node) => Node<"float">; -export const fog: (color: Node, factor: Node) => Node; +export const exponentialHeightFogFactor: (density: Node, height: Node) => Node; + +export const fog: (color: Node, factor: Node) => Node<"vec4">; /** * @deprecated diff --git a/types/three/src/nodes/geometry/RangeNode.d.ts b/types/three/src/nodes/geometry/RangeNode.d.ts index 61a91b01424231..54352eabd4693f 100644 --- a/types/three/src/nodes/geometry/RangeNode.d.ts +++ b/types/three/src/nodes/geometry/RangeNode.d.ts @@ -5,16 +5,58 @@ import { Vector4 } from "../../math/Vector4.js"; import Node from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; -export default class RangeNode extends Node { - minNode: Node; - maxNode: Node; - - constructor(minNode: Node, maxNode: Node); +interface RangeNodeInterface { + minNode: Node; + maxNode: Node; getVectorLength(builder: NodeBuilder): number; } -export const range: ( - minNode: Node | number | Color | Vector2 | Vector3 | Vector4, - maxNode: Node | number | Color | Vector2 | Vector3 | Vector4, -) => RangeNode; +declare const RangeNode: { + new(minNode: Node, maxNode: Node): RangeNode; +}; + +type RangeNode = RangeNodeInterface & Node; + +export default RangeNode; + +interface Range { + ( + minNode: number, + maxNode: number, + ): RangeNode<"float">; + ( + minNode: Vector2, + maxNode: Vector2, + ): RangeNode<"vec2">; + ( + minNode: Vector3, + maxNode: Vector3, + ): RangeNode<"vec3">; + ( + minNode: Vector4, + maxNode: Vector4, + ): RangeNode<"vec4">; + ( + minNode: Color, + maxNode: Color, + ): RangeNode<"vec3">; + ( + minNode: Node<"float">, + maxNode: Node<"float">, + ): RangeNode<"float">; + ( + minNode: Node<"vec2">, + maxNode: Node<"vec2">, + ): RangeNode<"vec2">; + ( + minNode: Node<"vec3">, + maxNode: Node<"vec3">, + ): RangeNode<"vec3">; + ( + minNode: Node<"vec4">, + maxNode: Node<"vec4">, + ): RangeNode<"vec4">; +} + +export const range: Range; diff --git a/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts b/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts index c31c5d4b0c9708..b247b2b7f7a402 100644 --- a/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +++ b/types/three/src/nodes/gpgpu/AtomicFunctionNode.d.ts @@ -30,6 +30,8 @@ declare class AtomicFunctionNode extends Node { static ATOMIC_XOR: "atomicXor"; } +export default AtomicFunctionNode; + export const atomicFunc: ( method: AtomicMethod, pointerNode: Node, diff --git a/types/three/src/nodes/gpgpu/BarrierNode.d.ts b/types/three/src/nodes/gpgpu/BarrierNode.d.ts index 65cb90b9e41bc5..7323ed72e343eb 100644 --- a/types/three/src/nodes/gpgpu/BarrierNode.d.ts +++ b/types/three/src/nodes/gpgpu/BarrierNode.d.ts @@ -6,6 +6,8 @@ declare class BarrierNode extends Node { constructor(scope: string); } +export default BarrierNode; + export const workgroupBarrier: () => Node; export const storageBarrier: () => Node; export const textureBarrier: () => Node; diff --git a/types/three/src/nodes/gpgpu/ComputeNode.d.ts b/types/three/src/nodes/gpgpu/ComputeNode.d.ts index aa1f483e63c13c..c3a6507f3629db 100644 --- a/types/three/src/nodes/gpgpu/ComputeNode.d.ts +++ b/types/three/src/nodes/gpgpu/ComputeNode.d.ts @@ -34,18 +34,13 @@ export const compute: ( workgroupSize?: number[], ) => ComputeNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { compute: ( count: number, workgroupSize?: number[], ) => ComputeNode; - computeAssign: ( - count: number, - workgroupSize?: number[], - ) => this; computeKernel: (workgroupSize?: number[]) => ComputeNode; - computeKernelAssign: (workgroupSize?: number[]) => this; } } diff --git a/types/three/src/nodes/lighting/AnalyticLightNode.d.ts b/types/three/src/nodes/lighting/AnalyticLightNode.d.ts index 9fc3e022854676..7534146305f2b4 100644 --- a/types/three/src/nodes/lighting/AnalyticLightNode.d.ts +++ b/types/three/src/nodes/lighting/AnalyticLightNode.d.ts @@ -6,7 +6,7 @@ import { DirectLightData, DirectRectAreaLightData } from "./LightsNode.js"; import ShadowNode from "./ShadowNode.js"; declare module "../../lights/LightShadow.js" { - export interface LightShadow { + interface LightShadow { shadowNode?: Node; } } diff --git a/types/three/src/nodes/lighting/HemisphereLightNode.d.ts b/types/three/src/nodes/lighting/HemisphereLightNode.d.ts index 7cf38dd79d4711..d72d0c029e10bb 100644 --- a/types/three/src/nodes/lighting/HemisphereLightNode.d.ts +++ b/types/three/src/nodes/lighting/HemisphereLightNode.d.ts @@ -1,10 +1,11 @@ import { HemisphereLight } from "../../lights/HemisphereLight.js"; -import Object3DNode from "../accessors/Object3DNode.js"; +import { Vector3 } from "../../math/Vector3.js"; import Node from "../core/Node.js"; +import UniformNode from "../core/UniformNode.js"; import AnalyticLightNode from "./AnalyticLightNode.js"; export default class HemisphereLightNode extends AnalyticLightNode { - lightPositionNode: Object3DNode; + lightPositionNode: UniformNode<"vec3", Vector3>; lightDirectionNode: Node; groundColorNode: Node; diff --git a/types/three/src/nodes/lighting/LightProbeNode.d.ts b/types/three/src/nodes/lighting/LightProbeNode.d.ts index 3a5b12963615c1..a2c1e371aa9057 100644 --- a/types/three/src/nodes/lighting/LightProbeNode.d.ts +++ b/types/three/src/nodes/lighting/LightProbeNode.d.ts @@ -3,7 +3,7 @@ import UniformArrayNode from "../accessors/UniformArrayNode.js"; import AnalyticLightNode from "./AnalyticLightNode.js"; declare class LightProbeNode extends AnalyticLightNode { - lightProbe: UniformArrayNode; + lightProbe: UniformArrayNode<"vec3">; constructor(light?: LightProbe | null); } diff --git a/types/three/src/nodes/lighting/LightUtils.d.ts b/types/three/src/nodes/lighting/LightUtils.d.ts index 7f10cdf64ca9cd..92127cd68e4964 100644 --- a/types/three/src/nodes/lighting/LightUtils.d.ts +++ b/types/three/src/nodes/lighting/LightUtils.d.ts @@ -5,4 +5,4 @@ export const getDistanceAttenuation: (args: { lightDistance: Node; cutoffDistance: Node; decayExponent: Node; -}) => ConditionalNode; +}) => Node<"float">; diff --git a/types/three/src/nodes/lighting/LightingContextNode.d.ts b/types/three/src/nodes/lighting/LightingContextNode.d.ts index bb7079b6ceea22..ce2d027ad73f03 100644 --- a/types/three/src/nodes/lighting/LightingContextNode.d.ts +++ b/types/three/src/nodes/lighting/LightingContextNode.d.ts @@ -13,7 +13,7 @@ export interface LightingContext { backdropAlpha: Node; } -export default class LightingContextNode extends ContextNode { +export default class LightingContextNode extends ContextNode { lightingModelNode: LightingModel | null; backdropNode: Node | null; backdropAlphaNode: Node | null; diff --git a/types/three/src/nodes/lighting/SpotLightNode.d.ts b/types/three/src/nodes/lighting/SpotLightNode.d.ts index 2929c1cc1f1471..04e7ba68f91254 100644 --- a/types/three/src/nodes/lighting/SpotLightNode.d.ts +++ b/types/three/src/nodes/lighting/SpotLightNode.d.ts @@ -19,10 +19,4 @@ declare class SpotLightNode extends AnalyticLightNode { getLightCoord(builder: NodeBuilder): Node; } -declare module "three" { - export interface SpotLight { - attenuationNode?: ((lightNode: SpotLightNode) => Node) | null | undefined; - } -} - export default SpotLightNode; diff --git a/types/three/src/nodes/materialx/MaterialXNodes.d.ts b/types/three/src/nodes/materialx/MaterialXNodes.d.ts index 9297660c2fba77..a55c8f0430fb80 100644 --- a/types/three/src/nodes/materialx/MaterialXNodes.d.ts +++ b/types/three/src/nodes/materialx/MaterialXNodes.d.ts @@ -55,17 +55,17 @@ export const mx_noise_float: ( texcoord?: Node, amplitude?: Node | number, pivot?: Node | number, -) => Node; +) => Node<"float">; export const mx_noise_vec3: ( texcoord?: Node, amplitude?: Node | number, pivot?: Node | number, -) => Node; +) => Node<"vec3">; export const mx_noise_vec4: ( texcoord?: Node, amplitude?: Node | number, pivot?: Node | number, -) => Node; +) => Node<"vec4">; export const mx_unifiednoise2d: ( noiseType: Node, @@ -97,17 +97,17 @@ export const mx_unifiednoise3d: ( export function mx_worley_noise_float( texcoord?: Node, jitter?: Node | number, -): Node; +): Node<"float">; export function mx_worley_noise_vec2( texcoord?: Node, jitter?: Node | number, -): Node; +): Node<"vec2">; export function mx_worley_noise_vec3( texcoord?: Node, jitter?: Node | number, -): Node; +): Node<"vec3">; -export function mx_cell_noise_float(texcoord?: Node): Node; +export function mx_cell_noise_float(texcoord?: Node): Node<"float">; export function mx_fractal_noise_float( position?: Node, @@ -115,28 +115,28 @@ export function mx_fractal_noise_float( lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"float">; export function mx_fractal_noise_vec2( position?: Node, octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"vec2">; export function mx_fractal_noise_vec3( position?: Node, octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"vec3">; export function mx_fractal_noise_vec4( position?: Node, octaves?: Node | number, lacunarity?: Node | number, diminish?: Node | number, amplitude?: Node | number, -): Node; +): Node<"vec4">; export { mx_hsvtorgb, mx_rgbtohsv, mx_srgb_texture_to_lin_rec709 }; diff --git a/types/three/src/nodes/math/BitcountNode.d.ts b/types/three/src/nodes/math/BitcountNode.d.ts index c2811336dddebd..59d9b0e6d443a2 100644 --- a/types/three/src/nodes/math/BitcountNode.d.ts +++ b/types/three/src/nodes/math/BitcountNode.d.ts @@ -16,6 +16,8 @@ declare class BitcountNode extends MathNode { static COUNT_ONE_BITS: "countOneBits"; } +export default BitcountNode; + export const countTrailingZeros: (x: Node | number) => BitcountNode; export const countLeadingZeros: (x: Node | number) => BitcountNode; export const countOneBits: (x: Node | number) => BitcountNode; diff --git a/types/three/src/nodes/math/ConditionalNode.d.ts b/types/three/src/nodes/math/ConditionalNode.d.ts index 77e83a04640e73..e528610f3565d7 100644 --- a/types/three/src/nodes/math/ConditionalNode.d.ts +++ b/types/three/src/nodes/math/ConditionalNode.d.ts @@ -1,30 +1,51 @@ import Node from "../core/Node.js"; -declare class ConditionalNode extends Node { - condNode: Node; - ifNode: Node; - elseNode: Node | null; - - constructor(condNode: Node, ifNode: Node, elseNode?: Node | null); +interface ConditionalNodeInterface { + condNode: Node<"bool">; + ifNode: Node; + elseNode: Node | null; } +declare const ConditionalNode: { + new( + condNode: Node<"bool">, + ifNode: Node, + elseNode?: Node | null, + ): ConditionalNode; +}; + +type ConditionalNode = Node & ConditionalNodeInterface; + export default ConditionalNode; -export const select: ( - condNode: Node, - ifNode: Node | number, - elseNode?: Node | number | null, -) => Node; - -declare module "../Nodes.js" { - interface Node { - select: ( - ifNode: Node | number, - elseNode?: Node | number | null, - ) => Node; - selectAssign: ( - ifNode: Node | number, - elseNode?: Node | number | null, - ) => this; +interface Select { + ( + condNode: Node<"bool">, + ifNode: Node<"float"> | number, + elseNode?: Node<"float"> | number | null, + ): Node<"float">; + ( + condNode: Node<"bool">, + ifNode: Node, + elseNode?: Node | null, + ): Node; +} + +export const select: Select; + +interface SelectExtension { + ( + ifNode: Node<"float"> | number, + elseNode?: Node<"float"> | number | null, + ): Node<"float">; + ( + ifNode: Node, + elseNode?: Node | null, + ): Node; +} + +declare module "../core/Node.js" { + interface NodeElements { + select: SelectExtension; } } diff --git a/types/three/src/nodes/math/Hash.d.ts b/types/three/src/nodes/math/Hash.d.ts index 57620ad34f89a8..82649fadad3760 100644 --- a/types/three/src/nodes/math/Hash.d.ts +++ b/types/three/src/nodes/math/Hash.d.ts @@ -1,3 +1,3 @@ import Node from "../core/Node.js"; -export const hash: (seed: Node) => Node; +export const hash: (seed: Node) => Node<"float">; diff --git a/types/three/src/nodes/math/MathNode.d.ts b/types/three/src/nodes/math/MathNode.d.ts index 2d718b4a894b10..b0708bc59295d8 100644 --- a/types/three/src/nodes/math/MathNode.d.ts +++ b/types/three/src/nodes/math/MathNode.d.ts @@ -1,7 +1,8 @@ +import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; +import { Vector4 } from "../../math/Vector4.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -import OperatorNode from "./OperatorNode.js"; export type MathNodeMethod1 = | typeof MathNode.RADIANS @@ -62,7 +63,6 @@ export default class MathNode extends TempNode { static ALL: "all"; static ANY: "any"; - static EQUALS: "equals"; static RADIANS: "radians"; static DEGREES: "degrees"; @@ -99,6 +99,7 @@ export default class MathNode extends TempNode { // 2 inputs + static EQUALS: "equals"; static MIN: "min"; static MAX: "max"; static STEP: "step"; @@ -129,319 +130,654 @@ export default class MathNode extends TempNode { constructor(method: MathNodeMethod3, aNode: Node, bNode: Node, cNode: Node); } -export const EPSILON: Node; -export const INFINITY: Node; -export const PI: Node; - -/** - * @deprecated Please use the non-deprecated version `TWO_PI`. - */ -export const PI2: Node; - -export const TWO_PI: Node; - -export const HALF_PI: Node; +type FloatOrNumber = Node<"float"> | number; +type IntOrNumber = Node<"int"> | number; +type FloatVector = Node<"vec2"> | Node<"vec3"> | Node<"vec4">; +type FloatVectorOrNumber = FloatOrNumber | Node<"vec2"> | Node<"vec3"> | Node<"vec4">; -type MathNodeParameter = Node | number; +type BoolVector = Node<"bvec2"> | Node<"bvec3"> | Node<"bvec4">; -type Unary = (a: MathNodeParameter) => MathNode; +type Matrix = Node<"mat2"> | Node<"mat3"> | Node<"mat4">; -export const all: Unary; -export const any: Unary; +type Vec2OrLessOrFloat = FloatOrNumber | Node<"vec2">; +type Vec3OrLessOrFloat = Vec2OrLessOrFloat | Node<"vec3">; +type Vec4OrLessOrFloat = Vec3OrLessOrFloat | Node<"vec4">; -/** - * @deprecated "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )" - */ -export const equals: Unary; - -export const radians: Unary; -export const degrees: Unary; -export const exp: Unary; -export const exp2: Unary; -export const log: Unary; -export const log2: Unary; -export const sqrt: Unary; -export const inverseSqrt: Unary; -export const floor: Unary; -export const ceil: Unary; -export const normalize: (a: Node | Vector3) => MathNode; -export const fract: Unary; -export const sin: Unary; -export const cos: Unary; -export const tan: Unary; -export const asin: Unary; -export const acos: Unary; -export const atan: (a: MathNodeParameter, b?: MathNodeParameter) => MathNode; -export const abs: Unary; -export const sign: Unary; -export const length: Unary; -export const negate: Unary; -export const oneMinus: Unary; -export const dFdx: Unary; -export const dFdy: Unary; -export const round: Unary; -export const reciprocal: Unary; -export const trunc: Unary; -export const fwidth: Unary; -export const transpose: Unary; -export const determinant: (x: Node) => MathNode; -export const inverse: (x: Node) => MathNode; - -type Binary = (a: MathNodeParameter, b: MathNodeParameter) => MathNode; - -export const min: ( - x: MathNodeParameter, - y: MathNodeParameter, - ...values: MathNodeParameter[] -) => MathNode; -export const max: ( - x: MathNodeParameter, - y: MathNodeParameter, - ...values: MathNodeParameter[] -) => MathNode; -export const step: Binary; -export const reflect: Binary; -export const distance: Binary; -export const difference: Binary; -export const dot: Binary; -export const cross: (x: Node, y: Node) => MathNode; -export const pow: Binary; -export const pow2: Unary; -export const pow3: Unary; -export const pow4: Unary; -export const transformDirection: Binary; -export const cbrt: Unary; -export const lengthSq: Unary; - -type Ternary = (a: MathNodeParameter, b: MathNodeParameter, c: MathNodeParameter) => MathNode; - -export const mix: Ternary; -export const clamp: ( - a: MathNodeParameter, - b?: MathNodeParameter, - c?: MathNodeParameter, -) => MathNode; -export const saturate: Unary; -export const refract: Ternary; -export const smoothstep: Ternary; -export const faceForward: Ternary; - -export const rand: (uv: MathNodeParameter) => OperatorNode; - -export const mixElement: Ternary; -export const smoothstepElement: Ternary; -export const stepElement: Binary; +export const EPSILON: Node<"float">; +export const INFINITY: Node<"float">; +export const PI: Node<"float">; /** - * @deprecated + * @deprecated Please use the non-deprecated version `TWO_PI`. */ -export const atan2: Binary; - -// GLSL alias function - -export const faceforward: typeof faceForward; -export const inversesqrt: typeof inverseSqrt; - -// Method chaining - -declare module "../Nodes.js" { - interface Node { - all: () => MathNode; - allAssign: () => this; - - any: () => MathNode; - anyAssign: () => this; - - /** - * @deprecated "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )" - */ - equals: () => MathNode; - /** - * @deprecated "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )" - */ - equalsAssign: () => this; - - radians: () => MathNode; - radiansAssign: () => this; - - degrees: () => MathNode; - degreesAssign: () => this; - - exp: () => MathNode; - expAssign: () => this; +export const PI2: Node<"float">; - exp2: () => MathNode; - exp2Assign: () => this; +export const TWO_PI: Node<"float">; - log: () => MathNode; - logAssign: () => this; +export const HALF_PI: Node<"float">; - log2: () => MathNode; - log2Assign: () => this; - - sqrt: () => MathNode; - sqrtAssign: () => this; - - inverseSqrt: () => MathNode; - inverseSqrtAssign: () => this; - - floor: () => MathNode; - floorAssign: () => this; - - ceil: () => MathNode; - ceilAssign: () => this; - - normalize: () => MathNode; - normalizeAssign: () => this; - - fract: () => MathNode; - fractAssign: () => this; - - sin: () => MathNode; - sinAssign: () => this; - - cos: () => MathNode; - cosAssign: () => this; +export const all: (x: BoolVector) => Node<"bool">; +export const any: (x: BoolVector) => Node<"bool">; +declare module "../core/Node.js" { + interface BvecExtensions { + all: () => Node<"bool">; + any: () => Node<"bool">; + } +} - tan: () => MathNode; - tanAssign: () => this; +interface UnaryFunction { + (x: FloatOrNumber): Node<"float">; +} +export const radians: UnaryFunction; +export const degrees: UnaryFunction; +export const exp: UnaryFunction; +export const exp2: UnaryFunction; +export const log: UnaryFunction; +export const log2: UnaryFunction; +export const sqrt: UnaryFunction; +export const inverseSqrt: UnaryFunction; +declare module "../core/Node.js" { + interface FloatExtensions { + radians: () => Node<"float">; + degrees: () => Node<"float">; + exp: () => Node<"float">; + exp2: () => Node<"float">; + log: () => Node<"float">; + log2: () => Node<"float">; + sqrt: () => Node<"float">; + inverseSqrt: () => Node<"float">; + } +} - asin: () => MathNode; - asinAssign: () => this; +interface FloorCeil { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const floor: FloorCeil; +export const ceil: FloorCeil; +declare module "../core/Node.js" { + interface FloatExtensions { + floor: () => Node<"float">; + ceil: () => Node<"float">; + } + interface FloatVecExtensions { + floor: () => Node; + ceil: () => Node; + } +} - acos: () => MathNode; - acosAssign: () => this; +interface Normalize { + (x: Node<"vec2"> | Vector2): Node<"vec2">; + (x: Node<"vec3"> | Vector3): Node<"vec3">; + (x: Node<"vec4"> | Vector4): Node<"vec4">; +} +export const normalize: Normalize; +declare module "../core/Node.js" { + interface FloatVecExtensions { + normalize: () => Node; + } +} - atan: (b?: MathNodeParameter) => MathNode; - atanAssign: (b?: MathNodeParameter) => this; +interface Fract { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const fract: Fract; +declare module "../core/Node.js" { + interface FloatExtensions { + fract: () => Node<"float">; + } + interface FloatVecExtensions { + fract: () => Node; + } +} - abs: () => MathNode; - absAssign: () => this; +export const sin: (x: FloatOrNumber) => Node<"float">; +export const cos: (x: FloatOrNumber) => Node<"float">; +export const tan: (x: FloatOrNumber) => Node<"float">; +export const asin: (x: FloatOrNumber) => Node<"float">; +export const acos: (x: FloatOrNumber) => Node<"float">; +export const atan: (y: FloatOrNumber, x?: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + sin: () => Node<"float">; + cos: () => Node<"float">; + tan: () => Node<"float">; + asin: () => Node<"float">; + acos: () => Node<"float">; + atan: (x?: FloatOrNumber) => Node<"float">; + } +} - sign: () => MathNode; - signAssign: () => this; +interface Abs { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; + (x: IntOrNumber): Node<"int">; +} +export const abs: Abs; +declare module "../core/Node.js" { + interface FloatExtensions { + abs: () => Node<"float">; + } + interface IntExtensions { + abs: () => Node<"int">; + } + interface FloatVecExtensions { + abs: () => Node; + } +} - length: () => MathNode; - lengthAssign: () => this; +interface Sign { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const sign: Sign; +declare module "../core/Node.js" { + interface FloatExtensions { + sign: () => Node<"float">; + } + interface FloatVecExtensions { + sign: () => Node; + } +} - lengthSq: () => MathNode; - lengthSqAssign: () => this; +export const length: (x: FloatVector | Node) => Node<"float">; +declare module "../core/Node.js" { + interface FloatVecExtensions { + length: () => Node<"float">; + } +} - negate: () => MathNode; - negateAssign: () => this; +interface Negate { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const negate: Negate; +declare module "../core/Node.js" { + interface FloatExtensions { + negate: () => Node<"float">; + } + interface FloatVecExtensions { + negate: () => Node; + } +} - oneMinus: () => MathNode; - oneMinusAssign: () => this; +interface OneMinus { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const oneMinus: OneMinus; +declare module "../core/Node.js" { + interface FloatExtensions { + oneMinus: () => Node<"float">; + } + interface FloatVecExtensions { + oneMinus: () => Node; + } +} - dFdx: () => MathNode; - dFdxAssign: () => this; +interface Derivative { + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const dFdx: Derivative; +export const dFdy: Derivative; +declare module "../core/Node.js" { + interface FloatVecExtensions { + dFdx: () => Node; + dFdy: () => Node; + } +} - dFdy: () => MathNode; - dFdyAssign: () => this; +export const round: (x: FloatOrNumber) => Node<"float">; +export const reciprocal: (x: FloatOrNumber) => Node<"float">; +export const trunc: (x: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + round: () => Node<"float">; + reciprocal: () => Node<"float">; + trunc: () => Node<"float">; + } +} - round: () => MathNode; - roundAssign: () => this; +interface Fwidth { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const fwidth: Fwidth; +declare module "../core/Node.js" { + interface FloatExtensions { + fwidth: () => Node<"float">; + } + interface FloatVecExtensions { + fwidth: () => Node; + } +} - reciprocal: () => MathNode; - reciprocalAssign: () => this; +interface Transpose { + (x: Node<"mat2">): Node<"mat2">; + (x: Node<"mat3">): Node<"mat3">; + (x: Node<"mat4">): Node<"mat4">; +} +export const transpose: Transpose; +declare module "../core/Node.js" { + interface MatExtensions { + transpose: () => Node; + } +} - trunc: () => MathNode; - truncAssign: () => this; +export const determinant: (x: Matrix) => Node<"float">; +declare module "../core/Node.js" { + interface MatExtensions { + determinant: () => Node<"float">; + } +} - fwidth: () => MathNode; - fwidthAssign: () => this; +interface Inverse { + (x: Node<"mat2">): Node<"mat2">; + (x: Node<"mat3">): Node<"mat3">; + (x: Node<"mat4">): Node<"mat4">; +} +export const inverse: Inverse; +declare module "../core/Node.js" { + interface MatExtensions { + inverse: () => Node; + } +} - /** - * @deprecated - */ - atan2: (b: MathNodeParameter) => MathNode; - /** - * @deprecated - */ - atan2Assign: (b: MathNodeParameter) => this; +interface MinMax { + (x: FloatOrNumber, y: FloatOrNumber, ...params: FloatOrNumber[]): Node<"float">; + (x: Vec2OrLessOrFloat, y: Vec2OrLessOrFloat, ...params: Vec2OrLessOrFloat[]): Node<"vec2">; + (x: Vec3OrLessOrFloat, y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (x: Vec4OrLessOrFloat, y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +export const min: MinMax; +export const max: MinMax; +interface MinMaxFloatExtension { + (y: FloatOrNumber, ...params: FloatOrNumber[]): Node<"float">; + (y: Vec2OrLessOrFloat, ...params: Vec2OrLessOrFloat[]): Node<"vec2">; + (y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +interface MinMaxVec2Extension { + (y: Vec2OrLessOrFloat, ...params: Vec2OrLessOrFloat[]): Node<"vec2">; + (y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +interface MinMaxVec3Extension { + (y: Vec3OrLessOrFloat, ...params: Vec3OrLessOrFloat[]): Node<"vec3">; + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +interface MinMaxVec4Extension { + (y: Vec4OrLessOrFloat, ...params: Vec4OrLessOrFloat[]): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + min: MinMaxFloatExtension; + max: MinMaxFloatExtension; + } + interface Vec2Extensions { + min: MinMaxVec2Extension; + max: MinMaxVec2Extension; + } + interface Vec3Extensions { + min: MinMaxVec3Extension; + max: MinMaxVec3Extension; + } + interface Vec4Extensions { + min: MinMaxVec4Extension; + max: MinMaxVec4Extension; + } +} - min: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => MathNode; - minAssign: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => this; +export const step: (x: FloatOrNumber, y: FloatOrNumber) => Node<"float">; - max: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => MathNode; - maxAssign: ( - y: MathNodeParameter, - ...values: MathNodeParameter[] - ) => this; +interface Reflect { + (I: Vec2OrLessOrFloat, N: Vec2OrLessOrFloat): Node<"vec2">; + (I: Vec3OrLessOrFloat, N: Vec3OrLessOrFloat): Node<"vec3">; + (I: Vec4OrLessOrFloat, N: Vec4OrLessOrFloat): Node<"vec4">; +} +export const reflect: Reflect; +interface ReflectVec2Extension { + (N: Vec2OrLessOrFloat): Node<"vec2">; + (N: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ReflectVec3Extension { + (N: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ReflectVec4Extension { + (N: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface Vec2Extensions { + reflect: ReflectVec2Extension; + } + interface Vec3Extensions { + reflect: ReflectVec3Extension; + } + interface Vec4Extensions { + reflect: ReflectVec4Extension; + } +} - step: (b: MathNodeParameter) => MathNode; - stepAssign: (b: MathNodeParameter) => this; +export const distance: (x: FloatVectorOrNumber, y: FloatVectorOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + distance: (y: FloatVectorOrNumber) => Node<"float">; + } + interface FloatVecExtensions { + distance: (y: FloatVectorOrNumber) => Node<"float">; + } +} - reflect: (b: MathNodeParameter) => MathNode; - reflectAssign: (b: MathNodeParameter) => this; +interface Difference { + (x: FloatOrNumber, y: FloatOrNumber): Node<"float">; + (x: Vec2OrLessOrFloat, y: Vec2OrLessOrFloat): Node<"vec2">; + (x: Vec3OrLessOrFloat, y: Vec3OrLessOrFloat): Node<"vec3">; + (x: Vec4OrLessOrFloat, y: Vec4OrLessOrFloat): Node<"vec4">; +} +export const difference: Difference; +interface DifferenceFloatExtension { + (y: FloatOrNumber): Node<"float">; + (y: Vec2OrLessOrFloat): Node<"vec2">; + (y: Vec3OrLessOrFloat): Node<"vec3">; + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +interface DifferenceVec2Extension { + (y: Vec2OrLessOrFloat): Node<"vec2">; + (y: Vec3OrLessOrFloat): Node<"vec3">; + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +interface DifferenceVec3Extension { + (y: Vec3OrLessOrFloat): Node<"vec3">; + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +interface DifferenceVec4Extension { + (y: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + difference: DifferenceFloatExtension; + } + interface Vec2Extensions { + difference: DifferenceVec2Extension; + } + interface Vec3Extensions { + difference: DifferenceVec3Extension; + } + interface Vec4Extensions { + difference: DifferenceVec4Extension; + } +} - distance: (b: MathNodeParameter) => MathNode; - distanceAssign: (b: MathNodeParameter) => this; +export const dot: (x: FloatVector, y: FloatVector) => Node<"float">; +declare module "../core/Node.js" { + interface FloatVecExtensions { + dot: (y: FloatVector) => Node<"float">; + } +} - dot: (b: MathNodeParameter) => MathNode; - dotAssign: (b: MathNodeParameter) => this; +export const cross: (x: Node<"vec3">, y: Node<"vec3">) => Node<"vec3">; +declare module "../core/Node.js" { + interface Vec3Extensions { + cross: (y: Node<"vec3">) => Node<"vec3">; + } +} - cross: (y: Node) => MathNode; - crossAssign: (y: Node) => this; +interface Pow { + (x: FloatOrNumber, y: FloatOrNumber): Node<"float">; + (x: Node<"vec2">, y: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">, y: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">, y: Node<"vec4">): Node<"vec4">; +} +export const pow: (x: FloatOrNumber, y: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + pow: (y: FloatOrNumber) => Node<"float">; + } + interface FloatVecExtensions { + pow: (y: Node) => Node; + } +} - pow: (b: MathNodeParameter) => MathNode; - powAssign: (b: MathNodeParameter) => this; +interface PowConstant { + (x: FloatOrNumber): Node<"float">; + (x: Node<"vec2">): Node<"vec2">; + (x: Node<"vec3">): Node<"vec3">; + (x: Node<"vec4">): Node<"vec4">; +} +export const pow2: PowConstant; +export const pow3: PowConstant; +export const pow4: PowConstant; +declare module "../core/Node.js" { + interface FloatExtensions { + pow2: () => Node<"float">; + pow3: () => Node<"float">; + pow4: () => Node<"float">; + } + interface FloatVecExtensions { + pow2: () => Node; + pow3: () => Node; + pow4: () => Node; + } +} - pow2: () => MathNode; - pow2Assign: () => this; +export const transformDirection: (direction: Node<"vec3">, matrix: Node<"mat3"> | Node<"mat4">) => Node<"vec3">; +declare module "../core/Node.js" { + interface Vec3Extensions { + transformDirection: (matrix: Node<"mat3"> | Node<"mat4">) => Node<"vec3">; + } +} - pow3: () => MathNode; - pow3Assign: () => this; +export const cbrt: (a: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + cbrt: () => Node<"float">; + } +} - pow4: () => MathNode; - pow4Assign: () => this; +export const lengthSq: (a: FloatVector) => Node<"float">; +declare module "../core/Node.js" { + interface FloatVecExtensions { + lengthSq: () => Node<"float">; + } +} - transformDirection: (b: MathNodeParameter) => MathNode; - transformDirectionAssign: (b: MathNodeParameter) => this; +interface Mix { + (a: FloatOrNumber, b: FloatOrNumber, t: FloatOrNumber): Node<"float">; + (a: Vec2OrLessOrFloat, b: Vec2OrLessOrFloat, t: FloatOrNumber): Node<"vec2">; + (a: Vec3OrLessOrFloat | Node<"color">, b: Vec3OrLessOrFloat | Node<"color">, t: FloatOrNumber): Node<"vec3">; + (a: Vec4OrLessOrFloat, b: Vec4OrLessOrFloat, t: FloatOrNumber): Node<"vec4">; +} +export const mix: Mix; - mix: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - mixAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface Clamp { + (value: FloatOrNumber, low?: FloatOrNumber, high?: FloatOrNumber): Node<"float">; + (value: Vec2OrLessOrFloat, low?: Vec2OrLessOrFloat, high?: Vec2OrLessOrFloat): Node<"vec2">; + (value: Vec3OrLessOrFloat, low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (value: Vec4OrLessOrFloat, low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +export const clamp: Clamp; +interface ClampFloatExtension { + (low?: FloatOrNumber, high?: FloatOrNumber): Node<"float">; + (low?: Vec2OrLessOrFloat, high?: Vec2OrLessOrFloat): Node<"vec2">; + (low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ClampVec2Extension { + (low?: Vec2OrLessOrFloat, high?: Vec2OrLessOrFloat): Node<"vec2">; + (low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ClampVec3Extension { + (low?: Vec3OrLessOrFloat, high?: Vec3OrLessOrFloat): Node<"vec3">; + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +interface ClampVec4Extension { + (low?: Vec4OrLessOrFloat, high?: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + clamp: ClampFloatExtension; + } + interface Vec2Extensions { + clamp: ClampVec2Extension; + } + interface Vec3Extensions { + clamp: ClampVec3Extension; + } + interface Vec4Extensions { + clamp: ClampVec4Extension; + } +} - clamp: (b?: MathNodeParameter, c?: MathNodeParameter) => MathNode; - clampAssign: (b?: MathNodeParameter, c?: MathNodeParameter) => this; +interface Saturate { + (value: FloatOrNumber): Node<"float">; + (value: Node<"vec2">): Node<"vec2">; + (value: Node<"vec3">): Node<"vec3">; + (value: Node<"vec4">): Node<"vec4">; +} +export const saturate: Saturate; +declare module "../core/Node.js" { + interface FloatExtensions { + saturate: () => Node<"float">; + } + interface FloatVecExtensions { + saturate: () => Node; + } +} - refract: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - refractAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface Refract { + (I: Vec2OrLessOrFloat, N: Vec2OrLessOrFloat, ratio: FloatOrNumber): Node<"vec2">; + (I: Vec3OrLessOrFloat, N: Vec3OrLessOrFloat, ratio: FloatOrNumber): Node<"vec3">; + (I: Vec4OrLessOrFloat, N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +export const refract: Refract; +interface RefractVec2Extension { + (N: Vec2OrLessOrFloat, ratio: FloatOrNumber): Node<"vec2">; + (N: Vec3OrLessOrFloat, ratio: FloatOrNumber): Node<"vec3">; + (N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +interface RefractVec3Extension { + (N: Vec3OrLessOrFloat, ratio: FloatOrNumber): Node<"vec3">; + (N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +interface RefractVec4Extension { + (N: Vec4OrLessOrFloat, ratio: FloatOrNumber): Node<"vec4">; +} +declare module "../core/Node.js" { + interface Vec2Extensions { + refract: RefractVec2Extension; + } + interface Vec3Extensions { + refract: RefractVec3Extension; + } + interface Vec4Extensions { + refract: RefractVec4Extension; + } +} - smoothstep: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - smoothstepAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface Smoothstep { + (low: FloatOrNumber, high: FloatOrNumber, x: FloatOrNumber): Node<"float">; +} +export const smoothstep: Smoothstep; - faceForward: (b: MathNodeParameter, c: MathNodeParameter) => MathNode; - faceForwardAssign: (b: MathNodeParameter, c: MathNodeParameter) => this; +interface FaceForward { + (N: Vec2OrLessOrFloat, I: Vec2OrLessOrFloat, Nref: Vec2OrLessOrFloat): Node<"vec2">; + (N: Vec3OrLessOrFloat, I: Vec3OrLessOrFloat, Nref: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat, I: Vec4OrLessOrFloat, Nref: Vec4OrLessOrFloat): Node<"vec4">; +} +export const faceForward: FaceForward; +interface FaceForwardVec2Extension { + (I: Vec2OrLessOrFloat, Nref: Vec2OrLessOrFloat): Node<"vec2">; + (I: Vec3OrLessOrFloat, Nref: Vec3OrLessOrFloat): Node<"vec3">; + (I: Vec4OrLessOrFloat, Nref: Vec4OrLessOrFloat): Node<"vec4">; +} +interface FaceForwardVec3Extension { + (N: Vec3OrLessOrFloat, ratio: Vec3OrLessOrFloat): Node<"vec3">; + (N: Vec4OrLessOrFloat, ratio: Vec4OrLessOrFloat): Node<"vec4">; +} +interface FaceForwardVec4Extension { + (N: Vec4OrLessOrFloat, ratio: Vec4OrLessOrFloat): Node<"vec4">; +} +declare module "../core/Node.js" { + interface Vec2Extensions { + faceForward: FaceForwardVec2Extension; + } + interface Vec3Extensions { + faceForward: FaceForwardVec3Extension; + } + interface Vec4Extensions { + faceForward: FaceForwardVec4Extension; + } +} - difference: (b: MathNodeParameter) => MathNode; - differenceAssign: (b: MathNodeParameter) => this; +export const rand: (uv: Node<"vec2">) => Node<"float">; +declare module "../core/Node.js" { + interface Vec2Extensions { + rand: () => Node<"float">; + } +} - saturate: () => MathNode; - saturateAssign: () => this; +interface MixElement { + (t: FloatOrNumber, e1: FloatOrNumber, e2: FloatOrNumber): Node<"float">; + (t: FloatOrNumber, e1: Vec2OrLessOrFloat, e2: Vec2OrLessOrFloat): Node<"vec2">; + (t: FloatOrNumber, e1: Vec3OrLessOrFloat | Node<"color">, e2: Vec3OrLessOrFloat | Node<"color">): Node<"vec3">; + (t: FloatOrNumber, e1: Vec4OrLessOrFloat, e2: Vec4OrLessOrFloat): Node<"vec4">; +} +export const mixElement: MixElement; +interface MixExtension { + (e1: FloatOrNumber, e2: FloatOrNumber): Node<"float">; + (e1: Vec2OrLessOrFloat, e2: Vec2OrLessOrFloat): Node<"vec2">; + (e1: Vec3OrLessOrFloat | Node<"color">, e2: Vec3OrLessOrFloat | Node<"color">): Node<"vec3">; + (e1: Vec4OrLessOrFloat | Node<"color">, e2: Vec4OrLessOrFloat | Node<"color">): Node<"vec4">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + mix: MixExtension; + } +} - cbrt: () => MathNode; - cbrtAssign: () => this; +interface SmoothstepElement { + (x: FloatOrNumber, low: FloatOrNumber, high: FloatOrNumber): Node<"float">; +} +export const smoothstepElement: SmoothstepElement; +interface SmoothstepExtension { + (low: FloatOrNumber, high: FloatOrNumber): Node<"float">; +} +declare module "../core/Node.js" { + interface FloatExtensions { + smoothstep: SmoothstepExtension; + } +} - transpose: () => MathNode; - transposeAssign: () => this; +export const stepElement: (x: FloatOrNumber, edge: FloatOrNumber) => Node<"float">; +declare module "../core/Node.js" { + interface FloatExtensions { + step: (edge: FloatOrNumber) => Node<"float">; + } +} - determinant: () => MathNode; - determinantAssign: () => this; +// GLSL alias function - inverse: () => MathNode; - inverseAssign: () => this; +export const faceforward: typeof faceForward; +export const inversesqrt: typeof inverseSqrt; - rand: () => OperatorNode; - randAssign: () => this; - } -} +export {}; diff --git a/types/three/src/nodes/math/MathUtils.d.ts b/types/three/src/nodes/math/MathUtils.d.ts index 572d9eef55033d..5261fafacdead5 100644 --- a/types/three/src/nodes/math/MathUtils.d.ts +++ b/types/three/src/nodes/math/MathUtils.d.ts @@ -1,6 +1,10 @@ -import { Binary, Ternary } from "./MathNode.js"; +import Node from "../core/Node.js"; -export const parabola: Binary; -export const gain: Binary; -export const pcurve: Ternary; -export const sinc: Binary; +type FloatOrNumber = Node<"float"> | number; + +export const parabola: (x: FloatOrNumber, k: FloatOrNumber) => Node<"float">; +export const gain: (x: FloatOrNumber, k: FloatOrNumber) => Node<"float">; +export const pcurve: (x: FloatOrNumber, a: FloatOrNumber, b: FloatOrNumber) => Node<"float">; +export const sinc: (x: FloatOrNumber, k: FloatOrNumber) => Node<"float">; + +export {}; diff --git a/types/three/src/nodes/math/OperatorNode.d.ts b/types/three/src/nodes/math/OperatorNode.d.ts index fc9fdde0d2d7a3..3aae9a650e2932 100644 --- a/types/three/src/nodes/math/OperatorNode.d.ts +++ b/types/three/src/nodes/math/OperatorNode.d.ts @@ -1,4 +1,4 @@ -import Node from "../core/Node.js"; +import Node, { IntegerType, NumType } from "../core/Node.js"; import TempNode from "../core/TempNode.js"; export type OperatorNodeOp = @@ -32,244 +32,507 @@ export default class OperatorNode extends TempNode { constructor(op: OperatorNodeOp, ...params: [Node, Node, ...Node[]]); } -type OperatorNodeParameter = Node | number; - -export const add: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const sub: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const mul: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const div: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const mod: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const equal: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const notEqual: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const lessThan: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const greaterThan: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const lessThanEqual: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const greaterThanEqual: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const and: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const or: ( - a: OperatorNodeParameter, - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] -) => OperatorNode; -export const not: (value: OperatorNodeParameter) => OperatorNode; -export const xor: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitAnd: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitNot: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitOr: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const bitXor: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const shiftLeft: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; -export const shiftRight: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; - -export const incrementBefore: (a: OperatorNodeParameter) => Node; -export const decrementBefore: (a: OperatorNodeParameter) => Node; -export const increment: (a: OperatorNodeParameter) => Node; -export const decrement: (a: OperatorNodeParameter) => Node; - -declare module "../Nodes.js" { - interface Node { - add: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - addAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - sub: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - subAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - mul: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - mulAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - div: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - divAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - mod: ( - b: OperatorNodeParameter, - ) => OperatorNode; - modAssign: ( - b: OperatorNodeParameter, - ) => this; - - equal: ( - b: OperatorNodeParameter, - ) => OperatorNode; - equalAssign: ( - b: OperatorNodeParameter, - ) => this; - - notEqual: ( - b: OperatorNodeParameter, - ) => OperatorNode; - notEqualAssign: ( - b: OperatorNodeParameter, - ) => this; - - lessThan: ( - b: OperatorNodeParameter, - ) => OperatorNode; - lessThanAssign: ( - b: OperatorNodeParameter, - ) => this; - - greaterThan: ( - b: OperatorNodeParameter, - ) => OperatorNode; - greaterThanAssign: ( - b: OperatorNodeParameter, - ) => this; - - lessThanEqual: ( - b: OperatorNodeParameter, - ) => OperatorNode; - lessThanEqualAssign: ( - b: OperatorNodeParameter, - ) => this; - - greaterThanEqual: ( - b: OperatorNodeParameter, - ) => OperatorNode; - greaterThanEqualAssign: ( - b: OperatorNodeParameter, - ) => this; - - and: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - andAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - or: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => OperatorNode; - orAssign: ( - b: OperatorNodeParameter, - ...params: OperatorNodeParameter[] - ) => this; - - not: () => OperatorNode; - notAssign: () => this; - - xor: ( - b: OperatorNodeParameter, - ) => OperatorNode; - xorAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitAnd: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitAndAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitNot: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitNotAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitOr: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitOrAssign: ( - b: OperatorNodeParameter, - ) => this; - - bitXor: ( - b: OperatorNodeParameter, - ) => OperatorNode; - bitXorAssign: ( - b: OperatorNodeParameter, - ) => this; - - shiftLeft: ( - b: OperatorNodeParameter, - ) => OperatorNode; - shiftLeftAssign: ( - b: OperatorNodeParameter, - ) => this; - - shiftRight: ( - b: OperatorNodeParameter, - ) => OperatorNode; - shiftRightAssign: ( - b: OperatorNodeParameter, - ) => this; - - incrementBefore: () => OperatorNode; - incrementBeforeAssign: () => this; - - decrementBefore: () => OperatorNode; - decrementBeforeAssign: () => this; - - increment: () => OperatorNode; - incrementAssign: () => this; - - decrement: () => OperatorNode; - decrementAssign: () => this; +type Vec2OrLess = Node<"vec2">; +type Vec3OrLess = Vec2OrLess | Node<"vec3">; +type Vec4OrLess = Vec3OrLess | Node<"vec4">; + +interface NumberToVec { + float: "vec"; + int: "ivec"; + uint: "uvec"; +} + +type NumberToVec2 = `${NumberToVec[TNum]}2`; +type NumberToVec3 = `${NumberToVec[TNum]}3`; +type NumberToVec4 = `${NumberToVec[TNum]}4`; + +type Number = AnyNumber; // FIXME Number | number +type Vec2OrLessOrNumber = Number | Node>; +type Vec3OrLessOrNumber = Vec2OrLessOrNumber | Node>; +type Vec4OrLessOrNumber = Vec3OrLessOrNumber | Node>; + +type AnyNumber = Node<"float"> | Node<"int"> | Node<"uint"> | number; + +// add/sub/mul/div + +// add/sub/mul/div numbers and/or vecs +// Every parameter gets converted to the longest type +// If the parameters are the same length, it gets converted to the first type +// FIXME We handle the case of converting number types, but not converting between vectors of different number types + +interface AddSubMulDivNumberVec { + (a: Number, b: AnyNumber, ...params: AnyNumber[]): Node; + ( + a: Vec2OrLessOrNumber, + b: Vec2OrLessOrNumber, + ...params: Vec2OrLessOrNumber[] + ): Node>; + ( + a: Vec3OrLessOrNumber, + b: Vec3OrLessOrNumber, + ...params: Vec3OrLessOrNumber[] + ): Node>; + ( + a: Vec4OrLessOrNumber, + b: Vec4OrLessOrNumber, + ...params: Vec4OrLessOrNumber[] + ): Node>; +} + +interface AddSubMulDivNumberVecNumExtensions { + (b: AnyNumber, ...params: AnyNumber[]): Node; + (b: Vec2OrLessOrNumber, ...params: Vec2OrLessOrNumber[]): Node>; + (b: Vec3OrLessOrNumber, ...params: Vec3OrLessOrNumber[]): Node>; + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecNumberAssignExtensions { + ( + b: Vec4OrLessOrNumber<"float"> | Vec4OrLessOrNumber<"int"> | Vec4OrLessOrNumber<"uint">, + ...params: (Vec4OrLessOrNumber<"float"> | Vec4OrLessOrNumber<"int"> | Vec4OrLessOrNumber<"uint">)[] + ): this; +} + +interface AddSubMulDivNumberVecVec2Extensions { + (b: Vec2OrLessOrNumber, ...params: Vec2OrLessOrNumber[]): Node>; + (b: Vec3OrLessOrNumber, ...params: Vec3OrLessOrNumber[]): Node>; + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecVec2AssignExtensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): this; +} + +interface AddSubMulDivNumberVecVec3Extensions { + (b: Vec3OrLessOrNumber, ...params: Vec3OrLessOrNumber[]): Node>; + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecVec3AssignExtensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): this; +} + +interface AddSubMulDivNumberVecVec4Extensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): Node>; +} + +interface AddSubMulDivNumberVecVec4AssignExtensions { + (b: Vec4OrLessOrNumber, ...params: Vec4OrLessOrNumber[]): this; +} + +// add/sub/mul mats + +interface AddSubMulMat { + (a: Node<"mat2">, b: Node<"mat2">): Node<"mat2">; + (a: Node<"mat3">, b: Node<"mat3">): Node<"mat3">; + (a: Node<"mat4">, b: Node<"mat4">): Node<"mat4">; +} + +interface AddSubMulMat2Extensions { + (b: Node<"mat2">): Node<"mat2">; +} + +interface AddSubMulMat2AssignExtensions { + (b: Node<"mat2">): this; +} + +interface AddSubMulMat3Extensions { + (b: Node<"mat3">): Node<"mat3">; +} + +interface AddSubMulMat3AssignExtensions { + (b: Node<"mat3">): this; +} + +interface AddSubMulMat4Extensions { + (b: Node<"mat4">): Node<"mat4">; +} + +interface AddSubMulMat4AssignExtensions { + (b: Node<"mat3">): this; +} + +// mut mats and vecs +// The vec parameter gets converted to matrix length + +interface MulMatVec { + (a: Node<"mat2">, b: Vec4OrLess): Node<"vec2">; + (a: Node<"mat3">, b: Vec4OrLess): Node<"vec3">; + (a: Node<"mat4">, b: Vec4OrLess): Node<"vec4">; + (a: Vec4OrLess, b: Node<"mat2">): Node<"vec2">; + (a: Vec4OrLess, b: Node<"mat3">): Node<"vec3">; + (a: Vec4OrLess, b: Node<"mat4">): Node<"vec4">; +} + +interface MulVecMatMat2Extensions { + (b: Vec4OrLess): Node<"vec2">; +} + +interface MulVecMatMat3Extensions { + (b: Vec4OrLess): Node<"vec3">; +} + +interface MulVecMatMat4Extensions { + (b: Vec4OrLess): Node<"vec4">; +} + +interface MulVecMatVecExtensions { + (b: Node<"mat2">): Node<"vec2">; + (b: Node<"mat3">): Node<"vec3">; + (b: Node<"mat4">): Node<"vec4">; +} + +// Exports + +interface AddSub + extends AddSubMulDivNumberVec<"float">, AddSubMulDivNumberVec<"int">, AddSubMulDivNumberVec<"uint">, AddSubMulMat +{} + +export const add: AddSub; +export const sub: AddSub; + +interface Mul + extends + AddSubMulDivNumberVec<"float">, + AddSubMulDivNumberVec<"int">, + AddSubMulDivNumberVec<"uint">, + AddSubMulMat, + MulMatVec +{ +} + +interface MulVec2Extensions + extends AddSubMulDivNumberVecVec2Extensions, MulVecMatVecExtensions +{ +} + +interface MulVec3Extensions + extends AddSubMulDivNumberVecVec3Extensions, MulVecMatVecExtensions +{ +} + +interface MulVec4Extensions + extends AddSubMulDivNumberVecVec4Extensions, MulVecMatVecExtensions +{ +} + +interface MulMat2Extensions extends AddSubMulMat2Extensions, MulVecMatMat2Extensions { +} + +interface MulMat3Extensions extends AddSubMulMat3Extensions, MulVecMatMat3Extensions { +} + +interface MulMat4Extensions extends AddSubMulMat4Extensions, MulVecMatMat4Extensions { +} + +export const mul: Mul; + +interface Div extends AddSubMulDivNumberVec<"float">, AddSubMulDivNumberVec<"int">, AddSubMulDivNumberVec<"uint"> { +} +export const div: Div; + +declare module "../core/Node.js" { + interface FloatExtensions { + mul: (b: Node<"color">) => Node<"vec3">; + } + + interface NumExtensions { + add: AddSubMulDivNumberVecNumExtensions; + sub: AddSubMulDivNumberVecNumExtensions; + mul: AddSubMulDivNumberVecNumExtensions; + div: AddSubMulDivNumberVecNumExtensions; + + addAssign: AddSubMulDivNumberVecNumberAssignExtensions; + subAssign: AddSubMulDivNumberVecNumberAssignExtensions; + mulAssign: AddSubMulDivNumberVecNumberAssignExtensions; + divAssign: AddSubMulDivNumberVecNumberAssignExtensions; + } + + interface Vec2Extensions { + add: (b: Node<"color">) => Node<"vec3">; + mul: (b: Node<"color">) => Node<"vec3">; + } + + interface Vec3Extensions { + add: (b: Node<"color">) => Node<"vec3">; + mul: (b: Node<"color">) => Node<"vec3">; + } + + interface Vec4Extensions { + add: (b: Node<"color">) => Node<"vec4">; + mul: (b: Node<"color">) => Node<"vec4">; + } + + interface ColorExtensions { + add: (b: Number<"float">) => Node<"vec3">; + sub: (b: Number<"float">) => Node<"vec3">; + mul: (b: Number<"float">) => Node<"vec3">; + div: (b: Number<"float">) => Node<"vec3">; + } + + interface NumVec2Extensions { + add: AddSubMulDivNumberVecVec2Extensions; + sub: AddSubMulDivNumberVecVec2Extensions; + mul: MulVec2Extensions; + div: AddSubMulDivNumberVecVec2Extensions; + + addAssign: AddSubMulDivNumberVecVec2AssignExtensions; + subAssign: AddSubMulDivNumberVecVec2AssignExtensions; + mulAssign: AddSubMulDivNumberVecVec2AssignExtensions; + divAssign: AddSubMulDivNumberVecVec2AssignExtensions; + } + + interface NumVec3Extensions { + add: AddSubMulDivNumberVecVec3Extensions; + sub: AddSubMulDivNumberVecVec3Extensions; + mul: MulVec3Extensions; + div: AddSubMulDivNumberVecVec3Extensions; + + addAssign: AddSubMulDivNumberVecVec3AssignExtensions; + subAssign: AddSubMulDivNumberVecVec3AssignExtensions; + mulAssign: AddSubMulDivNumberVecVec3AssignExtensions; + divAssign: AddSubMulDivNumberVecVec3AssignExtensions; + } + + interface NumVec4Extensions { + add: AddSubMulDivNumberVecVec4Extensions; + sub: AddSubMulDivNumberVecVec4Extensions; + mul: MulVec4Extensions; + div: AddSubMulDivNumberVecVec4Extensions; + + addAssign: AddSubMulDivNumberVecVec4AssignExtensions; + subAssign: AddSubMulDivNumberVecVec4AssignExtensions; + mulAssign: AddSubMulDivNumberVecVec4AssignExtensions; + divAssign: AddSubMulDivNumberVecVec4AssignExtensions; + } + + interface Mat2Extensions { + add: AddSubMulMat2Extensions; + sub: AddSubMulMat2Extensions; + mul: MulMat2Extensions; + + addAssign: AddSubMulMat2AssignExtensions; + subAssign: AddSubMulMat2AssignExtensions; + mulAssign: AddSubMulMat2AssignExtensions; + } + + interface Mat3Extensions { + add: AddSubMulMat3Extensions; + sub: AddSubMulMat3Extensions; + mul: MulMat3Extensions; + + addAssign: AddSubMulMat3AssignExtensions; + subAssign: AddSubMulMat3AssignExtensions; + mulAssign: AddSubMulMat3AssignExtensions; + } + + interface Mat4Extensions { + add: AddSubMulMat4Extensions; + sub: AddSubMulMat4Extensions; + mul: MulMat4Extensions; + + addAssign: AddSubMulMat4AssignExtensions; + subAssign: AddSubMulMat4AssignExtensions; + mulAssign: AddSubMulMat4AssignExtensions; + } +} + +// mod + +interface Mod { + (a: Number<"float">, b: Vec4OrLessOrNumber<"float">): Node<"float">; + (a: Node<"vec2">, b: Vec4OrLessOrNumber<"float">): Node<"vec2">; + (a: Node<"vec3">, b: Vec4OrLessOrNumber<"float">): Node<"vec3">; + (a: Node<"vec4">, b: Vec4OrLessOrNumber<"float">): Node<"vec4">; + + (a: Number<"int">, b: Vec4OrLessOrNumber<"int">): Node<"int">; + (a: Node<"ivec2">, b: Vec4OrLessOrNumber<"int">): Node<"ivec2">; + (a: Node<"ivec3">, b: Vec4OrLessOrNumber<"int">): Node<"ivec3">; + (a: Node<"ivec4">, b: Vec4OrLessOrNumber<"int">): Node<"ivec4">; + + (a: Number<"uint">, b: Vec4OrLessOrNumber<"uint">): Node<"uint">; + (a: Node<"uvec2">, b: Vec4OrLessOrNumber<"uint">): Node<"uvec2">; + (a: Node<"uvec3">, b: Vec4OrLessOrNumber<"uint">): Node<"uvec3">; + (a: Node<"uvec4">, b: Vec4OrLessOrNumber<"uint">): Node<"uvec4">; +} + +export const mod: Mod; + +declare module "../core/Node.js" { + interface NumExtensions { + mod: (b: Vec4OrLessOrNumber) => Node; + modAssign: (b: Vec4OrLessOrNumber) => this; + } + interface NumVec2Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } + interface NumVec3Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } + interface NumVec4Extensions { + mod: (b: Vec4OrLessOrNumber) => Node>; + modAssign: (b: Vec4OrLessOrNumber) => this; + } +} + +// Comparison operators + +interface ComparisonOperator { + (a: Number<"float">, b: Number<"float">): Node<"bool">; + (a: Number<"int"> | Number<"uint">, b: Number<"int"> | Number<"uint">): Node<"bool">; +} +export const equal: ComparisonOperator; +export const notEqual: ComparisonOperator; +export const lessThan: ComparisonOperator; +export const greaterThan: ComparisonOperator; +export const lessThanEqual: ComparisonOperator; +export const greaterThanEqual: ComparisonOperator; + +interface ComparisonOperatorNumExtensions { + (b: Number): Node<"bool">; +} + +declare module "../core/Node.js" { + interface FloatExtensions { + equal: ComparisonOperatorNumExtensions<"float">; + notEqual: ComparisonOperatorNumExtensions<"float">; + lessThan: ComparisonOperatorNumExtensions<"float">; + greaterThan: ComparisonOperatorNumExtensions<"float">; + lessThanEqual: ComparisonOperatorNumExtensions<"float">; + greaterThanEqual: ComparisonOperatorNumExtensions<"float">; + } + + interface IntExtensions { + equal: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + notEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + } + + interface UintExtensions { + equal: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + notEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThan: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + lessThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + greaterThanEqual: (b: Number<"int"> | Number<"uint">) => Node<"bool">; + } +} + +// and/or/not/xor + +interface AndOr { + (a: Node<"bool">, b: Node<"bool">, ...params: Node<"bool">[]): Node<"bool">; +} +export const and: AndOr; +export const or: AndOr; + +interface AndOrBoolExtensions { + (b: Node<"bool">, ...params: Node<"bool">[]): Node<"bool">; +} + +export const not: (a: Node<"bool">) => Node<"bool">; +export const xor: (a: Node<"bool">, b: Node<"bool">) => Node<"bool">; + +declare module "../core/Node.js" { + interface BoolExtensions { + and: AndOrBoolExtensions; + or: AndOrBoolExtensions; + not: () => Node<"bool">; + xor: (b: Node<"bool">) => Node<"bool">; + } +} + +// bit operators + +interface UnaryBitOperator { + (a: Number<"int">): Node<"int">; + (a: Number<"uint">): Node<"uint">; +} + +interface BinaryBitOperator { + (a: Number<"int">, b: Number<"int">): Node<"int">; + (a: Number<"uint">, b: Number<"uint">): Node<"uint">; +} + +export const bitAnd: BinaryBitOperator; +export const bitNot: UnaryBitOperator; +export const bitOr: BinaryBitOperator; +export const bitXor: BinaryBitOperator; +export const shiftLeft: BinaryBitOperator; +export const shiftRight: BinaryBitOperator; + +interface BinaryBitOperatorIntegerExtensions { + (b: Number): Node; +} + +interface BinaryBitOperatorIntegerAssignExtensions { + (b: Number): this; +} + +declare module "../core/Node.js" { + interface IntegerExtensions { + bitAnd: BinaryBitOperatorIntegerExtensions; + bitNot: () => Node; + bitOr: BinaryBitOperatorIntegerExtensions; + bitXor: BinaryBitOperatorIntegerExtensions; + shiftLeft: BinaryBitOperatorIntegerExtensions; + shiftRight: BinaryBitOperatorIntegerExtensions; + + bitAndAssign: BinaryBitOperatorIntegerAssignExtensions; + bitNotAssign: () => this; + bitOrAssign: BinaryBitOperatorIntegerAssignExtensions; + bitXorAssign: BinaryBitOperatorIntegerAssignExtensions; + shiftLeftAssign: BinaryBitOperatorIntegerAssignExtensions; + shiftRightAssign: BinaryBitOperatorIntegerAssignExtensions; + } +} + +// increment/decrement + +interface IncrementDecrement { + (a: Number<"int">): Node<"int">; + (a: Number<"uint">): Node<"uint">; +} + +export const incrementBefore: IncrementDecrement; +export const decrementBefore: IncrementDecrement; +export const increment: IncrementDecrement; +export const decrement: IncrementDecrement; + +interface IncrementDecrementIntegerExtensions { + (): Node; +} + +declare module "../core/Node.js" { + interface IntegerExtensions { + incrementBefore: IncrementDecrementIntegerExtensions; + decrementBefore: IncrementDecrementIntegerExtensions; + increment: IncrementDecrementIntegerExtensions; + decrement: IncrementDecrementIntegerExtensions; } } /** * @deprecated "modInt()" is deprecated. Use "mod( int( ... ) )" instead. */ -export const modInt: (a: OperatorNodeParameter, b: OperatorNodeParameter) => OperatorNode; +export const modInt: Mod; -declare module "../Nodes.js" { - interface Nodes { +declare module "../core/Node.js" { + interface NumExtensions { /** * @deprecated "modInt()" is deprecated. Use "mod( int( ... ) )" instead. */ - modInt: (b: OperatorNodeParameter) => OperatorNode; + modInt: (b: Number) => Node; /** * @deprecated "modInt()" is deprecated. Use "mod( int( ... ) )" instead. */ - modIntAssign: (b: OperatorNodeParameter) => this; + modIntAssign: (b: Number) => this; } } + +export {}; diff --git a/types/three/src/nodes/math/TriNoise3D.d.ts b/types/three/src/nodes/math/TriNoise3D.d.ts index c1ca74b9454235..fbbf3ae8d67a18 100644 --- a/types/three/src/nodes/math/TriNoise3D.d.ts +++ b/types/three/src/nodes/math/TriNoise3D.d.ts @@ -1,11 +1,11 @@ import Node from "../core/Node.js"; -export const tri: (x: Node) => Node; +export const tri: (x: Node) => Node<"float">; -export const tri3: (p: Node) => Node; +export const tri3: (p: Node) => Node<"vec3">; export const triNoise3D: ( position: Node, speed: Node | number, time: Node | number, -) => Node; +) => Node<"float">; diff --git a/types/three/src/nodes/pmrem/PMREMNode.d.ts b/types/three/src/nodes/pmrem/PMREMNode.d.ts index 6e52fb81cbdc94..a5b385afa7e52b 100644 --- a/types/three/src/nodes/pmrem/PMREMNode.d.ts +++ b/types/three/src/nodes/pmrem/PMREMNode.d.ts @@ -2,7 +2,7 @@ import { Texture } from "../../textures/Texture.js"; import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -declare class PMREMNode extends TempNode { +declare class PMREMNode extends TempNode<"vec3"> { uvNode: Node | null; levelNode: Node | null; diff --git a/types/three/src/nodes/procedural/Checker.d.ts b/types/three/src/nodes/procedural/Checker.d.ts index bcde98423daa9a..e20d01f808678e 100644 --- a/types/three/src/nodes/procedural/Checker.d.ts +++ b/types/three/src/nodes/procedural/Checker.d.ts @@ -1,3 +1,3 @@ import Node from "../core/Node.js"; -export const checker: (coord?: Node) => Node; +export const checker: (coord?: Node) => Node<"float">; diff --git a/types/three/src/nodes/tsl/TSLCore.d.ts b/types/three/src/nodes/tsl/TSLCore.d.ts index e8ebdcbfe45fd8..dcc649c0e37950 100644 --- a/types/three/src/nodes/tsl/TSLCore.d.ts +++ b/types/three/src/nodes/tsl/TSLCore.d.ts @@ -6,91 +6,1561 @@ import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; import { Vector4 } from "../../math/Vector4.js"; import ConstNode from "../core/ConstNode.js"; -import Node from "../core/Node.js"; +import Node, { NumOrBoolType } from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; import StackNode from "../core/StackNode.js"; -import JoinNode from "../utils/JoinNode.js"; export function addMethodChaining(name: string, nodeElement: unknown): void; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { assign: (sourceNode: Node | number) => this; get: (value: string) => Node; } } -type XYZWCharacter = "x" | "y" | "z" | "w"; -type RGBACharacter = "r" | "g" | "b" | "a"; -type STPQCharacter = "s" | "t" | "p" | "q"; - -type XYZWSwizzle = - | `${XYZWCharacter}` - | `${XYZWCharacter}${XYZWCharacter}` - | `${XYZWCharacter}${XYZWCharacter}${XYZWCharacter}` - | `${XYZWCharacter}${XYZWCharacter}${XYZWCharacter}${XYZWCharacter}`; - -type RGBASwizzle = - | `${RGBACharacter}` - | `${RGBACharacter}${RGBACharacter}` - | `${RGBACharacter}${RGBACharacter}${RGBACharacter}` - | `${RGBACharacter}${RGBACharacter}${RGBACharacter}${RGBACharacter}`; - -type STPQSwizzle = - | `${STPQCharacter}` - | `${STPQCharacter}${STPQCharacter}` - | `${STPQCharacter}${STPQCharacter}${STPQCharacter}` - | `${STPQCharacter}${STPQCharacter}${STPQCharacter}${STPQCharacter}`; - -export type SwizzleOption = XYZWSwizzle | RGBASwizzle | STPQSwizzle; - -export type ArrayElementIndex = - | 0 - | 1 - | 2 - | 3 - | 4 - | 5 - | 6 - | 7 - | 8 - | 9 - | 10 - | 11 - | 12 - | 13 - | 14 - | 15 - | 16 - | 17 - | 18 - | 19 - | 20 - | 21 - | 22 - | 23 - | 24 - | 25 - | 26 - | 27 - | 28 - | 29 - | 30 - | 31; - -export type Swizzable = - & { - [Key in SwizzleOption | ArrayElementIndex]: Node; +interface NumOrBoolToJsType { + float: number; + int: number; + uint: number; + bool: boolean; +} +type NumOrBool = Node | NumOrBoolToJsType[TNumOrBool]; + +interface NumOrBoolToVec { + float: "vec"; + int: "ivec"; + uint: "uvec"; + bool: "bvec"; +} +type NumOrBoolToVec2 = `${NumOrBoolToVec[TNumOrBool]}2`; +type NumOrBoolToVec3 = `${NumOrBoolToVec[TNumOrBool]}3`; +type NumOrBoolToVec4 = `${NumOrBoolToVec[TNumOrBool]}4`; + +interface Swizzle1From1 { + get x(): Node; + set x(value: NumOrBool); + get r(): Node; + set r(value: NumOrBool); + get s(): Node; + set s(value: NumOrBool); +} + +interface Swizzle1From2 extends Swizzle1From1 { + get y(): Node; + set y(value: NumOrBool); + get g(): Node; + set g(value: NumOrBool); + get t(): Node; + set t(value: NumOrBool); +} + +interface Swizzle1From3 extends Swizzle1From2 { + get z(): Node; + set z(value: NumOrBool); + get b(): Node; + set b(value: NumOrBool); + get p(): Node; + set p(value: NumOrBool); +} + +interface Swizzle1From4 extends Swizzle1From3 { + get w(): Node; + set w(value: NumOrBool); + get a(): Node; + set a(value: NumOrBool); + get q(): Node; + set q(value: NumOrBool); +} + +interface Swizzle2From1 { + get xx(): Node>; + get rr(): Node>; + get ss(): Node>; +} + +interface Swizzle2From2 extends Swizzle2From1 { + get xy(): Node>; + set xy(value: Node> | NumOrBool); + get rg(): Node>; + set rg(value: Node> | NumOrBool); + get st(): Node>; + set st(value: Node> | NumOrBool); + get yx(): Node>; + set yx(value: Node> | NumOrBool); + get gr(): Node>; + set gr(value: Node> | NumOrBool); + get ts(): Node>; + set ts(value: Node> | NumOrBool); + get yy(): Node>; + get gg(): Node>; + get tt(): Node>; +} + +interface Swizzle2From3 extends Swizzle2From2 { + get xz(): Node>; + set xz(value: Node> | NumOrBool); + get rb(): Node>; + set rb(value: Node> | NumOrBool); + get sp(): Node>; + set sp(value: Node> | NumOrBool); + get yz(): Node>; + set yz(value: Node> | NumOrBool); + get gb(): Node>; + set gb(value: Node> | NumOrBool); + get tp(): Node>; + set tp(value: Node> | NumOrBool); + get zx(): Node>; + set zx(value: Node> | NumOrBool); + get br(): Node>; + set br(value: Node> | NumOrBool); + get ps(): Node>; + set ps(value: Node> | NumOrBool); + get zy(): Node>; + set zy(value: Node> | NumOrBool); + get bg(): Node>; + set bg(value: Node> | NumOrBool); + get pt(): Node>; + set pt(value: Node> | NumOrBool); + get zz(): Node>; + get bb(): Node>; + get pp(): Node>; +} + +interface Swizzle2From4 extends Swizzle2From3 { + get xw(): Node>; + set xw(value: Node> | NumOrBool); + get ra(): Node>; + set ra(value: Node> | NumOrBool); + get sq(): Node>; + set sq(value: Node> | NumOrBool); + get yw(): Node>; + set yw(value: Node> | NumOrBool); + get ga(): Node>; + set ga(value: Node> | NumOrBool); + get tq(): Node>; + set tq(value: Node> | NumOrBool); + get zw(): Node>; + set zw(value: Node> | NumOrBool); + get ba(): Node>; + set ba(value: Node> | NumOrBool); + get pq(): Node>; + set pq(value: Node> | NumOrBool); + get wx(): Node>; + set wx(value: Node> | NumOrBool); + get ar(): Node>; + set ar(value: Node> | NumOrBool); + get qs(): Node>; + set qs(value: Node> | NumOrBool); + get wy(): Node>; + set wy(value: Node> | NumOrBool); + get ag(): Node>; + set ag(value: Node> | NumOrBool); + get qt(): Node>; + set qt(value: Node> | NumOrBool); + get wz(): Node>; + set wz(value: Node> | NumOrBool); + get ab(): Node>; + set ab(value: Node> | NumOrBool); + get qp(): Node>; + set qp(value: Node> | NumOrBool); + get ww(): Node>; + get aa(): Node>; + get qq(): Node>; +} + +interface Swizzle3From1 { + get xxx(): Node>; + get rrr(): Node>; + get sss(): Node>; +} + +interface Swizzle3From2 extends Swizzle3From1 { + get xxy(): Node>; + get rrg(): Node>; + get sst(): Node>; + get xyx(): Node>; + get rgr(): Node>; + get sts(): Node>; + get xyy(): Node>; + get rgg(): Node>; + get stt(): Node>; + get yxx(): Node>; + get grr(): Node>; + get tss(): Node>; + get yxy(): Node>; + get grg(): Node>; + get tst(): Node>; + get yyx(): Node>; + get ggr(): Node>; + get tts(): Node>; + get yyy(): Node>; + get ggg(): Node>; + get ttt(): Node>; +} + +interface Swizzle3From3 extends Swizzle3From2 { + get xxz(): Node>; + get rrb(): Node>; + get ssp(): Node>; + get xyz(): Node>; + set xyz(value: Node> | NumOrBool); + get rgb(): Node>; + set rgb(value: Node> | NumOrBool); + get stp(): Node>; + set stp(value: Node> | NumOrBool); + get xzx(): Node>; + get rbr(): Node>; + get sps(): Node>; + get xzy(): Node>; + set xzy(value: Node> | NumOrBool); + get rbg(): Node>; + set rbg(value: Node> | NumOrBool); + get spt(): Node>; + set spt(value: Node> | NumOrBool); + get xzz(): Node>; + get rbb(): Node>; + get spp(): Node>; + get yxz(): Node>; + set yxz(value: Node> | NumOrBool); + get grb(): Node>; + set grb(value: Node> | NumOrBool); + get tsp(): Node>; + set tsp(value: Node> | NumOrBool); + get yyz(): Node>; + get ggb(): Node>; + get ttp(): Node>; + get yzx(): Node>; + set yzx(value: Node> | NumOrBool); + get gbr(): Node>; + set gbr(value: Node> | NumOrBool); + get tps(): Node>; + set tps(value: Node> | NumOrBool); + get yzy(): Node>; + get gbg(): Node>; + get tpt(): Node>; + get yzz(): Node>; + get gbb(): Node>; + get tpp(): Node>; + get zxx(): Node>; + get brr(): Node>; + get pss(): Node>; + get zxy(): Node>; + set zxy(value: Node> | NumOrBool); + get brg(): Node>; + set brg(value: Node> | NumOrBool); + get pst(): Node>; + set pst(value: Node> | NumOrBool); + get zxz(): Node>; + get brb(): Node>; + get psp(): Node>; + get zyx(): Node>; + set zyx(value: Node> | NumOrBool); + get bgr(): Node>; + set bgr(value: Node> | NumOrBool); + get pts(): Node>; + set pts(value: Node> | NumOrBool); + get zyy(): Node>; + get bgg(): Node>; + get ptt(): Node>; + get zyz(): Node>; + get bgb(): Node>; + get ptp(): Node>; + get zzx(): Node>; + get bbr(): Node>; + get pps(): Node>; + get zzy(): Node>; + get bbg(): Node>; + get ppt(): Node>; + get zzz(): Node>; + get bbb(): Node>; + get ppp(): Node>; +} + +interface Swizzle3From4 extends Swizzle3From3 { + get xxw(): Node>; + get rra(): Node>; + get ssq(): Node>; + get xyw(): Node>; + set xyw(value: Node> | NumOrBool); + get rga(): Node>; + set rga(value: Node> | NumOrBool); + get stq(): Node>; + set stq(value: Node> | NumOrBool); + get xzw(): Node>; + set xzw(value: Node> | NumOrBool); + get rba(): Node>; + set rba(value: Node> | NumOrBool); + get spq(): Node>; + set spq(value: Node> | NumOrBool); + get xwx(): Node>; + get rar(): Node>; + get sqs(): Node>; + get xwy(): Node>; + set xwy(value: Node> | NumOrBool); + get rag(): Node>; + set rag(value: Node> | NumOrBool); + get sqt(): Node>; + set sqt(value: Node> | NumOrBool); + get xwz(): Node>; + set xwz(value: Node> | NumOrBool); + get rab(): Node>; + set rab(value: Node> | NumOrBool); + get sqp(): Node>; + set sqp(value: Node> | NumOrBool); + get xww(): Node>; + get raa(): Node>; + get sqq(): Node>; + get yxw(): Node>; + set yxw(value: Node> | NumOrBool); + get gra(): Node>; + set gra(value: Node> | NumOrBool); + get tsq(): Node>; + set tsq(value: Node> | NumOrBool); + get yyw(): Node>; + get gga(): Node>; + get ttq(): Node>; + get yzw(): Node>; + set yzw(value: Node> | NumOrBool); + get gba(): Node>; + set gba(value: Node> | NumOrBool); + get tpq(): Node>; + set tpq(value: Node> | NumOrBool); + get ywx(): Node>; + set ywx(value: Node> | NumOrBool); + get gar(): Node>; + set gar(value: Node> | NumOrBool); + get tqs(): Node>; + set tqs(value: Node> | NumOrBool); + get ywy(): Node>; + get gag(): Node>; + get tqt(): Node>; + get ywz(): Node>; + set ywz(value: Node> | NumOrBool); + get gab(): Node>; + set gab(value: Node> | NumOrBool); + get tqp(): Node>; + set tqp(value: Node> | NumOrBool); + get yww(): Node>; + get gaa(): Node>; + get tqq(): Node>; + get zxw(): Node>; + set zxw(value: Node> | NumOrBool); + get bra(): Node>; + set bra(value: Node> | NumOrBool); + get psq(): Node>; + set psq(value: Node> | NumOrBool); + get zyw(): Node>; + set zyw(value: Node> | NumOrBool); + get bga(): Node>; + set bga(value: Node> | NumOrBool); + get ptq(): Node>; + set ptq(value: Node> | NumOrBool); + get zzw(): Node>; + get bba(): Node>; + get ppq(): Node>; + get zwx(): Node>; + set zwx(value: Node> | NumOrBool); + get bar(): Node>; + set bar(value: Node> | NumOrBool); + get pqs(): Node>; + set pqs(value: Node> | NumOrBool); + get zwy(): Node>; + set zwy(value: Node> | NumOrBool); + get bag(): Node>; + set bag(value: Node> | NumOrBool); + get pqt(): Node>; + set pqt(value: Node> | NumOrBool); + get zwz(): Node>; + get bab(): Node>; + get pqp(): Node>; + get zww(): Node>; + get baa(): Node>; + get pqq(): Node>; + get wxx(): Node>; + get arr(): Node>; + get qss(): Node>; + get wxy(): Node>; + set wxy(value: Node> | NumOrBool); + get arg(): Node>; + set arg(value: Node> | NumOrBool); + get qst(): Node>; + set qst(value: Node> | NumOrBool); + get wxz(): Node>; + set wxz(value: Node> | NumOrBool); + get arb(): Node>; + set arb(value: Node> | NumOrBool); + get qsp(): Node>; + set qsp(value: Node> | NumOrBool); + get wxw(): Node>; + get ara(): Node>; + get qsq(): Node>; + get wyx(): Node>; + set wyx(value: Node> | NumOrBool); + get agr(): Node>; + set agr(value: Node> | NumOrBool); + get qts(): Node>; + set qts(value: Node> | NumOrBool); + get wyy(): Node>; + get agg(): Node>; + get qtt(): Node>; + get wyz(): Node>; + set wyz(value: Node> | NumOrBool); + get agb(): Node>; + set agb(value: Node> | NumOrBool); + get qtp(): Node>; + set qtp(value: Node> | NumOrBool); + get wyw(): Node>; + get aga(): Node>; + get qtq(): Node>; + get wzx(): Node>; + set wzx(value: Node> | NumOrBool); + get abr(): Node>; + set abr(value: Node> | NumOrBool); + get qps(): Node>; + set qps(value: Node> | NumOrBool); + get wzy(): Node>; + set wzy(value: Node> | NumOrBool); + get abg(): Node>; + set abg(value: Node> | NumOrBool); + get qpt(): Node>; + set qpt(value: Node> | NumOrBool); + get wzz(): Node>; + get abb(): Node>; + get qpp(): Node>; + get wzw(): Node>; + get aba(): Node>; + get qpq(): Node>; + get wwx(): Node>; + get aar(): Node>; + get qqs(): Node>; + get wwy(): Node>; + get aag(): Node>; + get qqt(): Node>; + get wwz(): Node>; + get aab(): Node>; + get qqp(): Node>; + get www(): Node>; + get aaa(): Node>; + get qqq(): Node>; +} + +interface Swizzle4From1 { + get xxxx(): Node>; + get rrrr(): Node>; + get ssss(): Node>; +} + +interface Swizzle4From2 extends Swizzle4From1 { + get xxxy(): Node>; + get rrrg(): Node>; + get ssst(): Node>; + get xxyx(): Node>; + get rrgr(): Node>; + get ssts(): Node>; + get xxyy(): Node>; + get rrgg(): Node>; + get sstt(): Node>; + get xyxx(): Node>; + get rgrr(): Node>; + get stss(): Node>; + get xyxy(): Node>; + get rgrg(): Node>; + get stst(): Node>; + get xyyx(): Node>; + get rggr(): Node>; + get stts(): Node>; + get xyyy(): Node>; + get rggg(): Node>; + get sttt(): Node>; + get yxxx(): Node>; + get grrr(): Node>; + get tsss(): Node>; + get yxxy(): Node>; + get grrg(): Node>; + get tsst(): Node>; + get yxyx(): Node>; + get grgr(): Node>; + get tsts(): Node>; + get yxyy(): Node>; + get grgg(): Node>; + get tstt(): Node>; + get yyxx(): Node>; + get ggrr(): Node>; + get ttss(): Node>; + get yyxy(): Node>; + get ggrg(): Node>; + get ttst(): Node>; + get yyyx(): Node>; + get gggr(): Node>; + get ttts(): Node>; + get yyyy(): Node>; + get gggg(): Node>; + get tttt(): Node>; +} + +interface Swizzle4From3 extends Swizzle4From2 { + get xxxz(): Node>; + get rrrb(): Node>; + get sssp(): Node>; + get xxyz(): Node>; + get rrgb(): Node>; + get sstp(): Node>; + get xxzx(): Node>; + get rrbr(): Node>; + get ssps(): Node>; + get xxzy(): Node>; + get rrbg(): Node>; + get sspt(): Node>; + get xxzz(): Node>; + get rrbb(): Node>; + get sspp(): Node>; + get xyxz(): Node>; + get rgrb(): Node>; + get stsp(): Node>; + get xyyz(): Node>; + get rggb(): Node>; + get sttp(): Node>; + get xyzx(): Node>; + get rgbr(): Node>; + get stps(): Node>; + get xyzy(): Node>; + get rgbg(): Node>; + get stpt(): Node>; + get xyzz(): Node>; + get rgbb(): Node>; + get stpp(): Node>; + get xzxx(): Node>; + get rbrr(): Node>; + get spss(): Node>; + get xzxy(): Node>; + get rbrg(): Node>; + get spst(): Node>; + get xzxz(): Node>; + get rbrb(): Node>; + get spsp(): Node>; + get xzyx(): Node>; + get rbgr(): Node>; + get spts(): Node>; + get xzyy(): Node>; + get rbgg(): Node>; + get sptt(): Node>; + get xzyz(): Node>; + get rbgb(): Node>; + get sptp(): Node>; + get xzzx(): Node>; + get rbbr(): Node>; + get spps(): Node>; + get xzzy(): Node>; + get rbbg(): Node>; + get sppt(): Node>; + get xzzz(): Node>; + get rbbb(): Node>; + get sppp(): Node>; + get yxxz(): Node>; + get grrb(): Node>; + get tssp(): Node>; + get yxyz(): Node>; + get grgb(): Node>; + get tstp(): Node>; + get yxzx(): Node>; + get grbr(): Node>; + get tsps(): Node>; + get yxzy(): Node>; + get grbg(): Node>; + get tspt(): Node>; + get yxzz(): Node>; + get grbb(): Node>; + get tspp(): Node>; + get yyxz(): Node>; + get ggrb(): Node>; + get ttsp(): Node>; + get yyyz(): Node>; + get gggb(): Node>; + get tttp(): Node>; + get yyzx(): Node>; + get ggbr(): Node>; + get ttps(): Node>; + get yyzy(): Node>; + get ggbg(): Node>; + get ttpt(): Node>; + get yyzz(): Node>; + get ggbb(): Node>; + get ttpp(): Node>; + get yzxx(): Node>; + get gbrr(): Node>; + get tpss(): Node>; + get yzxy(): Node>; + get gbrg(): Node>; + get tpst(): Node>; + get yzxz(): Node>; + get gbrb(): Node>; + get tpsp(): Node>; + get yzyx(): Node>; + get gbgr(): Node>; + get tpts(): Node>; + get yzyy(): Node>; + get gbgg(): Node>; + get tptt(): Node>; + get yzyz(): Node>; + get gbgb(): Node>; + get tptp(): Node>; + get yzzx(): Node>; + get gbbr(): Node>; + get tpps(): Node>; + get yzzy(): Node>; + get gbbg(): Node>; + get tppt(): Node>; + get yzzz(): Node>; + get gbbb(): Node>; + get tppp(): Node>; + get zxxx(): Node>; + get brrr(): Node>; + get psss(): Node>; + get zxxy(): Node>; + get brrg(): Node>; + get psst(): Node>; + get zxxz(): Node>; + get brrb(): Node>; + get pssp(): Node>; + get zxyx(): Node>; + get brgr(): Node>; + get psts(): Node>; + get zxyy(): Node>; + get brgg(): Node>; + get pstt(): Node>; + get zxyz(): Node>; + get brgb(): Node>; + get pstp(): Node>; + get zxzx(): Node>; + get brbr(): Node>; + get psps(): Node>; + get zxzy(): Node>; + get brbg(): Node>; + get pspt(): Node>; + get zxzz(): Node>; + get brbb(): Node>; + get pspp(): Node>; + get zyxx(): Node>; + get bgrr(): Node>; + get ptss(): Node>; + get zyxy(): Node>; + get bgrg(): Node>; + get ptst(): Node>; + get zyxz(): Node>; + get bgrb(): Node>; + get ptsp(): Node>; + get zyyx(): Node>; + get bggr(): Node>; + get ptts(): Node>; + get zyyy(): Node>; + get bggg(): Node>; + get pttt(): Node>; + get zyyz(): Node>; + get bggb(): Node>; + get pttp(): Node>; + get zyzx(): Node>; + get bgbr(): Node>; + get ptps(): Node>; + get zyzy(): Node>; + get bgbg(): Node>; + get ptpt(): Node>; + get zyzz(): Node>; + get bgbb(): Node>; + get ptpp(): Node>; + get zzxx(): Node>; + get bbrr(): Node>; + get ppss(): Node>; + get zzxy(): Node>; + get bbrg(): Node>; + get ppst(): Node>; + get zzxz(): Node>; + get bbrb(): Node>; + get ppsp(): Node>; + get zzyx(): Node>; + get bbgr(): Node>; + get ppts(): Node>; + get zzyy(): Node>; + get bbgg(): Node>; + get pptt(): Node>; + get zzyz(): Node>; + get bbgb(): Node>; + get pptp(): Node>; + get zzzx(): Node>; + get bbbr(): Node>; + get ppps(): Node>; + get zzzy(): Node>; + get bbbg(): Node>; + get pppt(): Node>; + get zzzz(): Node>; + get bbbb(): Node>; + get pppp(): Node>; +} + +interface Swizzle4From4 extends Swizzle4From3 { + get xxxw(): Node>; + get rrra(): Node>; + get sssq(): Node>; + get xxyw(): Node>; + get rrga(): Node>; + get sstq(): Node>; + get xxzw(): Node>; + get rrba(): Node>; + get sspq(): Node>; + get xxwx(): Node>; + get rrar(): Node>; + get ssqs(): Node>; + get xxwy(): Node>; + get rrag(): Node>; + get ssqt(): Node>; + get xxwz(): Node>; + get rrab(): Node>; + get ssqp(): Node>; + get xxww(): Node>; + get rraa(): Node>; + get ssqq(): Node>; + get xyxw(): Node>; + get rgra(): Node>; + get stsq(): Node>; + get xyyw(): Node>; + get rgga(): Node>; + get sttq(): Node>; + get xyzw(): Node>; + set xyzw(value: Node> | NumOrBool); + get rgba(): Node>; + set rgba(value: Node> | NumOrBool); + get stpq(): Node>; + set stpq(value: Node> | NumOrBool); + get xywx(): Node>; + get rgar(): Node>; + get stqs(): Node>; + get xywy(): Node>; + get rgag(): Node>; + get stqt(): Node>; + get xywz(): Node>; + set xywz(value: Node> | NumOrBool); + get rgab(): Node>; + set rgab(value: Node> | NumOrBool); + get stqp(): Node>; + set stqp(value: Node> | NumOrBool); + get xyww(): Node>; + get rgaa(): Node>; + get stqq(): Node>; + get xzxw(): Node>; + get rbra(): Node>; + get spsq(): Node>; + get xzyw(): Node>; + set xzyw(value: Node> | NumOrBool); + get rbga(): Node>; + set rbga(value: Node> | NumOrBool); + get sptq(): Node>; + set sptq(value: Node> | NumOrBool); + get xzzw(): Node>; + get rbba(): Node>; + get sppq(): Node>; + get xzwx(): Node>; + get rbar(): Node>; + get spqs(): Node>; + get xzwy(): Node>; + set xzwy(value: Node> | NumOrBool); + get rbag(): Node>; + set rbag(value: Node> | NumOrBool); + get spqt(): Node>; + set spqt(value: Node> | NumOrBool); + get xzwz(): Node>; + get rbab(): Node>; + get spqp(): Node>; + get xzww(): Node>; + get rbaa(): Node>; + get spqq(): Node>; + get xwxx(): Node>; + get rarr(): Node>; + get sqss(): Node>; + get xwxy(): Node>; + get rarg(): Node>; + get sqst(): Node>; + get xwxz(): Node>; + get rarb(): Node>; + get sqsp(): Node>; + get xwxw(): Node>; + get rara(): Node>; + get sqsq(): Node>; + get xwyx(): Node>; + get ragr(): Node>; + get sqts(): Node>; + get xwyy(): Node>; + get ragg(): Node>; + get sqtt(): Node>; + get xwyz(): Node>; + set xwyz(value: Node> | NumOrBool); + get ragb(): Node>; + set ragb(value: Node> | NumOrBool); + get sqtp(): Node>; + set sqtp(value: Node> | NumOrBool); + get xwyw(): Node>; + get raga(): Node>; + get sqtq(): Node>; + get xwzx(): Node>; + get rabr(): Node>; + get sqps(): Node>; + get xwzy(): Node>; + set xwzy(value: Node> | NumOrBool); + get rabg(): Node>; + set rabg(value: Node> | NumOrBool); + get sqpt(): Node>; + set sqpt(value: Node> | NumOrBool); + get xwzz(): Node>; + get rabb(): Node>; + get sqpp(): Node>; + get xwzw(): Node>; + get raba(): Node>; + get sqpq(): Node>; + get xwwx(): Node>; + get raar(): Node>; + get sqqs(): Node>; + get xwwy(): Node>; + get raag(): Node>; + get sqqt(): Node>; + get xwwz(): Node>; + get raab(): Node>; + get sqqp(): Node>; + get xwww(): Node>; + get raaa(): Node>; + get sqqq(): Node>; + get yxxw(): Node>; + get grra(): Node>; + get tssq(): Node>; + get yxyw(): Node>; + get grga(): Node>; + get tstq(): Node>; + get yxzw(): Node>; + set yxzw(value: Node> | NumOrBool); + get grba(): Node>; + set grba(value: Node> | NumOrBool); + get tspq(): Node>; + set tspq(value: Node> | NumOrBool); + get yxwx(): Node>; + get grar(): Node>; + get tsqs(): Node>; + get yxwy(): Node>; + get grag(): Node>; + get tsqt(): Node>; + get yxwz(): Node>; + set yxwz(value: Node> | NumOrBool); + get grab(): Node>; + set grab(value: Node> | NumOrBool); + get tsqp(): Node>; + set tsqp(value: Node> | NumOrBool); + get yxww(): Node>; + get graa(): Node>; + get tsqq(): Node>; + get yyxw(): Node>; + get ggra(): Node>; + get ttsq(): Node>; + get yyyw(): Node>; + get ggga(): Node>; + get tttq(): Node>; + get yyzw(): Node>; + get ggba(): Node>; + get ttpq(): Node>; + get yywx(): Node>; + get ggar(): Node>; + get ttqs(): Node>; + get yywy(): Node>; + get ggag(): Node>; + get ttqt(): Node>; + get yywz(): Node>; + get ggab(): Node>; + get ttqp(): Node>; + get yyww(): Node>; + get ggaa(): Node>; + get ttqq(): Node>; + get yzxw(): Node>; + set yzxw(value: Node> | NumOrBool); + get gbra(): Node>; + set gbra(value: Node> | NumOrBool); + get tpsq(): Node>; + set tpsq(value: Node> | NumOrBool); + get yzyw(): Node>; + get gbga(): Node>; + get tptq(): Node>; + get yzzw(): Node>; + get gbba(): Node>; + get tppq(): Node>; + get yzwx(): Node>; + set yzwx(value: Node> | NumOrBool); + get gbar(): Node>; + set gbar(value: Node> | NumOrBool); + get tpqs(): Node>; + set tpqs(value: Node> | NumOrBool); + get yzwy(): Node>; + get gbag(): Node>; + get tpqt(): Node>; + get yzwz(): Node>; + get gbab(): Node>; + get tpqp(): Node>; + get yzww(): Node>; + get gbaa(): Node>; + get tpqq(): Node>; + get ywxx(): Node>; + get garr(): Node>; + get tqss(): Node>; + get ywxy(): Node>; + get garg(): Node>; + get tqst(): Node>; + get ywxz(): Node>; + set ywxz(value: Node> | NumOrBool); + get garb(): Node>; + set garb(value: Node> | NumOrBool); + get tqsp(): Node>; + set tqsp(value: Node> | NumOrBool); + get ywxw(): Node>; + get gara(): Node>; + get tqsq(): Node>; + get ywyx(): Node>; + get gagr(): Node>; + get tqts(): Node>; + get ywyy(): Node>; + get gagg(): Node>; + get tqtt(): Node>; + get ywyz(): Node>; + get gagb(): Node>; + get tqtp(): Node>; + get ywyw(): Node>; + get gaga(): Node>; + get tqtq(): Node>; + get ywzx(): Node>; + set ywzx(value: Node> | NumOrBool); + get gabr(): Node>; + set gabr(value: Node> | NumOrBool); + get tqps(): Node>; + set tqps(value: Node> | NumOrBool); + get ywzy(): Node>; + get gabg(): Node>; + get tqpt(): Node>; + get ywzz(): Node>; + get gabb(): Node>; + get tqpp(): Node>; + get ywzw(): Node>; + get gaba(): Node>; + get tqpq(): Node>; + get ywwx(): Node>; + get gaar(): Node>; + get tqqs(): Node>; + get ywwy(): Node>; + get gaag(): Node>; + get tqqt(): Node>; + get ywwz(): Node>; + get gaab(): Node>; + get tqqp(): Node>; + get ywww(): Node>; + get gaaa(): Node>; + get tqqq(): Node>; + get zxxw(): Node>; + get brra(): Node>; + get pssq(): Node>; + get zxyw(): Node>; + set zxyw(value: Node> | NumOrBool); + get brga(): Node>; + set brga(value: Node> | NumOrBool); + get pstq(): Node>; + set pstq(value: Node> | NumOrBool); + get zxzw(): Node>; + get brba(): Node>; + get pspq(): Node>; + get zxwx(): Node>; + get brar(): Node>; + get psqs(): Node>; + get zxwy(): Node>; + set zxwy(value: Node> | NumOrBool); + get brag(): Node>; + set brag(value: Node> | NumOrBool); + get psqt(): Node>; + set psqt(value: Node> | NumOrBool); + get zxwz(): Node>; + get brab(): Node>; + get psqp(): Node>; + get zxww(): Node>; + get braa(): Node>; + get psqq(): Node>; + get zyxw(): Node>; + set zyxw(value: Node> | NumOrBool); + get bgra(): Node>; + set bgra(value: Node> | NumOrBool); + get ptsq(): Node>; + set ptsq(value: Node> | NumOrBool); + get zyyw(): Node>; + get bgga(): Node>; + get pttq(): Node>; + get zyzw(): Node>; + get bgba(): Node>; + get ptpq(): Node>; + get zywx(): Node>; + set zywx(value: Node> | NumOrBool); + get bgar(): Node>; + set bgar(value: Node> | NumOrBool); + get ptqs(): Node>; + set ptqs(value: Node> | NumOrBool); + get zywy(): Node>; + get bgag(): Node>; + get ptqt(): Node>; + get zywz(): Node>; + get bgab(): Node>; + get ptqp(): Node>; + get zyww(): Node>; + get bgaa(): Node>; + get ptqq(): Node>; + get zzxw(): Node>; + get bbra(): Node>; + get ppsq(): Node>; + get zzyw(): Node>; + get bbga(): Node>; + get pptq(): Node>; + get zzzw(): Node>; + get bbba(): Node>; + get pppq(): Node>; + get zzwx(): Node>; + get bbar(): Node>; + get ppqs(): Node>; + get zzwy(): Node>; + get bbag(): Node>; + get ppqt(): Node>; + get zzwz(): Node>; + get bbab(): Node>; + get ppqp(): Node>; + get zzww(): Node>; + get bbaa(): Node>; + get ppqq(): Node>; + get zwxx(): Node>; + get barr(): Node>; + get pqss(): Node>; + get zwxy(): Node>; + set zwxy(value: Node> | NumOrBool); + get barg(): Node>; + set barg(value: Node> | NumOrBool); + get pqst(): Node>; + set pqst(value: Node> | NumOrBool); + get zwxz(): Node>; + get barb(): Node>; + get pqsp(): Node>; + get zwxw(): Node>; + get bara(): Node>; + get pqsq(): Node>; + get zwyx(): Node>; + set zwyx(value: Node> | NumOrBool); + get bagr(): Node>; + set bagr(value: Node> | NumOrBool); + get pqts(): Node>; + set pqts(value: Node> | NumOrBool); + get zwyy(): Node>; + get bagg(): Node>; + get pqtt(): Node>; + get zwyz(): Node>; + get bagb(): Node>; + get pqtp(): Node>; + get zwyw(): Node>; + get baga(): Node>; + get pqtq(): Node>; + get zwzx(): Node>; + get babr(): Node>; + get pqps(): Node>; + get zwzy(): Node>; + get babg(): Node>; + get pqpt(): Node>; + get zwzz(): Node>; + get babb(): Node>; + get pqpp(): Node>; + get zwzw(): Node>; + get baba(): Node>; + get pqpq(): Node>; + get zwwx(): Node>; + get baar(): Node>; + get pqqs(): Node>; + get zwwy(): Node>; + get baag(): Node>; + get pqqt(): Node>; + get zwwz(): Node>; + get baab(): Node>; + get pqqp(): Node>; + get zwww(): Node>; + get baaa(): Node>; + get pqqq(): Node>; + get wxxx(): Node>; + get arrr(): Node>; + get qsss(): Node>; + get wxxy(): Node>; + get arrg(): Node>; + get qsst(): Node>; + get wxxz(): Node>; + get arrb(): Node>; + get qssp(): Node>; + get wxxw(): Node>; + get arra(): Node>; + get qssq(): Node>; + get wxyx(): Node>; + get argr(): Node>; + get qsts(): Node>; + get wxyy(): Node>; + get argg(): Node>; + get qstt(): Node>; + get wxyz(): Node>; + set wxyz(value: Node> | NumOrBool); + get argb(): Node>; + set argb(value: Node> | NumOrBool); + get qstp(): Node>; + set qstp(value: Node> | NumOrBool); + get wxyw(): Node>; + get arga(): Node>; + get qstq(): Node>; + get wxzx(): Node>; + get arbr(): Node>; + get qsps(): Node>; + get wxzy(): Node>; + set wxzy(value: Node> | NumOrBool); + get arbg(): Node>; + set arbg(value: Node> | NumOrBool); + get qspt(): Node>; + set qspt(value: Node> | NumOrBool); + get wxzz(): Node>; + get arbb(): Node>; + get qspp(): Node>; + get wxzw(): Node>; + get arba(): Node>; + get qspq(): Node>; + get wxwx(): Node>; + get arar(): Node>; + get qsqs(): Node>; + get wxwy(): Node>; + get arag(): Node>; + get qsqt(): Node>; + get wxwz(): Node>; + get arab(): Node>; + get qsqp(): Node>; + get wxww(): Node>; + get araa(): Node>; + get qsqq(): Node>; + get wyxx(): Node>; + get agrr(): Node>; + get qtss(): Node>; + get wyxy(): Node>; + get agrg(): Node>; + get qtst(): Node>; + get wyxz(): Node>; + set wyxz(value: Node> | NumOrBool); + get agrb(): Node>; + set agrb(value: Node> | NumOrBool); + get qtsp(): Node>; + set qtsp(value: Node> | NumOrBool); + get wyxw(): Node>; + get agra(): Node>; + get qtsq(): Node>; + get wyyx(): Node>; + get aggr(): Node>; + get qtts(): Node>; + get wyyy(): Node>; + get aggg(): Node>; + get qttt(): Node>; + get wyyz(): Node>; + get aggb(): Node>; + get qttp(): Node>; + get wyyw(): Node>; + get agga(): Node>; + get qttq(): Node>; + get wyzx(): Node>; + set wyzx(value: Node> | NumOrBool); + get agbr(): Node>; + set agbr(value: Node> | NumOrBool); + get qtps(): Node>; + set qtps(value: Node> | NumOrBool); + get wyzy(): Node>; + get agbg(): Node>; + get qtpt(): Node>; + get wyzz(): Node>; + get agbb(): Node>; + get qtpp(): Node>; + get wyzw(): Node>; + get agba(): Node>; + get qtpq(): Node>; + get wywx(): Node>; + get agar(): Node>; + get qtqs(): Node>; + get wywy(): Node>; + get agag(): Node>; + get qtqt(): Node>; + get wywz(): Node>; + get agab(): Node>; + get qtqp(): Node>; + get wyww(): Node>; + get agaa(): Node>; + get qtqq(): Node>; + get wzxx(): Node>; + get abrr(): Node>; + get qpss(): Node>; + get wzxy(): Node>; + set wzxy(value: Node> | NumOrBool); + get abrg(): Node>; + set abrg(value: Node> | NumOrBool); + get qpst(): Node>; + set qpst(value: Node> | NumOrBool); + get wzxz(): Node>; + get abrb(): Node>; + get qpsp(): Node>; + get wzxw(): Node>; + get abra(): Node>; + get qpsq(): Node>; + get wzyx(): Node>; + set wzyx(value: Node> | NumOrBool); + get abgr(): Node>; + set abgr(value: Node> | NumOrBool); + get qpts(): Node>; + set qpts(value: Node> | NumOrBool); + get wzyy(): Node>; + get abgg(): Node>; + get qptt(): Node>; + get wzyz(): Node>; + get abgb(): Node>; + get qptp(): Node>; + get wzyw(): Node>; + get abga(): Node>; + get qptq(): Node>; + get wzzx(): Node>; + get abbr(): Node>; + get qpps(): Node>; + get wzzy(): Node>; + get abbg(): Node>; + get qppt(): Node>; + get wzzz(): Node>; + get abbb(): Node>; + get qppp(): Node>; + get wzzw(): Node>; + get abba(): Node>; + get qppq(): Node>; + get wzwx(): Node>; + get abar(): Node>; + get qpqs(): Node>; + get wzwy(): Node>; + get abag(): Node>; + get qpqt(): Node>; + get wzwz(): Node>; + get abab(): Node>; + get qpqp(): Node>; + get wzww(): Node>; + get abaa(): Node>; + get qpqq(): Node>; + get wwxx(): Node>; + get aarr(): Node>; + get qqss(): Node>; + get wwxy(): Node>; + get aarg(): Node>; + get qqst(): Node>; + get wwxz(): Node>; + get aarb(): Node>; + get qqsp(): Node>; + get wwxw(): Node>; + get aara(): Node>; + get qqsq(): Node>; + get wwyx(): Node>; + get aagr(): Node>; + get qqts(): Node>; + get wwyy(): Node>; + get aagg(): Node>; + get qqtt(): Node>; + get wwyz(): Node>; + get aagb(): Node>; + get qqtp(): Node>; + get wwyw(): Node>; + get aaga(): Node>; + get qqtq(): Node>; + get wwzx(): Node>; + get aabr(): Node>; + get qqps(): Node>; + get wwzy(): Node>; + get aabg(): Node>; + get qqpt(): Node>; + get wwzz(): Node>; + get aabb(): Node>; + get qqpp(): Node>; + get wwzw(): Node>; + get aaba(): Node>; + get qqpq(): Node>; + get wwwx(): Node>; + get aaar(): Node>; + get qqqs(): Node>; + get wwwy(): Node>; + get aaag(): Node>; + get qqqt(): Node>; + get wwwz(): Node>; + get aaab(): Node>; + get qqqp(): Node>; + get wwww(): Node>; + get aaaa(): Node>; + get qqqq(): Node>; +} + +declare module "../core/Node.js" { + interface NumOrBoolExtensions + extends + Swizzle1From1, + Swizzle2From1, + Swizzle3From1, + Swizzle4From1 + { } - & { - [Key in SwizzleOption as `set${Uppercase}`]: (value: Node) => Node; + + interface NumOrBoolVec2Extensions + extends + Swizzle1From2, + Swizzle2From2, + Swizzle3From2, + Swizzle4From2 + { } - & { - [Key in SwizzleOption as `flip${Uppercase}`]: () => Node; - }; -declare module "../Nodes.js" { - interface Node extends Swizzable { + interface NumOrBoolVec3Extensions + extends + Swizzle1From3, + Swizzle2From3, + Swizzle3From3, + Swizzle4From3 + { + } + + interface ColorExtensions + extends Swizzle1From3<"float">, Swizzle2From3<"float">, Swizzle3From3<"float">, Swizzle4From3<"float"> + { + } + + interface NumOrBoolVec4Extensions + extends + Swizzle1From4, + Swizzle2From4, + Swizzle3From4, + Swizzle4From4 + { + } +} + +interface SetSwizzle1 { + setX(value: NumOrBool): Node; + setR(value: NumOrBool): Node; + setS(value: NumOrBool): Node; +} + +interface SetSwizzle2 { + setX(value: NumOrBool): Node>; + setR(value: NumOrBool): Node>; + setS(value: NumOrBool): Node>; + setY(value: NumOrBool): Node>; + setG(value: NumOrBool): Node>; + setT(value: NumOrBool): Node>; + setXY(value: Node> | NumOrBool): Node>; + setRG(value: Node> | NumOrBool): Node>; + setST(value: Node> | NumOrBool): Node>; +} + +interface SetSwizzle3 { + setX(value: NumOrBool): Node>; + setR(value: NumOrBool): Node>; + setS(value: NumOrBool): Node>; + setY(value: NumOrBool): Node>; + setG(value: NumOrBool): Node>; + setT(value: NumOrBool): Node>; + setZ(value: NumOrBool): Node>; + setB(value: NumOrBool): Node>; + setP(value: NumOrBool): Node>; + setXY(value: Node> | NumOrBool): Node>; + setRG(value: Node> | NumOrBool): Node>; + setST(value: Node> | NumOrBool): Node>; + setXZ(value: Node> | NumOrBool): Node>; + setRB(value: Node> | NumOrBool): Node>; + setSP(value: Node> | NumOrBool): Node>; + setYZ(value: Node> | NumOrBool): Node>; + setGB(value: Node> | NumOrBool): Node>; + setTP(value: Node> | NumOrBool): Node>; + setXYZ(value: Node> | NumOrBool): Node>; + setRGB(value: Node> | NumOrBool): Node>; + setSTP(value: Node> | NumOrBool): Node>; +} + +interface SetSwizzle4 { + setX(value: NumOrBool): Node>; + setR(value: NumOrBool): Node>; + setS(value: NumOrBool): Node>; + setY(value: NumOrBool): Node>; + setG(value: NumOrBool): Node>; + setT(value: NumOrBool): Node>; + setZ(value: NumOrBool): Node>; + setB(value: NumOrBool): Node>; + setP(value: NumOrBool): Node>; + setW(value: NumOrBool): Node>; + setA(value: NumOrBool): Node>; + setQ(value: NumOrBool): Node>; + setXY(value: Node> | NumOrBool): Node>; + setRG(value: Node> | NumOrBool): Node>; + setST(value: Node> | NumOrBool): Node>; + setXZ(value: Node> | NumOrBool): Node>; + setRB(value: Node> | NumOrBool): Node>; + setSP(value: Node> | NumOrBool): Node>; + setYZ(value: Node> | NumOrBool): Node>; + setGB(value: Node> | NumOrBool): Node>; + setTP(value: Node> | NumOrBool): Node>; + setXW(value: Node> | NumOrBool): Node>; + setRA(value: Node> | NumOrBool): Node>; + setSQ(value: Node> | NumOrBool): Node>; + setYW(value: Node> | NumOrBool): Node>; + setGA(value: Node> | NumOrBool): Node>; + setTQ(value: Node> | NumOrBool): Node>; + setZW(value: Node> | NumOrBool): Node>; + setBA(value: Node> | NumOrBool): Node>; + setPQ(value: Node> | NumOrBool): Node>; + setXYZ(value: Node> | NumOrBool): Node>; + setRGB(value: Node> | NumOrBool): Node>; + setSTP(value: Node> | NumOrBool): Node>; + setXYW(value: Node> | NumOrBool): Node>; + setRGA(value: Node> | NumOrBool): Node>; + setSTQ(value: Node> | NumOrBool): Node>; + setXZW(value: Node> | NumOrBool): Node>; + setRBA(value: Node> | NumOrBool): Node>; + setSPQ(value: Node> | NumOrBool): Node>; + setYZW(value: Node> | NumOrBool): Node>; + setGBA(value: Node> | NumOrBool): Node>; + setTPQ(value: Node> | NumOrBool): Node>; + setXYZW(value: Node> | NumOrBool): Node>; + setRGBA(value: Node> | NumOrBool): Node>; + setSTPQ(value: Node> | NumOrBool): Node>; +} + +declare module "../core/Node.js" { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface NumOrBoolExtensions extends SetSwizzle1 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface NumOrBoolVec2Extensions extends SetSwizzle2 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface NumOrBoolVec3Extensions extends SetSwizzle3 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface ColorExtensions extends SetSwizzle3<"float"> { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface NumOrBoolVec4Extensions extends SetSwizzle4 { + } +} + +interface FlipSwizzle1 { + flipX(): Node<"float">; + flipR(): Node<"float">; + flipS(): Node<"float">; +} + +interface FlipSwizzle2 { + flipX(): Node<"vec2">; + flipR(): Node<"vec2">; + flipS(): Node<"vec2">; + flipY(): Node<"vec2">; + flipG(): Node<"vec2">; + flipT(): Node<"vec2">; + flipXY(): Node<"vec2">; + flipRG(): Node<"vec2">; + flipST(): Node<"vec2">; +} + +interface FlipSwizzle3 { + flipX(): Node<"vec3">; + flipR(): Node<"vec3">; + flipS(): Node<"vec3">; + flipY(): Node<"vec3">; + flipG(): Node<"vec3">; + flipT(): Node<"vec3">; + flipZ(): Node<"vec3">; + flipB(): Node<"vec3">; + flipP(): Node<"vec3">; + flipXY(): Node<"vec3">; + flipRG(): Node<"vec3">; + flipST(): Node<"vec3">; + flipXZ(): Node<"vec3">; + flipRB(): Node<"vec3">; + flipSP(): Node<"vec3">; + flipYZ(): Node<"vec3">; + flipGB(): Node<"vec3">; + flipTP(): Node<"vec3">; + flipXYZ(): Node<"vec3">; + flipRGB(): Node<"vec3">; + flipSTP(): Node<"vec3">; +} + +interface FlipSwizzle4 { + flipX(): Node<"vec4">; + flipR(): Node<"vec4">; + flipS(): Node<"vec4">; + flipY(): Node<"vec4">; + flipG(): Node<"vec4">; + flipT(): Node<"vec4">; + flipZ(): Node<"vec4">; + flipB(): Node<"vec4">; + flipP(): Node<"vec4">; + flipW(): Node<"vec4">; + flipA(): Node<"vec4">; + flipQ(): Node<"vec4">; + flipXY(): Node<"vec4">; + flipRG(): Node<"vec4">; + flipST(): Node<"vec4">; + flipXZ(): Node<"vec4">; + flipRB(): Node<"vec4">; + flipSP(): Node<"vec4">; + flipYZ(): Node<"vec4">; + flipGB(): Node<"vec4">; + flipTP(): Node<"vec4">; + flipXW(): Node<"vec4">; + flipRA(): Node<"vec4">; + flipSQ(): Node<"vec4">; + flipYW(): Node<"vec4">; + flipGA(): Node<"vec4">; + flipTQ(): Node<"vec4">; + flipZW(): Node<"vec4">; + flipBA(): Node<"vec4">; + flipPQ(): Node<"vec4">; + flipXYZ(): Node<"vec4">; + flipRGB(): Node<"vec4">; + flipSTP(): Node<"vec4">; + flipXYW(): Node<"vec4">; + flipRGA(): Node<"vec4">; + flipSTQ(): Node<"vec4">; + flipXZW(): Node<"vec4">; + flipRBA(): Node<"vec4">; + flipSPQ(): Node<"vec4">; + flipYZW(): Node<"vec4">; + flipGBA(): Node<"vec4">; + flipTPQ(): Node<"vec4">; + flipXYZW(): Node<"vec4">; + flipRGBA(): Node<"vec4">; + flipSTPQ(): Node<"vec4">; +} + +declare module "../core/Node.js" { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface FloatExtensions extends FlipSwizzle1 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface Vec2Extensions extends FlipSwizzle2 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface Vec3Extensions extends FlipSwizzle3 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface ColorExtensions extends FlipSwizzle3 { + } + + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface Vec4Extensions extends FlipSwizzle4 { } } @@ -99,15 +1569,19 @@ export type NodeObjectOption = Node | number | string; // same logic as in ShaderNodeObject: number,boolean,node->node, otherwise do nothing export type NodeObject = T extends Node ? T - : T extends number | boolean ? ConstNode + : T extends number ? Node<"float"> + : T extends boolean ? Node<"bool"> : T; // opposite of NodeObject: node -> node|boolean|number, otherwise do nothing type Proxied = T extends Node | number ? Node | number : T; // https://github.com/microsoft/TypeScript/issues/42435#issuecomment-765557874 +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type export type ProxiedTuple = [...{ [index in keyof T]: Proxied }]; export type ProxiedObject = { [index in keyof T]: Proxied }; +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type type RemoveTail = T extends [unknown, ...infer X] ? X : []; +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type type RemoveHeadAndTail = T extends [unknown, ...infer X, unknown] ? X : []; /** @@ -116,9 +1590,13 @@ type RemoveHeadAndTail = T extends [unknown, * We use an object instead of tuple or union as it makes stuff easier, especially in Typescript 4.0. */ interface Constructors< + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type A extends undefined | [...unknown[]], + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type B extends undefined | [...unknown[]], + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type C extends undefined | [...unknown[]], + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type D extends undefined | [...unknown[]], > { a: A; @@ -192,17 +1670,16 @@ type ConstructedNode = T extends new(...args: any[]) => infer R ? (R extends export type NodeOrType = Node | string; -declare class ShaderCallNodeInternal extends Node { -} +type ShaderCallNodeInternal = Node; -declare class ShaderNodeInternal extends Node {} +type ShaderNodeInternal = Node; export const defined: (v: unknown) => unknown; export const getConstNodeType: (value: NodeOrType) => string | null; export class ShaderNode { - constructor(jsFunc: (inputs: NodeObjects, builder: NodeBuilder) => Node); + constructor(jsFunc: (inputs: NodeObjects, builder: NodeBuilder) => R); call: ( inputs: { [key in keyof T]: T[key] extends Node ? Node : T[key] }, builder?: NodeBuilder, @@ -213,6 +1690,7 @@ export function nodeObject(obj: T): NodeObject; export function nodeObjectIntent(obj: T): NodeObject; export function nodeObjects(obj: T): NodeObjects; +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type export function nodeArray(obj: readonly [...T]): NodeArray; export function nodeProxy( @@ -260,10 +1738,11 @@ interface Layout { }[]; } -export interface ShaderNodeFn { - (...args: Args): ShaderCallNodeInternal; +export interface FnNode { + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + (...args: Args): TReturn extends void ? ShaderCallNodeInternal : TReturn; - shaderNode: ShaderNodeInternal; + shaderNode: ShaderNodeInternal; id: number; getNodeType: (builder: NodeBuilder) => string | null; @@ -274,15 +1753,19 @@ export interface ShaderNodeFn { once: (subBuilds?: string[] | null) => this; } -export function Fn(jsFunc: (builder: NodeBuilder) => void, layout?: string | Record): ShaderNodeFn<[]>; -export function Fn( - jsFunc: (args: T, builder: NodeBuilder) => void, +export function Fn( + jsFunc: (builder: NodeBuilder) => TReturn, + layout?: string | Record, +): FnNode<[], TReturn>; +export function Fn( + jsFunc: (args: TArgs, builder: NodeBuilder) => TReturn, layout?: string | Record, -): ShaderNodeFn>; -export function Fn( - jsFunc: (args: T, builder: NodeBuilder) => void, +): FnNode, TReturn>; +export function Fn( + jsFunc: (args: TArgs, builder: NodeBuilder) => TReturn, layout?: string | Record, -): ShaderNodeFn<[ProxiedObject]>; + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type +): FnNode<[ProxiedObject], TReturn>; export const setCurrentStack: (stack: StackNode | null) => void; @@ -293,24 +1776,23 @@ export const Switch: (expression: Node) => StackNode; export function Stack(node: Node): Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { toStack: () => Node; - toStackAssign: () => this; } } interface ColorFunction { // The first branch in `ConvertType` will forward the parameters to the `Color` constructor if there are no // parameters or all the parameters are non-objects - (color?: string | number): ConstNode; - (r: number, g: number, b: number): ConstNode; + (color?: string | number): ConstNode<"color", Color>; + (r: number, g: number, b: number): ConstNode<"color", Color>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (color: Color): ConstNode; - (node: Node): Node; + (color: Color): ConstNode<"color", Color>; + (node: Node): Node<"color">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. Not sure which cases are worth considering here. @@ -318,94 +1800,114 @@ interface ColorFunction { export const color: ColorFunction; -interface NumberFunction { - (value?: number): ConstNode; - (node: Node): Node; +interface FloatFunction { + (value?: number): ConstNode<"float", number>; + (node: Node): Node<"float">; } -export const float: NumberFunction; -export const int: NumberFunction; -export const uint: NumberFunction; +export const float: FloatFunction; -interface BooleanFunction { - (value?: boolean): ConstNode; - (node: Node): Node; +interface IntFunction { + (value?: number): ConstNode<"int", number>; + (node: Node): Node<"int">; } -export const bool: BooleanFunction; +export const int: IntFunction; -interface Vector2Function { +interface UintFunction { + (value?: number): ConstNode<"uint", number>; + (node: Node): Node<"uint">; +} + +export const uint: UintFunction; + +interface BoolFunction { + (value?: boolean): ConstNode<"bool", boolean>; + (node: Node): Node<"bool">; +} + +export const bool: BoolFunction; + +interface Vec2Function { // The first branch in `ConvertType` will forward the parameters to the `Vector2` constructor if there are no // parameters or all the parameters are non-objects - (x?: number, y?: number): ConstNode; + (x?: number, y?: number): ConstNode<"vec2", Vector2>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (value: Vector2): ConstNode; - (node: Node): Node; + (value: Vector2): ConstNode<"vec2", Vector2>; + (node: Node): Node<"vec2">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. - (x: Node | number, y: Node | number): JoinNode; + (x: Node | number, y: Node | number): Node<"vec2">; } -export const vec2: Vector2Function; -export const ivec2: Vector2Function; -export const uvec2: Vector2Function; -export const bvec2: (node: Node) => Node; +export const vec2: Vec2Function; -interface Vector3Function { +interface Ivec2Function { + (x: number, y: number): ConstNode<"ivec2", Vector2>; + (x: Node, y: Node): Node<"ivec2">; +} + +export const ivec2: Ivec2Function; + +export const uvec2: (x: Node, y: Node) => Node<"uvec2">; +export const bvec2: (node: Node) => Node<"bvec2">; + +interface Vec3Function { // The first branch in `ConvertType` will forward the parameters to the `Vector3` constructor if there are no // parameters or all the parameters are non-objects - (x?: number, y?: number, z?: number): ConstNode; + (x?: number, y?: number, z?: number): ConstNode<"vec3", Vector3>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (value: Vector3): ConstNode; - (node: Node): Node; + (value: Vector3): ConstNode<"vec3", Vector3>; + (value: [number, number, number]): ConstNode<"vec3", Vector3>; + (node: Node): Node<"vec3">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. - (x: Node | number, y: Node | number, z?: Node | number): JoinNode; + (x: Node | number, y: Node | number, z?: Node | number): Node<"vec3">; } -export const vec3: Vector3Function; -export const ivec3: Vector3Function; -export const uvec3: Vector3Function; -export const bvec3: (node: Node) => Node; +export const vec3: Vec3Function; +export const ivec3: (node: Node) => Node<"ivec3">; +export const uvec3: (node: Node) => Node<"uvec3">; +export const bvec3: (node: Node) => Node<"bvec3">; -interface Vector4Function { +interface Vec4Function { // The first branch in `ConvertType` will forward the parameters to the `Vector4` constructor if there are no // parameters or all the parameters are non-objects - (x?: number, y?: number, z?: number, w?: number): ConstNode; + (x?: number, y?: number, z?: number, w?: number): ConstNode<"vec4", Vector4>; // The second branch does not apply because `cacheMap` is `null` // The third branch will be triggered if there is a single parameter. - (value: Vector4): ConstNode; - (node: Node): Node; + (value: Vector4): ConstNode<"vec4", Vector4>; + (node: Node): Node<"vec4">; // The fall-through branch will be triggered if there is more than one parameter, or one of the parameters is an // object. - (x: Node | number, y: Node | number, z?: Node | number, w?: Node | number): JoinNode; + (x: Node | number, y: Node | number, z?: Node | number, w?: Node | number): Node<"vec4">; } -export const vec4: Vector4Function; -export const ivec4: Vector4Function; -export const uvec4: Vector4Function; -export const bvec4: (node: Node) => Node; +export const vec4: Vec4Function; +export const ivec4: (node: Node) => Node<"ivec4">; +export const uvec4: (node: Node) => Node<"uvec4">; +export const bvec4: (node: Node) => Node<"bvec4">; -interface Matrix2Function { - (value: Matrix2): ConstNode; - (node: Node): Node; +interface Mat2Function { + (value: Matrix2): ConstNode<"mat2", Matrix2>; + (node: Node): Node<"mat2">; } -export const mat2: Matrix2Function; +export const mat2: Mat2Function; -interface Matrix3Function { - (value: Matrix3): ConstNode; +interface Mat3Function { + (value: Matrix3): ConstNode<"mat3", Matrix3>; ( n11: number | Node, n12: number | Node, @@ -416,20 +1918,20 @@ interface Matrix3Function { n31: number | Node, n32: number | Node, n33: number | Node, - ): Node; - (): ConstNode; + ): Node<"mat3">; + (): ConstNode<"mat3", Matrix3>; ( p1: Node, p2: Node, p3: Node, - ): Node; - (node: Node): Node; + ): Node<"mat3">; + (node: Node): Node<"mat3">; } -export const mat3: Matrix3Function; +export const mat3: Mat3Function; -interface Matrix4Function { - (value: Matrix4): ConstNode; +interface Mat4Function { + (value: Matrix4): ConstNode<"mat4", Matrix4>; ( n11: number | Node, n12: number | Node, @@ -447,83 +1949,44 @@ interface Matrix4Function { n42: number | Node, n43: number | Node, n44: number | Node, - ): Node; - (): ConstNode; + ): Node<"mat4">; + (): ConstNode<"mat4", Matrix4>; ( p1: Node, p2: Node, p3: Node, p4: Node, - ): Node; - (node: Node): Node; + ): Node<"mat4">; + (node: Node): Node<"mat4">; } -export const mat4: Matrix4Function; - -export const string: (value?: string) => ConstNode; -export const arrayBuffer: (value: ArrayBuffer) => ConstNode; - -declare module "../Nodes.js" { - interface Node { - toColor: () => Node; - toColorAssign: () => this; - - toFloat: () => Node; - toFloatAssign: () => this; - - toInt: () => Node; - toIntAssign: () => this; - - toUint: () => Node; - toUintAssign: () => this; - - toBool: () => Node; - toBoolAssign: () => this; - - toVec2: () => Node; - toVec2Assign: () => this; - - toIVec2: () => Node; - toIVec2Assign: () => this; - - toUVec2: () => Node; - toUVec2Assign: () => this; - - toBVec2: () => Node; - toBVec2Assign: () => this; - - toVec3: () => Node; - toVec3Assign: () => this; - - toIVec3: () => Node; - toIVec3Assign: () => this; - - toUVec3: () => Node; - toUVec3Assign: () => this; - - toBVec3: () => Node; - toBVec3Assign: () => this; - - toVec4: () => Node; - toVec4Assign: () => this; - - toIVec4: () => Node; - toIVec4Assign: () => this; - - toUVec4: () => Node; - toUVec4Assign: () => this; - - toBVec4: () => Node; - toBVec4Assign: () => this; - - toMat2: () => Node; - toMat2Assign: () => this; - - toMat3: () => Node; - toMat3Assign: () => this; - - toMat4: () => Node; - toMat4Assign: () => this; +export const mat4: Mat4Function; + +export const string: (value?: string) => Node<"string">; +export const arrayBuffer: (value: ArrayBuffer) => Node<"ArrayBuffer">; + +declare module "../core/Node.js" { + interface NodeElements { + toColor: () => Node<"color">; + toFloat: () => Node<"float">; + toInt: () => Node<"int">; + toUint: () => Node<"uint">; + toBool: () => Node<"bool">; + toVec2: () => Node<"vec2">; + toIVec2: () => Node<"ivec2">; + toUVec2: () => Node<"uvec2">; + toBVec2: () => Node<"bvec2">; + toVec3: () => Node<"vec3">; + toIVec3: () => Node<"ivec3">; + toUVec3: () => Node<"uvec3">; + toBVec3: () => Node<"bvec3">; + toVec4: () => Node<"vec4">; + toIVec4: () => Node<"ivec4">; + toUVec4: () => Node<"uvec4">; + toBVec4: () => Node<"bvec4">; + toMat2: () => Node<"mat2">; + toMat3: () => Node<"mat3">; + toMat4: () => Node<"mat4">; } } @@ -531,13 +1994,11 @@ export const element: (node: Node, indexNode: Node) => Node; export const convert: (node: Node, types: string) => Node; export const split: (node: Node, channels?: string) => Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { element: (indexNode: Node) => Node; - elementAssign: (indexNode: Node) => this; convert: (types: string) => Node; - convertAssign: (types: string) => this; } } @@ -546,15 +2007,13 @@ declare module "../Nodes.js" { */ export const append: (node: Node) => Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { /** * @deprecated append() has been renamed to Stack(). */ append: () => Node; - /** - * @deprecated append() has been renamed to Stack(). - */ - appendAssign: () => this; } } + +export {}; diff --git a/types/three/src/nodes/utils/ArrayElementNode.d.ts b/types/three/src/nodes/utils/ArrayElementNode.d.ts index 650f0404749ff7..b93aa33802f8d2 100644 --- a/types/three/src/nodes/utils/ArrayElementNode.d.ts +++ b/types/three/src/nodes/utils/ArrayElementNode.d.ts @@ -1,9 +1,14 @@ import Node from "../core/Node.js"; -import { TempNode } from "../Nodes.js"; -export default class ArrayElementNode extends TempNode { +interface ArrayElementNodeInterface { node: Node; indexNode: Node; - - constructor(node: Node, indexNode: Node); } + +declare const ArrayElementNode: { + new(node: Node, indexNode: Node): ArrayElementNode; +}; + +type ArrayElementNode = Node & ArrayElementNodeInterface; + +export default ArrayElementNode; diff --git a/types/three/src/nodes/utils/DebugNode.d.ts b/types/three/src/nodes/utils/DebugNode.d.ts index a86c21500f030b..b94734dabd36d1 100644 --- a/types/three/src/nodes/utils/DebugNode.d.ts +++ b/types/three/src/nodes/utils/DebugNode.d.ts @@ -13,13 +13,10 @@ export const debug: ( callback?: ((node: NodeBuilder, code: string) => void) | null, ) => DebugNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { debug: ( callback?: ((node: NodeBuilder, code: string) => void) | null, ) => DebugNode; - debugAssign: ( - callback?: ((node: NodeBuilder, code: string) => void) | null, - ) => this; } } diff --git a/types/three/src/nodes/utils/Discard.d.ts b/types/three/src/nodes/utils/Discard.d.ts index 3d148cc4a6d897..c8e3001f8ef6cb 100644 --- a/types/three/src/nodes/utils/Discard.d.ts +++ b/types/three/src/nodes/utils/Discard.d.ts @@ -3,9 +3,8 @@ import Node from "../core/Node.js"; export const Discard: (conditional?: Node) => Node; export const Return: () => Node; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface NodeElements { discard: () => Node; - discardAssign: () => this; } } diff --git a/types/three/src/nodes/utils/FlipNode.d.ts b/types/three/src/nodes/utils/FlipNode.d.ts new file mode 100644 index 00000000000000..0b3bbb6ae15d82 --- /dev/null +++ b/types/three/src/nodes/utils/FlipNode.d.ts @@ -0,0 +1,11 @@ +import Node from "../core/Node.js"; +import TempNode from "../core/TempNode.js"; + +declare class FlipNode extends TempNode { + sourceNode: Node; + components: string; + + constructor(sourceNode: Node, components: string); +} + +export default FlipNode; diff --git a/types/three/src/nodes/utils/LoopNode.d.ts b/types/three/src/nodes/utils/LoopNode.d.ts index 9fa5c088bc8f85..6e0f4b0670ce32 100644 --- a/types/three/src/nodes/utils/LoopNode.d.ts +++ b/types/three/src/nodes/utils/LoopNode.d.ts @@ -2,20 +2,20 @@ import Node from "../core/Node.js"; import NodeBuilder from "../core/NodeBuilder.js"; import { VarNode } from "../Nodes.js"; -interface LoopNodeObjectParameter { +type LoopNodeType = "int" | "uint" | "float"; + +interface LoopNodeObjectParameter { // TODO Expand to other types and update loop function types appropriately - type?: "int" | "uint" | "float"; + type?: TNodeType; // TODO The variable name should affect the type of the loop function // name?: string; - start: number | Node; - end: number | Node; + start: Node | number; + end: Node | number; condition?: string; update?: VarNode | number | string; } -type LoopNodeParameter = Node | number | LoopNodeObjectParameter; - -declare class LoopNode extends Node { +declare class LoopNode extends Node<"void"> { params: unknown[]; constructor(params?: unknown[]); @@ -26,12 +26,16 @@ declare class LoopNode extends Node { export default LoopNode; interface Loop { - (i: LoopNodeParameter, func: (inputs: { readonly i: Node }) => void): Node; - ( - i: LoopNodeParameter, - j: LoopNodeParameter, - func: (inputs: { readonly i: Node; readonly j: Node }) => void, - ): Node; + (i: number, func: (inputs: { readonly i: Node<"int"> }) => void): LoopNode; + ( + i: LoopNodeObjectParameter, + func: (inputs: { readonly i: Node }) => void, + ): LoopNode; + ( + i: LoopNodeObjectParameter, + j: LoopNodeObjectParameter, + func: (inputs: { readonly i: Node; readonly j: Node }) => void, + ): LoopNode; } export const Loop: Loop; diff --git a/types/three/src/nodes/utils/MaxMipLevelNode.d.ts b/types/three/src/nodes/utils/MaxMipLevelNode.d.ts index a25670111e184b..a9a895699dc18d 100644 --- a/types/three/src/nodes/utils/MaxMipLevelNode.d.ts +++ b/types/three/src/nodes/utils/MaxMipLevelNode.d.ts @@ -2,7 +2,7 @@ import { Texture } from "../../textures/Texture.js"; import TextureNode from "../accessors/TextureNode.js"; import UniformNode from "../core/UniformNode.js"; -export default class MaxMipLevelNode extends UniformNode<0> { +export default class MaxMipLevelNode extends UniformNode<"float", number> { constructor(textureNode: TextureNode); get textureNode(): TextureNode; diff --git a/types/three/src/nodes/utils/Oscillators.d.ts b/types/three/src/nodes/utils/Oscillators.d.ts index 256da27284eb8b..d39733875b45fe 100644 --- a/types/three/src/nodes/utils/Oscillators.d.ts +++ b/types/three/src/nodes/utils/Oscillators.d.ts @@ -1,6 +1,6 @@ import Node from "../core/Node.js"; -export const oscSine: (timeNode?: Node) => Node; -export const oscSquare: (timeNode?: Node) => Node; -export const oscTriangle: (timeNode?: Node) => Node; -export const oscSawtooth: (timeNode?: Node) => Node; +export const oscSine: (timeNode?: Node) => Node<"float">; +export const oscSquare: (timeNode?: Node) => Node<"float">; +export const oscTriangle: (timeNode?: Node) => Node<"float">; +export const oscSawtooth: (timeNode?: Node) => Node<"float">; diff --git a/types/three/src/nodes/utils/Packing.d.ts b/types/three/src/nodes/utils/Packing.d.ts index 07a4232f9b8f23..91b1b3fcde917a 100644 --- a/types/three/src/nodes/utils/Packing.d.ts +++ b/types/three/src/nodes/utils/Packing.d.ts @@ -1,5 +1,5 @@ import Node from "../core/Node.js"; -export const directionToColor: (node: Node) => Node; -export const colorToDirection: (node: Node) => Node; -export const unpackNormal: (xy: Node) => Node; +export const directionToColor: (node: Node) => Node<"vec3">; +export const colorToDirection: (node: Node) => Node<"vec3">; +export const unpackNormal: (xy: Node) => Node<"vec3">; diff --git a/types/three/src/nodes/utils/PostProcessingUtils.d.ts b/types/three/src/nodes/utils/PostProcessingUtils.d.ts index 4b6fe9c0511ff1..0b24e78ba385ea 100644 --- a/types/three/src/nodes/utils/PostProcessingUtils.d.ts +++ b/types/three/src/nodes/utils/PostProcessingUtils.d.ts @@ -13,7 +13,7 @@ export const getViewPosition: ( screenPosition: Node, depth: Node, projectionMatrixInverse: Node, -) => Node; +) => Node<"vec3">; /** * Computes a screen position expressed as uv coordinates based on a fragment's position in view space and the camera's @@ -26,7 +26,7 @@ export const getViewPosition: ( export const getScreenPosition: ( viewPosition: Node, projectionMatrix: Node, -) => 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 @@ -41,8 +41,8 @@ export const getNormalFromDepth: ( uv: Node, depthTexture: Node, projectionMatrixInverse: Node, -) => Node; +) => Node<"vec3">; -export const interleavedGradientNoise: (position: Node) => Node; +export const interleavedGradientNoise: (position: Node) => Node<"float">; -export const vogelDiskSample: (sampleIndex: Node, samplesCount: Node, phi: Node) => Node; +export const vogelDiskSample: (sampleIndex: Node, samplesCount: Node, phi: Node) => Node<"vec2">; diff --git a/types/three/src/nodes/utils/RemapNode.d.ts b/types/three/src/nodes/utils/RemapNode.d.ts index 1dc4a70c08ac29..36c3ee02988cba 100644 --- a/types/three/src/nodes/utils/RemapNode.d.ts +++ b/types/three/src/nodes/utils/RemapNode.d.ts @@ -1,58 +1,52 @@ import Node from "../core/Node.js"; -export default class RemapNode extends Node { - node: Node; - inLowNode: Node; - inHighNode: Node; - outLowNode: Node; - outHighNode: Node; +export default class RemapNode extends Node<"float"> { + node: Node<"float">; + inLowNode: Node<"float">; + inHighNode: Node<"float">; + outLowNode: Node<"float">; + outHighNode: Node<"float">; doClamp: boolean; - constructor(node: Node, inLowNode: Node, inHighNode: Node, outLowNode?: Node, outHighNode?: Node); + constructor( + node: Node<"float">, + inLowNode: Node<"float">, + inHighNode: Node<"float">, + outLowNode?: Node<"float">, + outHighNode?: Node<"float">, + ); } export const remap: ( - node: Node, - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + node: Node<"float">, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => RemapNode; export const remapClamp: ( - node: Node, - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + node: Node<"float">, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => RemapNode; -declare module "../Nodes.js" { - interface Node { +declare module "../core/Node.js" { + interface FloatExtensions { remap: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => RemapNode; - remapAssign: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, - ) => this; remapClamp: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, + inLowNode: Node<"float"> | number, + inHighNode: Node<"float"> | number, + outLowNode?: Node<"float"> | number, + outHighNode?: Node<"float"> | number, ) => RemapNode; - remapClampAssign: ( - inLowNode: Node | number, - inHighNode: Node | number, - outLowNode?: Node | number, - outHighNode?: Node | number, - ) => this; } } diff --git a/types/three/src/nodes/utils/RotateNode.d.ts b/types/three/src/nodes/utils/RotateNode.d.ts index 915bc21d3be9c4..c75f4317598d2b 100644 --- a/types/three/src/nodes/utils/RotateNode.d.ts +++ b/types/three/src/nodes/utils/RotateNode.d.ts @@ -1,14 +1,23 @@ import Node from "../core/Node.js"; import TempNode from "../core/TempNode.js"; -export default class RotateNode extends TempNode { - positionNode: Node; - rotationNode: Node; +interface RotateNodeInterface { + positionNode: Node; + rotationNode: Node<"vec3"> | Node<"float">; +} + +declare const RotateNode: { + new(positionNode: Node<"vec2">, rotationNode: Node<"float"> | number): RotateNode<"vec2">; + new(positionNode: Node<"vec3">, rotationNode: Node<"vec3">): RotateNode<"vec3">; +}; + +type RotateNode = RotateNodeInterface & TempNode; + +export default RotateNode; - constructor(positionNode: Node, rotationNode: Node); +interface Rotate { + (positionNode: Node<"vec2">, rotationNode: Node<"float"> | number): RotateNode<"vec2">; + (positionNode: Node<"vec3">, rotationNode: Node<"vec3">): RotateNode<"vec3">; } -export const rotate: ( - positionNode: Node, - rotationNode: Node | number, -) => RotateNode; +export const rotate: Rotate; diff --git a/types/three/src/nodes/utils/SplitNode.d.ts b/types/three/src/nodes/utils/SplitNode.d.ts index e21de043f612c7..dcc7d823adc199 100644 --- a/types/three/src/nodes/utils/SplitNode.d.ts +++ b/types/three/src/nodes/utils/SplitNode.d.ts @@ -1,5 +1,4 @@ import Node from "../core/Node.js"; -import { SwizzleOption } from "../tsl/TSLCore.js"; export default class SplitNode extends Node { node: Node; @@ -9,7 +8,7 @@ export default class SplitNode extends Node { * @param node the input node * @param components swizzle like string, default = "x" */ - constructor(node: Node, components?: SwizzleOption); + constructor(node: Node, components?: string); getVectorLength(): number; } diff --git a/types/three/src/nodes/utils/SpriteSheetUV.d.ts b/types/three/src/nodes/utils/SpriteSheetUV.d.ts new file mode 100644 index 00000000000000..5c9717d14df97c --- /dev/null +++ b/types/three/src/nodes/utils/SpriteSheetUV.d.ts @@ -0,0 +1,7 @@ +import Node from "../core/Node.js"; + +export const spritesheetUV: ( + countNode: Node, + uvNode?: Node, + frameNode?: Node, +) => Node; diff --git a/types/three/src/nodes/utils/SpriteSheetUVNode.d.ts b/types/three/src/nodes/utils/SpriteSheetUVNode.d.ts deleted file mode 100644 index 6eb266ac318855..00000000000000 --- a/types/three/src/nodes/utils/SpriteSheetUVNode.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import Node from "../core/Node.js"; - -export default class SpriteSheetUVNode extends Node { - countNode: Node; - uvNode: Node; - frameNode: Node; - - constructor(countNode: Node, uvNode?: Node, frameNode?: Node); -} - -export const spritesheetUV: ( - countNode: Node, - uvNode: Node | null, - frameNode: Node | null, -) => SpriteSheetUVNode; diff --git a/types/three/src/nodes/utils/StorageArrayElementNode.d.ts b/types/three/src/nodes/utils/StorageArrayElementNode.d.ts index a8110c50862b9b..e85e805b376f92 100644 --- a/types/three/src/nodes/utils/StorageArrayElementNode.d.ts +++ b/types/three/src/nodes/utils/StorageArrayElementNode.d.ts @@ -2,18 +2,27 @@ import StorageBufferNode from "../accessors/StorageBufferNode.js"; import Node from "../core/Node.js"; import ArrayElementNode from "./ArrayElementNode.js"; -export default class StorageArrayElementNode extends ArrayElementNode { - node: StorageBufferNode; +interface StorageArrayElementNodeInterface { + node: StorageBufferNode; readonly isStorageArrayElementNode: true; - constructor(storageBufferNode: StorageBufferNode, indexNode: Node); - - get storageBufferNode(): StorageBufferNode; - set storageBufferNode(value: StorageBufferNode); + get storageBufferNode(): StorageBufferNode; + set storageBufferNode(value: StorageBufferNode); } -export const storageElement: ( - storageBufferNode: Node, +declare const StorageArrayElementNode: { + new( + storageBufferNode: StorageBufferNode, + indexNode: Node, + ): StorageArrayElementNode; +}; + +type StorageArrayElementNode = ArrayElementNode & StorageArrayElementNodeInterface; + +export default StorageArrayElementNode; + +export const storageElement: ( + storageBufferNode: Node, indexNode: Node, -) => StorageArrayElementNode; +) => StorageArrayElementNode; diff --git a/types/three/src/nodes/utils/Timer.d.ts b/types/three/src/nodes/utils/Timer.d.ts index bc0a8bf9b8c7f8..a8ef3e44a09200 100644 --- a/types/three/src/nodes/utils/Timer.d.ts +++ b/types/three/src/nodes/utils/Timer.d.ts @@ -1,5 +1,5 @@ -import Node from "../core/Node.js"; +import UniformNode from "../core/UniformNode.js"; -export const time: Node; -export const deltaTime: Node; -export const frameId: Node; +export const time: UniformNode<"float", number>; +export const deltaTime: UniformNode<"float", number>; +export const frameId: UniformNode<"uint", number>; diff --git a/types/three/src/nodes/utils/TriplanarTextures.d.ts b/types/three/src/nodes/utils/TriplanarTextures.d.ts index e76f4f7c99080f..a90a878ef2a30e 100644 --- a/types/three/src/nodes/utils/TriplanarTextures.d.ts +++ b/types/three/src/nodes/utils/TriplanarTextures.d.ts @@ -7,7 +7,7 @@ export const triplanarTextures: ( scaleNode?: Node, positionNode?: Node, normalNode?: Node, -) => Node; +) => Node<"vec4">; export const triplanarTexture: ( textureXNode: Node, @@ -16,4 +16,4 @@ export const triplanarTexture: ( scaleNode?: Node, positionNode?: Node, normalNode?: Node, -) => Node; +) => Node<"vec4">; diff --git a/types/three/src/nodes/utils/UVUtils.d.ts b/types/three/src/nodes/utils/UVUtils.d.ts index 5c97558e2ce2b1..e52348828e027c 100644 --- a/types/three/src/nodes/utils/UVUtils.d.ts +++ b/types/three/src/nodes/utils/UVUtils.d.ts @@ -1,17 +1,19 @@ import ContextNode from "../core/ContextNode.js"; import Node from "../core/Node.js"; -import OperatorNode from "../math/OperatorNode.js"; -export function replaceDefaultUV(callback: (node: Node) => Node, node?: Node | null): ContextNode; +export function replaceDefaultUV( + callback: ((node: Node) => Node<"vec2">) | Node<"vec2">, + node?: Node | null, +): ContextNode; export const rotateUV: ( uv: Node, rotation: Node, center?: Node, -) => OperatorNode; +) => Node<"vec2">; export const spherizeUV: ( uv: Node, strength: Node | number, center?: Node, -) => OperatorNode; +) => Node<"vec2">; diff --git a/types/three/src/objects/BatchedMesh.d.ts b/types/three/src/objects/BatchedMesh.d.ts index 8c6bdace44468b..260b6f98668a33 100644 --- a/types/three/src/objects/BatchedMesh.d.ts +++ b/types/three/src/objects/BatchedMesh.d.ts @@ -5,6 +5,7 @@ import { Box3 } from "../math/Box3.js"; import { Color } from "../math/Color.js"; import { Matrix4 } from "../math/Matrix4.js"; import { Sphere } from "../math/Sphere.js"; +import { Vector4 } from "../math/Vector4.js"; import { Mesh } from "./Mesh.js"; export interface BatchedMeshGeometryRange { @@ -141,9 +142,10 @@ declare class BatchedMesh extends Mesh { /** * Get the color of the defined geometry. * @param instanceId The id of an instance to get the color of. - * @param target The target object to copy the color in to. + * @param color - The target object that is used to store the method's result. + * @return The instance's color. Use a `Vector4` to also retrieve alpha. */ - getColorAt(instanceId: number, target: Color): void; + getColorAt(instanceId: number, color: Color | Vector4): Color | Vector4; /** * Get the local transformation matrix of the defined instance. @@ -180,9 +182,9 @@ declare class BatchedMesh extends Mesh { /** * Sets the given color to the defined geometry instance. * @param instanceId The id of the instance to set the color of. - * @param color The color to set the instance to. + * @param color The color to set the instance to. Use a `Vector4` to also define alpha. */ - setColorAt(instanceId: number, color: Color): void; + setColorAt(instanceId: number, color: Color | Vector4): void; /** * Sets the given local transformation matrix to the defined instance. diff --git a/types/three/src/objects/InstancedMesh.d.ts b/types/three/src/objects/InstancedMesh.d.ts index 007674e349b61c..1d9bd3dcb05ccc 100644 --- a/types/three/src/objects/InstancedMesh.d.ts +++ b/types/three/src/objects/InstancedMesh.d.ts @@ -41,14 +41,6 @@ export class InstancedMesh< TMaterial extends Material | Material[] = Material | Material[], TEventMap extends InstancedMeshEventMap = InstancedMeshEventMap, > extends Mesh { - /** - * Create a new instance of {@link InstancedMesh} - * @param geometry An instance of {@link BufferGeometry}. - * @param material A single or an array of {@link Material}. Default is a new {@link MeshBasicMaterial}. - * @param count The **maximum** number of instances of this Mesh. Expects a `Integer` - */ - constructor(geometry: TGeometry | undefined, material: TMaterial | undefined, count: number); - /** * Read-only flag to check if a given object is of type {@link InstancedMesh}. * @remarks This is a _constant_ value @@ -57,18 +49,31 @@ export class InstancedMesh< readonly isInstancedMesh: true; /** - * This bounding box encloses all instances of the {@link InstancedMesh},, which can be calculated with {@link computeBoundingBox | .computeBoundingBox()}. - * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`. - * @defaultValue `null` + * Represents the local transformation of all instances. + * You have to set {@link InstancedBufferAttribute.needsUpdate | .instanceMatrix.needsUpdate()} flag to `true` if you modify instanced data via {@link setMatrixAt | .setMatrixAt()}. */ - boundingBox: Box3 | null; + instanceMatrix: InstancedBufferAttribute; /** - * This bounding sphere encloses all instances of the {@link InstancedMesh}, which can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}. - * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`. + * Represents the local transformation of all instances of the previous frame. + * Required for computing velocity. Maintained in {@link InstanceNode}. + * + * @default null + */ + previousInstancedMatrix: InstancedBufferAttribute | null; + + /** + * Represents the colors of all instances. + * You have to set {@link InstancedBufferAttribute.needsUpdate | .instanceColor.needsUpdate()} flag to `true` if you modify instanced data via {@link setColorAt | .setColorAt()}. * @defaultValue `null` */ - boundingSphere: Sphere | null; + instanceColor: InstancedBufferAttribute | null; + + /** + * Represents the morph target weights of all instances. You have to set its {@link .needsUpdate} flag to true if + * you modify instanced data via {@link .setMorphAt}. + */ + morphTexture: DataTexture | null; /** * The number of instances. @@ -81,23 +86,26 @@ export class InstancedMesh< count: number; /** - * Represents the colors of all instances. - * You have to set {@link InstancedBufferAttribute.needsUpdate | .instanceColor.needsUpdate()} flag to `true` if you modify instanced data via {@link setColorAt | .setColorAt()}. + * This bounding box encloses all instances of the {@link InstancedMesh},, which can be calculated with {@link computeBoundingBox | .computeBoundingBox()}. + * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`. * @defaultValue `null` */ - instanceColor: InstancedBufferAttribute | null; + boundingBox: Box3 | null; /** - * Represents the local transformation of all instances. - * You have to set {@link InstancedBufferAttribute.needsUpdate | .instanceMatrix.needsUpdate()} flag to `true` if you modify instanced data via {@link setMatrixAt | .setMatrixAt()}. + * This bounding sphere encloses all instances of the {@link InstancedMesh}, which can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}. + * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`. + * @defaultValue `null` */ - instanceMatrix: InstancedBufferAttribute; + boundingSphere: Sphere | null; /** - * Represents the morph target weights of all instances. You have to set its {@link .needsUpdate} flag to true if - * you modify instanced data via {@link .setMorphAt}. + * Create a new instance of {@link InstancedMesh} + * @param geometry An instance of {@link BufferGeometry}. + * @param material A single or an array of {@link Material}. Default is a new {@link MeshBasicMaterial}. + * @param count The **maximum** number of instances of this Mesh. Expects a `Integer` */ - morphTexture: DataTexture | null; + constructor(geometry: TGeometry | undefined, material: TMaterial | undefined, count: number); /** * Computes the bounding box of the instanced mesh, and updates the {@link .boundingBox} attribute. The bounding box diff --git a/types/three/src/renderers/WebGLRenderer.d.ts b/types/three/src/renderers/WebGLRenderer.d.ts index 87403901d86baf..47ff9f41fd80a4 100644 --- a/types/three/src/renderers/WebGLRenderer.d.ts +++ b/types/three/src/renderers/WebGLRenderer.d.ts @@ -1,7 +1,7 @@ import { Camera } from "../cameras/Camera.js"; -import { CullFace, ShadowMapType, TextureDataType, ToneMapping, WebGLCoordinateSystem } from "../constants.js"; +import { TextureDataType, ToneMapping, WebGLCoordinateSystem } from "../constants.js"; import { TypedArray } from "../core/BufferAttribute.js"; -import { BufferGeometry } from "../core/BufferGeometry.js"; +import { BufferGeometry, GeometryGroup } from "../core/BufferGeometry.js"; import { Object3D } from "../core/Object3D.js"; import { Material } from "../materials/Material.js"; import { Box2 } from "../math/Box2.js"; @@ -227,20 +227,10 @@ export class WebGLRenderer { * Return the WebGL context. */ getContext(): WebGLRenderingContext | WebGL2RenderingContext; - getContextAttributes(): any; + getContextAttributes(): WebGLContextAttributes; forceContextLoss(): void; forceContextRestore(): void; - /** - * @deprecated Use {@link WebGLCapabilities#getMaxAnisotropy .capabilities.getMaxAnisotropy()} instead. - */ - getMaxAnisotropy(): number; - - /** - * @deprecated Use {@link WebGLCapabilities#precision .capabilities.precision} instead. - */ - getPrecision(): string; - getPixelRatio(): number; setPixelRatio(value: number): void; @@ -327,10 +317,6 @@ export class WebGLRenderer { clearStencil(): void; clearTarget(renderTarget: WebGLRenderTarget, color: boolean, depth: boolean, stencil: boolean): void; - /** - * @deprecated Use {@link WebGLState#reset .state.reset()} instead. - */ - resetGLState(): void; dispose(): void; renderBufferDirect( @@ -339,7 +325,7 @@ export class WebGLRenderer { geometry: BufferGeometry, material: Material, object: Object3D, - geometryGroup: any, + group: GeometryGroup, ): void; /** @@ -348,11 +334,6 @@ export class WebGLRenderer { */ setAnimationLoop(callback: XRFrameRequestCallback | null): void; - /** - * @deprecated Use {@link WebGLRenderer#setAnimationLoop .setAnimationLoop()} instead. - */ - animate(callback: () => void): void; - /** * Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first * rendering. If you want to add a 3D object to an existing scene, use the third optional parameter for applying the @@ -396,11 +377,6 @@ export class WebGLRenderer { */ getRenderTarget(): WebGLRenderTarget | null; - /** - * @deprecated Use {@link WebGLRenderer#getRenderTarget .getRenderTarget()} instead. - */ - getCurrentRenderTarget(): WebGLRenderTarget | null; - /** * Sets the active render target. * @@ -490,69 +466,4 @@ export class WebGLRenderer { * Can be used to reset the internal WebGL state. */ resetState(): void; - - /** - * @deprecated Use {@link WebGLRenderer#xr .xr} instead. - */ - vr: boolean; - - /** - * @deprecated Use {@link WebGLShadowMap#enabled .shadowMap.enabled} instead. - */ - shadowMapEnabled: boolean; - - /** - * @deprecated Use {@link WebGLShadowMap#type .shadowMap.type} instead. - */ - shadowMapType: ShadowMapType; - - /** - * @deprecated Use {@link WebGLShadowMap#cullFace .shadowMap.cullFace} instead. - */ - shadowMapCullFace: CullFace; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_texture_float' )} instead. - */ - supportsFloatTextures(): any; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_texture_half_float' )} instead. - */ - supportsHalfFloatTextures(): any; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_standard_derivatives' )} instead. - */ - supportsStandardDerivatives(): any; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'WEBGL_compressed_texture_s3tc' )} instead. - */ - supportsCompressedTextureS3TC(): any; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'WEBGL_compressed_texture_pvrtc' )} instead. - */ - supportsCompressedTexturePVRTC(): any; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'EXT_blend_minmax' )} instead. - */ - supportsBlendMinMax(): any; - - /** - * @deprecated Use {@link WebGLCapabilities#vertexTextures .capabilities.vertexTextures} instead. - */ - supportsVertexTextures(): any; - - /** - * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'ANGLE_instanced_arrays' )} instead. - */ - supportsInstancedArrays(): any; - - /** - * @deprecated Use {@link WebGLRenderer#setScissorTest .setScissorTest()} instead. - */ - enableScissorTest(boolean: any): any; } diff --git a/types/three/src/renderers/common/Animation.d.ts b/types/three/src/renderers/common/Animation.d.ts index 33406ad8817dc7..1185e03293dbaa 100644 --- a/types/three/src/renderers/common/Animation.d.ts +++ b/types/three/src/renderers/common/Animation.d.ts @@ -1,22 +1,18 @@ import Info from "./Info.js"; -import Nodes from "./nodes/Nodes.js"; +import NodeManager from "./nodes/NodeManager.js"; import Renderer from "./Renderer.js"; + export interface AnimationContext { requestAnimationFrame(callback: FrameRequestCallback, xrFrame?: XRFrame): number; cancelAnimationFrame(handle: number): void; } + /** * This module manages the internal animation loop of the renderer. * * @private */ declare class Animation { - renderer: Renderer; - nodes: Nodes; - info: Info; - _context: AnimationContext | null; - _animationLoop: ((time: DOMHighResTimeStamp, xrFrame?: XRFrame) => void) | null; - _requestId: number | null; /** * Constructs a new animation loop management component. * @@ -24,7 +20,47 @@ declare class Animation { * @param {Nodes} nodes - Renderer component for managing nodes related logic. * @param {Info} info - Renderer component for managing metrics and monitoring data. */ - constructor(renderer: Renderer, nodes: Nodes, info: Info); + constructor(renderer: Renderer, nodes: NodeManager, info: Info); + /** + * A reference to the main renderer. + * + * @type {Renderer} + */ + renderer: Renderer; + /** + * Renderer component for managing nodes related logic. + * + * @type {Nodes} + */ + nodes: NodeManager; + /** + * Renderer component for managing metrics and monitoring data. + * + * @type {Info} + */ + info: Info; + /** + * A reference to the context from `requestAnimationFrame()` can + * be called (usually `window`). + * + * @type {?(Window|XRSession)} + */ + _context: AnimationContext | null; + /** + * The user-defined animation loop. + * + * @type {?Function} + * @default null + */ + _animationLoop: ((time: DOMHighResTimeStamp, xrFrame?: XRFrame) => void) | null; + /** + * The requestId which is returned from the `requestAnimationFrame()` call. + * Can be used to cancel the stop the animation loop. + * + * @type {?number} + * @default null + */ + _requestId: number | null; /** * Starts the internal animation loop. */ @@ -50,7 +86,7 @@ declare class Animation { * * @return {Window|XRSession} The animation context. */ - getContext(): AnimationContext | null; + getContext(): AnimationContext; /** * Defines the context in which `requestAnimationFrame()` is executed. * @@ -62,4 +98,5 @@ declare class Animation { */ dispose(): void; } + export default Animation; diff --git a/types/three/src/renderers/common/Attributes.d.ts b/types/three/src/renderers/common/Attributes.d.ts index 9bc739d8e6d1c5..20aa271c7dbfe6 100644 --- a/types/three/src/renderers/common/Attributes.d.ts +++ b/types/three/src/renderers/common/Attributes.d.ts @@ -2,37 +2,34 @@ import { BufferAttribute } from "../../core/BufferAttribute.js"; import { InterleavedBuffer } from "../../core/InterleavedBuffer.js"; import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribute.js"; import Backend from "./Backend.js"; -import { AttributeType } from "./Constants.js"; import DataMap from "./DataMap.js"; -interface Data { - version?: number | undefined; -} + /** * This renderer module manages geometry attributes. * * @private * @augments DataMap */ -declare class Attributes extends DataMap<{ - attribute: { - key: BufferAttribute | InterleavedBufferAttribute; - value: Data; - }; -}> { - backend: Backend; +declare class Attributes extends DataMap { /** * Constructs a new attribute management component. * * @param {Backend} backend - The renderer's backend. */ constructor(backend: Backend); + /** + * The renderer's backend. + * + * @type {Backend} + */ + backend: Backend; /** * Deletes the data for the given attribute. * * @param {BufferAttribute} attribute - The attribute. * @return {?Object} The deleted attribute data. */ - delete(attribute: BufferAttribute | InterleavedBufferAttribute): Data; + delete(attribute: BufferAttribute | InterleavedBufferAttribute): unknown; /** * Updates the given attribute. This method creates attribute buffers * for new attributes and updates data for existing ones. @@ -40,7 +37,7 @@ declare class Attributes extends DataMap<{ * @param {BufferAttribute} attribute - The attribute to update. * @param {number} type - The attribute type. */ - update(attribute: BufferAttribute | InterleavedBufferAttribute, type: AttributeType): void; + update(attribute: BufferAttribute | InterleavedBufferAttribute, type: number): void; /** * Utility method for handling interleaved buffer attributes correctly. * To process them, their `InterleavedBuffer` is returned. @@ -50,4 +47,5 @@ declare class Attributes extends DataMap<{ */ _getBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute): BufferAttribute | InterleavedBuffer; } + export default Attributes; diff --git a/types/three/src/renderers/common/Backend.d.ts b/types/three/src/renderers/common/Backend.d.ts index 105dd96135a656..567522ebaba8b8 100644 --- a/types/three/src/renderers/common/Backend.d.ts +++ b/types/three/src/renderers/common/Backend.d.ts @@ -7,8 +7,6 @@ declare module "../../core/Object3D.js" { count?: number | undefined; // See https://github.com/mrdoob/three.js/pull/26335 occlusionTest?: boolean | undefined; - // https://github.com/mrdoob/three.js/pull/29386 - static?: boolean | undefined; } } diff --git a/types/three/src/renderers/common/Background.d.ts b/types/three/src/renderers/common/Background.d.ts index b3c6e59f2457a4..9a4ee4ff9ee888 100644 --- a/types/three/src/renderers/common/Background.d.ts +++ b/types/three/src/renderers/common/Background.d.ts @@ -1,35 +1,36 @@ -import { Mesh } from "../../objects/Mesh.js"; import { Scene } from "../../scenes/Scene.js"; import DataMap from "./DataMap.js"; -import Nodes from "./nodes/Nodes.js"; +import NodeManager from "./nodes/NodeManager.js"; import RenderContext from "./RenderContext.js"; import Renderer from "./Renderer.js"; import RenderList from "./RenderList.js"; -interface SceneData { - backgroundMesh?: Mesh; - backgroundCacheKey: string; -} + /** * This renderer module manages the background. * * @private * @augments DataMap */ -declare class Background extends DataMap<{ - scene: { - key: Scene; - value: SceneData; - }; -}> { - renderer: Renderer; - nodes: Nodes; +declare class Background extends DataMap { /** * Constructs a new background management component. * * @param {Renderer} renderer - The renderer. * @param {Nodes} nodes - Renderer component for managing nodes related logic. */ - constructor(renderer: Renderer, nodes: Nodes); + constructor(renderer: Renderer, nodes: NodeManager); + /** + * The renderer. + * + * @type {Renderer} + */ + renderer: Renderer; + /** + * Renderer component for managing nodes related logic. + * + * @type {Nodes} + */ + nodes: NodeManager; /** * Updates the background for the given scene. Depending on how `Scene.background` * or `Scene.backgroundNode` are configured, this method might configure a simple clear @@ -42,4 +43,5 @@ declare class Background extends DataMap<{ */ update(scene: Scene, renderList: RenderList, renderContext: RenderContext): void; } + export default Background; diff --git a/types/three/src/renderers/common/BindGroup.d.ts b/types/three/src/renderers/common/BindGroup.d.ts index 030079b924f977..e20ac3f9c8e840 100644 --- a/types/three/src/renderers/common/BindGroup.d.ts +++ b/types/three/src/renderers/common/BindGroup.d.ts @@ -1,5 +1,5 @@ import Binding from "./Binding.js"; -import NodeUniformsGroup from "./nodes/NodeUniformsGroup.js"; + /** * A bind group represents a collection of bindings and thus a collection * or resources. Bind groups are assigned to pipelines to provide them @@ -8,24 +8,38 @@ import NodeUniformsGroup from "./nodes/NodeUniformsGroup.js"; * @private */ declare class BindGroup { - name: string; - bindings: NodeUniformsGroup[] | Binding[]; - index: number; - bindingsReference: NodeUniformsGroup[] | BindGroup; - id: number; /** * Constructs a new bind group. * * @param {string} name - The bind group's name. * @param {Array} bindings - An array of bindings. * @param {number} index - The group index. - * @param {Array} bindingsReference - An array of reference bindings. */ - constructor( - name?: string, - bindings?: NodeUniformsGroup[], - index?: number, - bindingsReference?: NodeUniformsGroup[] | BindGroup, - ); + constructor(name?: string, bindings?: Binding[], index?: number); + /** + * The bind group's name. + * + * @type {string} + */ + name: string; + /** + * An array of bindings. + * + * @type {Array} + */ + bindings: Binding[]; + /** + * The group index. + * + * @type {number} + */ + index: number; + /** + * The group's ID. + * + * @type {number} + */ + id: number; } + export default BindGroup; diff --git a/types/three/src/renderers/common/Binding.d.ts b/types/three/src/renderers/common/Binding.d.ts index 9aed5315ca07e0..d876c3b7e4759c 100644 --- a/types/three/src/renderers/common/Binding.d.ts +++ b/types/three/src/renderers/common/Binding.d.ts @@ -8,14 +8,25 @@ * @private */ declare class Binding { - name: string; - visibility: number; /** * Constructs a new binding. * * @param {string} [name=''] - The binding's name. */ constructor(name?: string); + /** + * The binding's name. + * + * @type {string} + */ + name: string; + /** + * A bitmask that defines in what shader stages the + * binding's resource is accessible. + * + * @type {number} + */ + visibility: number; /** * Makes sure binding's resource is visible for the given shader stage. * @@ -33,6 +44,7 @@ declare class Binding { * * @return {Binding} The cloned binding. */ - clone(): Binding & this; + clone(): Binding; } + export default Binding; diff --git a/types/three/src/renderers/common/Bindings.d.ts b/types/three/src/renderers/common/Bindings.d.ts index b46d587a703694..0702ef1a32515b 100644 --- a/types/three/src/renderers/common/Bindings.d.ts +++ b/types/three/src/renderers/common/Bindings.d.ts @@ -4,20 +4,18 @@ import Backend from "./Backend.js"; import BindGroup from "./BindGroup.js"; import DataMap from "./DataMap.js"; import Info from "./Info.js"; -import Nodes from "./nodes/Nodes.js"; +import NodeManager from "./nodes/NodeManager.js"; import Pipelines from "./Pipelines.js"; import RenderObject from "./RenderObject.js"; import Textures from "./Textures.js"; -interface BindGroupData { - bindGroup?: BindGroup | undefined; -} + /** * This renderer module manages the bindings of the renderer. * * @private * @augments DataMap */ -declare class Bindings extends DataMap<{ +declare class Bindings extends DataMap { /** * Constructs a new bindings management component. * @@ -28,25 +26,50 @@ declare class Bindings extends DataMap<{ * @param {Pipelines} pipelines - Renderer component for managing pipelines. * @param {Info} info - Renderer component for managing metrics and monitoring data. */ - bindGroup: { - key: BindGroup; - value: BindGroupData; - }; -}> { - backend: Backend; - textures: Textures; - pipelines: Pipelines; - attributes: Attributes; - nodes: Nodes; - info: Info; constructor( backend: Backend, - nodes: Nodes, + nodes: NodeManager, textures: Textures, attributes: Attributes, pipelines: Pipelines, info: Info, ); + /** + * The renderer's backend. + * + * @type {Backend} + */ + backend: Backend; + /** + * Renderer component for managing textures. + * + * @type {Textures} + */ + textures: Textures; + /** + * Renderer component for managing pipelines. + * + * @type {Pipelines} + */ + pipelines: Pipelines; + /** + * Renderer component for managing attributes. + * + * @type {Attributes} + */ + attributes: Attributes; + /** + * Renderer component for managing nodes related logic. + * + * @type {Nodes} + */ + nodes: NodeManager; + /** + * Renderer component for managing metrics and monitoring data. + * + * @type {Info} + */ + info: Info; /** * Returns the bind groups for the given render object. * @@ -105,4 +128,5 @@ declare class Bindings extends DataMap<{ */ _update(bindGroup: BindGroup, bindings: BindGroup[]): void; } + export default Bindings; diff --git a/types/three/src/renderers/common/BlendMode.d.ts b/types/three/src/renderers/common/BlendMode.d.ts new file mode 100644 index 00000000000000..12f202e4afd72b --- /dev/null +++ b/types/three/src/renderers/common/BlendMode.d.ts @@ -0,0 +1,22 @@ +import { Blending, BlendingDstFactor, BlendingEquation, BlendingSrcFactor } from "../../constants.js"; + +declare class BlendMode { + blending: Blending; + + blendSrc: BlendingSrcFactor; + blendDst: BlendingDstFactor; + blendEquation: BlendingEquation; + + blendSrcAlpha: BlendingSrcFactor | null; + blendDstAlpha: BlendingDstFactor | null; + blendEquationAlpha: BlendingEquation | null; + premultiplyAlpha: boolean; + + constructor(blending: Blending); + + copy(source: BlendMode): this; + + clone(): BlendMode; +} + +export default BlendMode; diff --git a/types/three/src/renderers/common/Buffer.d.ts b/types/three/src/renderers/common/Buffer.d.ts index c4ca552477a2f2..4e8832b45f8eb4 100644 --- a/types/three/src/renderers/common/Buffer.d.ts +++ b/types/three/src/renderers/common/Buffer.d.ts @@ -1,4 +1,6 @@ +import { TypedArray } from "../../core/BufferAttribute.js"; import Binding from "./Binding.js"; + /** * Represents a buffer binding type. * @@ -7,29 +9,50 @@ import Binding from "./Binding.js"; * @augments Binding */ declare class Buffer extends Binding { - readonly isBuffer: true; - bytesPerElement: number; - _buffer: Float32Array | null; - _updateRanges: { - start: number; - count: number; - }[]; /** * Constructs a new buffer. * * @param {string} name - The buffer's name. * @param {TypedArray} [buffer=null] - The buffer. */ - constructor(name?: string, buffer?: Float32Array | null); + constructor(name: string, buffer?: TypedArray); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isBuffer: boolean; + /** + * The bytes per element. + * + * @type {number} + */ + bytesPerElement: number; + /** + * A reference to the internal buffer. + * + * @private + * @type {TypedArray} + */ + private _buffer; + /** + * An array of update ranges. + * + * @private + * @type {Array<{start: number, count: number}>} + */ + private _updateRanges; /** * The array of update ranges. * * @type {Array<{start: number, count: number}>} */ - get updateRanges(): { + get updateRanges(): Array<{ start: number; count: number; - }[]; + }>; /** * Adds an update range. * @@ -54,7 +77,7 @@ declare class Buffer extends Binding { * @type {Float32Array} * @readonly */ - get buffer(): Float32Array | null; + get buffer(): TypedArray; /** * Updates the binding. * @@ -63,4 +86,5 @@ declare class Buffer extends Binding { */ update(): boolean; } + export default Buffer; diff --git a/types/three/src/renderers/common/BufferUtils.d.ts b/types/three/src/renderers/common/BufferUtils.d.ts index dc441d93da6bc8..4d149b3a78cf73 100644 --- a/types/three/src/renderers/common/BufferUtils.d.ts +++ b/types/three/src/renderers/common/BufferUtils.d.ts @@ -6,7 +6,7 @@ * @param {number} floatLength - The buffer length. * @return {number} The padded length. */ -declare function getFloatLength(floatLength: number): number; +export function getFloatLength(floatLength: number): number; /** * Given the count of vectors and their vector length, this function computes * a total length in bytes with buffer alignment according to STD140 layout. @@ -16,7 +16,7 @@ declare function getFloatLength(floatLength: number): number; * @param {number} [vectorLength=4] - The vector length. * @return {number} The padded length. */ -declare function getVectorLength(count: number, vectorLength?: number): number; +export function getVectorLength(count: number, vectorLength?: number): number; /** * This function is called with a vector length and ensure the computed length * matches a predefined stride (in this case `4`). @@ -25,5 +25,4 @@ declare function getVectorLength(count: number, vectorLength?: number): number; * @param {number} vectorLength - The vector length. * @return {number} The padded length. */ -declare function getStrideLength(vectorLength: number): number; -export { getFloatLength, getStrideLength, getVectorLength }; +export function getStrideLength(vectorLength: number): number; diff --git a/types/three/src/renderers/common/BundleGroup.d.ts b/types/three/src/renderers/common/BundleGroup.d.ts index d9fd773ee758bf..937afe339a2b2a 100644 --- a/types/three/src/renderers/common/BundleGroup.d.ts +++ b/types/three/src/renderers/common/BundleGroup.d.ts @@ -1,4 +1,5 @@ import { Group } from "../../objects/Group.js"; + /** * A specialized group which enables applications access to the * Render Bundle API of WebGPU. The group with all its descendant nodes @@ -12,14 +13,22 @@ import { Group } from "../../objects/Group.js"; * @augments Group */ declare class BundleGroup extends Group { - readonly isBundleGroup: true; - readonly type: string; - static: boolean; - version: number; /** - * Constructs a new bundle group. + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isBundleGroup: boolean; + /** + * The bundle group's version. + * + * @type {number} + * @readonly + * @default 0 */ - constructor(); + readonly version: number; /** * Set this property to `true` when the bundle group has changed. * @@ -29,4 +38,5 @@ declare class BundleGroup extends Group { */ set needsUpdate(value: boolean); } + export default BundleGroup; diff --git a/types/three/src/renderers/common/CanvasTarget.d.ts b/types/three/src/renderers/common/CanvasTarget.d.ts index fb337706733bbb..fad50f862b911e 100644 --- a/types/three/src/renderers/common/CanvasTarget.d.ts +++ b/types/three/src/renderers/common/CanvasTarget.d.ts @@ -3,31 +3,87 @@ import { Vector2 } from "../../math/Vector2.js"; import { Vector4 } from "../../math/Vector4.js"; import { DepthTexture } from "../../textures/DepthTexture.js"; import { FramebufferTexture } from "../../textures/FramebufferTexture.js"; + export interface CanvasTargetEventMap { resize: {}; dispose: {}; } + /** * CanvasTarget is a class that represents the final output destination of the renderer. * * @augments EventDispatcher */ declare class CanvasTarget extends EventDispatcher { - domElement: HTMLCanvasElement; - _pixelRatio: number; - _width: number; - _height: number; - _viewport: Vector4; - _scissor: Vector4; - _scissorTest: boolean; - colorTexture: FramebufferTexture; - depthTexture: DepthTexture; /** * Constructs a new CanvasTarget. * * @param {HTMLCanvasElement|OffscreenCanvas} domElement - The canvas element to render to. */ - constructor(domElement: HTMLCanvasElement); + constructor(domElement: HTMLCanvasElement | OffscreenCanvas); + /** + * A reference to the canvas element the renderer is drawing to. + * This value of this property will automatically be created by + * the renderer. + * + * @type {HTMLCanvasElement|OffscreenCanvas} + */ + domElement: HTMLCanvasElement | OffscreenCanvas; + /** + * The renderer's pixel ratio. + * + * @private + * @type {number} + * @default 1 + */ + private _pixelRatio; + /** + * The width of the renderer's default framebuffer in logical pixel unit. + * + * @private + * @type {number} + */ + private _width; + /** + * The height of the renderer's default framebuffer in logical pixel unit. + * + * @private + * @type {number} + */ + private _height; + /** + * The viewport of the renderer in logical pixel unit. + * + * @private + * @type {Vector4} + */ + private _viewport; + /** + * The scissor rectangle of the renderer in logical pixel unit. + * + * @private + * @type {Vector4} + */ + private _scissor; + /** + * Whether the scissor test should be enabled or not. + * + * @private + * @type {boolean} + */ + private _scissorTest; + /** + * The color texture of the default framebuffer. + * + * @type {FramebufferTexture} + */ + colorTexture: FramebufferTexture; + /** + * The depth texture of the default framebuffer. + * + * @type {DepthTexture} + */ + depthTexture: DepthTexture; /** * Returns the pixel ratio. * @@ -83,6 +139,10 @@ declare class CanvasTarget extends EventDispatcher { * @return {Vector4} The scissor rectangle. */ getScissor(target: Vector4): Vector4; + /** + * Defines the scissor rectangle. + */ + setScissor(x: Vector4): void; /** * Defines the scissor rectangle. * @@ -92,7 +152,6 @@ declare class CanvasTarget extends EventDispatcher { * @param {number} width - The width of the scissor box in logical pixel unit. * @param {number} height - The height of the scissor box in logical pixel unit. */ - setScissor(x: Vector4): void; setScissor(x: number, y: number, width: number, height: number): void; /** * Returns the scissor test value. @@ -113,6 +172,10 @@ declare class CanvasTarget extends EventDispatcher { * @return {Vector4} The viewport definition. */ getViewport(target: Vector4): Vector4; + /** + * Defines the viewport. + */ + setViewport(x: Vector4): void; /** * Defines the viewport. * @@ -123,14 +186,13 @@ declare class CanvasTarget extends EventDispatcher { * @param {number} minDepth - The minimum depth value of the viewport. WebGPU only. * @param {number} maxDepth - The maximum depth value of the viewport. WebGPU only. */ - setViewport(x: Vector4): void; setViewport(x: number, y: number, width: number, height: number, minDepth?: number, maxDepth?: number): void; /** * Dispatches the resize event. * * @private */ - _dispatchResize(): void; + private _dispatchResize; /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. @@ -139,4 +201,5 @@ declare class CanvasTarget extends EventDispatcher { */ dispose(): void; } + export default CanvasTarget; diff --git a/types/three/src/renderers/common/ChainMap.d.ts b/types/three/src/renderers/common/ChainMap.d.ts index cdc517cb9998b7..d467ebfc04b2b6 100644 --- a/types/three/src/renderers/common/ChainMap.d.ts +++ b/types/three/src/renderers/common/ChainMap.d.ts @@ -1,4 +1,3 @@ -type RecursiveWeakMap = WeakMap>; /** * Data structure for the renderer. It allows defining values * with chained, hierarchical keys. Keys are meant to be @@ -7,26 +6,29 @@ type RecursiveWeakMap = WeakMap { - weakMaps: Record>; +declare class ChainMap { /** - * Constructs a new Chain Map. + * A map of Weak Maps by their key length. + * + * @type {Object} */ - constructor(); + weakMaps: { + [x: number]: WeakMap; + }; /** * Returns the Weak Map for the given keys. * * @param {Array} keys - List of keys. * @return {WeakMap} The weak map. */ - _getWeakMap(keys: K): RecursiveWeakMap; + _getWeakMap(keys: object[]): WeakMap; /** * Returns the value for the given array of keys. * * @param {Array} keys - List of keys. * @return {any} The value. Returns `undefined` if no value was found. */ - get(keys: K): V | undefined; + get(keys: object[]): unknown; /** * Sets the value for the given keys. * @@ -34,13 +36,14 @@ declare class ChainMap { * @param {any} value - The value to set. * @return {ChainMap} A reference to this Chain Map. */ - set(keys: K, value: V): this; + set(keys: object[], value: unknown): ChainMap; /** * Deletes a value for the given keys. * * @param {Array} keys - The keys. * @return {boolean} Returns `true` if the value has been removed successfully and `false` if the value has not be found. */ - delete(keys: K): boolean; + delete(keys: object[]): boolean; } + export default ChainMap; diff --git a/types/three/src/renderers/common/ClippingContext.d.ts b/types/three/src/renderers/common/ClippingContext.d.ts index 5577e211166d54..e0848b1d4d60a7 100644 --- a/types/three/src/renderers/common/ClippingContext.d.ts +++ b/types/three/src/renderers/common/ClippingContext.d.ts @@ -5,6 +5,7 @@ import { Plane } from "../../math/Plane.js"; import { Vector4 } from "../../math/Vector4.js"; import { ClippingGroup } from "../../objects/ClippingGroup.js"; import { Scene } from "../../scenes/Scene.js"; + /** * Represents the state that is used to perform clipping via clipping planes. * There is a default clipping context for each render context. When the @@ -14,22 +15,71 @@ import { Scene } from "../../scenes/Scene.js"; * @private */ declare class ClippingContext { - version: number; + /** + * Constructs a new clipping context. + * + * @param {?ClippingContext} [parentContext=null] - A reference to the parent clipping context. + */ + constructor(parentContext?: ClippingContext | null); + /** + * The clipping context's version. + * + * @type {number} + * @readonly + */ + readonly version: number; + /** + * Whether the intersection of the clipping planes is used to clip objects, rather than their union. + * + * @type {?boolean} + * @default null + */ clipIntersection: boolean | null; + /** + * The clipping context's cache key. + * + * @type {string} + */ cacheKey: string; - intersectionPlanes?: Plane[]; - unionPlanes?: Plane[]; + /** + * Whether the shadow pass is active or not. + * + * @type {boolean} + * @default false + */ + shadowPass: boolean; + /** + * The view normal matrix. + * + * @type {Matrix3} + */ viewNormalMatrix: Matrix3; + /** + * Internal cache for maintaining clipping contexts. + * + * @type {WeakMap} + */ clippingGroupContexts: WeakMap; - shadowPass: boolean; - viewMatrix?: Matrix4; - parentVersion: number | null; /** - * Constructs a new clipping context. + * The intersection planes. * - * @param {?ClippingContext} [parentContext=null] - A reference to the parent clipping context. + * @type {Array} */ - constructor(parentContext?: ClippingContext | null); + intersectionPlanes: Vector4[]; + /** + * The intersection planes. + * + * @type {Array} + */ + unionPlanes: Vector4[]; + /** + * The version of the clipping context's parent context. + * + * @type {?number} + * @readonly + */ + readonly parentVersion: number | null; + viewMatrix?: Matrix4; /** * Projects the given source clipping planes and writes the result into the * destination array. @@ -38,7 +88,7 @@ declare class ClippingContext { * @param {Array} destination - The destination. * @param {number} offset - The offset. */ - projectPlanes(source: readonly Plane[], destination: readonly Vector4[], offset: number): void; + projectPlanes(source: Plane[], destination: Vector4[], offset: number): void; /** * Updates the root clipping context of a scene. * @@ -68,4 +118,5 @@ declare class ClippingContext { */ get unionClippingCount(): number; } + export default ClippingContext; diff --git a/types/three/src/renderers/common/Color4.d.ts b/types/three/src/renderers/common/Color4.d.ts index 3bad626ec74085..884b1f02fbe57b 100644 --- a/types/three/src/renderers/common/Color4.d.ts +++ b/types/three/src/renderers/common/Color4.d.ts @@ -1,4 +1,5 @@ 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 @@ -8,19 +9,22 @@ import { Color, ColorRepresentation } from "../../math/Color.js"; * @augments Color */ declare class Color4 extends Color { - a: number; /** * Constructs a new four-component color. - * You can also pass a single THREE.Color, hex or + * You can pass a single THREE.Color, hex or * string argument to this constructor. + */ + constructor(color?: ColorRepresentation); + /** + * Constructs a new four-component color. * - * @param {number|string} [r=1] - The red value. + * @param {number} [r=1] - The red value. * @param {number} [g=1] - The green value. * @param {number} [b=1] - The blue value. * @param {number} [a=1] - The alpha value. */ - constructor(color?: ColorRepresentation); constructor(r: number, g: number, b: number, a?: number); + a: number; /** * Overwrites the default to honor alpha. * You can also pass a single THREE.Color, hex or @@ -39,7 +43,7 @@ declare class Color4 extends Color { * @param {Color4} color - The color to copy. * @return {Color4} A reference to this object. */ - copy(color: Color): this; + copy(color: Color4): this; /** * Overwrites the default to honor alpha. * @@ -47,4 +51,5 @@ declare class Color4 extends Color { */ clone(): this; } + export default Color4; diff --git a/types/three/src/renderers/common/ComputePipeline.d.ts b/types/three/src/renderers/common/ComputePipeline.d.ts index acb14a531edfc1..a8ada4fe5bc7bd 100644 --- a/types/three/src/renderers/common/ComputePipeline.d.ts +++ b/types/three/src/renderers/common/ComputePipeline.d.ts @@ -1,5 +1,6 @@ import Pipeline from "./Pipeline.js"; import ProgrammableStage from "./ProgrammableStage.js"; + /** * Class for representing compute pipelines. * @@ -7,8 +8,6 @@ import ProgrammableStage from "./ProgrammableStage.js"; * @augments Pipeline */ declare class ComputePipeline extends Pipeline { - computeProgram: ProgrammableStage; - readonly isComputePipeline: true; /** * Constructs a new render pipeline. * @@ -16,5 +15,20 @@ declare class ComputePipeline extends Pipeline { * @param {ProgrammableStage} computeProgram - The pipeline's compute shader. */ constructor(cacheKey: string, computeProgram: ProgrammableStage); + /** + * The pipeline's compute shader. + * + * @type {ProgrammableStage} + */ + computeProgram: ProgrammableStage; + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isComputePipeline: boolean; } + export default ComputePipeline; diff --git a/types/three/src/renderers/common/Constants.d.ts b/types/three/src/renderers/common/Constants.d.ts index 8e036f2eaa027a..0ded1192bf06f5 100644 --- a/types/three/src/renderers/common/Constants.d.ts +++ b/types/three/src/renderers/common/Constants.d.ts @@ -5,6 +5,8 @@ export declare const AttributeType: { readonly INDIRECT: 4; }; export type AttributeType = (typeof AttributeType)[keyof typeof AttributeType]; -export declare const GPU_CHUNK_BYTES = 16; -export declare const BlendColorFactor = 211; -export declare const OneMinusBlendColorFactor = 212; + +export const GPU_CHUNK_BYTES: 16; + +export const BlendColorFactor: 211; +export const OneMinusBlendColorFactor: 212; diff --git a/types/three/src/renderers/common/CubeRenderTarget.d.ts b/types/three/src/renderers/common/CubeRenderTarget.d.ts index 9bca1fa54a2b2e..6f129a159024e7 100644 --- a/types/three/src/renderers/common/CubeRenderTarget.d.ts +++ b/types/three/src/renderers/common/CubeRenderTarget.d.ts @@ -1,15 +1,14 @@ -import { RenderTargetOptions } from "../../core/RenderTarget.js"; -import { WebGLCubeRenderTarget } from "../../renderers/WebGLCubeRenderTarget.js"; +import { RenderTarget, RenderTargetOptions } from "../../core/RenderTarget.js"; import { Texture } from "../../textures/Texture.js"; -import { WebGLRenderer } from "../WebGLRenderer.js"; +import Renderer from "./Renderer.js"; + /** * This class represents a cube render target. It is a special version * of `WebGLCubeRenderTarget` which is compatible with `WebGPURenderer`. * - * @augments WebGLCubeRenderTarget + * @augments RenderTarget */ -declare class CubeRenderTarget extends WebGLCubeRenderTarget { - readonly isCubeRenderTarget: true; +declare class CubeRenderTarget extends RenderTarget { /** * Constructs a new cube render target. * @@ -17,6 +16,14 @@ declare class CubeRenderTarget extends WebGLCubeRenderTarget { * @param {RenderTarget~Options} [options] - The configuration object. */ constructor(size?: number, options?: RenderTargetOptions); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isCubeRenderTarget: boolean; /** * Converts the given equirectangular texture to a cube map. * @@ -24,6 +31,16 @@ declare class CubeRenderTarget extends WebGLCubeRenderTarget { * @param {Texture} texture - The equirectangular texture. * @return {CubeRenderTarget} A reference to this cube render target. */ - fromEquirectangularTexture(renderer: WebGLRenderer, texture: Texture): this; + fromEquirectangularTexture(renderer: Renderer, texture: Texture): this; + /** + * Clears this cube render target. + * + * @param {Renderer} renderer - The renderer. + * @param {boolean} [color=true] - Whether the color buffer should be cleared or not. + * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not. + * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not. + */ + clear(renderer: Renderer, color?: boolean, depth?: boolean, stencil?: boolean): void; } + export default CubeRenderTarget; diff --git a/types/three/src/renderers/common/DataMap.d.ts b/types/three/src/renderers/common/DataMap.d.ts index 18f4539ab80393..fb9571fa09f6ce 100644 --- a/types/three/src/renderers/common/DataMap.d.ts +++ b/types/three/src/renderers/common/DataMap.d.ts @@ -4,47 +4,39 @@ * * @private */ -declare class DataMap< - M extends { - [key: string]: { - key: object; - value: unknown; - }; - }, -> { - data: WeakMap; +declare class DataMap { /** - * Constructs a new data map. + * `DataMap` internally uses a weak map + * to manage its data. + * + * @type {WeakMap} */ - constructor(); + data: WeakMap; /** * Returns the dictionary for the given object. * * @param {Object} object - The object. * @return {Object} The dictionary. */ - get(object: K): Extract["value"]; + get(object: object): unknown; /** * Deletes the dictionary for the given object. * * @param {Object} object - The object. * @return {?Object} The deleted dictionary. */ - delete(object: K): Extract["value"]; + delete(object: object): unknown | null; /** * Returns `true` if the given object has a dictionary defined. * * @param {Object} object - The object to test. * @return {boolean} Whether a dictionary is defined or not. */ - has(object: M[keyof M]["key"]): boolean; + has(object: object): boolean; /** * Frees internal resources. */ dispose(): void; } + export default DataMap; diff --git a/types/three/src/renderers/common/Geometries.d.ts b/types/three/src/renderers/common/Geometries.d.ts index fb0cf4ddbac2c4..74ab02700d1849 100644 --- a/types/three/src/renderers/common/Geometries.d.ts +++ b/types/three/src/renderers/common/Geometries.d.ts @@ -1,31 +1,18 @@ import { BufferAttribute } from "../../core/BufferAttribute.js"; import { BufferGeometry } from "../../core/BufferGeometry.js"; -import { InterleavedBuffer } from "../../core/InterleavedBuffer.js"; -import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribute.js"; import Attributes from "./Attributes.js"; import { AttributeType } from "./Constants.js"; import DataMap from "./DataMap.js"; import Info from "./Info.js"; import RenderObject from "./RenderObject.js"; -interface GeometryData { - initialized?: boolean | undefined; -} + /** * This renderer module manages geometries. * * @private * @augments DataMap */ -declare class Geometries extends DataMap<{ - geometry: { - key: BufferGeometry; - value: GeometryData; - }; -}> { - attributes: Attributes; - info: Info; - wireframes: WeakMap; - attributeCall: WeakMap; +declare class Geometries extends DataMap { /** * Constructs a new geometry management component. * @@ -33,13 +20,45 @@ declare class Geometries extends DataMap<{ * @param {Info} info - Renderer component for managing metrics and monitoring data. */ constructor(attributes: Attributes, info: Info); + /** + * Renderer component for managing attributes. + * + * @type {Attributes} + */ + attributes: Attributes; + /** + * Renderer component for managing metrics and monitoring data. + * + * @type {Info} + */ + info: Info; + /** + * Weak Map for managing attributes for wireframe rendering. + * + * @type {WeakMap} + */ + wireframes: WeakMap; + /** + * This Weak Map is used to make sure buffer attributes are + * updated only once per render call. + * + * @type {WeakMap} + */ + attributeCall: WeakMap; + /** + * Stores the event listeners attached to geometries. + * + * @private + * @type {Map} + */ + private _geometryDisposeListeners; /** * Returns `true` if the given render object has an initialized geometry. * * @param {RenderObject} renderObject - The render object. * @return {boolean} Whether if the given render object has an initialized geometry or not. */ - has(renderObject: RenderObject | BufferGeometry): boolean; + has(renderObject: RenderObject): boolean; /** * Prepares the geometry of the given render object for rendering. * @@ -64,21 +83,21 @@ declare class Geometries extends DataMap<{ * @param {BufferAttribute} attribute - The attribute to update. * @param {number} type - The attribute type. */ - updateAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, type: AttributeType): void; + updateAttribute(attribute: BufferAttribute, type: AttributeType): void; /** * Returns the indirect buffer attribute of the given render object. * * @param {RenderObject} renderObject - The render object. * @return {?BufferAttribute} The indirect attribute. `null` if no indirect drawing is used. */ - getIndirect(renderObject: RenderObject): import("./IndirectStorageBufferAttribute.js").default | null; + getIndirect(renderObject: RenderObject): BufferAttribute | null; /** * Returns the byte offset into the indirect attribute buffer of the given render object. * * @param {RenderObject} renderObject - The render object. * @return {number} The byte offset into the indirect attribute buffer. */ - getIndirectOffset(renderObject: RenderObject): number | number[]; + getIndirectOffset(renderObject: RenderObject): number; /** * Returns the index of the given render object's geometry. This is implemented * in a method to return a wireframe index if necessary. @@ -87,6 +106,6 @@ declare class Geometries extends DataMap<{ * @return {?BufferAttribute} The index. Returns `null` for non-indexed geometries. */ getIndex(renderObject: RenderObject): BufferAttribute | null; - dispose(): void; } + export default Geometries; diff --git a/types/three/src/renderers/common/Info.d.ts b/types/three/src/renderers/common/Info.d.ts index aa0621cdc0a6e3..351f20a47ad017 100644 --- a/types/three/src/renderers/common/Info.d.ts +++ b/types/three/src/renderers/common/Info.d.ts @@ -1,14 +1,53 @@ import { Object3D } from "../../core/Object3D.js"; + /** * This renderer module provides a series of statistical information * about the GPU memory and the rendering process. Useful for debugging * and monitoring. */ declare class Info { + /** + * Whether frame related metrics should automatically + * be resetted or not. This property should be set to `false` + * by apps which manage their own animation loop. They must + * then call `renderer.info.reset()` once per frame manually. + * + * @type {boolean} + * @default true + */ autoReset: boolean; - frame: number; - calls: number; - render: { + /** + * The current frame ID. This ID is managed + * by `NodeFrame`. + * + * @type {number} + * @readonly + * @default 0 + */ + readonly frame: number; + /** + * The number of render calls since the + * app has been started. + * + * @type {number} + * @readonly + * @default 0 + */ + readonly calls: number; + /** + * Render related metrics. + * + * @type {Object} + * @readonly + * @property {number} calls - The number of render calls since the app has been started. + * @property {number} frameCalls - The number of render calls of the current frame. + * @property {number} drawCalls - The number of draw calls of the current frame. + * @property {number} triangles - The number of rendered triangle primitives of the current frame. + * @property {number} points - The number of rendered point primitives of the current frame. + * @property {number} lines - The number of rendered line primitives of the current frame. + * @property {number} timestamp - The timestamp of the frame. + */ + readonly render: { calls: number; frameCalls: number; drawCalls: number; @@ -17,19 +56,32 @@ declare class Info { lines: number; timestamp: number; }; - compute: { + /** + * Compute related metrics. + * + * @type {Object} + * @readonly + * @property {number} calls - The number of compute calls since the app has been started. + * @property {number} frameCalls - The number of compute calls of the current frame. + * @property {number} timestamp - The timestamp of the frame when using `renderer.computeAsync()`. + */ + readonly compute: { calls: number; frameCalls: number; timestamp: number; }; - memory: { + /** + * Memory related metrics. + * + * @type {Object} + * @readonly + * @property {number} geometries - The number of active geometries. + * @property {number} frameCalls - The number of active textures. + */ + readonly memory: { geometries: number; textures: number; }; - /** - * Constructs a new info component. - */ - constructor(); /** * This method should be executed per draw call and updates the corresponding metrics. * @@ -47,4 +99,5 @@ declare class Info { */ dispose(): void; } + export default Info; diff --git a/types/three/src/renderers/common/InspectorBase.d.ts b/types/three/src/renderers/common/InspectorBase.d.ts index 9e9b13ff43e51e..e86c5818b0ad0d 100644 --- a/types/three/src/renderers/common/InspectorBase.d.ts +++ b/types/three/src/renderers/common/InspectorBase.d.ts @@ -1,39 +1,50 @@ import { Camera } from "../../cameras/Camera.js"; import { RenderTarget } from "../../core/RenderTarget.js"; +import Node from "../../nodes/core/Node.js"; +import NodeFrame from "../../nodes/core/NodeFrame.js"; import ComputeNode from "../../nodes/gpgpu/ComputeNode.js"; import { Scene } from "../../scenes/Scene.js"; import { Texture } from "../../textures/Texture.js"; import Renderer from "./Renderer.js"; + /** * InspectorBase is the base class for all inspectors. * * @class InspectorBase */ declare class InspectorBase { - _renderer: Renderer | null; /** - * Creates a new InspectorBase. + * The renderer associated with this inspector. + * + * @type {WebGLRenderer} + * @private + */ + private _renderer; + /** + * The current frame being processed. + * + * @type {Object} */ - constructor(); + currentFrame: unknown; /** * Returns the node frame for the current renderer. * * @return {Object} The node frame. */ - get nodeFrame(): import("../../Three.WebGPU.Nodes.js").NodeFrame; + get nodeFrame(): NodeFrame; /** * Sets the renderer for this inspector. * * @param {WebGLRenderer} renderer - The renderer to associate with this inspector. * @return {InspectorBase} This inspector instance. */ - setRenderer(renderer: Renderer | null): this; + setRenderer(renderer: Renderer): InspectorBase; /** * Returns the renderer associated with this inspector. * * @return {WebGLRenderer} The associated renderer. */ - getRenderer(): Renderer | null; + getRenderer(): Renderer; /** * Initializes the inspector. */ @@ -51,7 +62,7 @@ declare class InspectorBase { * * @param {Node} node - The node to inspect. */ - inspect(): void; + inspect(node: Node): void; /** * When a compute operation is performed. * @@ -102,4 +113,5 @@ declare class InspectorBase { */ copyFramebufferToTexture(framebufferTexture: Texture): void; } + export default InspectorBase; diff --git a/types/three/src/renderers/common/Lighting.d.ts b/types/three/src/renderers/common/Lighting.d.ts index 72842e6e7a3c6a..6570d9c3b78fce 100644 --- a/types/three/src/renderers/common/Lighting.d.ts +++ b/types/three/src/renderers/common/Lighting.d.ts @@ -1,15 +1,11 @@ -import { Camera } from "../../cameras/Camera.js"; import { Object3D } from "../../core/Object3D.js"; import { Light } from "../../lights/Light.js"; import LightsNode from "../../nodes/lighting/LightsNode.js"; -import ChainMap from "./ChainMap.js"; - -declare class Lighting extends ChainMap<[Object3D, Camera], LightsNode> { - constructor(); +declare class Lighting { createNode(lights?: Light[]): LightsNode; - getNode(scene: Object3D, camera: Camera): LightsNode; + getNode(scene: Object3D): LightsNode; } export default Lighting; diff --git a/types/three/src/renderers/common/Pipeline.d.ts b/types/three/src/renderers/common/Pipeline.d.ts index 6e7fae7b1b4a01..16708fb9463937 100644 --- a/types/three/src/renderers/common/Pipeline.d.ts +++ b/types/three/src/renderers/common/Pipeline.d.ts @@ -5,13 +5,25 @@ * @abstract */ declare class Pipeline { - cacheKey: string; - usedTimes: number; /** * Constructs a new pipeline. * * @param {string} cacheKey - The pipeline's cache key. */ constructor(cacheKey: string); + /** + * The pipeline's cache key. + * + * @type {string} + */ + cacheKey: string; + /** + * How often the pipeline is currently in use. + * + * @type {number} + * @default 0 + */ + usedTimes: number; } + export default Pipeline; diff --git a/types/three/src/renderers/common/Pipelines.d.ts b/types/three/src/renderers/common/Pipelines.d.ts index 6203e6ab84ce9f..36246ce378c6b6 100644 --- a/types/three/src/renderers/common/Pipelines.d.ts +++ b/types/three/src/renderers/common/Pipelines.d.ts @@ -1,53 +1,69 @@ import ComputeNode from "../../nodes/gpgpu/ComputeNode.js"; import Backend from "./Backend.js"; -import Binding from "./Binding.js"; +import BindGroup from "./BindGroup.js"; import Bindings from "./Bindings.js"; import ComputePipeline from "./ComputePipeline.js"; import DataMap from "./DataMap.js"; -import Nodes from "./nodes/Nodes.js"; +import NodeManager from "./nodes/NodeManager.js"; import Pipeline from "./Pipeline.js"; import ProgrammableStage from "./ProgrammableStage.js"; import RenderObject from "./RenderObject.js"; -import RenderPipeline from "./RenderPipeline.js"; -interface ComputeNodeData { - version: number; - pipeline: ComputePipeline; -} -interface RenderObjectData { - pipeline: RenderPipeline; -} +import RenderObjectPipeline from "./RenderObjectPipeline.js"; + /** * This renderer module manages the pipelines of the renderer. * * @private * @augments DataMap */ -declare class Pipelines extends DataMap<{ - computeNode: { - key: ComputeNode; - value: ComputeNodeData; - }; - renderObject: { - key: RenderObject; - value: RenderObjectData; - }; -}> { +declare class Pipelines extends DataMap { + /** + * Constructs a new pipeline management component. + * + * @param {Backend} backend - The renderer's backend. + * @param {Nodes} nodes - Renderer component for managing nodes related logic. + */ + constructor(backend: Backend, nodes: NodeManager); + /** + * The renderer's backend. + * + * @type {Backend} + */ backend: Backend; - nodes: Nodes; + /** + * Renderer component for managing nodes related logic. + * + * @type {Nodes} + */ + nodes: NodeManager; + /** + * A references to the bindings management component. + * This reference will be set inside the `Bindings` + * constructor. + * + * @type {?Bindings} + * @default null + */ bindings: Bindings | null; + /** + * Internal cache for maintaining pipelines. + * The key of the map is a cache key, the value the pipeline. + * + * @type {Map} + */ caches: Map; + /** + * This dictionary maintains for each shader stage type (vertex, + * fragment and compute) the programmable stage objects which + * represent the actual shader code. + * + * @type {Object>} + */ programs: { vertex: Map; fragment: Map; compute: Map; }; - /** - * Constructs a new pipeline management component. - * - * @param {Backend} backend - The renderer's backend. - * @param {Nodes} nodes - Renderer component for managing nodes related logic. - */ - constructor(backend: Backend, nodes: Nodes); /** * Returns a compute pipeline for the given compute node. * @@ -55,26 +71,22 @@ declare class Pipelines extends DataMap<{ * @param {Array} bindings - The bindings. * @return {ComputePipeline} The compute pipeline. */ - getForCompute(computeNode: ComputeNode, bindings: Binding[]): ComputePipeline; + getForCompute(computeNode: ComputeNode, bindings: BindGroup[]): ComputePipeline; /** * Returns a render pipeline for the given render object. * * @param {RenderObject} renderObject - The render object. * @param {?Array} [promises=null] - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`. - * @return {RenderPipeline} The render pipeline. + * @return {RenderObjectPipeline} The render pipeline. */ - getForRender(renderObject: RenderObject, promises?: Promise[] | null): RenderPipeline; + getForRender(renderObject: RenderObject, promises?: Promise[] | null): RenderObjectPipeline; /** * Deletes the pipeline for the given render object. * * @param {RenderObject} object - The render object. * @return {?Object} The deleted dictionary. */ - delete(object: ComputeNode | RenderObject): never; - /** - * Frees internal resources. - */ - dispose(): void; + delete(object: RenderObject): unknown; /** * Updates the pipeline for the given render object. * @@ -91,12 +103,7 @@ declare class Pipelines extends DataMap<{ * @param {Array} bindings - The bindings. * @return {ComputePipeline} The compute pipeline. */ - _getComputePipeline( - computeNode: ComputeNode, - stageCompute: ProgrammableStage, - cacheKey: string, - bindings: Binding[], - ): ComputePipeline; + private _getComputePipeline; /** * Returns a render pipeline for the given parameters. * @@ -106,15 +113,9 @@ declare class Pipelines extends DataMap<{ * @param {ProgrammableStage} stageFragment - The programmable stage representing the fragment shader. * @param {string} cacheKey - The cache key. * @param {?Array} promises - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`. - * @return {ComputePipeline} The compute pipeline. + * @return {RenderObjectPipeline} The render pipeline. */ - _getRenderPipeline( - renderObject: RenderObject, - stageVertex: ProgrammableStage, - stageFragment: ProgrammableStage, - cacheKey: string, - promises: Promise[] | null, - ): RenderPipeline; + private _getRenderPipeline; /** * Computes a cache key representing a compute pipeline. * @@ -123,7 +124,7 @@ declare class Pipelines extends DataMap<{ * @param {ProgrammableStage} stageCompute - The programmable stage representing the compute shader. * @return {string} The cache key. */ - _getComputeCacheKey(computeNode: ComputeNode, stageCompute: ProgrammableStage): string; + private _getComputeCacheKey; /** * Computes a cache key representing a render pipeline. * @@ -133,25 +134,21 @@ declare class Pipelines extends DataMap<{ * @param {ProgrammableStage} stageFragment - The programmable stage representing the fragment shader. * @return {string} The cache key. */ - _getRenderCacheKey( - renderObject: RenderObject, - stageVertex: ProgrammableStage, - stageFragment: ProgrammableStage, - ): string; + private _getRenderCacheKey; /** * Releases the given pipeline. * * @private * @param {Pipeline} pipeline - The pipeline to release. */ - _releasePipeline(pipeline: Pipeline): void; + private _releasePipeline; /** * Releases the shader program. * * @private * @param {Object} program - The shader program to release. */ - _releaseProgram(program: ProgrammableStage): void; + private _releaseProgram; /** * Returns `true` if the compute pipeline for the given compute node requires an update. * @@ -159,7 +156,7 @@ declare class Pipelines extends DataMap<{ * @param {Node} computeNode - The compute node. * @return {boolean} Whether the compute pipeline for the given compute node requires an update or not. */ - _needsComputeUpdate(computeNode: ComputeNode): boolean; + private _needsComputeUpdate; /** * Returns `true` if the render pipeline for the given render object requires an update. * @@ -167,6 +164,7 @@ declare class Pipelines extends DataMap<{ * @param {RenderObject} renderObject - The render object. * @return {boolean} Whether the render object for the given render object requires an update or not. */ - _needsRenderUpdate(renderObject: RenderObject): true | void; + private _needsRenderUpdate; } + export default Pipelines; diff --git a/types/three/src/renderers/common/PostProcessing.d.ts b/types/three/src/renderers/common/PostProcessing.d.ts index 3b0566150eea89..66d1b5ece6aa3c 100644 --- a/types/three/src/renderers/common/PostProcessing.d.ts +++ b/types/three/src/renderers/common/PostProcessing.d.ts @@ -1,24 +1,21 @@ import { Node } from "../../nodes/Nodes.js"; import Renderer from "./Renderer.js"; - -declare class PostProcessing { - renderer: Renderer; - outputNode: Node; - - outputColorTransform: boolean; - - needsUpdate: boolean; - - constructor(renderer: Renderer, outputNode?: Node); - - render(): void; - - dispose(): void; - +import RenderPipeline from "./RenderPipeline.js"; + +/** + * @deprecated Use {@link RenderPipeline} instead. PostProcessing has been renamed to RenderPipeline. + * + * This class is a wrapper for backward compatibility and will be removed in a future version. + */ +declare class PostProcessing extends RenderPipeline { /** - * @deprecated "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer. + * Constructs a new post processing management module. + * + * @param {Renderer} renderer - A reference to the renderer. + * @param {Node} outputNode - An optional output node. + * @deprecated since r183. Use {@link RenderPipeline} instead. */ - renderAsync(): Promise; + constructor(renderer: Renderer, outputNode?: Node); } export default PostProcessing; diff --git a/types/three/src/renderers/common/ProgrammableStage.d.ts b/types/three/src/renderers/common/ProgrammableStage.d.ts index 9c54ca9658d6d2..281619ac8b0f59 100644 --- a/types/three/src/renderers/common/ProgrammableStage.d.ts +++ b/types/three/src/renderers/common/ProgrammableStage.d.ts @@ -1,4 +1,5 @@ import NodeAttribute from "../../nodes/core/NodeAttribute.js"; + /** * Class for representing programmable stages which are vertex, * fragment or compute shaders. Unlike fixed-function states (like blending), @@ -7,12 +8,6 @@ import NodeAttribute from "../../nodes/core/NodeAttribute.js"; * @private */ declare class ProgrammableStage { - id: number; - code: string; - stage: "compute" | "vertex" | "fragment"; - name: string; - attributes: NodeAttribute[] | null; - usedTimes: number; /** * Constructs a new programmable stage. * @@ -24,10 +19,55 @@ declare class ProgrammableStage { */ constructor( code: string, - stage: "compute" | "vertex" | "fragment", + stage: "vertex" | "fragment" | "compute", name: string, - transforms?: null, + transforms?: unknown[] | null, attributes?: NodeAttribute[] | null, ); + /** + * The id of the programmable stage. + * + * @type {number} + */ + id: number; + /** + * The shader code. + * + * @type {string} + */ + code: string; + /** + * The type of stage. + * + * @type {string} + */ + stage: "vertex" | "fragment" | "compute"; + /** + * The name of the stage. + * This is used for debugging purposes. + * + * @type {string} + */ + name: string; + /** + * The transforms (only relevant for compute stages with WebGL 2 which uses Transform Feedback). + * + * @type {?Array} + */ + transforms: unknown[] | null; + /** + * The attributes (only relevant for compute stages with WebGL 2 which uses Transform Feedback). + * + * @type {?Array} + */ + attributes: NodeAttribute[] | null; + /** + * How often the programmable stage is currently in use. + * + * @type {number} + * @default 0 + */ + usedTimes: number; } + export default ProgrammableStage; diff --git a/types/three/src/renderers/common/RenderBundle.d.ts b/types/three/src/renderers/common/RenderBundle.d.ts index f0ed002dd4ac5d..26da454cbed14f 100644 --- a/types/three/src/renderers/common/RenderBundle.d.ts +++ b/types/three/src/renderers/common/RenderBundle.d.ts @@ -1,5 +1,6 @@ import { Camera } from "../../cameras/Camera.js"; import BundleGroup from "./BundleGroup.js"; + /** * This module is used to represent render bundles inside the renderer * for further processing. @@ -7,8 +8,6 @@ import BundleGroup from "./BundleGroup.js"; * @private */ declare class RenderBundle { - bundleGroup: BundleGroup; - camera: Camera; /** * Constructs a new bundle group. * @@ -16,5 +15,8 @@ declare class RenderBundle { * @param {Camera} camera - The camera the bundle group is rendered with. */ constructor(bundleGroup: BundleGroup, camera: Camera); + bundleGroup: BundleGroup; + camera: Camera; } + export default RenderBundle; diff --git a/types/three/src/renderers/common/RenderBundles.d.ts b/types/three/src/renderers/common/RenderBundles.d.ts index 8ad36964b33b52..26017877b5444a 100644 --- a/types/three/src/renderers/common/RenderBundles.d.ts +++ b/types/three/src/renderers/common/RenderBundles.d.ts @@ -2,17 +2,19 @@ import { Camera } from "../../cameras/Camera.js"; import BundleGroup from "./BundleGroup.js"; import ChainMap from "./ChainMap.js"; import RenderBundle from "./RenderBundle.js"; + /** * This renderer module manages render bundles. * * @private */ declare class RenderBundles { - bundles: ChainMap; /** - * Constructs a new render bundle management component. + * A chain map for maintaining the render bundles. + * + * @type {ChainMap} */ - constructor(); + bundles: ChainMap; /** * Returns a render bundle for the given bundle group and camera. * @@ -26,4 +28,5 @@ declare class RenderBundles { */ dispose(): void; } + export default RenderBundles; diff --git a/types/three/src/renderers/common/RenderContext.d.ts b/types/three/src/renderers/common/RenderContext.d.ts index 79f93fd96420c6..324b834bfae1f9 100644 --- a/types/three/src/renderers/common/RenderContext.d.ts +++ b/types/three/src/renderers/common/RenderContext.d.ts @@ -1,8 +1,11 @@ +import { Camera } from "../../cameras/Camera.js"; import { RenderTarget } from "../../core/RenderTarget.js"; import { Vector4 } from "../../math/Vector4.js"; +import MRTNode from "../../nodes/core/MRTNode.js"; import { DepthTexture } from "../../textures/DepthTexture.js"; import { Texture } from "../../textures/Texture.js"; import ClippingContext from "./ClippingContext.js"; + /** * Any render or compute command is executed in a specific context that defines * the state of the renderer and its backend. Typical examples for such context @@ -12,42 +15,205 @@ import ClippingContext from "./ClippingContext.js"; * @private */ declare class RenderContext { + /** + * The context's ID. + * + * @type {number} + */ id: number; + /** + * The MRT configuration. + * + * @type {?MRTNode} + * @default null + */ + mrt: MRTNode | null; + /** + * Whether the current active framebuffer has a color attachment. + * + * @type {boolean} + * @default true + */ color: boolean; + /** + * Whether the color attachment should be cleared or not. + * + * @type {boolean} + * @default true + */ clearColor: boolean; + /** + * The clear color value. + * + * @type {Object} + * @default true + */ clearColorValue: { r: number; g: number; b: number; a: number; }; + /** + * Whether the current active framebuffer has a depth attachment. + * + * @type {boolean} + * @default true + */ depth: boolean; + /** + * Whether the depth attachment should be cleared or not. + * + * @type {boolean} + * @default true + */ clearDepth: boolean; + /** + * The clear depth value. + * + * @type {number} + * @default 1 + */ clearDepthValue: number; + /** + * Whether the current active framebuffer has a stencil attachment. + * + * @type {boolean} + * @default false + */ stencil: boolean; + /** + * Whether the stencil attachment should be cleared or not. + * + * @type {boolean} + * @default true + */ clearStencil: boolean; + /** + * The clear stencil value. + * + * @type {number} + * @default 1 + */ clearStencilValue: number; + /** + * By default the viewport encloses the entire framebuffer If a smaller + * viewport is manually defined, this property is to `true` by the renderer. + * + * @type {boolean} + * @default false + */ viewport: boolean; + /** + * The viewport value. This value is in physical pixels meaning it incorporates + * the renderer's pixel ratio. The viewport property of render targets or + * the renderer is in logical pixels. + * + * @type {Vector4} + */ viewportValue: Vector4; + /** + * When the scissor test is active and scissor rectangle smaller than the + * framebuffers dimensions, this property is to `true` by the renderer. + * + * @type {boolean} + * @default false + */ scissor: boolean; + /** + * The scissor rectangle. + * + * @type {Vector4} + */ scissorValue: Vector4; + /** + * The active render target. + * + * @type {?RenderTarget} + * @default null + */ renderTarget: RenderTarget | null; + /** + * The textures of the active render target. + * `null` when no render target is set. + * + * @type {?Array} + * @default null + */ textures: Texture[] | null; + /** + * The depth texture of the active render target. + * `null` when no render target is set. + * + * @type {?DepthTexture} + * @default null + */ depthTexture: DepthTexture | null; + /** + * The active cube face. + * + * @type {number} + * @default 0 + */ activeCubeFace: number; + /** + * The active mipmap level. + * + * @type {number} + * @default 0 + */ + activeMipmapLevel: number; + /** + * The number of MSAA samples. This value is always `1` when + * MSAA isn't used. + * + * @type {number} + * @default 1 + */ sampleCount: number; + /** + * The active render target's width in physical pixels. + * + * @type {number} + * @default 0 + */ width: number; + /** + * The active render target's height in physical pixels. + * + * @type {number} + * @default 0 + */ height: number; + /** + * The occlusion query count. + * + * @type {number} + * @default 0 + */ occlusionQueryCount: number; + /** + * The current clipping context. + * + * @type {?ClippingContext} + * @default null + */ clippingContext: ClippingContext | null; - readonly isRenderContext: true; - depthClearValue?: number | undefined; - stencilClearValue?: number | undefined; - activeMipmapLevel?: number | undefined; /** - * Constructs a new render context. + * The current camera. + * + * @type {?Camera} + * @default null + */ + camera: Camera | null; + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true */ - constructor(); + readonly isRenderContext: boolean; /** * Returns the cache key of this render context. * @@ -55,6 +221,7 @@ declare class RenderContext { */ getCacheKey(): number; } + /** * Computes a cache key for the given render context. This key * should identify the render target state so it is possible to @@ -63,5 +230,6 @@ declare class RenderContext { * @param {RenderContext} renderContext - The render context. * @return {number} The cache key. */ -export declare function getCacheKey(renderContext: RenderContext): number; +export function getCacheKey(renderContext: RenderContext): number; + export default RenderContext; diff --git a/types/three/src/renderers/common/RenderContexts.d.ts b/types/three/src/renderers/common/RenderContexts.d.ts index d9782c4e8b4070..423b904fc083e2 100644 --- a/types/three/src/renderers/common/RenderContexts.d.ts +++ b/types/three/src/renderers/common/RenderContexts.d.ts @@ -1,52 +1,47 @@ -import { Camera } from "../../cameras/Camera.js"; import { RenderTarget } from "../../core/RenderTarget.js"; import MRTNode from "../../nodes/core/MRTNode.js"; -import { Scene } from "../../scenes/Scene.js"; -import ChainMap from "./ChainMap.js"; import RenderContext from "./RenderContext.js"; +import Renderer from "./Renderer.js"; + /** * This module manages the render contexts of the renderer. * * @private */ declare class RenderContexts { - chainMaps: { - [attachmentState: string]: ChainMap | undefined; - }; /** * Constructs a new render context management component. + * + * @param {Renderer} renderer - The renderer. */ - constructor(); + constructor(renderer: Renderer); /** - * Returns a render context for the given scene, camera and render target. + * The renderer. * - * @param {Scene} scene - The scene. - * @param {Camera} camera - The camera that is used to render the scene. - * @param {?RenderTarget} [renderTarget=null] - The active render target. - * @param {?MRT} [mrt=null] - The active multiple render target. - * @return {RenderContext} The render context. + * @type {Renderer} */ - get(scene: Scene, camera: Camera, renderTarget?: RenderTarget | null, mrt?: MRTNode | null): RenderContext; + renderer: Renderer; /** - * Returns a render context intended for clear operations. + * A dictionary that manages render contexts. * - * @param {?RenderTarget} [renderTarget=null] - The active render target. - * @return {RenderContext} The render context. + * @type {Object} */ - getForClear(renderTarget?: RenderTarget | null): RenderContext; + _renderContexts: { + [x: string]: RenderContext; + }; /** - * Returns a chain map for the given attachment state. + * Returns a render context for the given scene, camera and render target. * - * @private - * @param {string} attachmentState - The attachment state. - * @return {ChainMap} The chain map. + * @param {?RenderTarget} [renderTarget=null] - The active render target. + * @param {?MRTNode} [mrt=null] - The MRT configuration + * @param {?number} [callDepth=0] - The call depth of the renderer. + * @return {RenderContext} The render context. */ - _getChainMap( - attachmentState: string, - ): ChainMap, Camera], RenderContext>; + get(renderTarget?: RenderTarget | null, mrt?: MRTNode | null, callDepth?: number | null): RenderContext; /** * Frees internal resources. */ dispose(): void; } + export default RenderContexts; diff --git a/types/three/src/renderers/common/RenderList.d.ts b/types/three/src/renderers/common/RenderList.d.ts index aefd9da09913f8..1840d42d00f16a 100644 --- a/types/three/src/renderers/common/RenderList.d.ts +++ b/types/three/src/renderers/common/RenderList.d.ts @@ -3,15 +3,18 @@ import { BufferGeometry, GeometryGroup } from "../../core/BufferGeometry.js"; import { Object3D } from "../../core/Object3D.js"; import { Light } from "../../lights/Light.js"; import { Material } from "../../materials/Material.js"; -import { LightsNode } from "../../nodes/Nodes.js"; +import LightsNode from "../../nodes/lighting/LightsNode.js"; +import { Scene } from "../../scenes/Scene.js"; import BundleGroup from "./BundleGroup.js"; import ClippingContext from "./ClippingContext.js"; import Lighting from "./Lighting.js"; + export interface Bundle { bundleGroup: BundleGroup; camera: Camera; renderList: RenderList; } + export interface RenderItem { id: number | null; object: Object3D | null; @@ -23,6 +26,7 @@ export interface RenderItem { group: GeometryGroup | null; clippingContext: ClippingContext | null; } + /** * When the renderer analyzes the scene at the beginning of a render call, * it stores 3D object for further processing in render lists. Depending on the @@ -35,25 +39,86 @@ export interface RenderItem { * @augments Pipeline */ declare class RenderList { + /** + * Constructs a render list. + * + * @param {Lighting} lighting - The lighting management component. + * @param {Scene} scene - The scene. + * @param {Camera} camera - The camera the scene is rendered with. + */ + constructor(lighting: Lighting, scene: Scene, camera: Camera); + /** + * 3D objects are transformed into render items and stored in this array. + * + * @type {Array} + */ renderItems: RenderItem[]; + /** + * The current render items index. + * + * @type {number} + * @default 0 + */ renderItemsIndex: number; + /** + * A list with opaque render items. + * + * @type {Array} + */ opaque: RenderItem[]; + /** + * A list with transparent render items which require + * double pass rendering (e.g. transmissive objects). + * + * @type {Array} + */ transparentDoublePass: RenderItem[]; + /** + * A list with transparent render items. + * + * @type {Array} + */ transparent: RenderItem[]; + /** + * A list with transparent render bundle data. + * + * @type {Array} + */ bundles: Bundle[]; + /** + * The render list's lights node. This node is later + * relevant for the actual analytical light nodes which + * compute the scene's lighting in the shader. + * + * @type {LightsNode} + */ lightsNode: LightsNode; + /** + * The scene's lights stored in an array. This array + * is used to setup the lights node. + * + * @type {Array} + */ lightsArray: Light[]; - scene: Object3D; + /** + * The scene. + * + * @type {Scene} + */ + scene: Scene; + /** + * The camera the scene is rendered with. + * + * @type {Camera} + */ camera: Camera; - occlusionQueryCount: number; /** - * Constructs a render list. + * How many objects perform occlusion query tests. * - * @param {Lighting} lighting - The lighting management component. - * @param {Scene} scene - The scene. - * @param {Camera} camera - The camera the scene is rendered with. + * @type {number} + * @default 0 */ - constructor(lighting: Lighting, scene: Object3D, camera: Camera); + occlusionQueryCount: number; /** * This method is called right at the beginning of a render call * before the scene is analyzed. It prepares the internal data @@ -85,7 +150,7 @@ declare class RenderList { groupOrder: number, z: number, group: GeometryGroup | null, - clippingContext: ClippingContext | null, + clippingContext: ClippingContext, ): RenderItem; /** * Pushes the given object as a render item to the internal render lists. @@ -106,7 +171,7 @@ declare class RenderList { groupOrder: number, z: number, group: GeometryGroup | null, - clippingContext: ClippingContext | null, + clippingContext: ClippingContext, ): void; /** * Inserts the given object as a render item at the start of the internal render lists. @@ -127,7 +192,7 @@ declare class RenderList { groupOrder: number, z: number, group: GeometryGroup | null, - clippingContext: ClippingContext | null, + clippingContext: ClippingContext, ): void; /** * Pushes render bundle group data into the render list. @@ -157,4 +222,5 @@ declare class RenderList { */ finish(): void; } + export default RenderList; diff --git a/types/three/src/renderers/common/RenderLists.d.ts b/types/three/src/renderers/common/RenderLists.d.ts index fce404a7f71da5..8a53d17a003e0c 100644 --- a/types/three/src/renderers/common/RenderLists.d.ts +++ b/types/three/src/renderers/common/RenderLists.d.ts @@ -1,8 +1,9 @@ import { Camera } from "../../cameras/Camera.js"; -import { Object3D } from "../../core/Object3D.js"; +import { Scene } from "../../scenes/Scene.js"; import ChainMap from "./ChainMap.js"; import Lighting from "./Lighting.js"; import RenderList from "./RenderList.js"; + /** * This renderer module manages the render lists which are unique * per scene and camera combination. @@ -10,14 +11,24 @@ import RenderList from "./RenderList.js"; * @private */ declare class RenderLists { - lighting: Lighting; - lists: ChainMap; /** * Constructs a render lists management component. * * @param {Lighting} lighting - The lighting management component. */ constructor(lighting: Lighting); + /** + * The lighting management component. + * + * @type {Lighting} + */ + lighting: Lighting; + /** + * The internal chain map which holds the render lists. + * + * @type {ChainMap} + */ + lists: ChainMap; /** * Returns a render list for the given scene and camera. * @@ -25,10 +36,11 @@ declare class RenderLists { * @param {Camera} camera - The camera. * @return {RenderList} The render list. */ - get(scene: Object3D, camera: Camera): RenderList; + get(scene: Scene, camera: Camera): RenderList; /** * Frees all internal resources. */ dispose(): void; } + export default RenderLists; diff --git a/types/three/src/renderers/common/RenderObject.d.ts b/types/three/src/renderers/common/RenderObject.d.ts index 3e5cbe54f7dbde..a0d4a8b2213bc8 100644 --- a/types/three/src/renderers/common/RenderObject.d.ts +++ b/types/three/src/renderers/common/RenderObject.d.ts @@ -2,21 +2,21 @@ import { Camera } from "../../cameras/Camera.js"; import { BufferAttribute } from "../../core/BufferAttribute.js"; import { BufferGeometry } from "../../core/BufferGeometry.js"; import { InterleavedBuffer } from "../../core/InterleavedBuffer.js"; -import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribute.js"; import { Object3D } from "../../core/Object3D.js"; import { Material } from "../../materials/Material.js"; import NodeMaterialObserver from "../../materials/nodes/manager/NodeMaterialObserver.js"; -import { LightsNode } from "../../nodes/Nodes.js"; +import LightsNode from "../../nodes/lighting/LightsNode.js"; import { Scene } from "../../scenes/Scene.js"; import BindGroup from "./BindGroup.js"; import BundleGroup from "./BundleGroup.js"; import ClippingContext from "./ClippingContext.js"; import Geometries from "./Geometries.js"; import NodeBuilderState from "./nodes/NodeBuilderState.js"; -import Nodes from "./nodes/Nodes.js"; +import NodeManager from "./nodes/NodeManager.js"; import RenderContext from "./RenderContext.js"; import Renderer from "./Renderer.js"; import RenderPipeline from "./RenderPipeline.js"; + /** * A render object is the renderer's representation of single entity that gets drawn * with a draw command. There is no unique mapping of render objects to 3D objects in the @@ -36,76 +36,256 @@ import RenderPipeline from "./RenderPipeline.js"; * @private */ declare class RenderObject { - _nodes: Nodes; - _geometries: Geometries; + /** + * Constructs a new render object. + * + * @param {Nodes} nodes - Renderer component for managing nodes related logic. + * @param {Geometries} geometries - Renderer component for managing geometries. + * @param {Renderer} renderer - The renderer. + * @param {Object3D} object - The 3D object. + * @param {Material} material - The 3D object's material. + * @param {Scene} scene - The scene the 3D object belongs to. + * @param {Camera} camera - The camera the object should be rendered with. + * @param {LightsNode} lightsNode - The lights node. + * @param {RenderContext} renderContext - The render context. + * @param {ClippingContext} clippingContext - The clipping context. + */ + constructor( + nodes: NodeManager, + geometries: Geometries, + renderer: Renderer, + object: Object3D, + material: Material, + scene: Scene, + camera: Camera, + lightsNode: LightsNode, + renderContext: RenderContext, + clippingContext: ClippingContext, + ); id: number; + /** + * Renderer component for managing nodes related logic. + * + * @type {Nodes} + * @private + */ + private _nodes; + /** + * Renderer component for managing geometries. + * + * @type {Geometries} + * @private + */ + private _geometries; + /** + * The renderer. + * + * @type {Renderer} + */ renderer: Renderer; + /** + * The 3D object. + * + * @type {Object3D} + */ object: Object3D; + /** + * The 3D object's material. + * + * @type {Material} + */ material: Material; + /** + * The scene the 3D object belongs to. + * + * @type {Scene} + */ scene: Scene; + /** + * The camera the 3D object should be rendered with. + * + * @type {Camera} + */ camera: Camera; + /** + * The lights node. + * + * @type {LightsNode} + */ lightsNode: LightsNode; + /** + * The render context. + * + * @type {RenderContext} + */ context: RenderContext; + /** + * The 3D object's geometry. + * + * @type {BufferGeometry} + */ geometry: BufferGeometry; + /** + * The render object's version. + * + * @type {number} + */ version: number; + /** + * The draw range of the geometry. + * + * @type {?Object} + * @default null + */ drawRange: { start: number; count: number; } | null; - attributes: Array | null; + /** + * An array holding the buffer attributes + * of the render object. This entails attribute + * definitions on geometry and node level. + * + * @type {?Array} + * @default null + */ + attributes: BufferAttribute[] | null; + /** + * An object holding the version of the + * attributes. The keys are the attribute names + * and the values are the attribute versions. + * + * @type {?Object} + * @default null + */ attributesId: { - [attributeName: string]: number; + [x: string]: number; } | null; - pipeline: RenderPipeline | null; + /** + * A reference to a render pipeline the render + * object is processed with. + * + * @type {RenderPipeline} + * @default null + */ + pipeline: RenderPipeline; + /** + * Only relevant for objects using + * multiple materials. This represents a group entry + * from the respective `BufferGeometry`. + * + * @type {?{start: number, count: number}} + * @default null + */ group: { start: number; count: number; } | null; + /** + * An array holding the vertex buffers which can + * be buffer attributes but also interleaved buffers. + * + * @type {?Array} + * @default null + */ vertexBuffers: Array | null; + /** + * The parameters for the draw command. + * + * @type {?Object} + * @default null + */ drawParams: { vertexCount: number; firstVertex: number; instanceCount: number; firstInstance: number; } | null; + /** + * If this render object is used inside a render bundle, + * this property points to the respective bundle group. + * + * @type {?BundleGroup} + * @default null + */ bundle: BundleGroup | null; - clippingContext: ClippingContext | null; + /** + * The clipping context. + * + * @type {ClippingContext} + */ + clippingContext: ClippingContext; + /** + * The clipping context's cache key. + * + * @type {string} + */ clippingContextCacheKey: string; + /** + * The initial node cache key. + * + * @type {number} + */ initialNodesCacheKey: number; + /** + * The initial cache key. + * + * @type {number} + */ initialCacheKey: number; - _nodeBuilderState: NodeBuilderState | null; - _bindings: BindGroup[] | null; - _monitor: NodeMaterialObserver | null; + /** + * The node builder state. + * + * @type {?NodeBuilderState} + * @private + * @default null + */ + private _nodeBuilderState; + /** + * An array of bindings. + * + * @type {?Array} + * @private + * @default null + */ + private _bindings; + /** + * Reference to the node material observer. + * + * @type {?NodeMaterialObserver} + * @private + * @default null + */ + private _monitor; + /** + * An event listener which is defined by `RenderObjects`. It performs + * clean up tasks when `dispose()` on this render object. + * + * @method + */ onDispose: (() => void) | null; - readonly isRenderObject: true; + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isRenderObject: boolean; + /** + * An event listener which is executed when `dispose()` is called on + * the material of this render object. + * + * @method + */ onMaterialDispose: () => void; - onGeometryDispose: () => void; /** - * Constructs a new render object. + * An event listener which is executed when `dispose()` is called on + * the geometry of this render object. * - * @param {Nodes} nodes - Renderer component for managing nodes related logic. - * @param {Geometries} geometries - Renderer component for managing geometries. - * @param {Renderer} renderer - The renderer. - * @param {Object3D} object - The 3D object. - * @param {Material} material - The 3D object's material. - * @param {Scene} scene - The scene the 3D object belongs to. - * @param {Camera} camera - The camera the object should be rendered with. - * @param {LightsNode} lightsNode - The lights node. - * @param {RenderContext} renderContext - The render context. - * @param {ClippingContext} clippingContext - The clipping context. + * @method */ - constructor( - nodes: Nodes, - geometries: Geometries, - renderer: Renderer, - object: Object3D, - material: Material, - scene: Scene, - camera: Camera, - lightsNode: LightsNode, - renderContext: RenderContext, - clippingContext: ClippingContext | null, - ); + onGeometryDispose: () => void; /** * Updates the clipping context. * @@ -150,7 +330,7 @@ declare class RenderObject { * @param {string} name - The name of the binding group. * @return {?BindGroup} The bindings. */ - getBindingGroup(name: string): BindGroup | undefined; + getBindingGroup(name: string): BindGroup | null; /** * Returns the index of the render object's geometry. * @@ -162,7 +342,7 @@ declare class RenderObject { * * @return {?BufferAttribute} The indirect attribute. `null` if no indirect drawing is used. */ - getIndirect(): import("./IndirectStorageBufferAttribute.js").default | null; + getIndirect(): BufferAttribute | null; /** * Returns the byte offset into the indirect attribute buffer. * @@ -174,12 +354,7 @@ declare class RenderObject { * * @return {Array} An array with object references. */ - getChainArray(): readonly [ - Object3D, - Material, - RenderContext, - LightsNode, - ]; + getChainArray(): unknown[]; /** * This method is used when the geometry of a 3D object has been exchanged and the * respective render object now requires an update. @@ -193,13 +368,13 @@ declare class RenderObject { * * @return {Array} An array with buffer attributes. */ - getAttributes(): (BufferAttribute | InterleavedBufferAttribute)[]; + getAttributes(): BufferAttribute[]; /** * Returns the vertex buffers of the render object. * * @return {Array} An array with buffer attribute or interleaved buffers. */ - getVertexBuffers(): (BufferAttribute | InterleavedBuffer)[] | null; + getVertexBuffers(): Array; /** * Returns the draw parameters for the render object. * @@ -269,4 +444,5 @@ declare class RenderObject { */ dispose(): void; } + export default RenderObject; diff --git a/types/three/src/renderers/common/RenderPipeline.d.ts b/types/three/src/renderers/common/RenderObjectPipeline.d.ts similarity index 65% rename from types/three/src/renderers/common/RenderPipeline.d.ts rename to types/three/src/renderers/common/RenderObjectPipeline.d.ts index bd9ec21c2f2c45..927aa7189568bd 100644 --- a/types/three/src/renderers/common/RenderPipeline.d.ts +++ b/types/three/src/renderers/common/RenderObjectPipeline.d.ts @@ -1,21 +1,33 @@ import Pipeline from "./Pipeline.js"; import ProgrammableStage from "./ProgrammableStage.js"; + /** * Class for representing render pipelines. * * @private * @augments Pipeline */ -declare class RenderPipeline extends Pipeline { - vertexProgram: ProgrammableStage; - fragmentProgram: ProgrammableStage; +declare class RenderObjectPipeline extends Pipeline { /** - * Constructs a new render pipeline. + * Constructs a new render object pipeline. * * @param {string} cacheKey - The pipeline's cache key. * @param {ProgrammableStage} vertexProgram - The pipeline's vertex shader. * @param {ProgrammableStage} fragmentProgram - The pipeline's fragment shader. */ constructor(cacheKey: string, vertexProgram: ProgrammableStage, fragmentProgram: ProgrammableStage); + /** + * The pipeline's vertex shader. + * + * @type {ProgrammableStage} + */ + vertexProgram: ProgrammableStage; + /** + * The pipeline's fragment shader. + * + * @type {ProgrammableStage} + */ + fragmentProgram: ProgrammableStage; } -export default RenderPipeline; + +export default RenderObjectPipeline; diff --git a/types/three/src/renderers/common/RenderObjects.d.ts b/types/three/src/renderers/common/RenderObjects.d.ts index 84fa1ce8467ab8..9c26209092ee50 100644 --- a/types/three/src/renderers/common/RenderObjects.d.ts +++ b/types/three/src/renderers/common/RenderObjects.d.ts @@ -8,26 +8,18 @@ import ChainMap from "./ChainMap.js"; import ClippingContext from "./ClippingContext.js"; import Geometries from "./Geometries.js"; import Info from "./Info.js"; -import Nodes from "./nodes/Nodes.js"; +import NodeManager from "./nodes/NodeManager.js"; import Pipelines from "./Pipelines.js"; import RenderContext from "./RenderContext.js"; import Renderer from "./Renderer.js"; import RenderObject from "./RenderObject.js"; + /** * This module manages the render objects of the renderer. * * @private */ declare class RenderObjects { - renderer: Renderer; - nodes: Nodes; - geometries: Geometries; - pipelines: Pipelines; - bindings: Bindings; - info: Info; - chainMaps: { - [passId: string]: ChainMap; - }; /** * Constructs a new render object management component. * @@ -40,12 +32,57 @@ declare class RenderObjects { */ constructor( renderer: Renderer, - nodes: Nodes, + nodes: NodeManager, geometries: Geometries, pipelines: Pipelines, bindings: Bindings, info: Info, ); + /** + * The renderer. + * + * @type {Renderer} + */ + renderer: Renderer; + /** + * Renderer component for managing nodes related logic. + * + * @type {Nodes} + */ + nodes: NodeManager; + /** + * Renderer component for managing geometries. + * + * @type {Geometries} + */ + geometries: Geometries; + /** + * Renderer component for managing pipelines. + * + * @type {Pipelines} + */ + pipelines: Pipelines; + /** + * Renderer component for managing bindings. + * + * @type {Bindings} + */ + bindings: Bindings; + /** + * Renderer component for managing metrics and monitoring data. + * + * @type {Info} + */ + info: Info; + /** + * A dictionary that manages render contexts in chain maps + * for each pass ID. + * + * @type {Object} + */ + chainMaps: { + [x: string]: ChainMap; + }; /** * Returns a render object for the given object and state data. * @@ -66,8 +103,8 @@ declare class RenderObjects { camera: Camera, lightsNode: LightsNode, renderContext: RenderContext, - clippingContext: ClippingContext | null, - passId?: string | undefined, + clippingContext: ClippingContext, + passId?: string, ): RenderObject; /** * Returns a chain map for the given pass ID. @@ -75,12 +112,7 @@ declare class RenderObjects { * @param {string} [passId='default'] - The pass ID. * @return {ChainMap} The chain map. */ - getChainMap( - passId?: string, - ): ChainMap< - readonly [Object3D, Material, RenderContext, LightsNode], - RenderObject - >; + getChainMap(passId?: string): ChainMap; /** * Frees internal resources. */ @@ -102,7 +134,7 @@ declare class RenderObjects { * @return {RenderObject} The render object. */ createRenderObject( - nodes: Nodes, + nodes: NodeManager, geometries: Geometries, renderer: Renderer, object: Object3D, @@ -111,8 +143,9 @@ declare class RenderObjects { camera: Camera, lightsNode: LightsNode, renderContext: RenderContext, - clippingContext: ClippingContext | null, - passId: string | undefined, + clippingContext: ClippingContext, + passId?: string, ): RenderObject; } + export default RenderObjects; diff --git a/types/three/src/renderers/common/RenderPipeline.ts b/types/three/src/renderers/common/RenderPipeline.ts new file mode 100644 index 00000000000000..5e6575e8552f3c --- /dev/null +++ b/types/three/src/renderers/common/RenderPipeline.ts @@ -0,0 +1,24 @@ +import { Node } from "../../nodes/Nodes.js"; +import Renderer from "./Renderer.js"; + +declare class RenderPipeline { + renderer: Renderer; + outputNode: Node; + + outputColorTransform: boolean; + + needsUpdate: boolean; + + constructor(renderer: Renderer, outputNode?: Node); + + render(): void; + + dispose(): void; + + /** + * @deprecated "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer. + */ + renderAsync(): Promise; +} + +export default RenderPipeline; diff --git a/types/three/src/renderers/common/Renderer.d.ts b/types/three/src/renderers/common/Renderer.d.ts index 09be70c01d0194..179e9db6b84977 100644 --- a/types/three/src/renderers/common/Renderer.d.ts +++ b/types/three/src/renderers/common/Renderer.d.ts @@ -1,6 +1,6 @@ import { Camera } from "../../cameras/Camera.js"; -import { ShadowMapType, TextureDataType, TimestampQuery, ToneMapping } from "../../constants.js"; -import { BufferAttribute } from "../../core/BufferAttribute.js"; +import { CoordinateSystem, ShadowMapType, TextureDataType, TimestampQuery, ToneMapping } from "../../constants.js"; +import { BufferAttribute, TypedArray } from "../../core/BufferAttribute.js"; import { BufferGeometry, GeometryGroup } from "../../core/BufferGeometry.js"; import { Object3D } from "../../core/Object3D.js"; import { RenderTarget } from "../../core/RenderTarget.js"; @@ -11,53 +11,36 @@ import { ColorRepresentation } from "../../math/Color.js"; import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; import { Vector4 } from "../../math/Vector4.js"; +import ContextNode from "../../nodes/core/ContextNode.js"; import MRTNode from "../../nodes/core/MRTNode.js"; import ComputeNode from "../../nodes/gpgpu/ComputeNode.js"; import LightsNode from "../../nodes/lighting/LightsNode.js"; -import { Group } from "../../objects/Group.js"; import { Scene } from "../../scenes/Scene.js"; import { FramebufferTexture } from "../../textures/FramebufferTexture.js"; import { Texture } from "../../textures/Texture.js"; -import Animation from "./Animation.js"; -import Attributes from "./Attributes.js"; import Backend from "./Backend.js"; -import Background from "./Background.js"; -import Bindings from "./Bindings.js"; import CanvasTarget from "./CanvasTarget.js"; import ClippingContext from "./ClippingContext.js"; import Color4 from "./Color4.js"; -import Geometries from "./Geometries.js"; import IndirectStorageBufferAttribute from "./IndirectStorageBufferAttribute.js"; import Info from "./Info.js"; import InspectorBase from "./InspectorBase.js"; import Lighting from "./Lighting.js"; import NodeLibrary from "./nodes/NodeLibrary.js"; -import Nodes from "./nodes/Nodes.js"; -import Pipelines from "./Pipelines.js"; -import QuadMesh from "./QuadMesh.js"; -import RenderBundle from "./RenderBundle.js"; -import RenderBundles from "./RenderBundles.js"; -import RenderContext from "./RenderContext.js"; -import RenderContexts from "./RenderContexts.js"; -import RenderList, { Bundle, RenderItem } from "./RenderList.js"; -import RenderLists from "./RenderLists.js"; -import RenderObjects from "./RenderObjects.js"; -import Textures from "./Textures.js"; +import { RenderItem } from "./RenderList.js"; +import StorageBufferAttribute from "./StorageBufferAttribute.js"; import XRManager from "./XRManager.js"; -interface Rectangle { - x: number; - y: number; - z: number; - w: number; -} + interface DeviceLostInfo { api: "WebGL" | "WebGPU"; message: string; reason: string | null; originalEvent: unknown; } + export interface RendererParameters { logarithmicDepthBuffer?: boolean | undefined; + reversedDepthBuffer?: boolean | undefined; alpha?: boolean | undefined; depth?: boolean | undefined; stencil?: boolean | undefined; @@ -67,108 +50,591 @@ export interface RendererParameters { outputBufferType?: TextureDataType | undefined; multiview?: boolean | undefined; } + /** * Base class for renderers. */ declare class Renderer { - readonly isRenderer: true; + /** + * Renderer options. + * + * @typedef {Object} Renderer~Options + * @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not. + * @property {boolean} [reversedDepthBuffer=false] - Whether reversed depth buffer is enabled or not. + * @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque. + * @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not. + * @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not. + * @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not. + * @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0 + * to overwrite the default. + * @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted. + * @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best + * quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though. + * @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported. + */ + /** + * Constructs a new renderer. + * + * @param {Backend} backend - The backend the renderer is targeting (e.g. WebGPU or WebGL 2). + * @param {Renderer~Options} [parameters] - The configuration parameter. + */ + constructor(backend: Backend, parameters?: RendererParameters); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isRenderer: boolean; + /** + * A reference to the current backend. + * + * @type {Backend} + */ backend: Backend; + /** + * Whether the renderer should automatically clear the current rendering target + * before execute a `render()` call. The target can be the canvas (default framebuffer) + * or the current bound render target (custom framebuffer). + * + * @type {boolean} + * @default true + */ autoClear: boolean; + /** + * When `autoClear` is set to `true`, this property defines whether the renderer + * should clear the color buffer. + * + * @type {boolean} + * @default true + */ autoClearColor: boolean; + /** + * When `autoClear` is set to `true`, this property defines whether the renderer + * should clear the depth buffer. + * + * @type {boolean} + * @default true + */ autoClearDepth: boolean; + /** + * When `autoClear` is set to `true`, this property defines whether the renderer + * should clear the stencil buffer. + * + * @type {boolean} + * @default true + */ autoClearStencil: boolean; + /** + * Whether the default framebuffer should be transparent or opaque. + * + * @type {boolean} + * @default true + */ alpha: boolean; - logarithmicDepthBuffer: boolean; + /** + * Whether logarithmic depth buffer is enabled or not. + * + * @type {boolean} + * @default false + * @readonly + */ + readonly logarithmicDepthBuffer: boolean; + /** + * Whether reversed depth buffer is enabled or not. + * + * @type {boolean} + * @default false + * @readonly + */ + readonly reversedDepthBuffer: boolean; + /** + * Defines the output color space of the renderer. + * + * @type {string} + * @default SRGBColorSpace + */ outputColorSpace: string; + /** + * Defines the tone mapping of the renderer. + * + * @type {number} + * @default NoToneMapping + */ toneMapping: ToneMapping; + /** + * Defines the tone mapping exposure. + * + * @type {number} + * @default 1 + */ toneMappingExposure: number; + /** + * Whether the renderer should sort its render lists or not. + * + * Note: Sorting is used to attempt to properly render objects that have some degree of transparency. + * By definition, sorting objects may not work in all cases. Depending on the needs of application, + * it may be necessary to turn off sorting and use other methods to deal with transparency rendering + * e.g. manually determining each object's rendering order. + * + * @type {boolean} + * @default true + */ sortObjects: boolean; + /** + * Whether the default framebuffer should have a depth buffer or not. + * + * @type {boolean} + * @default true + */ depth: boolean; + /** + * Whether the default framebuffer should have a stencil buffer or not. + * + * @type {boolean} + * @default false + */ stencil: boolean; + /** + * Holds a series of statistical information about the GPU memory + * and the rendering process. Useful for debugging and monitoring. + * + * @type {Info} + */ info: Info; + /** + * A global context node that stores override nodes for specific transformations or calculations. + * These nodes can be used to replace default behavior in the rendering pipeline. + * + * @type {ContextNode} + * @property {Object} value - The context value object. + */ + contextNode: ContextNode; + /** + * The node library defines how certain library objects like materials, lights + * or tone mapping functions are mapped to node types. This is required since + * although instances of classes like `MeshBasicMaterial` or `PointLight` can + * be part of the scene graph, they are internally represented as nodes for + * further processing. + * + * @type {NodeLibrary} + */ library: NodeLibrary; + /** + * A map-like data structure for managing lights. + * + * @type {Lighting} + */ lighting: Lighting; - _samples: number; - _canvasTarget: CanvasTarget; - _inspector: InspectorBase; - _getFallback: ((error: unknown) => Backend) | null; - _attributes: Attributes | null; - _geometries: Geometries | null; - _nodes: Nodes | null; - _animation: Animation | null; - _bindings: Bindings | null; - _objects: RenderObjects | null; - _pipelines: Pipelines | null; - _bundles: RenderBundles | null; - _renderLists: RenderLists | null; - _renderContexts: RenderContexts | null; - _textures: Textures | null; - _background: Background | null; - _quad: QuadMesh; - _currentRenderContext: RenderContext | null; - _opaqueSort: ((a: RenderItem, b: RenderItem) => number) | null; - _transparentSort: ((a: RenderItem, b: RenderItem) => number) | null; - _frameBufferTarget: RenderTarget | null; - _clearColor: Color4; - _clearDepth: number; - _clearStencil: number; - _renderTarget: RenderTarget | null; - _activeCubeFace: number; - _activeMipmapLevel: number; - _outputRenderTarget: RenderTarget | null; - _mrt: MRTNode | null; - _renderObjectFunction: - | (( - object: Object3D, - scene: Scene, - camera: Camera, - geometry: BufferGeometry, - material: Material, - group: GeometryGroup, - lightsNode: LightsNode, - clippingContext: ClippingContext | null, - passId: string | null, - ) => void) - | null; - _currentRenderObjectFunction: - | (( - object: Object3D, - scene: Scene, - camera: Camera, - geometry: BufferGeometry, - material: Material, - group: GeometryGroup, - lightsNode: LightsNode, - clippingContext: ClippingContext | null, - passId: string | null, - ) => void) - | null; - _currentRenderBundle: RenderBundle | null; - _handleObjectFunction: ( - object: Object3D, - material: Material, - scene: Scene, - camera: Camera, - lightsNode: LightsNode, - group: GeometryGroup, - clippingContext: ClippingContext | null, - passId?: string, - ) => void; - _isDeviceLost: boolean; + /** + * The number of MSAA samples. + * + * @private + * @type {number} + * @default 0 + */ + private _samples; + /** + * Callback when the canvas has been resized. + * + * @private + */ + private _onCanvasTargetResize; + /** + * The canvas target for rendering. + * + * @private + * @type {CanvasTarget} + */ + private _canvasTarget; + /** + * The inspector provides information about the internal renderer state. + * + * @private + * @type {InspectorBase} + */ + private _inspector; + /** + * This callback function can be used to provide a fallback backend, if the primary backend can't be targeted. + * + * @private + * @type {?Function} + */ + private _getFallback; + /** + * A reference to a renderer module for managing shader attributes. + * + * @private + * @type {?Attributes} + * @default null + */ + private _attributes; + /** + * A reference to a renderer module for managing geometries. + * + * @private + * @type {?Geometries} + * @default null + */ + private _geometries; + /** + * A reference to a renderer module for managing node related logic. + * + * @private + * @type {?NodeManager} + * @default null + */ + private _nodes; + /** + * A reference to a renderer module for managing the internal animation loop. + * + * @private + * @type {?Animation} + * @default null + */ + private _animation; + /** + * A reference to a renderer module for managing shader program bindings. + * + * @private + * @type {?Bindings} + * @default null + */ + private _bindings; + /** + * A reference to a renderer module for managing render objects. + * + * @private + * @type {?RenderObjects} + * @default null + */ + private _objects; + /** + * A reference to a renderer module for managing render and compute pipelines. + * + * @private + * @type {?Pipelines} + * @default null + */ + private _pipelines; + /** + * A reference to a renderer module for managing render bundles. + * + * @private + * @type {?RenderBundles} + * @default null + */ + private _bundles; + /** + * A reference to a renderer module for managing render lists. + * + * @private + * @type {?RenderLists} + * @default null + */ + private _renderLists; + /** + * A reference to a renderer module for managing render contexts. + * + * @private + * @type {?RenderContexts} + * @default null + */ + private _renderContexts; + /** + * A reference to a renderer module for managing textures. + * + * @private + * @type {?Textures} + * @default null + */ + private _textures; + /** + * A reference to a renderer module for backgrounds. + * + * @private + * @type {?Background} + * @default null + */ + private _background; + /** + * This fullscreen quad is used for internal render passes + * like the tone mapping and color space output pass. + * + * @private + * @type {QuadMesh} + */ + private _quad; + /** + * A reference to the current render context. + * + * @private + * @type {?RenderContext} + * @default null + */ + private _currentRenderContext; + /** + * A custom sort function for the opaque render list. + * + * @private + * @type {?Function} + * @default null + */ + private _opaqueSort; + /** + * A custom sort function for the transparent render list. + * + * @private + * @type {?Function} + * @default null + */ + private _transparentSort; + /** + * The framebuffer target. + * + * @private + * @type {?RenderTarget} + * @default null + */ + private _frameBufferTarget; + /** + * The clear color value. + * + * @private + * @type {Color4} + */ + private _clearColor; + /** + * The clear depth value. + * + * @private + * @type {number} + * @default 1 + */ + private _clearDepth; + /** + * The clear stencil value. + * + * @private + * @type {number} + * @default 0 + */ + private _clearStencil; + /** + * The current render target. + * + * @private + * @type {?RenderTarget} + * @default null + */ + private _renderTarget; + /** + * The active cube face. + * + * @private + * @type {number} + * @default 0 + */ + private _activeCubeFace; + /** + * The active mipmap level. + * + * @private + * @type {number} + * @default 0 + */ + private _activeMipmapLevel; + /** + * The current output render target. + * + * @private + * @type {?RenderTarget} + * @default null + */ + private _outputRenderTarget; + /** + * The MRT setting. + * + * @private + * @type {?MRTNode} + * @default null + */ + private _mrt; + /** + * This function defines how a render object is going + * to be rendered. + * + * @private + * @type {?Function} + * @default null + */ + private _renderObjectFunction; + /** + * Used to keep track of the current render object function. + * + * @private + * @type {?Function} + * @default null + */ + private _currentRenderObjectFunction; + /** + * Used to keep track of the current render bundle. + * + * @private + * @type {?RenderBundle} + * @default null + */ + private _currentRenderBundle; + /** + * Next to `_renderObjectFunction()`, this function provides another hook + * for influencing the render process of a render object. It is meant for internal + * use and only relevant for `compileAsync()` right now. Instead of using + * the default logic of `_renderObjectDirect()` which actually draws the render object, + * a different function might be used which performs no draw but just the node + * and pipeline updates. + * + * @private + * @type {Function} + */ + private _handleObjectFunction; + /** + * Indicates whether the device has been lost or not. In WebGL terms, the device + * lost is considered as a context lost. When this is set to `true`, rendering + * isn't possible anymore. + * + * @private + * @type {boolean} + * @default false + */ + private _isDeviceLost; + /** + * A callback function that defines what should happen when a device/context lost occurs. + * + * @type {Function} + */ onDeviceLost: (info: DeviceLostInfo) => void; - _outputBufferType: TextureDataType; - _initialized: boolean; - _initPromise: Promise | null; - _compilationPromises: Promise[] | null; + /** + * Defines the type of output buffers. The default `HalfFloatType` is recommend for + * best quality. To save memory and bandwidth, `UnsignedByteType` might be used. + * This will reduce rendering quality though. + * + * @private + * @type {number} + * @default HalfFloatType + */ + private _outputBufferType; + /** + * A cache for shadow nodes per material + * + * @private + * @type {WeakMap} + */ + private _cacheShadowNodes; + /** + * Whether the renderer has been initialized or not. + * + * @private + * @type {boolean} + * @default false + */ + private _initialized; + /** + * The call depth of the renderer. Counts the number of + * nested render calls. + * + * @private + * @type {number} + * @default - 1 + */ + private _callDepth; + /** + * A reference to the promise which initializes the renderer. + * + * @private + * @type {?Promise} + * @default null + */ + private _initPromise; + /** + * An array of compilation promises which are used in `compileAsync()`. + * + * @private + * @type {?Array} + * @default null + */ + private _compilationPromises; + /** + * Whether the renderer should render transparent render objects or not. + * + * @type {boolean} + * @default true + */ transparent: boolean; + /** + * Whether the renderer should render opaque render objects or not. + * + * @type {boolean} + * @default true + */ opaque: boolean; + /** + * Shadow map configuration + * @typedef {Object} ShadowMapConfig + * @property {boolean} enabled - Whether to globally enable shadows or not. + * @property {boolean} transmitted - Whether to enable light transmission through non-opaque materials. + * @property {number} type - The shadow map type. + */ + /** + * The renderer's shadow configuration. + * + * @type {ShadowMapConfig} + */ shadowMap: { + /** + * - Whether to globally enable shadows or not. + */ enabled: boolean; - type: ShadowMapType | null; + /** + * - Whether to enable light transmission through non-opaque materials. + */ + transmitted: boolean; + /** + * - The shadow map type. + */ + type: ShadowMapType; }; + /** + * XR configuration. + * @typedef {Object} XRConfig + * @property {boolean} enabled - Whether to globally enable XR or not. + */ + /** + * The renderer's XR manager. + * + * @type {XRManager} + */ xr: XRManager; + /** + * Debug configuration. + * @typedef {Object} DebugConfig + * @property {boolean} checkShaderErrors - Whether shader errors should be checked or not. + * @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. + */ + /** + * The renderer's debug configuration. + * + * @type {DebugConfig} + */ debug: { + /** + * - Whether shader errors should be checked or not. + */ checkShaderErrors: boolean; + /** + * - A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now. + */ onShaderError: | (( gl: WebGL2RenderingContext, @@ -177,35 +643,14 @@ declare class Renderer { glFragmentShader: WebGLShader, ) => void) | null; + /** + * - Allows the get the raw shader code for the given scene, camera and 3D object. + */ getShaderAsync: (scene: Scene, camera: Camera, object: Object3D) => Promise<{ fragmentShader: string | null; vertexShader: string | null; }>; }; - localClippingEnabled?: boolean | undefined; - /** - * Renderer options. - * - * @typedef {Object} Renderer~Options - * @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not. - * @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque. - * @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not. - * @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not. - * @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not. - * @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0 - * to overwrite the default. - * @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted. - * @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best - * quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though. - * @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported. - */ - /** - * Constructs a new renderer. - * - * @param {Backend} backend - The backend the renderer is targeting (e.g. WebGPU or WebGL 2). - * @param {Renderer~Options} [parameters] - The configuration parameter. - */ - constructor(backend: Backend, parameters?: RendererParameters); /** * Initializes the renderer so it is ready for usage. * @@ -229,7 +674,7 @@ declare class Renderer { * @readonly * @type {number} */ - get coordinateSystem(): import("../../constants.js").CoordinateSystem; + get coordinateSystem(): CoordinateSystem; /** * Compiles all materials in the given scene. This can be useful to avoid a * phenomenon which is called "shader compilation stutter", which occurs when @@ -295,13 +740,13 @@ declare class Renderer { * @param {MRTNode} mrt - The MRT node to set. * @return {Renderer} A reference to this renderer. */ - setMRT(mrt: MRTNode | null): this; + setMRT(mrt: MRTNode | null): Renderer; /** * Returns the MRT configuration. * * @return {MRTNode} The MRT configuration. */ - getMRT(): MRTNode | null; + getMRT(): MRTNode; /** * Returns the output buffer type. * @@ -321,7 +766,7 @@ declare class Renderer { * @private * @param {Object} info - Information about the context lost. */ - _onDeviceLost(info: DeviceLostInfo): void; + private _onDeviceLost; /** * Renders the given render bundle. * @@ -330,7 +775,7 @@ declare class Renderer { * @param {Scene} sceneRef - The scene the render bundle belongs to. * @param {LightsNode} lightsNode - The lights node. */ - _renderBundle(bundle: Bundle, sceneRef: Scene, lightsNode: LightsNode): void; + private _renderBundle; /** * Renders the scene or 3D object with the given camera. This method can only be called * if the renderer has been initialized. When using `render()` inside an animation loop, @@ -362,7 +807,7 @@ declare class Renderer { * @private * @return {?RenderTarget} The render target. The method returns `null` if no output conversion should be applied. */ - _getFrameBufferTarget(): RenderTarget> | null; + private _getFrameBufferTarget; /** * Renders the scene or 3D object with the given camera. * @@ -372,7 +817,7 @@ declare class Renderer { * @param {boolean} [useFrameBufferTarget=true] - Whether to use a framebuffer target or not. * @return {RenderContext} The current render context. */ - _renderScene(scene: Object3D, camera: Camera, useFrameBufferTarget?: boolean): RenderContext | undefined; + private _renderScene; _setXRLayerSize(width: number, height: number): void; /** * The output pass performs tone mapping and color space conversion. @@ -380,7 +825,7 @@ declare class Renderer { * @private * @param {RenderTarget} renderTarget - The current render target. */ - _renderOutput(renderTarget: RenderTarget): void; + private _renderOutput; /** * Returns the maximum available anisotropy for texture filtering. * @@ -429,7 +874,7 @@ declare class Renderer { * * @return {GPUCanvasContext|WebGL2RenderingContext} The rendering context. */ - getContext(): void; + getContext(): unknown; /** * Returns the pixel ratio. * @@ -499,16 +944,18 @@ declare class Renderer { * @return {Vector4} The scissor rectangle. */ getScissor(target: Vector4): Vector4; + /** + * Defines the scissor rectangle. + */ + setScissor(x: Vector4): void; /** * Defines the scissor rectangle. * - * @param {number | Vector4} x - The horizontal coordinate for the upper left corner of the box in logical pixel unit. - * Instead of passing four arguments, the method also works with a single four-dimensional vector. + * @param {number} x - The horizontal coordinate for the upper left corner of the box in logical pixel unit. * @param {number} y - The vertical coordinate for the upper left corner of the box in logical pixel unit. * @param {number} width - The width of the scissor box in logical pixel unit. * @param {number} height - The height of the scissor box in logical pixel unit. */ - setScissor(x: Vector4): void; setScissor(x: number, y: number, width: number, height: number): void; /** * Returns the scissor test value. @@ -529,17 +976,20 @@ declare class Renderer { * @return {Vector4} The viewport definition. */ getViewport(target: Vector4): Vector4; + /** + * Defines the viewport. + */ + setViewport(x: Vector4): void; /** * Defines the viewport. * - * @param {number | Vector4} x - The horizontal coordinate for the upper left corner of the viewport origin in logical pixel unit. + * @param {number} x - The horizontal coordinate for the upper left corner of the viewport origin in logical pixel unit. * @param {number} y - The vertical coordinate for the upper left corner of the viewport origin in logical pixel unit. * @param {number} width - The width of the viewport in logical pixel unit. * @param {number} height - The height of the viewport in logical pixel unit. * @param {number} minDepth - The minimum depth value of the viewport. WebGPU only. * @param {number} maxDepth - The maximum depth value of the viewport. WebGPU only. */ - setViewport(x: Vector4): void; setViewport(x: number, y: number, width: number, height: number, minDepth?: number, maxDepth?: number): void; /** * Returns the clear color. @@ -599,7 +1049,7 @@ declare class Renderer { * @param {Object3D} object - The 3D object to test. * @return {boolean} Whether the 3D object is fully occluded or not. */ - isOccluded(object: Object3D): boolean | null; + isOccluded(object: Object3D): boolean; /** * Performs a manual clear operation. This method ignores `autoClear` properties. * @@ -723,7 +1173,7 @@ declare class Renderer { * * @param {Object} renderTarget - The render target to set as the output target. */ - setOutputRenderTarget(renderTarget: RenderTarget | null): void; + setOutputRenderTarget(renderTarget: RenderTarget): void; /** * Returns the current output target. * @@ -748,7 +1198,7 @@ declare class Renderer { * * @private */ - _resetXRState(): void; + private _resetXRState; /** * Callback for {@link Renderer#setRenderObjectFunction}. * @@ -782,8 +1232,10 @@ declare class Renderer { camera: Camera, geometry: BufferGeometry, material: Material, - group: GeometryGroup, + group: GeometryGroup | null, lightsNode: LightsNode, + clippingContext: ClippingContext, + passId?: string | null | undefined, ) => void) | null, ): void; @@ -799,10 +1251,10 @@ declare class Renderer { camera: Camera, geometry: BufferGeometry, material: Material, - group: GeometryGroup, + group: GeometryGroup | null, lightsNode: LightsNode, - clippingContext: ClippingContext | null, - passId: string | null, + clippingContext: ClippingContext, + passId?: string | null | undefined, ) => void) | null; /** @@ -818,7 +1270,7 @@ declare class Renderer { */ compute( computeNodes: ComputeNode | ComputeNode[], - dispatchSize?: number[] | number | IndirectStorageBufferAttribute | null, + dispatchSize?: number | number[] | IndirectStorageBufferAttribute, ): Promise | undefined; /** * Execute a single or an array of compute nodes. @@ -833,7 +1285,7 @@ declare class Renderer { */ computeAsync( computeNodes: ComputeNode | ComputeNode[], - dispatchSize?: number[] | number | IndirectStorageBufferAttribute | null, + dispatchSize?: number | number[] | IndirectStorageBufferAttribute, ): Promise; /** * Checks if the given feature is supported by the selected backend. @@ -843,7 +1295,7 @@ declare class Renderer { * @param {string} name - The feature's name. * @return {Promise} A Promise that resolves with a bool that indicates whether the feature is supported or not. */ - hasFeatureAsync(name: string): Promise; + hasFeatureAsync(name: string): Promise; resolveTimestampsAsync(type?: TimestampQuery): Promise; /** * Checks if the given feature is supported by the selected backend. If the @@ -852,7 +1304,7 @@ declare class Renderer { * @param {string} name - The feature's name. * @return {boolean} Whether the feature is supported or not. */ - hasFeature(name: string): void; + hasFeature(name: string): boolean; /** * Returns `true` when the renderer has been initialized. * @@ -878,13 +1330,19 @@ declare class Renderer { * @param {Texture} texture - The texture. */ initTexture(texture: Texture): void; + /** + * Initializes the given render target. + * + * @param {RenderTarget} renderTarget - The render target to intialize. + */ + initRenderTarget(renderTarget: RenderTarget): void; /** * Copies the current bound framebuffer into the given texture. * * @param {FramebufferTexture} framebufferTexture - The texture. * @param {?(Vector2|Vector4)} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied. */ - copyFramebufferToTexture(framebufferTexture: FramebufferTexture, rectangle?: Rectangle | null): void; + copyFramebufferToTexture(framebufferTexture: FramebufferTexture, rectangle?: (Vector2 | Vector4) | null): void; /** * Copies data of the given source texture into a destination texture. * @@ -924,7 +1382,7 @@ declare class Renderer { height: number, textureIndex?: number, faceIndex?: number, - ): Promise; + ): Promise; /** * Analyzes the given 3D object's hierarchy and builds render lists from the * processed hierarchy. @@ -936,13 +1394,7 @@ declare class Renderer { * @param {RenderList} renderList - The current render list. * @param {ClippingContext} clippingContext - The current clipping context. */ - _projectObject( - object: Object3D, - camera: Camera, - groupOrder: number, - renderList: RenderList, - clippingContext: ClippingContext | null, - ): void; + private _projectObject; /** * Renders the given render bundles. * @@ -951,7 +1403,7 @@ declare class Renderer { * @param {Scene} sceneRef - The scene the render bundles belong to. * @param {LightsNode} lightsNode - The current lights node. */ - _renderBundles(bundles: Bundle[], sceneRef: Scene, lightsNode: LightsNode): void; + private _renderBundles; /** * Renders the transparent objects from the given render lists. * @@ -962,13 +1414,7 @@ declare class Renderer { * @param {Scene} scene - The scene the render list belongs to. * @param {LightsNode} lightsNode - The current lights node. */ - _renderTransparents( - renderList: RenderItem[], - doublePassList: RenderItem[], - camera: Camera, - scene: Scene, - lightsNode: LightsNode, - ): void; + private _renderTransparents; /** * Renders the objects from the given render list. * @@ -979,13 +1425,7 @@ declare class Renderer { * @param {LightsNode} lightsNode - The current lights node. * @param {?string} [passId=null] - An optional ID for identifying the pass. */ - _renderObjects( - renderList: RenderItem[], - camera: Camera, - scene: Scene, - lightsNode: LightsNode, - passId?: string | null, - ): void; + private _renderObjects; /** * Retrieves shadow nodes for the given material. This is used to setup shadow passes. * The result is cached per material and updated when the material's version changes. @@ -994,7 +1434,7 @@ declare class Renderer { * @param {Material} material * @returns {Object} - The shadow nodes for the material. */ - _getShadowNodes(material: Material): any; + private _getShadowNodes; /** * This method represents the default render object function that manages the render lifecycle * of the object. @@ -1015,11 +1455,19 @@ declare class Renderer { camera: Camera, geometry: BufferGeometry, material: Material, - group: GeometryGroup, + group: GeometryGroup | null, lightsNode: LightsNode, clippingContext?: ClippingContext | null, passId?: string | null, ): void; + /** + * Checks if the given compatibility is supported by the selected backend. If the + * renderer has not been initialized, this method always returns `false`. + * + * @param {string} name - The compatibility's name. + * @return {boolean} Whether the compatibility is supported or not. + */ + hasCompatibility(name: string): boolean; /** * This method represents the default `_handleObjectFunction` implementation which creates * a render object from the given data and performs the draw command with the selected backend. @@ -1034,16 +1482,7 @@ declare class Renderer { * @param {ClippingContext} clippingContext - The clipping context. * @param {string} [passId] - An optional ID for identifying the pass. */ - _renderObjectDirect( - object: Object3D, - material: Material, - scene: Scene, - camera: Camera, - lightsNode: LightsNode, - group: GeometryGroup, - clippingContext: ClippingContext | null, - passId?: string, - ): void; + private _renderObjectDirect; /** * A different implementation for `_handleObjectFunction` which only makes sure the object is ready for rendering. * Used in `compileAsync()`. @@ -1058,22 +1497,7 @@ declare class Renderer { * @param {ClippingContext} clippingContext - The clipping context. * @param {string} [passId] - An optional ID for identifying the pass. */ - _createObjectPipeline( - object: Object3D, - material: Material, - scene: Scene, - camera: Camera, - lightsNode: LightsNode, - group: Group, - clippingContext: ClippingContext | null, - passId?: string, - ): void; - /** - * Callback when the canvas has been resized. - * - * @private - */ - _onCanvasTargetResize(): void; + private _createObjectPipeline; /** * Alias for `compileAsync()`. * @@ -1085,11 +1509,5 @@ declare class Renderer { */ get compile(): (scene: Object3D, camera: Camera, targetScene?: Scene | null) => Promise; } -/** - * Animation loop parameter of `renderer.setAnimationLoop()`. - * - * @callback onAnimationCallback - * @param {DOMHighResTimeStamp} time - A timestamp indicating the end time of the previous frame's rendering. - * @param {XRFrame} [frame] - A reference to the current XR frame. Only relevant when using XR rendering. - */ + export default Renderer; diff --git a/types/three/src/renderers/common/Textures.d.ts b/types/three/src/renderers/common/Textures.d.ts index d81082f94ef270..1dc6d85fad6f97 100644 --- a/types/three/src/renderers/common/Textures.d.ts +++ b/types/three/src/renderers/common/Textures.d.ts @@ -1,41 +1,11 @@ import { RenderTarget } from "../../core/RenderTarget.js"; import { Vector3 } from "../../math/Vector3.js"; -import { DepthTexture } from "../../textures/DepthTexture.js"; import { Texture } from "../../textures/Texture.js"; import Backend from "./Backend.js"; import DataMap from "./DataMap.js"; import Info from "./Info.js"; import Renderer from "./Renderer.js"; -type SizeVector3Uninitialized = Vector3 & { - width?: number; - height?: number; - depth?: number; -}; -type SizeVector3 = Vector3 & { - width: number; - height: number; - depth: number; -}; -interface RenderTargetData { - depthTextureMips?: { - [activeMipmapLevel: number]: DepthTexture; - }; - width?: number; - height?: number; - textures?: Texture[]; - depthTexture?: DepthTexture; - depth?: boolean; - stencil?: boolean; - renderTarget?: RenderTarget; - sampleCount?: number; - initialized?: boolean; -} -interface TextureData { - initialized?: boolean; - version?: number; - isDefaultTexture?: boolean; - generation?: number; -} + interface TextureOptions { width?: number; height?: number; @@ -43,25 +13,14 @@ interface TextureOptions { needsMipmaps?: boolean; levels?: number; } + /** * This module manages the textures of the renderer. * * @private * @augments DataMap */ -declare class Textures extends DataMap<{ - renderTarget: { - key: RenderTarget; - value: RenderTargetData; - }; - texture: { - key: Texture; - value: TextureData; - }; -}> { - renderer: Renderer; - backend: Backend; - info: Info; +declare class Textures extends DataMap { /** * Constructs a new texture management component. * @@ -70,6 +29,24 @@ declare class Textures extends DataMap<{ * @param {Info} info - Renderer component for managing metrics and monitoring data. */ constructor(renderer: Renderer, backend: Backend, info: Info); + /** + * The renderer. + * + * @type {Renderer} + */ + renderer: Renderer; + /** + * The backend. + * + * @type {Backend} + */ + backend: Backend; + /** + * Renderer component for managing metrics and monitoring data. + * + * @type {Info} + */ + info: Info; /** * Updates the given render target. Based on the given render target configuration, * it updates the texture states representing the attachments of the framebuffer. @@ -99,7 +76,7 @@ declare class Textures extends DataMap<{ * @param {Texture} texture - The texture to update the sampler for. * @return {string} The current sampler key. */ - updateSampler(texture: Texture): void; + updateSampler(texture: Texture): string; /** * Computes the size of the given texture and writes the result * into the target vector. This vector is also returned by the @@ -112,7 +89,7 @@ declare class Textures extends DataMap<{ * @param {Vector3} target - The target vector. * @return {Vector3} The target vector. */ - getSize(texture: Texture, target?: SizeVector3Uninitialized): SizeVector3; + getSize(texture: Texture, target?: Vector3): Vector3; /** * Computes the number of mipmap levels for the given texture. * @@ -144,4 +121,5 @@ declare class Textures extends DataMap<{ */ _destroyTexture(texture: Texture): void; } + export default Textures; diff --git a/types/three/src/renderers/common/TimestampQueryPool.d.ts b/types/three/src/renderers/common/TimestampQueryPool.d.ts index 99136ddcbec60b..f34d38405325f8 100644 --- a/types/three/src/renderers/common/TimestampQueryPool.d.ts +++ b/types/three/src/renderers/common/TimestampQueryPool.d.ts @@ -4,21 +4,74 @@ * @abstract */ declare abstract class TimestampQueryPool { + /** + * Creates a new timestamp query pool. + * + * @param {number} [maxQueries=256] - Maximum number of queries this pool can hold. + */ + constructor(maxQueries?: number); + /** + * Whether to track timestamps or not. + * + * @type {boolean} + * @default true + */ trackTimestamp: boolean; + /** + * Maximum number of queries this pool can hold. + * + * @type {number} + * @default 256 + */ maxQueries: number; + /** + * How many queries allocated so far. + * + * @type {number} + * @default 0 + */ currentQueryIndex: number; - queryOffsets: Map; + /** + * Tracks offsets for different contexts. + * + * @type {Map} + */ + queryOffsets: Map; + /** + * Whether the pool has been disposed or not. + * + * @type {boolean} + * @default false + */ isDisposed: boolean; + /** + * The total frame duration until the next update. + * + * @type {number} + * @default 0 + */ lastValue: number; + /** + * Stores all timestamp frames. + * + * @type {Array} + */ frames: number[]; - pendingResolve: boolean; - timestamps: Map; /** - * Creates a new timestamp query pool. + * This property is used to avoid multiple concurrent resolve operations. + * The WebGL backend uses it as a boolean flag. In context of WebGPU, it holds + * the promise of the current resolve operation. * - * @param {number} [maxQueries=256] - Maximum number of queries this pool can hold. + * @type {boolean|Promise} + * @default false */ - constructor(maxQueries?: number); + pendingResolve: boolean | Promise; + /** + * Stores the latest timestamp for each render context. + * + * @type {Map} + */ + timestamps: Map; /** * Returns all timestamp frames. * @@ -31,7 +84,7 @@ declare abstract class TimestampQueryPool { * @param {string} uid - A unique identifier for the render context. * @return {?number} The timestamp, or undefined if not available. */ - getTimestamp(uid: string): number; + getTimestamp(uid: string): number | null; /** * Returns whether a timestamp is available for a given render context. * @@ -55,7 +108,7 @@ declare abstract class TimestampQueryPool { * @async * @returns {Promise|number} The resolved timestamp value. */ - abstract resolveQueriesAsync(): Promise; + abstract resolveQueriesAsync(): Promise | number; /** * Dispose of the query pool. * @@ -63,4 +116,5 @@ declare abstract class TimestampQueryPool { */ abstract dispose(): void; } + export default TimestampQueryPool; diff --git a/types/three/src/renderers/common/Uniform.d.ts b/types/three/src/renderers/common/Uniform.d.ts index 9d3bddc4762800..4e947de1014170 100644 --- a/types/three/src/renderers/common/Uniform.d.ts +++ b/types/three/src/renderers/common/Uniform.d.ts @@ -5,46 +5,14 @@ import { Matrix4 } from "../../math/Matrix4.js"; import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; import { Vector4 } from "../../math/Vector4.js"; -/** - * Abstract base class for uniforms. - * - * @abstract - * @private - */ -declare class Uniform { - name: string; - value: TValue; - boundary: number; - itemSize: number; - offset: number; - /** - * Constructs a new uniform. - * - * @param {string} name - The uniform's name. - * @param {any} value - The uniform's value. - */ - constructor(name: string, value: TValue); - /** - * Sets the uniform's value. - * - * @param {any} value - The value to set. - */ - setValue(value: TValue): void; - /** - * Returns the uniform's value. - * - * @return {any} The value. - */ - getValue(): TValue; -} + /** * Represents a Number uniform. * * @private * @augments Uniform */ -declare class NumberUniform extends Uniform { - readonly isNumberUniform: true; +export class NumberUniform extends Uniform { /** * Constructs a new Number uniform. * @@ -52,6 +20,14 @@ declare class NumberUniform extends Uniform { * @param {number} value - The uniform's value. */ constructor(name: string, value?: number); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isNumberUniform: boolean; } /** * Represents a Vector2 uniform. @@ -59,8 +35,7 @@ declare class NumberUniform extends Uniform { * @private * @augments Uniform */ -declare class Vector2Uniform extends Uniform { - readonly isVector2Uniform: true; +export class Vector2Uniform extends Uniform { /** * Constructs a new Number uniform. * @@ -68,6 +43,14 @@ declare class Vector2Uniform extends Uniform { * @param {Vector2} value - The uniform's value. */ constructor(name: string, value?: Vector2); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isVector2Uniform: boolean; } /** * Represents a Vector3 uniform. @@ -75,8 +58,7 @@ declare class Vector2Uniform extends Uniform { * @private * @augments Uniform */ -declare class Vector3Uniform extends Uniform { - readonly isVector3Uniform: true; +export class Vector3Uniform extends Uniform { /** * Constructs a new Number uniform. * @@ -84,6 +66,14 @@ declare class Vector3Uniform extends Uniform { * @param {Vector3} value - The uniform's value. */ constructor(name: string, value?: Vector3); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isVector3Uniform: boolean; } /** * Represents a Vector4 uniform. @@ -91,8 +81,7 @@ declare class Vector3Uniform extends Uniform { * @private * @augments Uniform */ -declare class Vector4Uniform extends Uniform { - readonly isVector4Uniform: true; +export class Vector4Uniform extends Uniform { /** * Constructs a new Number uniform. * @@ -100,6 +89,14 @@ declare class Vector4Uniform extends Uniform { * @param {Vector4} value - The uniform's value. */ constructor(name: string, value?: Vector4); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isVector4Uniform: boolean; } /** * Represents a Color uniform. @@ -107,8 +104,7 @@ declare class Vector4Uniform extends Uniform { * @private * @augments Uniform */ -declare class ColorUniform extends Uniform { - readonly isColorUniform: true; +export class ColorUniform extends Uniform { /** * Constructs a new Number uniform. * @@ -116,6 +112,14 @@ declare class ColorUniform extends Uniform { * @param {Color} value - The uniform's value. */ constructor(name: string, value?: Color); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isColorUniform: boolean; } /** * Represents a Matrix2 uniform. @@ -123,8 +127,7 @@ declare class ColorUniform extends Uniform { * @private * @augments Uniform */ -declare class Matrix2Uniform extends Uniform { - readonly isMatrix2Uniform: true; +export class Matrix2Uniform extends Uniform { /** * Constructs a new Number uniform. * @@ -132,6 +135,14 @@ declare class Matrix2Uniform extends Uniform { * @param {Matrix2} value - The uniform's value. */ constructor(name: string, value?: Matrix2); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isMatrix2Uniform: boolean; } /** * Represents a Matrix3 uniform. @@ -139,8 +150,7 @@ declare class Matrix2Uniform extends Uniform { * @private * @augments Uniform */ -declare class Matrix3Uniform extends Uniform { - readonly isMatrix3Uniform: true; +export class Matrix3Uniform extends Uniform { /** * Constructs a new Number uniform. * @@ -148,6 +158,14 @@ declare class Matrix3Uniform extends Uniform { * @param {Matrix3} value - The uniform's value. */ constructor(name: string, value?: Matrix3); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isMatrix3Uniform: boolean; } /** * Represents a Matrix4 uniform. @@ -155,8 +173,7 @@ declare class Matrix3Uniform extends Uniform { * @private * @augments Uniform */ -declare class Matrix4Uniform extends Uniform { - readonly isMatrix4Uniform: true; +export class Matrix4Uniform extends Uniform { /** * Constructs a new Number uniform. * @@ -164,14 +181,82 @@ declare class Matrix4Uniform extends Uniform { * @param {Matrix4} value - The uniform's value. */ constructor(name: string, value?: Matrix4); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isMatrix4Uniform: boolean; +} +/** + * Abstract base class for uniforms. + * + * @abstract + * @private + */ +declare class Uniform { + /** + * Constructs a new uniform. + * + * @param {string} name - The uniform's name. + * @param {any} value - The uniform's value. + */ + constructor(name: string, value: TValue); + /** + * The uniform's name. + * + * @type {string} + */ + name: string; + /** + * The uniform's value. + * + * @type {any} + */ + value: TValue; + /** + * Used to build the uniform buffer according to the STD140 layout. + * Derived uniforms will set this property to a data type specific + * value. + * + * @type {number} + */ + boundary: number; + /** + * The item size. Derived uniforms will set this property to a data + * type specific value. + * + * @type {number} + */ + itemSize: number; + /** + * This property is set by {@link UniformsGroup} and marks + * the start position in the uniform buffer. + * + * @type {number} + */ + offset: number; + /** + * This property is set by {@link UniformsGroup} and marks + * the index position in the uniform array. + * + * @type {number} + */ + index: number; + /** + * Sets the uniform's value. + * + * @param {any} value - The value to set. + */ + setValue(value: TValue): void; + /** + * Returns the uniform's value. + * + * @return {any} The value. + */ + getValue(): TValue; } -export { - ColorUniform, - Matrix2Uniform, - Matrix3Uniform, - Matrix4Uniform, - NumberUniform, - Vector2Uniform, - Vector3Uniform, - Vector4Uniform, -}; + +export type { Uniform }; diff --git a/types/three/src/renderers/common/UniformBuffer.d.ts b/types/three/src/renderers/common/UniformBuffer.d.ts index 808ecbaebc5afc..c6088e81aed414 100644 --- a/types/three/src/renderers/common/UniformBuffer.d.ts +++ b/types/three/src/renderers/common/UniformBuffer.d.ts @@ -1,4 +1,5 @@ import Buffer from "./Buffer.js"; + /** * Represents a uniform buffer binding type. * @@ -6,13 +7,14 @@ import Buffer from "./Buffer.js"; * @augments Buffer */ declare class UniformBuffer extends Buffer { - readonly isUniformBuffer: true; /** - * Constructs a new uniform buffer. + * This flag can be used for type testing. * - * @param {string} name - The buffer's name. - * @param {TypedArray} [buffer=null] - The buffer. + * @type {boolean} + * @readonly + * @default true */ - constructor(name?: string, buffer?: null); + readonly isUniformBuffer: boolean; } + export default UniformBuffer; diff --git a/types/three/src/renderers/common/UniformsGroup.d.ts b/types/three/src/renderers/common/UniformsGroup.d.ts index 7f48f89da9536e..5813e3470cea2e 100644 --- a/types/three/src/renderers/common/UniformsGroup.d.ts +++ b/types/three/src/renderers/common/UniformsGroup.d.ts @@ -8,7 +8,9 @@ import { Vector3NodeUniform, Vector4NodeUniform, } from "./nodes/NodeUniform.js"; +import { Uniform } from "./Uniform.js"; import UniformBuffer from "./UniformBuffer.js"; + /** * This class represents a uniform buffer binding but with * an API that allows to maintain individual uniform objects. @@ -17,15 +19,49 @@ import UniformBuffer from "./UniformBuffer.js"; * @augments UniformBuffer */ declare class UniformsGroup extends UniformBuffer { - readonly isUniformsGroup: true; - _values: number[] | null; - uniforms: NodeUniformGPU[]; /** * Constructs a new uniforms group. * * @param {string} name - The group's name. */ - constructor(name?: string); + constructor(name: string); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isUniformsGroup: boolean; + /** + * An array with the raw uniform values. + * + * @private + * @type {?Array} + * @default null + */ + private _values; + /** + * An array of uniform objects. + * + * The order of uniforms in this array must match the order of uniforms in the shader. + * + * @type {Array} + */ + uniforms: NodeUniformGPU[]; + /** + * A cache for the uniform update ranges. + * + * @private + * @type {Map} + */ + private _updateRangeCache; + /** + * Adds a uniform's update range to this buffer. + * + * @param {Uniform} uniform - The uniform. + */ + addUniformUpdateRange(uniform: Uniform): void; /** * Adds a uniform to this group. * @@ -46,28 +82,6 @@ declare class UniformsGroup extends UniformBuffer { * @type {Array} */ get values(): number[]; - /** - * A Float32 array buffer with the uniform values. - * - * @type {Float32Array} - */ - get buffer(): Float32Array; - /** - * The byte length of the buffer with correct buffer alignment. - * - * @type {number} - */ - get byteLength(): number; - /** - * Updates this group by updating each uniform object of - * the internal uniform list. The uniform objects check if their - * values has actually changed so this method only returns - * `true` if there is a real value change. - * - * @return {boolean} Whether the uniforms have been updated and - * must be uploaded to the GPU. - */ - update(): boolean; /** * Updates a given uniform by calling an update method matching * the uniforms type. @@ -75,56 +89,56 @@ declare class UniformsGroup extends UniformBuffer { * @param {Uniform} uniform - The uniform to update. * @return {boolean} Whether the uniform has been updated or not. */ - updateByType(uniform: NodeUniformGPU): boolean | undefined; + updateByType(uniform: NodeUniformGPU): boolean; /** * Updates a given Number uniform. * * @param {NumberUniform} uniform - The Number uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateNumber(uniform: NumberNodeUniform): boolean; + updateNumber(uniform: NumberNodeUniform): boolean; /** * Updates a given Vector2 uniform. * * @param {Vector2Uniform} uniform - The Vector2 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector2(uniform: Vector2NodeUniform): boolean; + updateVector2(uniform: Vector2NodeUniform): boolean; /** * Updates a given Vector3 uniform. * * @param {Vector3Uniform} uniform - The Vector3 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector3(uniform: Vector3NodeUniform): boolean; + updateVector3(uniform: Vector3NodeUniform): boolean; /** * Updates a given Vector4 uniform. * * @param {Vector4Uniform} uniform - The Vector4 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateVector4(uniform: Vector4NodeUniform): boolean; + updateVector4(uniform: Vector4NodeUniform): boolean; /** * Updates a given Color uniform. * * @param {ColorUniform} uniform - The Color uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateColor(uniform: ColorNodeUniform): boolean; + updateColor(uniform: ColorNodeUniform): boolean; /** * Updates a given Matrix3 uniform. * * @param {Matrix3Uniform} uniform - The Matrix3 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateMatrix3(uniform: Matrix3NodeUniform): boolean; + updateMatrix3(uniform: Matrix3NodeUniform): boolean; /** * Updates a given Matrix4 uniform. * * @param {Matrix4Uniform} uniform - The Matrix4 uniform. * @return {boolean} Whether the uniform has been updated or not. */ - updateMatrix4(uniform: Matrix4NodeUniform): boolean; + updateMatrix4(uniform: Matrix4NodeUniform): boolean; /** * Returns a typed array that matches the given data type. * @@ -132,6 +146,7 @@ declare class UniformsGroup extends UniformBuffer { * @param {string} type - The data type. * @return {TypedArray} The typed array. */ - _getBufferForType(type: string | null): Int32Array | Uint32Array | Float32Array; + private _getBufferForType; } + export default UniformsGroup; diff --git a/types/three/src/renderers/common/XRManager.d.ts b/types/three/src/renderers/common/XRManager.d.ts index ed12c0d97337ea..8b7b0ff4d42bf8 100644 --- a/types/three/src/renderers/common/XRManager.d.ts +++ b/types/three/src/renderers/common/XRManager.d.ts @@ -4,17 +4,15 @@ import { EventDispatcher } from "../../core/EventDispatcher.js"; import { RenderTarget } from "../../core/RenderTarget.js"; import { CylinderGeometry } from "../../geometries/CylinderGeometry.js"; import { PlaneGeometry } from "../../geometries/PlaneGeometry.js"; -import { Material } from "../../materials/Material.js"; import { MeshBasicMaterial } from "../../materials/MeshBasicMaterial.js"; import { Quaternion } from "../../math/Quaternion.js"; -import { Vector2 } from "../../math/Vector2.js"; import { Vector3 } from "../../math/Vector3.js"; import { Mesh } from "../../objects/Mesh.js"; -import { WebXRController } from "../webxr/WebXRController.js"; -import { AnimationContext } from "./Animation.js"; +import { XRGripSpace, XRHandSpace, XRTargetRaySpace } from "../webxr/WebXRController.js"; import QuadMesh from "./QuadMesh.js"; import Renderer from "./Renderer.js"; import { XRRenderTarget } from "./XRRenderTarget.js"; + export interface XRManagerEventMap { sessionstart: {}; sessionend: {}; @@ -22,39 +20,11 @@ export interface XRManagerEventMap { data: XRFrame; }; } -export interface XRQuadLayerObject { - type: "quad"; - width: number; - height: number; - translation: Vector3; - quaternion: Quaternion; - pixelwidth: number; - pixelheight: number; - plane: Mesh; - material: Material; - rendercall: () => void; - renderTarget: XRRenderTarget; - xrlayer?: XRLayer; -} -export interface XRCylinderLayerObject { - type: "cylinder"; - radius: number; - centralAngle: number; - aspectratio: number; - translation: Vector3; - quaternion: Quaternion; - pixelwidth: number; - pixelheight: number; - plane: Mesh; - material: Material; - rendercall: () => void; - renderTarget: XRRenderTarget; - xrlayer?: XRLayer; -} -export type XRLayerObject = XRQuadLayerObject | XRCylinderLayerObject; + export interface LayerAttributes { stencil?: boolean | undefined; } + /** * The XR manager is built on top of the WebXR Device API to * manage XR sessions with `WebGPURenderer`. @@ -64,59 +34,326 @@ export interface LayerAttributes { * @augments EventDispatcher */ declare class XRManager extends EventDispatcher { + /** + * Constructs a new XR manager. + * + * @param {Renderer} renderer - The renderer. + * @param {boolean} [multiview=false] - Enables multiview if the device supports it. + */ + constructor(renderer: Renderer, multiview?: boolean); + /** + * This flag globally enables XR rendering. + * + * @type {boolean} + * @default false + */ enabled: boolean; - isPresenting: boolean; + /** + * Whether the XR device is currently presenting or not. + * + * @type {boolean} + * @default false + * @readonly + */ + readonly isPresenting: boolean; + /** + * Whether the XR camera should automatically be updated or not. + * + * @type {boolean} + * @default true + */ cameraAutoUpdate: boolean; - _renderer: Renderer; - _cameraL: PerspectiveCamera; - _cameraR: PerspectiveCamera; - _cameras: PerspectiveCamera[]; - _cameraXR: ArrayCamera; - _currentDepthNear: number | null; - _currentDepthFar: number | null; - _controllers: WebXRController[]; - _controllerInputSources: (XRInputSource | null)[]; - _xrRenderTarget: XRRenderTarget | null; - _layers: XRLayerObject[]; - _sessionUsesLayers: boolean; - _supportsLayers: boolean; - _supportsGlBinding: boolean; + /** + * The renderer. + * + * @private + * @type {Renderer} + */ + private _renderer; + /** + * Represents the camera for the left eye. + * + * @private + * @type {PerspectiveCamera} + */ + private _cameraL; + /** + * Represents the camera for the right eye. + * + * @private + * @type {PerspectiveCamera} + */ + private _cameraR; + /** + * A list of cameras used for rendering the XR views. + * + * @private + * @type {Array} + */ + private _cameras; + /** + * The main XR camera. + * + * @private + * @type {ArrayCamera} + */ + private _cameraXR; + /** + * The current near value of the XR camera. + * + * @private + * @type {?number} + * @default null + */ + private _currentDepthNear; + /** + * The current far value of the XR camera. + * + * @private + * @type {?number} + * @default null + */ + private _currentDepthFar; + /** + * A list of WebXR controllers requested by the application. + * + * @private + * @type {Array} + */ + private _controllers; + /** + * A list of XR input source. Each input source belongs to + * an instance of WebXRController. + * + * @private + * @type {Array} + */ + private _controllerInputSources; + /** + * The XR render target that represents the rendering destination + * during an active XR session. + * + * @private + * @type {?RenderTarget} + * @default null + */ + private _xrRenderTarget; + /** + * An array holding all the non-projection layers + * + * @private + * @type {Array} + * @default [] + */ + private _layers; + /** + * Whether the XR session uses layers. + * + * @private + * @type {boolean} + * @default false + */ + private _sessionUsesLayers; + /** + * Whether the device supports binding gl objects. + * + * @private + * @type {boolean} + * @readonly + */ + private readonly _supportsGlBinding; _frameBufferTargets: | WeakMap | null; - _createXRLayer: (layer: XRLayerObject) => XRLayer; - _gl: WebGL2RenderingContext | null; - _currentAnimationContext: AnimationContext | null; - _currentAnimationLoop: ((time: DOMHighResTimeStamp, frame?: XRFrame) => void) | null; - _currentPixelRatio: number | null; - _currentSize: Vector2; - _onSessionEvent: (event: XRInputSourceEvent) => void; - _onSessionEnd: () => void; - _onInputSourcesChange: (event: XRInputSourcesChangeEvent) => void; - _onAnimationFrame: (time: DOMHighResTimeStamp, frame?: XRFrame) => void; - _referenceSpace: XRReferenceSpace | null; - _referenceSpaceType: XRReferenceSpaceType; - _customReferenceSpace: XRReferenceSpace | null; - _framebufferScaleFactor: number; - _foveation: number; - _session: XRSession | null; - _glBaseLayer: XRWebGLLayer | null; - _glBinding: XRWebGLBinding | null; - _glProjLayer: XRProjectionLayer | null; - _xrFrame: XRFrame | null; - _useLayers: boolean; - _useMultiviewIfPossible: boolean; - _useMultiview: boolean; /** - * Constructs a new XR manager. + * Helper function to create native WebXR Layer. * - * @param {Renderer} renderer - The renderer. - * @param {boolean} [multiview=false] - Enables multiview if the device supports it. + * @private + * @type {Function} */ - constructor(renderer: Renderer, multiview?: boolean); + private _createXRLayer; + /** + * The current WebGL context. + * + * @private + * @type {?WebGL2RenderingContext} + * @default null + */ + private _gl; + /** + * The current animation context. + * + * @private + * @type {?Window} + * @default null + */ + private _currentAnimationContext; + /** + * The current animation loop. + * + * @private + * @type {?Function} + * @default null + */ + private _currentAnimationLoop; + /** + * The current pixel ratio. + * + * @private + * @type {?number} + * @default null + */ + private _currentPixelRatio; + /** + * The current size of the renderer's canvas + * in logical pixel unit. + * + * @private + * @type {Vector2} + */ + private _currentSize; + /** + * The default event listener for handling events inside a XR session. + * + * @private + * @type {Function} + */ + private _onSessionEvent; + /** + * The event listener for handling the end of a XR session. + * + * @private + * @type {Function} + */ + private _onSessionEnd; + /** + * The event listener for handling the `inputsourceschange` event. + * + * @private + * @type {Function} + */ + private _onInputSourcesChange; + /** + * The animation loop which is used as a replacement for the default + * animation loop of the application. It is only used when a XR session + * is active. + * + * @private + * @type {Function} + */ + private _onAnimationFrame; + /** + * The current XR reference space. + * + * @private + * @type {?XRReferenceSpace} + * @default null + */ + private _referenceSpace; + /** + * The current XR reference space type. + * + * @private + * @type {XRReferenceSpaceType} + * @default 'local-floor' + */ + private _referenceSpaceType; + /** + * A custom reference space defined by the application. + * + * @private + * @type {?XRReferenceSpace} + * @default null + */ + private _customReferenceSpace; + /** + * The framebuffer scale factor. + * + * @private + * @type {number} + * @default 1 + */ + private _framebufferScaleFactor; + /** + * The foveation factor. + * + * @private + * @type {number} + * @default 1 + */ + private _foveation; + /** + * A reference to the current XR session. + * + * @private + * @type {?XRSession} + * @default null + */ + private _session; + /** + * A reference to the current XR base layer. + * + * @private + * @type {?XRWebGLLayer} + * @default null + */ + private _glBaseLayer; + /** + * A reference to the current XR binding. + * + * @private + * @type {?XRWebGLBinding} + * @default null + */ + private _glBinding; + /** + * A reference to the current XR projection layer. + * + * @private + * @type {?XRProjectionLayer} + * @default null + */ + private _glProjLayer; + /** + * A reference to the current XR frame. + * + * @private + * @type {?XRFrame} + * @default null + */ + private _xrFrame; + /** + * Whether the browser supports the APIs necessary to use XRProjectionLayers. + * + * Note: this does not represent XRSession explicitly requesting + * `'layers'` as a feature - see `_sessionUsesLayers` and #30112 + * + * @private + * @type {boolean} + * @readonly + */ + private readonly _supportsLayers; + /** + * Whether the usage of multiview has been requested by the application or not. + * + * @private + * @type {boolean} + * @default false + * @readonly + */ + private readonly _useMultiviewIfPossible; + /** + * Whether the usage of multiview is actually enabled. This flag only evaluates to `true` + * if multiview has been requested by the application and the `OVR_multiview2` is available. + * + * @private + * @type {boolean} + * @readonly + */ + private readonly _useMultiview; /** * Returns an instance of `THREE.Group` that represents the transformation * of a XR controller in target ray space. The requested controller is defined @@ -125,7 +362,7 @@ declare class XRManager extends EventDispatcher { * @param {number} index - The index of the XR controller. * @return {Group} A group that represents the controller's transformation. */ - getController(index: number): import("../webxr/WebXRController.js").XRTargetRaySpace; + getController(index: number): XRTargetRaySpace; /** * Returns an instance of `THREE.Group` that represents the transformation * of a XR controller in grip space. The requested controller is defined @@ -134,7 +371,7 @@ declare class XRManager extends EventDispatcher { * @param {number} index - The index of the XR controller. * @return {Group} A group that represents the controller's transformation. */ - getControllerGrip(index: number): import("../webxr/WebXRController.js").XRGripSpace; + getControllerGrip(index: number): XRGripSpace; /** * Returns an instance of `THREE.Group` that represents the transformation * of a XR controller in hand space. The requested controller is defined @@ -143,7 +380,7 @@ declare class XRManager extends EventDispatcher { * @param {number} index - The index of the XR controller. * @return {Group} A group that represents the controller's transformation. */ - getHand(index: number): import("../webxr/WebXRController.js").XRHandSpace; + getHand(index: number): XRHandSpace; /** * Returns the foveation value. * @@ -190,7 +427,7 @@ declare class XRManager extends EventDispatcher { * * @return {XRReferenceSpace} The XR reference space. */ - getReferenceSpace(): XRReferenceSpace | null; + getReferenceSpace(): XRReferenceSpace; /** * Sets a custom XR reference space. * @@ -254,7 +491,7 @@ declare class XRManager extends EventDispatcher { pixelheight: number, rendercall: () => void, attributes?: LayerAttributes, - ): Mesh; + ): Mesh; /** * This method can be used in XR applications to create a cylindrical layer that presents a separate * rendered scene. @@ -281,7 +518,7 @@ declare class XRManager extends EventDispatcher { pixelheight: number, rendercall: () => void, attributes?: LayerAttributes, - ): Mesh; + ): Mesh; /** * Renders the XR layers that have been previously added to the scene. * @@ -320,6 +557,7 @@ declare class XRManager extends EventDispatcher { * @param {number} index - The controller index. * @return {WebXRController} The XR controller. */ - _getController(index: number): WebXRController; + private _getController; } + export default XRManager; diff --git a/types/three/src/renderers/common/XRRenderTarget.d.ts b/types/three/src/renderers/common/XRRenderTarget.d.ts index ae73f84f80298a..2c8ff28a1e339b 100644 --- a/types/three/src/renderers/common/XRRenderTarget.d.ts +++ b/types/three/src/renderers/common/XRRenderTarget.d.ts @@ -1,4 +1,5 @@ import { RenderTarget, RenderTargetOptions } from "../../core/RenderTarget.js"; + /** * A special type of render target that is used when rendering * with the WebXR Device API. @@ -6,11 +7,7 @@ import { RenderTarget, RenderTargetOptions } from "../../core/RenderTarget.js"; * @private * @augments RenderTarget */ -declare class XRRenderTarget extends RenderTarget { - readonly isXRRenderTarget: true; - _hasExternalTextures: boolean; - _autoAllocateDepthBuffer: boolean; - _isOpaqueFramebuffer: boolean; +export class XRRenderTarget extends RenderTarget { /** * Constructs a new XR render target. * @@ -19,6 +16,52 @@ declare class XRRenderTarget extends RenderTarget { * @param {Object} [options={}] - The configuration options. */ constructor(width?: number, height?: number, options?: RenderTargetOptions); + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isXRRenderTarget: boolean; + /** + * Whether the attachments of the render target + * are defined by external textures. This flag is + * set to `true` when using the WebXR Layers API. + * + * @private + * @type {boolean} + * @default false + */ + private _hasExternalTextures; + /** + * Whether a depth buffer should automatically be allocated + * for this XR render target or not. + * + * Allocating a depth buffer is the default behavior of XR render + * targets. However, when using the WebXR Layers API, this flag + * must be set to `false` when the `ignoreDepthValues` property of + * the projection layers evaluates to `false`. + * + * Reference: {@link https://www.w3.org/TR/webxrlayers-1/#dom-xrprojectionlayer-ignoredepthvalues}. + * + * @private + * @type {boolean} + * @default true + */ + private _autoAllocateDepthBuffer; + /** + * Whether this render target is associated with a XRWebGLLayer. + * + * A XRWebGLLayer points to an opaque framebuffer. Basically, + * this means that you don't have access to its bound color, + * stencil and depth buffers. We need to handle this framebuffer + * differently since its textures are always bound. + * + * @private + * @type {boolean} + * @default false + */ + private _isOpaqueFramebuffer; copy(source: XRRenderTarget): this; } -export { XRRenderTarget }; diff --git a/types/three/src/renderers/common/nodes/NodeBuilderState.d.ts b/types/three/src/renderers/common/nodes/NodeBuilderState.d.ts index a166ca35acb65e..828ecb286b92f7 100644 --- a/types/three/src/renderers/common/nodes/NodeBuilderState.d.ts +++ b/types/three/src/renderers/common/nodes/NodeBuilderState.d.ts @@ -2,6 +2,7 @@ import NodeMaterialObserver from "../../../materials/nodes/manager/NodeMaterialO import Node from "../../../nodes/core/Node.js"; import NodeAttribute from "../../../nodes/core/NodeAttribute.js"; import BindGroup from "../BindGroup.js"; + /** * This module represents the state of a node builder after it was * used to build the nodes for a render object. The state holds the @@ -12,17 +13,6 @@ import BindGroup from "../BindGroup.js"; * @private */ declare class NodeBuilderState { - vertexShader: string | null; - fragmentShader: string | null; - computeShader: string | null; - transforms: never[]; - nodeAttributes: NodeAttribute[]; - bindings: BindGroup[]; - updateNodes: Node[]; - updateBeforeNodes: Node[]; - updateAfterNodes: Node[]; - observer: NodeMaterialObserver; - usedTimes: number; /** * Constructs a new node builder state. * @@ -38,17 +28,86 @@ declare class NodeBuilderState { * @param {Array} transforms - An array with transform attribute objects. Only relevant when using compute shaders with WebGL 2. */ constructor( - vertexShader: string | null, - fragmentShader: string | null, - computeShader: string | null, + vertexShader: string, + fragmentShader: string, + computeShader: string, nodeAttributes: NodeAttribute[], bindings: BindGroup[], updateNodes: Node[], updateBeforeNodes: Node[], updateAfterNodes: Node[], observer: NodeMaterialObserver, - transforms?: never[], + transforms?: unknown[], ); + /** + * The native vertex shader code. + * + * @type {string} + */ + vertexShader: string; + /** + * The native fragment shader code. + * + * @type {string} + */ + fragmentShader: string; + /** + * The native compute shader code. + * + * @type {string} + */ + computeShader: string; + /** + * An array with transform attribute objects. + * Only relevant when using compute shaders with WebGL 2. + * + * @type {Array} + */ + transforms: unknown[]; + /** + * An array of node attributes representing + * the attributes of the shaders. + * + * @type {Array} + */ + nodeAttributes: NodeAttribute[]; + /** + * An array of bind groups representing the uniform or storage + * buffers, texture or samplers of the shader. + * + * @type {Array} + */ + bindings: BindGroup[]; + /** + * An array of nodes that implement their `update()` method. + * + * @type {Array} + */ + updateNodes: Node[]; + /** + * An array of nodes that implement their `updateBefore()` method. + * + * @type {Array} + */ + updateBeforeNodes: Node[]; + /** + * An array of nodes that implement their `updateAfter()` method. + * + * @type {Array} + */ + updateAfterNodes: Node[]; + /** + * A node material observer. + * + * @type {NodeMaterialObserver} + */ + observer: NodeMaterialObserver; + /** + * How often this state is used by render objects. + * + * @type {number} + */ + usedTimes: number; /** * This method is used to create a array of bind groups based * on the existing bind groups of this state. Shared groups are @@ -58,4 +117,5 @@ declare class NodeBuilderState { */ createBindings(): BindGroup[]; } + export default NodeBuilderState; diff --git a/types/three/src/renderers/common/nodes/NodeLibrary.d.ts b/types/three/src/renderers/common/nodes/NodeLibrary.d.ts index e3a078a147b39c..019d66f29e59e8 100644 --- a/types/three/src/renderers/common/nodes/NodeLibrary.d.ts +++ b/types/three/src/renderers/common/nodes/NodeLibrary.d.ts @@ -4,6 +4,7 @@ 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 @@ -13,19 +14,31 @@ import AnalyticLightNode from "../../../nodes/lighting/AnalyticLightNode.js"; * @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; - toneMappingNodes: Map Node>; /** - * Constructs a new node library. + * A map that maps tone mapping techniques (constants) + * to tone mapping node functions. + * + * @type {Map} */ - constructor(); + toneMappingNodes: Map Node>; /** * Returns a matching node material instance for the given material object. * @@ -36,7 +49,7 @@ declare class NodeLibrary { * @param {Material} material - A material. * @return {NodeMaterial} The corresponding node material. */ - fromMaterial(material: Material): Material | NodeMaterial | null; + fromMaterial(material: Material): NodeMaterial; /** * Adds a tone mapping node function for a tone mapping technique (constant). * @@ -73,7 +86,13 @@ declare class NodeLibrary { * @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: Light): (new(light: Light) => AnalyticLightNode) | null; + getLightNodeClass(light: { + new(): Light; + }): + | ({ + new(light: Light): AnalyticLightNode; + }) + | null; /** * Adds a light node class definition for a given light class definition. * @@ -106,4 +125,5 @@ declare class NodeLibrary { library: WeakMap, ): void; } + export default NodeLibrary; diff --git a/types/three/src/renderers/common/nodes/Nodes.d.ts b/types/three/src/renderers/common/nodes/NodeManager.d.ts similarity index 76% rename from types/three/src/renderers/common/nodes/Nodes.d.ts rename to types/three/src/renderers/common/nodes/NodeManager.d.ts index d2a1b20d6e17e1..28fae2113a1d2d 100644 --- a/types/three/src/renderers/common/nodes/Nodes.d.ts +++ b/types/three/src/renderers/common/nodes/NodeManager.d.ts @@ -1,17 +1,11 @@ import { Camera } from "../../../cameras/Camera.js"; import { Object3D } from "../../../core/Object3D.js"; import { Material } from "../../../materials/Material.js"; -import { Color } from "../../../math/Color.js"; import Node from "../../../nodes/core/Node.js"; -import NodeBuilder from "../../../nodes/core/NodeBuilder.js"; -import UniformGroupNode from "../../../nodes/core/UniformGroupNode.js"; +import NodeFrame from "../../../nodes/core/NodeFrame.js"; import ComputeNode from "../../../nodes/gpgpu/ComputeNode.js"; import LightsNode from "../../../nodes/lighting/LightsNode.js"; -import { NodeFrame } from "../../../nodes/Nodes.js"; -import { Fog } from "../../../scenes/Fog.js"; -import { FogExp2 } from "../../../scenes/FogExp2.js"; import { Scene } from "../../../scenes/Scene.js"; -import { CubeTexture } from "../../../textures/CubeTexture.js"; import { Texture } from "../../../textures/Texture.js"; import Backend from "../Backend.js"; import ChainMap from "../ChainMap.js"; @@ -20,35 +14,15 @@ import Renderer from "../Renderer.js"; import RenderObject from "../RenderObject.js"; import NodeBuilderState from "./NodeBuilderState.js"; import NodeUniformsGroup from "./NodeUniformsGroup.js"; -interface NodeUniformsGroupData { - renderId?: number | undefined; - frameId?: number | undefined; -} -interface RenderObjectData { - nodeBuilderState?: NodeBuilderState | undefined; -} -interface ComputeNodeData { - nodeBuilderState?: NodeBuilderState | undefined; -} -interface SceneData { - background?: Color | Texture | CubeTexture | undefined; - backgroundNode?: Node | undefined; - fog?: Fog | FogExp2 | undefined; - fogNode?: Node | undefined; - environment?: Texture | undefined; - environmentNode?: Node | undefined; -} -interface CacheKeyData { - callId: number; - cacheKey: number; -} + declare module "../../../scenes/Scene.js" { interface Scene { - environmentNode?: Node | null | undefined; + environmentNode?: Node<"vec3"> | null | undefined; backgroundNode?: Node | null | undefined; fogNode?: Node | null | undefined; } } + /** * This renderer module manages node-related objects and is the * primary interface between the renderer and the node system. @@ -56,42 +30,59 @@ declare module "../../../scenes/Scene.js" { * @private * @augments DataMap */ -declare class Nodes extends DataMap<{ +declare class NodeManager extends DataMap { /** * Constructs a new nodes management component. * * @param {Renderer} renderer - The renderer. * @param {Backend} backend - The renderer's backend. */ - nodeUniformsGroup: { - key: NodeUniformsGroup; - value: NodeUniformsGroupData; - }; - renderObject: { - key: RenderObject; - value: RenderObjectData; - }; - computeNode: { - key: ComputeNode; - value: ComputeNodeData; - }; - scene: { - key: Scene; - value: SceneData; - }; -}> { + constructor(renderer: Renderer, backend: Backend); + /** + * The renderer. + * + * @type {Renderer} + */ renderer: Renderer; + /** + * The renderer's backend. + * + * @type {Backend} + */ backend: Backend; + /** + * The node frame. + * + * @type {Renderer} + */ nodeFrame: NodeFrame; - nodeBuilderCache: Map; - callHashCache: ChainMap; - groupsData: ChainMap; + /** + * A cache for managing node builder states. + * + * @type {Map} + */ + nodeBuilderCache: Map; + /** + * A cache for managing data cache key data. + * + * @type {ChainMap} + */ + callHashCache: ChainMap; + /** + * A cache for managing node uniforms group data. + * + * @type {ChainMap} + */ + groupsData: ChainMap; + /** + * A cache for managing node objects of + * scene properties like fog or environments. + * + * @type {Object} + */ cacheLib: { - [type: string]: WeakMap; + [x: string]: WeakMap; }; - constructor(renderer: Renderer, backend: Backend); /** * Returns `true` if the given node uniforms group must be updated or not. * @@ -119,9 +110,7 @@ declare class Nodes extends DataMap<{ * @param {any} object - The object to delete. * @return {?Object} The deleted dictionary. */ - delete( - object: NodeUniformsGroup | RenderObject | ComputeNode | Scene, - ): RenderObjectData | NodeUniformsGroupData | ComputeNodeData | SceneData; + delete(object: unknown): unknown | null; /** * Returns a node builder state for the given compute node. * @@ -136,7 +125,7 @@ declare class Nodes extends DataMap<{ * @param {NodeBuilder} nodeBuilder - The node builder. * @return {NodeBuilderState} The node builder state. */ - _createNodeBuilderState(nodeBuilder: NodeBuilder): NodeBuilderState; + private _createNodeBuilderState; /** * Returns an environment node for the current configured * scene environment. @@ -144,7 +133,7 @@ declare class Nodes extends DataMap<{ * @param {Scene} scene - The scene. * @return {Node} A node representing the current scene environment. */ - getEnvironmentNode(scene: Scene): Node | null; + getEnvironmentNode(scene: Scene): Node; /** * Returns a background node for the current configured * scene background. @@ -152,14 +141,14 @@ declare class Nodes extends DataMap<{ * @param {Scene} scene - The scene. * @return {Node} A node representing the current scene background. */ - getBackgroundNode(scene: Scene): Node | null; + getBackgroundNode(scene: Scene): Node; /** * Returns a fog node for the current configured scene fog. * * @param {Scene} scene - The scene. * @return {Node} A node representing the current scene fog. */ - getFogNode(scene: Scene): Node | null; + getFogNode(scene: Scene): Node; /** * Returns a cache key for the given scene and lights node. * This key is used by `RenderObject` as a part of the dynamic @@ -195,12 +184,7 @@ declare class Nodes extends DataMap<{ * @param {boolean} [forceUpdate=false] - Whether an update should be enforced or not. * @return {Node} The node representation. */ - getCacheNode( - type: string, - object: object, - callback: () => Node | undefined, - forceUpdate?: boolean, - ): Node | undefined; + getCacheNode(type: string, object: object, callback: () => Node | undefined, forceUpdate?: boolean): Node; /** * If a scene fog is configured, this method makes sure to * represent the fog with a corresponding node-based implementation. @@ -280,9 +264,6 @@ declare class Nodes extends DataMap<{ * @return {boolean} Whether the given render object requires a refresh or not. */ needsRefresh(renderObject: RenderObject): boolean; - /** - * Frees the internal resources. - */ - dispose(): void; } -export default Nodes; + +export default NodeManager; diff --git a/types/three/src/renderers/common/nodes/NodeUniform.d.ts b/types/three/src/renderers/common/nodes/NodeUniform.d.ts index b5d6209e23f21f..a01bb19a5d5afd 100644 --- a/types/three/src/renderers/common/nodes/NodeUniform.d.ts +++ b/types/three/src/renderers/common/nodes/NodeUniform.d.ts @@ -16,6 +16,7 @@ import { Vector3Uniform, Vector4Uniform, } from "../Uniform.js"; + /** * A special form of Number uniform binding type. * It's value is managed by a node object. @@ -23,14 +24,19 @@ import { * @private * @augments NumberUniform */ -declare class NumberNodeUniform extends NumberUniform { - nodeUniform: NodeUniform; +export class NumberNodeUniform extends NumberUniform { /** * Constructs a new node-based Number uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); + /** + * The node uniform. + * + * @type {NodeUniform} + */ + nodeUniform: NodeUniform; /** * Overwritten to return the value of the node uniform. * @@ -42,7 +48,7 @@ declare class NumberNodeUniform extends NumberUniform { * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Vector2 uniform binding type. @@ -51,26 +57,25 @@ declare class NumberNodeUniform extends NumberUniform { * @private * @augments Vector2Uniform */ -declare class Vector2NodeUniform extends Vector2Uniform { - nodeUniform: NodeUniform; +export class Vector2NodeUniform extends Vector2Uniform { /** * Constructs a new node-based Vector2 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Vector2} The value. + * @type {NodeUniform} */ - getValue(): Vector2; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Vector3 uniform binding type. @@ -79,26 +84,25 @@ declare class Vector2NodeUniform extends Vector2Uniform { * @private * @augments Vector3Uniform */ -declare class Vector3NodeUniform extends Vector3Uniform { - nodeUniform: NodeUniform; +export class Vector3NodeUniform extends Vector3Uniform { /** * Constructs a new node-based Vector3 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Vector3} The value. + * @type {NodeUniform} */ - getValue(): Vector3; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Vector4 uniform binding type. @@ -107,26 +111,25 @@ declare class Vector3NodeUniform extends Vector3Uniform { * @private * @augments Vector4Uniform */ -declare class Vector4NodeUniform extends Vector4Uniform { - nodeUniform: NodeUniform; +export class Vector4NodeUniform extends Vector4Uniform { /** * Constructs a new node-based Vector4 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Vector4} The value. + * @type {NodeUniform} */ - getValue(): Vector4; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Color uniform binding type. @@ -135,26 +138,25 @@ declare class Vector4NodeUniform extends Vector4Uniform { * @private * @augments ColorUniform */ -declare class ColorNodeUniform extends ColorUniform { - nodeUniform: NodeUniform; +export class ColorNodeUniform extends ColorUniform { /** * Constructs a new node-based Color uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Color} The value. + * @type {NodeUniform} */ - getValue(): Color; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Matrix2 uniform binding type. @@ -163,26 +165,25 @@ declare class ColorNodeUniform extends ColorUniform { * @private * @augments Matrix2Uniform */ -declare class Matrix2NodeUniform extends Matrix2Uniform { - nodeUniform: NodeUniform; +export class Matrix2NodeUniform extends Matrix2Uniform { /** * Constructs a new node-based Matrix2 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Matrix2} The value. + * @type {NodeUniform} */ - getValue(): Matrix2; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Matrix3 uniform binding type. @@ -191,26 +192,25 @@ declare class Matrix2NodeUniform extends Matrix2Uniform { * @private * @augments Matrix3Uniform */ -declare class Matrix3NodeUniform extends Matrix3Uniform { - nodeUniform: NodeUniform; +export class Matrix3NodeUniform extends Matrix3Uniform { /** * Constructs a new node-based Matrix3 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Matrix3} The value. + * @type {NodeUniform} */ - getValue(): Matrix3; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } /** * A special form of Matrix4 uniform binding type. @@ -219,42 +219,32 @@ declare class Matrix3NodeUniform extends Matrix3Uniform { * @private * @augments Matrix4Uniform */ -declare class Matrix4NodeUniform extends Matrix4Uniform { - nodeUniform: NodeUniform; +export class Matrix4NodeUniform extends Matrix4Uniform { /** * Constructs a new node-based Matrix4 uniform. * * @param {NodeUniform} nodeUniform - The node uniform. */ - constructor(nodeUniform: NodeUniform); + constructor(nodeUniform: NodeUniform); /** - * Overwritten to return the value of the node uniform. + * The node uniform. * - * @return {Matrix4} The value. + * @type {NodeUniform} */ - getValue(): Matrix4; + nodeUniform: NodeUniform; /** * Returns the node uniform data type. * * @return {string} The data type. */ - getType(): string | null; + getType(): string; } -export { - ColorNodeUniform, - Matrix2NodeUniform, - Matrix3NodeUniform, - Matrix4NodeUniform, - NumberNodeUniform, - Vector2NodeUniform, - Vector3NodeUniform, - Vector4NodeUniform, -}; + export type NodeUniformGPU = - | NumberNodeUniform - | Vector2NodeUniform - | Vector3NodeUniform - | Vector4NodeUniform - | ColorNodeUniform - | Matrix3NodeUniform - | Matrix4NodeUniform; + | NumberNodeUniform + | Vector2NodeUniform + | Vector3NodeUniform + | Vector4NodeUniform + | ColorNodeUniform + | Matrix3NodeUniform + | Matrix4NodeUniform; diff --git a/types/three/src/renderers/common/nodes/NodeUniformsGroup.d.ts b/types/three/src/renderers/common/nodes/NodeUniformsGroup.d.ts index abb6775714b1c2..8dfe5e108e578b 100644 --- a/types/three/src/renderers/common/nodes/NodeUniformsGroup.d.ts +++ b/types/three/src/renderers/common/nodes/NodeUniformsGroup.d.ts @@ -1,5 +1,6 @@ -import { UniformGroupNode } from "../../../nodes/Nodes.js"; +import UniformGroupNode from "../../../nodes/core/UniformGroupNode.js"; import UniformsGroup from "../UniformsGroup.js"; + /** * A special form of uniforms group that represents * the individual uniforms as node-based uniforms. @@ -8,9 +9,6 @@ import UniformsGroup from "../UniformsGroup.js"; * @augments UniformsGroup */ declare class NodeUniformsGroup extends UniformsGroup { - id: number; - groupNode: UniformGroupNode; - readonly isNodeUniformsGroup: true; /** * Constructs a new node-based uniforms group. * @@ -18,5 +16,26 @@ declare class NodeUniformsGroup extends UniformsGroup { * @param {UniformGroupNode} groupNode - The uniform group node. */ constructor(name: string, groupNode: UniformGroupNode); + /** + * The group's ID. + * + * @type {number} + */ + id: number; + /** + * The uniform group node. + * + * @type {UniformGroupNode} + */ + groupNode: UniformGroupNode; + /** + * This flag can be used for type testing. + * + * @type {boolean} + * @readonly + * @default true + */ + readonly isNodeUniformsGroup: boolean; } + export default NodeUniformsGroup; diff --git a/types/three/src/renderers/shaders/UniformsLib.d.ts b/types/three/src/renderers/shaders/UniformsLib.d.ts index cb0d808bdc7c13..c43cb57222cca1 100644 --- a/types/three/src/renderers/shaders/UniformsLib.d.ts +++ b/types/three/src/renderers/shaders/UniformsLib.d.ts @@ -96,7 +96,6 @@ export const UniformsLib: { shadowMapSize: {}; }; }; - directionalShadowMap: IUniform; directionalShadowMatrix: IUniform; spotLights: { value: unknown[]; @@ -121,7 +120,6 @@ export const UniformsLib: { }; }; spotLightMap: IUniform; - spotShadowMap: IUniform; spotLightMatrix: IUniform; pointLights: { value: unknown[]; @@ -144,7 +142,6 @@ export const UniformsLib: { shadowCameraFar: {}; }; }; - pointShadowMap: IUniform; pointShadowMatrix: IUniform; hemisphereLights: { value: unknown[]; diff --git a/types/three/src/renderers/webgl/WebGLAttributes.d.ts b/types/three/src/renderers/webgl/WebGLAttributes.d.ts index 8f4a9757b9d1b7..41754003eb2cab 100644 --- a/types/three/src/renderers/webgl/WebGLAttributes.d.ts +++ b/types/three/src/renderers/webgl/WebGLAttributes.d.ts @@ -2,17 +2,19 @@ import { BufferAttribute } from "../../core/BufferAttribute.js"; import { GLBufferAttribute } from "../../core/GLBufferAttribute.js"; import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribute.js"; +export interface WebGLAttribute { + buffer: WebGLBuffer; + type: number; + bytesPerElement: number; + version: number; + size: number; +} + export class WebGLAttributes { constructor(gl: WebGLRenderingContext | WebGL2RenderingContext); get(attribute: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute): - | { - buffer: WebGLBuffer; - type: number; - bytesPerElement: number; - version: number; - size: number; - } + | WebGLAttribute | undefined; remove(attribute: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute): void; diff --git a/types/three/src/renderers/webgl/WebGLCubeMaps.d.ts b/types/three/src/renderers/webgl/WebGLCubeMaps.d.ts deleted file mode 100644 index 32cda3f61203f4..00000000000000 --- a/types/three/src/renderers/webgl/WebGLCubeMaps.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { WebGLRenderer } from "../WebGLRenderer.js"; - -export class WebGLCubeMaps { - constructor(renderer: WebGLRenderer); - - get(texture: any): any; - dispose(): void; -} diff --git a/types/three/src/renderers/webgl/WebGLCubeUVMaps.d.ts b/types/three/src/renderers/webgl/WebGLCubeUVMaps.d.ts deleted file mode 100644 index e942463258a362..00000000000000 --- a/types/three/src/renderers/webgl/WebGLCubeUVMaps.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Texture } from "../../textures/Texture.js"; -import { WebGLRenderer } from "../WebGLRenderer.js"; - -export class WebGLCubeUVMaps { - constructor(renderer: WebGLRenderer); - - get(texture: T): T extends Texture ? Texture : T; - dispose(): void; -} diff --git a/types/three/src/renderers/webgl/WebGLEnvironments.d.ts b/types/three/src/renderers/webgl/WebGLEnvironments.d.ts new file mode 100644 index 00000000000000..dad8f7e5c12db8 --- /dev/null +++ b/types/three/src/renderers/webgl/WebGLEnvironments.d.ts @@ -0,0 +1,8 @@ +import { Texture } from "../../textures/Texture.js"; + +declare class WebGLEnvironments { + get(texture: Texture): Texture | null; + dispose(): void; +} + +export { WebGLEnvironments }; diff --git a/types/three/src/renderers/webgl/WebGLExtensions.d.ts b/types/three/src/renderers/webgl/WebGLExtensions.d.ts index 0f0c0bf4b8103b..364d0eab65f737 100644 --- a/types/three/src/renderers/webgl/WebGLExtensions.d.ts +++ b/types/three/src/renderers/webgl/WebGLExtensions.d.ts @@ -3,5 +3,5 @@ export class WebGLExtensions { has(name: string): boolean; init(): void; - get(name: string): any; + get(name: string): unknown; } diff --git a/types/three/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts b/types/three/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts index 8e016e847cb61e..7fe363cfa57b8f 100644 --- a/types/three/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts +++ b/types/three/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts @@ -1,10 +1,14 @@ +import { WebGLAttribute } from "./WebGLAttributes.js"; +import { WebGLExtensions } from "./WebGLExtensions.js"; +import { WebGLInfo } from "./WebGLInfo.js"; + export class WebGLIndexedBufferRenderer { - constructor(gl: WebGLRenderingContext, extensions: any, info: any); + constructor(gl: WebGLRenderingContext, extensions: WebGLExtensions, info: WebGLInfo); - setMode: (value: any) => void; - setIndex: (index: any) => void; - render: (start: any, count: number) => void; - renderInstances: (start: any, count: number, primcount: number) => void; + setMode: (value: number) => void; + setIndex: (value: WebGLAttribute) => void; + render: (start: number, count: number) => void; + renderInstances: (start: number, count: number, primcount: number) => void; renderMultiDraw: (starts: Int32Array, counts: Int32Array, drawCount: number) => void; renderMultiDrawInstances: ( starts: Int32Array, diff --git a/types/three/src/renderers/webgl/WebGLLights.d.ts b/types/three/src/renderers/webgl/WebGLLights.d.ts index 4c01422e809c0b..249490a419ca51 100644 --- a/types/three/src/renderers/webgl/WebGLLights.d.ts +++ b/types/three/src/renderers/webgl/WebGLLights.d.ts @@ -1,3 +1,5 @@ +import { Camera } from "../../cameras/Camera.js"; +import { Light } from "../../lights/Light.js"; import { WebGLExtensions } from "./WebGLExtensions.js"; export interface WebGLLightsState { @@ -19,21 +21,21 @@ export interface WebGLLightsState { }; ambient: number[]; - probe: any[]; - directional: any[]; - directionalShadow: any[]; - directionalShadowMap: any[]; - directionalShadowMatrix: any[]; - spot: any[]; - spotShadow: any[]; - spotShadowMap: any[]; - spotShadowMatrix: any[]; - rectArea: any[]; - point: any[]; - pointShadow: any[]; - pointShadowMap: any[]; - pointShadowMatrix: any[]; - hemi: any[]; + probe: unknown[]; + directional: unknown[]; + directionalShadow: unknown[]; + directionalShadowMap: unknown[]; + directionalShadowMatrix: unknown[]; + spot: unknown[]; + spotShadow: unknown[]; + spotShadowMap: unknown[]; + spotShadowMatrix: unknown[]; + rectArea: unknown[]; + point: unknown[]; + pointShadow: unknown[]; + pointShadowMap: unknown[]; + pointShadowMatrix: unknown[]; + hemi: unknown[]; numSpotLightShadowsWithMaps: number; numLightProbes: number; } @@ -43,7 +45,6 @@ export class WebGLLights { state: WebGLLightsState; - get(light: any): any; - setup(lights: any): void; - setupView(lights: any, camera: any): void; + setup(lights: Light[]): void; + setupView(lights: Light[], camera: Camera): void; } diff --git a/types/three/src/renderers/webgl/WebGLObjects.d.ts b/types/three/src/renderers/webgl/WebGLObjects.d.ts index aeb0356f7d0240..0002555954927e 100644 --- a/types/three/src/renderers/webgl/WebGLObjects.d.ts +++ b/types/three/src/renderers/webgl/WebGLObjects.d.ts @@ -1,6 +1,19 @@ +import { BufferGeometry } from "../../core/BufferGeometry.js"; +import { Object3D } from "../../core/Object3D.js"; +import { WebGLAttributes } from "./WebGLAttributes.js"; +import { WebGLBindingStates } from "./WebGLBindingStates.js"; +import { WebGLGeometries } from "./WebGLGeometries.js"; +import { WebGLInfo } from "./WebGLInfo.js"; + export class WebGLObjects { - constructor(gl: WebGLRenderingContext, geometries: any, attributes: any, info: any); + constructor( + gl: WebGLRenderingContext, + geometries: WebGLGeometries, + attributes: WebGLAttributes, + bindingStates: WebGLBindingStates, + info: WebGLInfo, + ); - update(object: any): any; + update(object: Object3D): BufferGeometry; dispose(): void; } diff --git a/types/three/src/renderers/webgl/WebGLProgram.d.ts b/types/three/src/renderers/webgl/WebGLProgram.d.ts index b3e5d6fd804ee4..aadc9253458a77 100644 --- a/types/three/src/renderers/webgl/WebGLProgram.d.ts +++ b/types/three/src/renderers/webgl/WebGLProgram.d.ts @@ -12,19 +12,11 @@ export class WebGLProgram { * @default 1 */ usedTimes: number; - program: any; + program: unknown; // TODO This should be the WebGLProgram in the DOM types vertexShader: WebGLShader; fragmentShader: WebGLShader; - /** - * @deprecated Use {@link WebGLProgram#getUniforms getUniforms()} instead. - */ - uniforms: any; - /** - * @deprecated Use {@link WebGLProgram#getAttributes getAttributes()} instead. - */ - attributes: any; getUniforms(): WebGLUniforms; - getAttributes(): any; + getAttributes(): unknown; destroy(): void; } diff --git a/types/three/src/renderers/webgl/WebGLPrograms.d.ts b/types/three/src/renderers/webgl/WebGLPrograms.d.ts index 717ada6c71bbac..bb7ad57bfa6b09 100644 --- a/types/three/src/renderers/webgl/WebGLPrograms.d.ts +++ b/types/three/src/renderers/webgl/WebGLPrograms.d.ts @@ -8,7 +8,7 @@ import { WebGLRenderer } from "../WebGLRenderer.js"; import { WebGLBindingStates } from "./WebGLBindingStates.js"; import { WebGLCapabilities } from "./WebGLCapabilities.js"; import { WebGLClipping } from "./WebGLClipping.js"; -import { WebGLCubeMaps } from "./WebGLCubeMaps.js"; +import { WebGLEnvironments } from "./WebGLEnvironments.js"; import { WebGLExtensions } from "./WebGLExtensions.js"; import { WebGLLightsState } from "./WebGLLights.js"; import { WebGLProgram } from "./WebGLProgram.js"; @@ -208,7 +208,7 @@ export interface WebGLProgramParametersWithUniforms extends WebGLProgramParamete export class WebGLPrograms { constructor( renderer: WebGLRenderer, - cubemaps: WebGLCubeMaps, + environments: WebGLEnvironments, extensions: WebGLExtensions, capabilities: WebGLCapabilities, bindingStates: WebGLBindingStates, diff --git a/types/three/src/renderers/webgl/WebGLRenderLists.d.ts b/types/three/src/renderers/webgl/WebGLRenderLists.d.ts index 0f16a42873f978..e9215cddd4d2fb 100644 --- a/types/three/src/renderers/webgl/WebGLRenderLists.d.ts +++ b/types/three/src/renderers/webgl/WebGLRenderLists.d.ts @@ -1,10 +1,8 @@ -import { Camera } from "../../cameras/Camera.js"; import { BufferGeometry } from "../../core/BufferGeometry.js"; import { Object3D } from "../../core/Object3D.js"; import { Material } from "../../materials/Material.js"; import { Group } from "../../objects/Group.js"; import { Scene } from "../../scenes/Scene.js"; -import { WebGLProgram } from "./WebGLProgram.js"; import { WebGLProperties } from "./WebGLProperties.js"; export interface RenderItem { @@ -12,7 +10,7 @@ export interface RenderItem { object: Object3D; geometry: BufferGeometry | null; material: Material; - program: WebGLProgram; + materialVariant: number; groupOrder: number; renderOrder: number; z: number; diff --git a/types/three/src/renderers/webgl/WebGLShadowMap.d.ts b/types/three/src/renderers/webgl/WebGLShadowMap.d.ts index 8368fdee76c022..f0a8fe65fce438 100644 --- a/types/three/src/renderers/webgl/WebGLShadowMap.d.ts +++ b/types/three/src/renderers/webgl/WebGLShadowMap.d.ts @@ -30,9 +30,4 @@ export class WebGLShadowMap { type: ShadowMapType; render(shadowsArray: Light[], scene: Scene, camera: Camera): void; - - /** - * @deprecated Use {@link Material#shadowSide} instead. - */ - cullFace: any; } diff --git a/types/three/src/renderers/webgl/WebGLState.d.ts b/types/three/src/renderers/webgl/WebGLState.d.ts index 42c55bceeda48c..43f01659afcc8f 100644 --- a/types/three/src/renderers/webgl/WebGLState.d.ts +++ b/types/three/src/renderers/webgl/WebGLState.d.ts @@ -56,7 +56,7 @@ declare class WebGLState { disable(id: number): void; bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void; drawBuffers(renderTarget: WebGLRenderTarget | null, framebuffer: WebGLFramebuffer | null): void; - useProgram(program: any): boolean; + useProgram(program: WebGLProgram): boolean; setBlending( blending: Blending, blendEquation?: BlendingEquation, @@ -74,43 +74,320 @@ declare class WebGLState { setPolygonOffset(polygonoffset: boolean, factor?: number, units?: number): void; setScissorTest(scissorTest: boolean): void; activeTexture(webglSlot: number): void; - bindTexture(webglType: number, webglTexture: any): void; + bindTexture(webglType: number, webglTexture: WebGLTexture, webglSlot?: number): void; unbindTexture(): void; + // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/compressedTexImage2D compressedTexImage2D( - target: number, - level: number, - internalformat: number, - width: number, - height: number, - border: number, - data: ArrayBufferView, + target: GLenum, + level: GLint, + internalformat: GLenum, + width: GLsizei, + height: GLsizei, + border: GLint, + imageSize: GLsizei, + offset: GLintptr, + ): void; + compressedTexImage2D( + target: GLenum, + level: GLint, + internalformat: GLenum, + width: GLsizei, + height: GLsizei, + border: GLint, + srcData: ArrayBufferView, + srcOffset?: number, + srcLengthOverride?: GLuint, + ): void; + + compressedTexImage3D( + target: GLenum, + level: GLint, + internalformat: GLenum, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + border: GLint, + imageSize: GLsizei, + offset: GLintptr, + ): void; + compressedTexImage3D( + target: GLenum, + level: GLint, + internalformat: GLenum, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + border: GLint, + srcData: ArrayBufferView, + srcOffset?: number, + srcLengthOverride?: GLuint, + ): void; + + texSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + width: GLsizei, + height: GLsizei, + format: GLenum, + type: GLenum, + pixels: ArrayBufferView | null, + ): void; + texSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + format: GLenum, + type: GLenum, + source: TexImageSource, + ): void; + texSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + width: GLsizei, + height: GLsizei, + format: GLenum, + type: GLenum, + pboOffset: GLintptr, + ): void; + texSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + width: GLsizei, + height: GLsizei, + format: GLenum, + type: GLenum, + source: TexImageSource, + ): void; + texSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + width: GLsizei, + height: GLsizei, + format: GLenum, + type: GLenum, + srcData: ArrayBufferView, + srcOffset: number, + ): void; + + texSubImage3D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + zoffset: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + format: GLenum, + type: GLenum, + pboOffset: GLintptr, + ): void; + texSubImage3D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + zoffset: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + format: GLenum, + type: GLenum, + source: TexImageSource, + ): void; + texSubImage3D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + zoffset: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + format: GLenum, + type: GLenum, + srcData: ArrayBufferView | null, + srcOffset?: number, + ): void; + + compressedTexSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + width: GLsizei, + height: GLsizei, + format: GLenum, + imageSize: GLsizei, + offset: GLintptr, + ): void; + compressedTexSubImage2D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + width: GLsizei, + height: GLsizei, + format: GLenum, + srcData: ArrayBufferView, + srcOffset?: number, + srcLengthOverride?: GLuint, + ): void; + + compressedTexSubImage3D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + zoffset: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + format: GLenum, + imageSize: GLsizei, + offset: GLintptr, ): void; + compressedTexSubImage3D( + target: GLenum, + level: GLint, + xoffset: GLint, + yoffset: GLint, + zoffset: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + format: GLenum, + srcData: ArrayBufferView, + srcOffset?: number, + srcLengthOverride?: GLuint, + ): void; + + texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei): void; + + texStorage3D( + target: GLenum, + levels: GLsizei, + internalformat: GLenum, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + ): void; + // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D texImage2D( - target: number, - level: number, - internalformat: number, - width: number, - height: number, - border: number, - format: number, - type: number, + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, pixels: ArrayBufferView | null, ): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, source: any): void; + texImage2D( + target: GLenum, + level: GLint, + internalformat: GLint, + format: GLenum, + type: GLenum, + source: TexImageSource, + ): void; + texImage2D( + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + pboOffset: GLintptr, + ): void; + texImage2D( + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + source: TexImageSource, + ): void; + texImage2D( + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + srcData: ArrayBufferView, + srcOffset: number, + ): void; + + texImage3D( + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + pboOffset: GLintptr, + ): void; texImage3D( - target: number, - level: number, - internalformat: number, - width: number, - height: number, - depth: number, - border: number, - format: number, - type: number, - pixels: any, + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + source: TexImageSource, ): void; + texImage3D( + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + srcData: ArrayBufferView | null, + ): void; + texImage3D( + target: GLenum, + level: GLint, + internalformat: GLint, + width: GLsizei, + height: GLsizei, + depth: GLsizei, + border: GLint, + format: GLenum, + type: GLenum, + srcData: ArrayBufferView, + srcOffset: number, + ): void; + scissor(scissor: Vector4): void; viewport(viewport: Vector4): void; reset(): void; diff --git a/types/three/src/renderers/webgl/WebGLTextures.d.ts b/types/three/src/renderers/webgl/WebGLTextures.d.ts index 031866deeb0e61..87985bb343cb56 100644 --- a/types/three/src/renderers/webgl/WebGLTextures.d.ts +++ b/types/three/src/renderers/webgl/WebGLTextures.d.ts @@ -1,3 +1,5 @@ +import { RenderTarget } from "../../core/RenderTarget.js"; +import { Texture } from "../../textures/Texture.js"; import { WebGLCapabilities } from "./WebGLCapabilities.js"; import { WebGLExtensions } from "./WebGLExtensions.js"; import { WebGLInfo } from "./WebGLInfo.js"; @@ -18,13 +20,12 @@ export class WebGLTextures { allocateTextureUnit(): void; resetTextureUnits(): void; - setTexture2D(texture: any, slot: number): void; - setTexture2DArray(texture: any, slot: number): void; - setTexture3D(texture: any, slot: number): void; - setTextureCube(texture: any, slot: number): void; - setupRenderTarget(renderTarget: any): void; - updateRenderTargetMipmap(renderTarget: any): void; - updateMultisampleRenderTarget(renderTarget: any): void; - safeSetTexture2D(texture: any, slot: number): void; - safeSetTextureCube(texture: any, slot: number): void; + + setTexture2D(texture: Texture, slot: number): void; + setTexture2DArray(texture: Texture, slot: number): void; + setTexture3D(texture: Texture, slot: number): void; + setTextureCube(texture: Texture, slot: number): void; + setupRenderTarget(renderTarget: RenderTarget): void; + updateRenderTargetMipmap(renderTarget: RenderTarget): void; + updateMultisampleRenderTarget(renderTarget: RenderTarget): void; } diff --git a/types/three/src/renderers/webgl/WebGLUniforms.d.ts b/types/three/src/renderers/webgl/WebGLUniforms.d.ts index 925b5e4bf0a173..493373744dd345 100644 --- a/types/three/src/renderers/webgl/WebGLUniforms.d.ts +++ b/types/three/src/renderers/webgl/WebGLUniforms.d.ts @@ -1,12 +1,5 @@ import { WebGLProgram } from "./WebGLProgram.js"; -import { WebGLTextures } from "./WebGLTextures.js"; export class WebGLUniforms { constructor(gl: WebGLRenderingContext, program: WebGLProgram); - - setValue(gl: WebGLRenderingContext, name: string, value: any, textures: WebGLTextures): void; - setOptional(gl: WebGLRenderingContext, object: any, name: string): void; - - static upload(gl: WebGLRenderingContext, seq: any, values: any[], textures: WebGLTextures): void; - static seqWithValue(seq: any, values: any[]): any[]; } diff --git a/types/three/src/renderers/webgpu/WebGPUBackend.d.ts b/types/three/src/renderers/webgpu/WebGPUBackend.d.ts index 4e407ec35006a2..09138368b5bea5 100644 --- a/types/three/src/renderers/webgpu/WebGPUBackend.d.ts +++ b/types/three/src/renderers/webgpu/WebGPUBackend.d.ts @@ -5,7 +5,6 @@ import Backend, { BackendParameters } from "../common/Backend.js"; export interface WebGPUBackendParameters extends BackendParameters { alpha?: boolean | undefined; - compatibilityMode?: boolean | undefined; requiredLimits?: Record | undefined; trackTimestamp?: boolean | undefined; device?: GPUDevice | undefined; diff --git a/types/three/src/renderers/webgpu/nodes/BasicNodeLibrary.d.ts b/types/three/src/renderers/webgpu/nodes/BasicNodeLibrary.d.ts index d78b1b2f88d94f..94165b2e95db7a 100644 --- a/types/three/src/renderers/webgpu/nodes/BasicNodeLibrary.d.ts +++ b/types/three/src/renderers/webgpu/nodes/BasicNodeLibrary.d.ts @@ -1,4 +1,5 @@ import NodeLibrary from "../../common/nodes/NodeLibrary.js"; + /** * This version of a node library represents a basic version * just focusing on lights and tone mapping techniques. @@ -7,9 +8,6 @@ import NodeLibrary from "../../common/nodes/NodeLibrary.js"; * @augments NodeLibrary */ declare class BasicNodeLibrary extends NodeLibrary { - /** - * Constructs a new basic node library. - */ - constructor(); } + export default BasicNodeLibrary; diff --git a/types/three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts b/types/three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts index 3ed5750ce4460d..5715e3fa3425ce 100644 --- a/types/three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +++ b/types/three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts @@ -12,6 +12,7 @@ import { PointsNodeMaterialNodeProperties } from "../../../materials/nodes/Point import { ShadowNodeMaterialNodeProperties } from "../../../materials/nodes/ShadowNodeMaterial.js"; import { SpriteNodeMaterialNodeProperties } from "../../../materials/nodes/SpriteNodeMaterial.js"; import NodeLibrary from "../../common/nodes/NodeLibrary.js"; + /** * This version of a node library represents the standard version * used in {@link WebGPURenderer}. It maps lights, tone mapping @@ -21,61 +22,71 @@ import NodeLibrary from "../../common/nodes/NodeLibrary.js"; * @augments NodeLibrary */ declare class StandardNodeLibrary extends NodeLibrary { - /** - * Constructs a new standard node library. - */ - constructor(); } + declare module "../../../materials/MeshPhongMaterial.js" { interface MeshPhongMaterialProperties extends MeshPhongNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshStandardMaterial.js" { interface MeshStandardMaterialProperties extends MeshStandardNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshPhysicalMaterial.js" { interface MeshPhysicalMaterialProperties extends MeshPhysicalNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshToonMaterial.js" { interface MeshToonMaterialProperties extends MeshToonNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshBasicMaterial.js" { interface MeshBasicMaterialProperties extends MeshBasicNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshLambertMaterial.js" { interface MeshLambertMaterialProperties extends MeshLambertNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshNormalMaterial.js" { interface MeshNormalMaterialProperties extends MeshNormalNodeMaterialNodeProperties { } } + declare module "../../../materials/MeshMatcapMaterial.js" { interface MeshMatcapMaterialProperties extends MeshMatcapNodeMaterialNodeProperties { } } + declare module "../../../materials/LineBasicMaterial.js" { interface LineBasicMaterialProperties extends LineBasicNodeMaterialNodeProperties { } } + declare module "../../../materials/LineDashedMaterial.js" { interface LineDashedMaterialProperties extends LineDashedNodeMaterialNodeProperties { } } + declare module "../../../materials/PointsMaterial.js" { interface PointsMaterialProperties extends PointsNodeMaterialNodeProperties { } } + declare module "../../../materials/SpriteMaterial.js" { interface SpriteMaterialProperties extends SpriteNodeMaterialNodeProperties { } } + declare module "../../../materials/ShadowMaterial.js" { interface ShadowMaterialProperties extends ShadowNodeMaterialNodeProperties { } } + export default StandardNodeLibrary; diff --git a/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts b/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts index 8991342187820c..f3dd9efbaa2ffd 100644 --- a/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +++ b/types/three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts @@ -82,7 +82,7 @@ export default class WGSLNodeBuilder extends NodeBuilder { shaderStage: NodeShaderStage, ): string; - getPropertyName(node: NodeVar | NodeUniform, shaderStage: NodeShaderStage): string; + getPropertyName(node: NodeVar | NodeUniform, shaderStage: NodeShaderStage): string; getOutputStructName(): string; diff --git a/types/three/src/scenes/Fog.d.ts b/types/three/src/scenes/Fog.d.ts index fc0f180197fd30..b002b5cc08a180 100644 --- a/types/three/src/scenes/Fog.d.ts +++ b/types/three/src/scenes/Fog.d.ts @@ -9,69 +9,63 @@ export interface FogJSON { } /** - * This class contains the parameters that define linear fog, i.e., that grows linearly denser with the distance. - * @example - * ```typescript + * This class can be used to define a linear fog that grows linearly denser + * with the distance. + * + * ```js * const scene = new THREE.Scene(); - * scene.fog = new THREE.Fog(0xcccccc, 10, 15); + * scene.fog = new THREE.Fog( 0xcccccc, 10, 15 ); * ``` - * @see {@link https://threejs.org/docs/index.html#api/en/scenes/Fog | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/scenes/Fog.js | Source} */ export class Fog { /** - * The color parameter is passed to the {@link THREE.Color | Color} constructor to set the color property - * @remarks - * Color can be a hexadecimal integer or a CSS-style string. - * @param color - * @param near Expects a `Float` - * @param far Expects a `Float` + * Constructs a new fog. + * + * @param {number|Color} color - The fog's color. + * @param {number} [near=1] - The minimum distance to start applying fog. + * @param {number} [far=1000] - The maximum distance at which fog stops being calculated and applied. */ constructor(color: ColorRepresentation, near?: number, far?: number); - /** - * Read-only flag to check if a given object is of type {@link Fog}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * This flag can be used for type testing. + * + * @default true */ - readonly isFog: true; - + readonly isFog: boolean; /** - * Optional name of the object - * @remarks _(doesn't need to be unique)_. - * @defaultValue `""` + * The name of the fog. */ name: string; - /** - * Fog color. - * @remarks If set to black, far away objects will be rendered black. + * The fog's color. */ color: Color; - /** - * The minimum distance to start applying fog. - * @remarks Objects that are less than **near** units from the active camera won't be affected by fog. - * @defaultValue `1` - * @remarks Expects a `Float` + * The minimum distance to start applying fog. Objects that are less than + * `near` units from the active camera won't be affected by fog. + * + * @default 1 */ near: number; - /** * The maximum distance at which fog stops being calculated and applied. - * @remarks Objects that are more than **far** units away from the active camera won't be affected by fog. - * @defaultValue `1000` - * @remarks Expects a `Float` + * Objects that are more than `far` units away from the active camera won't + * be affected by fog. + * + * @default 1000 */ far: number; - /** - * Returns a new {@link Fog} instance with the same parameters as this one. + * Returns a new fog with copied values from this instance. + * + * @return {Fog} A clone of this instance. */ clone(): Fog; - /** - * Return {@link Fog} data in JSON format. + * Serializes the fog into JSON. + * + * @param {?(Object|string)} meta - An optional value holding meta information about the serialization. + * @return {Object} A JSON object representing the serialized fog */ toJSON(): FogJSON; } diff --git a/types/three/src/scenes/FogExp2.d.ts b/types/three/src/scenes/FogExp2.d.ts index af00981e666096..2f7a6b84453bff 100644 --- a/types/three/src/scenes/FogExp2.d.ts +++ b/types/three/src/scenes/FogExp2.d.ts @@ -8,59 +8,54 @@ export interface FogExp2JSON { } /** - * This class contains the parameters that define exponential squared fog, which gives a clear view near the camera and a faster than exponentially densening fog farther from the camera. - * @example - * ```typescript + * This class can be used to define an exponential squared fog, + * which gives a clear view near the camera and a faster than exponentially + * densening fog farther from the camera. + * + * ```js * const scene = new THREE.Scene(); - * scene.fog = new THREE.FogExp2(0xcccccc, 0.002); + * scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 ); * ``` - * @see Example: {@link https://threejs.org/examples/#webgl_geometry_terrain | webgl geometry terrain} - * @see {@link https://threejs.org/docs/index.html#api/en/scenes/FogExp2 | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/scenes/FogExp2.js | Source} */ export class FogExp2 { /** - * The color parameter is passed to the {@link THREE.Color | Color} constructor to set the color property - * @remarks Color can be a hexadecimal integer or a CSS-style string. - * @param color - * @param density Expects a `Float` + * Constructs a new fog. + * + * @param {number|Color} color - The fog's color. + * @param {number} [density=0.00025] - Defines how fast the fog will grow dense. */ constructor(color: ColorRepresentation, density?: number); - /** - * Read-only flag to check if a given object is of type {@link FogExp2}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * This flag can be used for type testing. + * + * @default true */ - readonly isFogExp2: true; - + readonly isFogExp2: boolean; /** - * Optional name of the object - * @remarks _(doesn't need to be unique)_. - * @defaultValue `""` + * The name of the fog. */ name: string; - /** - * Fog color. - * @remarks If set to black, far away objects will be rendered black. + * The fog's color. */ color: Color; - /** - * Defines how fast the fog will grow dense. - * @defaultValue `0.00025` - * @remarks Expects a `Float` + * Defines how fast the fog will grow dense. + * + * @default 0.00025 */ density: number; - /** - * Returns a new {@link FogExp2} instance with the same parameters as this one. + * Returns a new fog with copied values from this instance. + * + * @return {FogExp2} A clone of this instance. */ clone(): FogExp2; - /** - * Return {@link FogExp2} data in JSON format. + * Serializes the fog into JSON. + * + * @param {?(Object|string)} meta - An optional value holding meta information about the serialization. + * @return {Object} A JSON object representing the serialized fog */ toJSON(): FogExp2JSON; } diff --git a/types/three/src/scenes/Scene.d.ts b/types/three/src/scenes/Scene.d.ts index c03c9ec9e4061f..366bfba1e4fd25 100644 --- a/types/three/src/scenes/Scene.d.ts +++ b/types/three/src/scenes/Scene.d.ts @@ -1,8 +1,7 @@ -import { JSONMeta, Object3D, Object3DEventMap, Object3DJSON, Object3DJSONObject } from "../core/Object3D.js"; +import { JSONMeta, Object3D, Object3DJSON, Object3DJSONObject } from "../core/Object3D.js"; import { Material } from "../materials/Material.js"; import { Color } from "../math/Color.js"; import { Euler, EulerTuple } from "../math/Euler.js"; -import { CubeTexture } from "../textures/CubeTexture.js"; import { Texture } from "../textures/Texture.js"; import { Fog, FogJSON } from "./Fog.js"; import { FogExp2, FogExp2JSON } from "./FogExp2.js"; @@ -23,96 +22,83 @@ export interface SceneJSON extends Object3DJSON { } /** - * Scenes allow you to set up what and where is to be rendered by three.js - * @remarks - * This is where you place objects, lights and cameras. - * @see Example: {@link https://threejs.org/examples/#webgl_multiple_scenes_comparison | webgl multiple scenes comparison} - * @see {@link https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene | Manual: Creating a scene} - * @see {@link https://threejs.org/docs/index.html#api/en/scenes/Scene | Official Documentation} - * @see {@link https://github.com/mrdoob/three.js/blob/master/src/scenes/Scene.js | Source} + * Scenes allow you to set up what is to be rendered and where by three.js. + * This is where you place 3D objects like meshes, lines or lights. */ -export class Scene extends Object3D { +export class Scene extends Object3D { /** - * Create a new {@link Scene} object. + * This flag can be used for type testing. + * + * @default true */ - constructor(); - + readonly isScene: boolean; /** - * Read-only flag to check if a given object is of type {@link Scene}. - * @remarks This is a _constant_ value - * @defaultValue `true` + * Defines the background of the scene. Valid inputs are: + * + * - A color for defining a uniform colored background. + * - A texture for defining a (flat) textured background. + * - Cube textures or equirectangular textures for defining a skybox. + * + * @default null */ - readonly isScene: true; - + background: (Color | Texture) | null; /** - * @defaultValue `Scene` + * Sets the environment map for all physical materials in the scene. However, + * it's not possible to overwrite an existing texture assigned to the `envMap` + * material property. + * + * @default null */ - type: "Scene"; - + environment: Texture | null; /** - * A {@link Fog | fog} instance defining the type of fog that affects everything rendered in the scene. - * @defaultValue `null` + * A fog instance defining the type of fog that affects everything + * rendered in the scene. + * + * @default null */ - fog: Fog | FogExp2 | null; - + fog: (Fog | FogExp2) | null; /** - * Sets the blurriness of the background. Only influences environment maps assigned to {@link THREE.Scene.background | Scene.background}. - * @defaultValue `0` - * @remarks Expects a `Float` between `0` and `1`. + * Sets the blurriness of the background. Only influences environment maps + * assigned to {@link Scene#background}. Valid input is a float between `0` + * and `1`. + * + * @default 0 */ backgroundBlurriness: number; - /** * Attenuates the color of the background. Only applies to background textures. - * @defaultValue `1` - * @remarks Expects a `Float` + * + * @default 1 */ backgroundIntensity: number; - - /** - * Forces everything in the {@link Scene} to be rendered with the defined material. - * @defaultValue `null` - */ - overrideMaterial: Material | null; - /** - * Defines the background of the scene. - * @remarks Valid inputs are: - * - A {@link THREE.Color | Color} for defining a uniform colored background. - * - A {@link THREE.Texture | Texture} for defining a (flat) textured background. - * - Texture cubes ({@link THREE.CubeTexture | CubeTexture}) or equirectangular textures for defining a skybox. - * @defaultValue `null` - */ - background: Color | Texture | CubeTexture | null; - - /** - * The rotation of the background in radians. Only influences environment maps assigned to {@link .background}. - * Default is `(0,0,0)`. + * The rotation of the background in radians. Only influences environment maps + * assigned to {@link Scene#background}. + * + * @default (0,0,0) */ backgroundRotation: Euler; - /** - * Sets the environment map for all physical materials in the scene. - * However, it's not possible to overwrite an existing texture assigned to {@link THREE.MeshStandardMaterial.envMap | MeshStandardMaterial.envMap}. - * @defaultValue `null` - */ - environment: Texture | null; - - /** - * Attenuates the color of the environment. Only influences environment maps assigned to {@link Scene.environment}. + * Attenuates the color of the environment. Only influences environment maps + * assigned to {@link Scene#environment}. + * * @default 1 */ environmentIntensity: number; - /** - * The rotation of the environment map in radians. Only influences physical materials in the scene when - * {@link .environment} is used. Default is `(0,0,0)`. + * The rotation of the environment map in radians. Only influences physical materials + * in the scene when {@link Scene#environment} is used. + * + * @default (0,0,0) */ environmentRotation: Euler; - /** - * Convert the {@link Scene} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}. - * @param meta Object containing metadata such as textures or images for the scene. + * Forces everything in the scene to be rendered with the defined material. It is possible + * to exclude materials from override by setting {@link Material#allowOverride} to `false`. + * + * @default null */ + overrideMaterial: Material | null; + copy(source: Scene, recursive?: boolean): this; toJSON(meta?: JSONMeta): SceneJSON; } diff --git a/types/three/src/textures/CompressedArrayTexture.d.ts b/types/three/src/textures/CompressedArrayTexture.d.ts index fb3f46dbe4bea1..4b04b3bc54869c 100644 --- a/types/three/src/textures/CompressedArrayTexture.d.ts +++ b/types/three/src/textures/CompressedArrayTexture.d.ts @@ -57,7 +57,7 @@ export class CompressedArrayTexture extends CompressedTexture { /** * Resets the layer updates registry. See {@link DataArrayTexture.addLayerUpdate}. */ - clearLayoutUpdates(): void; + clearLayerUpdates(): void; } export interface DataArrayTextureImageData { diff --git a/types/three/src/utils.d.ts b/types/three/src/utils.d.ts index a75693756f18b4..8cfbb266a3b13a 100644 --- a/types/three/src/utils.d.ts +++ b/types/three/src/utils.d.ts @@ -1,3 +1,5 @@ +import { DepthModes } from "./constants.js"; + declare function isTypedArray(object: unknown): boolean; declare function createCanvasElement(): HTMLCanvasElement; @@ -18,6 +20,8 @@ declare function warnOnce(...params: unknown[]): void; declare function probeAsync(gl: WebGLRenderingContext, sync: WebGLSync, interval: number): Promise; +declare const ReversedDepthFuncs: { [K in DepthModes]: DepthModes }; + export { createCanvasElement, error, @@ -25,6 +29,7 @@ export { isTypedArray, log, probeAsync, + ReversedDepthFuncs, setConsoleFunction, warn, warnOnce, diff --git a/types/three/test/integration/lights-pointlights2.ts b/types/three/test/integration/lights-pointlights2.ts index 869ac404af75a6..17fbf74fdf08bd 100644 --- a/types/three/test/integration/lights-pointlights2.ts +++ b/types/three/test/integration/lights-pointlights2.ts @@ -13,8 +13,6 @@ let light4: THREE.PointLight; let light5: THREE.PointLight; let light6: THREE.PointLight; -const clock = new THREE.Clock(); - init(); animate(); diff --git a/types/three/test/integration/materials-meshgouraud.ts b/types/three/test/integration/materials-meshgouraud.ts deleted file mode 100644 index 5029446a426346..00000000000000 --- a/types/three/test/integration/materials-meshgouraud.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as THREE from "three"; -import { MeshGouraudMaterial } from "three/addons/materials/MeshGouraudMaterial.js"; - -const scene = new THREE.Scene(); -const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); - -const renderer = new THREE.WebGLRenderer(); -renderer.setSize(window.innerWidth, window.innerHeight); -document.body.appendChild(renderer.domElement); - -const geometry = new THREE.BoxGeometry(); -const material = new MeshGouraudMaterial(); -const cube = new THREE.Mesh(geometry, material); -scene.add(cube); - -camera.position.z = 5; - -const animate = () => { - requestAnimationFrame(animate); - - cube.rotation.x += 0.01; - cube.rotation.y += 0.01; - - renderer.render(scene, camera); -}; - -animate(); diff --git a/types/three/test/unit/examples/jsm/postprocessing/EffectComposer.ts b/types/three/test/unit/examples/jsm/postprocessing/EffectComposer.ts index 846a063afefca0..d41e2464631368 100644 --- a/types/three/test/unit/examples/jsm/postprocessing/EffectComposer.ts +++ b/types/three/test/unit/examples/jsm/postprocessing/EffectComposer.ts @@ -1,5 +1,6 @@ import * as THREE from "three"; -import { EffectComposer, FullScreenQuad, Pass } from "three/addons/postprocessing/EffectComposer.js"; +import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js"; +import { FullScreenQuad, Pass } from "three/addons/postprocessing/Pass.js"; class FooPass extends Pass { fsQuad: FullScreenQuad; diff --git a/types/three/test/unit/src/nodes/code/FunctionNode.ts b/types/three/test/unit/src/nodes/code/FunctionNode.ts index 9a0cb27a72c165..221cda4fa03938 100644 --- a/types/three/test/unit/src/nodes/code/FunctionNode.ts +++ b/types/three/test/unit/src/nodes/code/FunctionNode.ts @@ -8,9 +8,11 @@ import { FunctionNode, Node } from "three/webgpu"; export const mx_noise = code("whatever"); const includes = [mx_noise]; +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type const someFunc1 = new FunctionNode<[a: Node]>(); const someFunc2 = new FunctionNode<{ a: Node }>(); +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type type A = ProxiedObject; call(someFunc1, [1]); @@ -20,6 +22,7 @@ call(someFunc2, { a: 1 }); call(someFunc2, { a: uv() }); call(someFunc2, { a: uv().xy }); +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type export const mx_cell_noise_float_call = wgslFn<[Node]>("float mx_cell_noise_float( vec3 p )", includes); export const mx_worley_noise_float_call = wgslFn<[Node, Node, Node]>( "float mx_worley_noise_float( vec3 p, float jitter, int metric )", @@ -31,6 +34,7 @@ mx_cell_noise_float_call(uv()); mx_worley_noise_float_call(uv(), 1, 1); ab_call({ a: 1, b: uv() }); +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type export const mx_cell_noise_float = glslFn<[Node]>("float mx_cell_noise_float( vec3 p )", includes); export const mx_worley_noise_float = glslFn<[Node, Node, Node]>( "float mx_worley_noise_float( vec3 p, float jitter, int metric )", diff --git a/types/three/test/unit/src/nodes/display/ColorAdjustment.ts b/types/three/test/unit/src/nodes/display/ColorAdjustment.ts index 4e815e917f1e25..134bc6bf967ad8 100644 --- a/types/three/test/unit/src/nodes/display/ColorAdjustment.ts +++ b/types/three/test/unit/src/nodes/display/ColorAdjustment.ts @@ -1,81 +1,167 @@ /** - * A copy of ColorAdjustmentNode.js converted to typescript - * - * It was chosen because it is short and nicely shows interaction - * between ShaderNode a normal node. + * A copy of ColorAdjustment.js converted to TypeScript. */ -import { add, atan2, cos, div, dot, float, mat3, max, mix, mul, ShaderNode, sin, sqrt, sub, vec3 } from "three/tsl"; -import { Node, TempNode } from "three/webgpu"; - -const luminanceNode = new ShaderNode<{ color: Node }>(({ color }) => { - const LUMA = vec3(0.2125, 0.7154, 0.0721); +import { add, dot, float, Fn, If, max, mix, vec3, vec4 } from "three/tsl"; +import { ColorManagement, LinearSRGBColorSpace, Node, Vector3 } from "three/webgpu"; - return dot(color, LUMA); +/** + * Computes a grayscale value for the given RGB color value. + * + * @param {Node} color - The color value to compute the grayscale for. + * @return {Node} The grayscale color. + */ +// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type +export const grayscale = /*@__PURE__*/ Fn(([color]: [Node<"vec3">]) => { + return luminance(color.rgb); }); -const saturationNode = new ShaderNode<{ color: Node; adjustment: Node }>(({ color, adjustment }) => { - const intensityNode = luminanceNode.call({ color }); +/** + * Super-saturates or desaturates the given RGB color. + * + * @param {Node} color - The input color. + * @param {Node} [adjustment=1] - Specifies the amount of the conversion. A value under `1` desaturates the color, a value over `1` super-saturates it. + * @return {Node} The saturated color. + */ +export const saturation = /*@__PURE__*/ Fn( + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type + ([color, adjustment = float(1)]: [Node<"vec3">, Node<"float">] | [Node<"vec3">]) => { + return adjustment.mix(luminance(color.rgb), color.rgb); + }, +); - return mix(intensityNode, color, adjustment); -}); +/** + * Selectively enhance the intensity of less saturated RGB colors. Can result + * in a more natural and visually appealing image with enhanced color depth + * compared to {@link ColorAdjustment#saturation}. + * + * @param {Node} color - The input color. + * @param {Node} [adjustment=1] - Controls the intensity of the vibrance effect. + * @return {Node} The updated color. + */ +export const vibrance = /*@__PURE__*/ Fn( + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type + ([color, adjustment = float(1)]: [Node<"vec3">, Node<"float">] | [Node<"vec3">]) => { + const average = add(color.r, color.g, color.b).div(3.0); -const vibranceNode = new ShaderNode<{ color: Node; adjustment: Node }>(({ color, adjustment }) => { - const average = div(add(color.r, color.g, color.b), 3.0); + const mx = color.r.max(color.g.max(color.b)); + const amt = mx.sub(average).mul(adjustment).mul(-3.0); - const mx = max(color.r, max(color.g, color.b)); - const amt = mul(sub(mx, average), mul(-3.0, adjustment)); + return mix(color.rgb, mx, amt); + }, +); - return mix(color.rgb, vec3(mx), amt); -}); +/** + * Updates the hue component of the given RGB color while preserving its luminance and saturation. + * + * @param {Node} color - The input color. + * @param {Node} [adjustment=1] - Defines the degree of hue rotation in radians. A positive value rotates the hue clockwise, while a negative value rotates it counterclockwise. + * @return {Node} The updated color. + */ +export const hue = /*@__PURE__*/ Fn( + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type + ([color, adjustment = float(1)]: [Node<"vec3">, Node<"float">] | [Node<"vec3">]) => { + const k = vec3(0.57735, 0.57735, 0.57735); -const hueNode = new ShaderNode<{ color: Node; adjustment: Node }>(({ color, adjustment }) => { - const RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135); - const YIQtoRGB = mat3(1.0, 0.9563, 0.621, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046); + const cosAngle = adjustment.cos(); - const yiq = mul(RGBtoYIQ, color); + return vec3( + color.rgb.mul(cosAngle).add( + k.cross(color.rgb).mul(adjustment.sin()).add(k.mul(dot(k, color.rgb).mul(cosAngle.oneMinus()))), + ), + ); + }, +); - const hue = add(atan2(yiq.z, yiq.y), adjustment); - const chroma = sqrt(add(mul(yiq.z, yiq.z), mul(yiq.y, yiq.y))); +/** + * Computes the luminance for the given RGB color value. + * + * @param {Node} color - The color value to compute the luminance for. + * @param {?Node} luminanceCoefficients - The luminance coefficients. By default predefined values of the current working color space are used. + * @return {Node} The luminance. + */ +export const luminance = ( + color: Node<"vec3">, + luminanceCoefficients: Node<"vec3"> = vec3(ColorManagement.getLuminanceCoefficients(new Vector3())), +) => dot(color, luminanceCoefficients); - return mul(YIQtoRGB, vec3(yiq.x, mul(chroma, cos(hue)), mul(chroma, sin(hue)))); +/** + * Color Decision List (CDL) v1.2 + * + * Compact representation of color grading information, defined by slope, offset, power, and + * saturation. The CDL should be typically be given input in a log space (such as LogC, ACEScc, + * or AgX Log), and will return output in the same space. Output may require clamping >=0. + * + * @param {Node} color Input (-Infinity < input < +Infinity) + * @param {Node} slope Slope (0 ≤ slope < +Infinity) + * @param {Node} offset Offset (-Infinity < offset < +Infinity; typically -1 < offset < 1) + * @param {Node} power Power (0 < power < +Infinity) + * @param {Node} saturation Saturation (0 ≤ saturation < +Infinity; typically 0 ≤ saturation < 4) + * @param {Node} luminanceCoefficients Luminance coefficients for saturation term, typically Rec. 709 + * @return {Node} Output, -Infinity < output < +Infinity + * + * References: + * - ASC CDL v1.2 + * - {@link https://blender.stackexchange.com/a/55239/43930} + * - {@link https://docs.acescentral.com/specifications/acescc/} + */ +export const cdl = /*@__PURE__*/ Fn(([ + color, + slope = vec3(1), + offset = vec3(0), + power = vec3(1), + saturation = float(1), + // ASC CDL v1.2 explicitly requires Rec. 709 luminance coefficients. + luminanceCoefficients = vec3(ColorManagement.getLuminanceCoefficients(new Vector3(), LinearSRGBColorSpace)), +]: [ + Node<"vec4">, + Node<"vec3">, + Node<"vec3">, + Node<"vec3">, + Node<"float">, + Node<"vec3">, +] | [ + Node<"vec4">, + Node<"vec3">, + Node<"vec3">, + Node<"vec3">, + Node<"float">, +] | [ + Node<"vec4">, + Node<"vec3">, + Node<"vec3">, + Node<"vec3">, +] | [ + Node<"vec4">, + Node<"vec3">, + Node<"vec3">, +] | [ + Node<"vec4">, + Node<"vec3">, + // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type +] | [ + Node<"vec4">, +]) => { + // NOTE: The ASC CDL v1.2 defines a [0, 1] clamp on the slope+offset term, and another on the + // saturation term. Per the ACEScc specification and Filament, limits may be omitted to support + // values outside [0, 1], requiring a workaround for negative values in the power expression. + + const luma = color.rgb.dot(vec3(luminanceCoefficients)); + + const v = max(color.rgb.mul(slope).add(offset), 0.0).toVar(); + const pv = v.pow(power).toVar(); + + If(v.r.greaterThan(0.0), () => { + v.r.assign(pv.r); + }); + If(v.g.greaterThan(0.0), () => { + v.g.assign(pv.g); + }); + If(v.b.greaterThan(0.0), () => { + v.b.assign(pv.b); + }); + + v.assign(luma.add(v.sub(luma).mul(saturation))); + + return vec4(v.rgb, color.a); }); - -class TestNode extends TempNode { - static SATURATION = "saturation"; - static VIBRANCE = "vibrance"; - static HUE = "hue"; - method: string; - colorNode: Node; - adjustmentNode: Node; - - constructor(method: string, colorNode: Node, adjustmentNode = float(1)) { - super("vec3"); - - this.method = method; - - this.colorNode = colorNode; - this.adjustmentNode = adjustmentNode; - } - - setup() { - const { method, colorNode, adjustmentNode } = this; - - const callParams = { color: colorNode, adjustment: adjustmentNode }; - - let outputNode = null; - - switch (method) { - case TestNode.SATURATION: - outputNode = saturationNode.call(callParams); - case TestNode.VIBRANCE: - outputNode = vibranceNode.call(callParams); - case TestNode.HUE: - outputNode = hueNode.call(callParams); - default: - console.error(`${this.type}: Method "${this.method}" not supported!`); - } - - return outputNode; - } -} diff --git a/types/three/test/unit/src/nodes/tsl/TSLCore.ts b/types/three/test/unit/src/nodes/tsl/TSLCore.ts index 33e66378a5a736..5c026da4255308 100644 --- a/types/three/test/unit/src/nodes/tsl/TSLCore.ts +++ b/types/three/test/unit/src/nodes/tsl/TSLCore.ts @@ -1,18 +1,9 @@ -/** - * Various tests of ShaderNode and related type inference - */ - -import { color, Fn, nodeArray, nodeImmutable, ShaderNode, vec3 } from "three/tsl"; +import { color, Fn, nodeImmutable, ShaderNode, vec3 } from "three/tsl"; import { ConstNode, MaterialNode, Node, PropertyNode } from "three/webgpu"; const s = color(1); s.xyz; -const aa = nodeArray([1, 2, "hello"]); -aa[0].xy = s; -aa[1].w = s; -aa[2] = "hello"; - nodeImmutable(MaterialNode, MaterialNode.ROTATION); nodeImmutable(PropertyNode, "vec4", "DiffuseColor"); @@ -24,8 +15,8 @@ shader.call({ a: s, b: new ConstNode(1) }); const fnWithoutArgs = Fn(() => vec3(1, 2, 3)); fnWithoutArgs(); -const fnWithArrayArgs = Fn(([a, b]: [a: Node, b: Node]) => a.add(b)); +const fnWithArrayArgs = Fn(([a, b]: [a: Node<"float">, b: Node<"vec3">]) => a.add(b)); fnWithArrayArgs(0.5, color(0.0, 0.25, 0.5)); -const fnWithArgs = Fn(({ a, b }: { a: Node; b: Node }) => a.add(b)); +const fnWithArgs = Fn(({ a, b }: { a: Node<"float">; b: Node<"vec3"> }) => a.add(b)); fnWithArgs({ a: 0.5, b: color(0.0, 0.25, 0.5) }); diff --git a/types/three/tsconfig.json b/types/three/tsconfig.json index 2eb642969c75fd..c34044e54a6c6c 100644 --- a/types/three/tsconfig.json +++ b/types/three/tsconfig.json @@ -20,7 +20,6 @@ "test/integration/instanced-mesh.ts", "test/integration/lights-pointlights2.ts", "test/integration/loaders-gltfloader-plugin.ts", - "test/integration/materials-meshgouraud.ts", "test/integration/objects-reflector.ts", "test/integration/three-examples/webgl2_rendertarget_texture2darray.ts", "test/integration/three-examples/webgl_loader_ldraw.ts",