rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
103 lines • 3.4 kB
TypeScript
import { ATypedArrayTuple, TTypedArrayTupleMutativeMethods } from "../a-typed-array-tuple.js";
import { TTypedArray } from "../t-typed-array.js";
import { ITypedArrayTupleFactory } from "../i-typed-array-tuple-factory.js";
import { TTypedArrayCtor } from "../t-typed-array-ctor.js";
import { TPickExcept } from "../../../typescript/t-pick-except.js";
/**
* @public
*/
export type TVec3CtorArgs = [x: number, y: number, z: number];
/**
* @public
* Constructor for {@link Vec3}.
*/
export interface IVec3Ctor<TArray extends TTypedArray> {
/**
* The size in bytes of each element in the array.
*/
readonly BYTES_PER_ELEMENT: number;
readonly prototype: Vec3<TArray>;
readonly factory: ITypedArrayTupleFactory<Vec3<TArray>, TVec3CtorArgs>;
new (): Vec3<TArray>;
}
/**
* @public
* {@link Vec3}.
*/
export interface IReadonlyVec3<TArray extends TTypedArray> extends TPickExcept<Readonly<Vec3<TArray>>, "update" | "setX" | "setY" | "setZ" | "copyFromBuffer" | TTypedArrayTupleMutativeMethods> {
}
/**
* @public
* Vector 3.
*
* @remarks
* See static properties for constructors. Instances are not an extension of this class, but of the static members.
*/
export declare abstract class Vec3<TArray extends TTypedArray> extends ATypedArrayTuple<3, TArray> {
static f64: IVec3Ctor<Float64Array>;
static f32: IVec3Ctor<Float32Array>;
static i64: null;
static u64: null;
static u32: IVec3Ctor<Uint32Array>;
static i32: IVec3Ctor<Int32Array>;
static u16: IVec3Ctor<Uint16Array>;
static i16: IVec3Ctor<Int16Array>;
static u8c: IVec3Ctor<Uint8ClampedArray>;
static u8: IVec3Ctor<Uint8Array>;
static i8: IVec3Ctor<Int8Array>;
static getCtor<TCtor extends TTypedArrayCtor>(ctor: TCtor): IVec3Ctor<InstanceType<TCtor>>;
protected static constructors: Map<import("../t-typed-array-ctor.js").TFullSetTypedArrayCtor, Function>;
["constructor"]: IVec3Ctor<TArray>;
/**
* x
*/
0: number;
/**
* y
*/
1: number;
/**
* z
*/
2: number;
/**
* Component-wise equals.
*/
isEqualTo(_other: Vec3<TTypedArray>): boolean;
getX(): number;
getY(): number;
getZ(): number;
getMagnitude(): number;
getMagnitudeSquared(): number;
dotProduct(_vec: IReadonlyVec3<TTypedArray>): number;
update(_x: number, _y: number, _z: number): void;
setX(_x: number): void;
setY(_y: number): void;
setZ(_z: number): void;
getLoggableValue(): number[][];
/**
* If endianness is not supplied the platform's endianness will be used.
*/
copyFromBuffer(_memoryDataView: DataView, _pointer: number, _littleEndian?: boolean): void;
/**
* If endianness is not supplied the platform's endianness will be used.
*/
copyToBuffer(_memoryDataView: DataView, _pointer: number, _littleEndian?: boolean): void;
/**
* Although the typed array tuples extend a typed array, they are not structurally compatible.
* This function returns the argument passed without modification but cast as the underlying storage type, e.g. Float32Array.
*/
castToBaseType(): TArray;
TTypeGuardVec3: true;
}
/**
* @public
* Float32 {@link Vec3}.
*/
export type TF32Vec3 = Vec3<Float32Array>;
/**
* @public
* Float64 {@link Vec3}.
*/
export type TF64Vec3 = Vec3<Float64Array>;
//# sourceMappingURL=vec3.d.ts.map