typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
232 lines (231 loc) • 6.48 kB
TypeScript
import { $internal, $resolve } from '../shared/symbols.ts';
import type { ResolutionCtx, SelfResolvable } from '../types.ts';
import { type ResolvedSnippet } from './snippet.ts';
import { type BaseData, type VecKind } from './wgslTypes.ts';
type ElementSchema<S> = BaseData & ((v?: S) => S);
export declare abstract class VecBase<S> extends Array implements SelfResolvable {
abstract readonly [$internal]: {
elementSchema: ElementSchema<S>;
};
abstract get kind(): VecKind;
abstract get _Vec2(): new (x: S, y: S) => Vec2<S>;
abstract get _Vec3(): new (x: S, y: S, z: S) => Vec3<S>;
abstract get _Vec4(): new (x: S, y: S, z: S, w: S) => Vec4<S>;
castElement(): (v?: S) => S;
[$resolve](ctx: ResolutionCtx): ResolvedSnippet;
toString(): string;
}
type Tuple2<S> = [S, S];
type Tuple3<S> = [S, S, S];
type Tuple4<S> = [S, S, S, S];
declare abstract class Vec2<S> extends VecBase<S> implements Tuple2<S> {
readonly length: 2;
e0: S;
e1: S;
constructor(x?: S, y?: S);
get 0(): S;
get 1(): S;
set 0(value: S);
set 1(value: S);
get x(): S;
get y(): S;
set x(value: S);
set y(value: S);
get r(): S;
get g(): S;
set r(value: S);
set g(value: S);
}
declare abstract class Vec3<S> extends VecBase<S> implements Tuple3<S> {
readonly length: 3;
e0: S;
e1: S;
e2: S;
constructor(x?: S, y?: S, z?: S);
get 0(): S;
get 1(): S;
get 2(): S;
set 0(value: S);
set 1(value: S);
set 2(value: S);
get x(): S;
get y(): S;
get z(): S;
set x(value: S);
set y(value: S);
set z(value: S);
get r(): S;
get g(): S;
get b(): S;
set r(value: S);
set g(value: S);
set b(value: S);
}
declare abstract class Vec4<S> extends VecBase<S> implements Tuple4<S> {
readonly length: 4;
e0: S;
e1: S;
e2: S;
e3: S;
constructor(x?: S, y?: S, z?: S, w?: S);
get 0(): S;
get 1(): S;
get 2(): S;
get 3(): S;
set 0(value: S);
set 1(value: S);
set 2(value: S);
set 3(value: S);
get x(): S;
get y(): S;
get z(): S;
get w(): S;
set x(value: S);
set y(value: S);
set z(value: S);
set w(value: S);
get r(): S;
get g(): S;
get b(): S;
get a(): S;
set r(value: S);
set g(value: S);
set b(value: S);
set a(value: S);
}
export declare class Vec2fImpl extends Vec2<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").F32;
};
get kind(): "vec2f";
get _Vec2(): typeof Vec2fImpl;
get _Vec3(): typeof Vec3fImpl;
get _Vec4(): typeof Vec4fImpl;
}
export declare class Vec2hImpl extends Vec2<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").F16;
};
get kind(): "vec2h";
get _Vec2(): typeof Vec2hImpl;
get _Vec3(): typeof Vec3hImpl;
get _Vec4(): typeof Vec4hImpl;
}
export declare class Vec2iImpl extends Vec2<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").I32;
};
get kind(): "vec2i";
get _Vec2(): typeof Vec2iImpl;
get _Vec3(): typeof Vec3iImpl;
get _Vec4(): typeof Vec4iImpl;
}
export declare class Vec2uImpl extends Vec2<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").U32;
};
get kind(): "vec2u";
get _Vec2(): typeof Vec2uImpl;
get _Vec3(): typeof Vec3uImpl;
get _Vec4(): typeof Vec4uImpl;
}
export declare class Vec2bImpl extends Vec2<boolean> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").Bool;
};
get kind(): "vec2<bool>";
get _Vec2(): typeof Vec2bImpl;
get _Vec3(): typeof Vec3bImpl;
get _Vec4(): typeof Vec4bImpl;
}
export declare class Vec3fImpl extends Vec3<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").F32;
};
get kind(): "vec3f";
get _Vec2(): typeof Vec2fImpl;
get _Vec3(): typeof Vec3fImpl;
get _Vec4(): typeof Vec4fImpl;
}
export declare class Vec3hImpl extends Vec3<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").F16;
};
get kind(): "vec3h";
get _Vec2(): typeof Vec2hImpl;
get _Vec3(): typeof Vec3hImpl;
get _Vec4(): typeof Vec4hImpl;
}
export declare class Vec3iImpl extends Vec3<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").I32;
};
get kind(): "vec3i";
get _Vec2(): typeof Vec2iImpl;
get _Vec3(): typeof Vec3iImpl;
get _Vec4(): typeof Vec4iImpl;
}
export declare class Vec3uImpl extends Vec3<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").U32;
};
get kind(): "vec3u";
get _Vec2(): typeof Vec2uImpl;
get _Vec3(): typeof Vec3uImpl;
get _Vec4(): typeof Vec4uImpl;
}
export declare class Vec3bImpl extends Vec3<boolean> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").Bool;
};
get kind(): "vec3<bool>";
get _Vec2(): typeof Vec2bImpl;
get _Vec3(): typeof Vec3bImpl;
get _Vec4(): typeof Vec4bImpl;
}
export declare class Vec4fImpl extends Vec4<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").F32;
};
get kind(): "vec4f";
get _Vec2(): typeof Vec2fImpl;
get _Vec3(): typeof Vec3fImpl;
get _Vec4(): typeof Vec4fImpl;
}
export declare class Vec4hImpl extends Vec4<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").F16;
};
get kind(): "vec4h";
get _Vec2(): typeof Vec2hImpl;
get _Vec3(): typeof Vec3hImpl;
get _Vec4(): typeof Vec4hImpl;
}
export declare class Vec4iImpl extends Vec4<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").I32;
};
get kind(): "vec4i";
get _Vec2(): typeof Vec2iImpl;
get _Vec3(): typeof Vec3iImpl;
get _Vec4(): typeof Vec4iImpl;
}
export declare class Vec4uImpl extends Vec4<number> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").U32;
};
get kind(): "vec4u";
get _Vec2(): typeof Vec2uImpl;
get _Vec3(): typeof Vec3uImpl;
get _Vec4(): typeof Vec4uImpl;
}
export declare class Vec4bImpl extends Vec4<boolean> {
get [$internal](): {
elementSchema: import("./wgslTypes.ts").Bool;
};
get kind(): "vec4<bool>";
get _Vec2(): typeof Vec2bImpl;
get _Vec3(): typeof Vec3bImpl;
get _Vec4(): typeof Vec4bImpl;
}
export {};