diff --git a/packages/vector-pools/src/api.ts b/packages/vector-pools/src/api.ts index 10e7222fe4..657ecc0345 100644 --- a/packages/vector-pools/src/api.ts +++ b/packages/vector-pools/src/api.ts @@ -1,4 +1,5 @@ import { + GLType, ILogger, IObjectOf, IRelease, @@ -55,52 +56,6 @@ export type VecFactory = ( stride: number ) => StridedVec; -/** - * WebGL numeric type constants. These can be used by classes in this - * package as aliases for thi.ng/malloc's `Type` enum (see `GL2TYPE` LUT - * below), but also then used directly when initializing WebGL buffers - * from given attribute buffer specs. - * - * See `AttribPool` & readme examples for more details. - */ -export const enum GLType { - I8 = 0x1400, - U8 = 0x1401, - I16 = 0x1402, - U16 = 0x1403, - I32 = 0x1404, - U32 = 0x1405, - F32 = 0x1406 -} - -/** - * Conversion from `GLType` to `Type`. - */ -export const GL2TYPE: { [id: number]: Type } = { - [GLType.I8]: Type.I8, - [GLType.U8]: Type.U8, - [GLType.I16]: Type.I16, - [GLType.U16]: Type.U16, - [GLType.I32]: Type.I32, - [GLType.I32]: Type.I32, - [GLType.U32]: Type.U32, - [GLType.F32]: Type.F32 -}; - -/** - * Conversion from `Type` to `GLType`. - */ -export const TYPE2GL: { [id: number]: GLType } = { - [Type.I8]: GLType.I8, - [Type.U8]: GLType.U8, - [Type.I16]: GLType.I16, - [Type.U16]: GLType.U16, - [Type.I32]: GLType.I32, - [Type.I32]: GLType.I32, - [Type.U32]: GLType.U32, - [Type.F32]: GLType.F32 -}; - export let LOGGER = NULL_LOGGER; export const setLogger = (logger: ILogger) => (LOGGER = logger); diff --git a/packages/vector-pools/src/attrib-pool.ts b/packages/vector-pools/src/attrib-pool.ts index c96de931a9..6613d5049f 100644 --- a/packages/vector-pools/src/attrib-pool.ts +++ b/packages/vector-pools/src/attrib-pool.ts @@ -3,11 +3,12 @@ import { IObjectOf, IRelease, SIZEOF, - TypedArray + TypedArray, + TYPEDARRAY_CTORS } from "@thi.ng/api"; import { align, Pow2 } from "@thi.ng/binary"; import { isNumber } from "@thi.ng/checks"; -import { MemPool, TYPEDARRAY_CTORS, wrap } from "@thi.ng/malloc"; +import { MemPool, wrap } from "@thi.ng/malloc"; import { range } from "@thi.ng/transducers"; import { ReadonlyVec, Vec, zeroes } from "@thi.ng/vectors"; import { AttribPoolOpts, AttribSpec, LOGGER } from "./api"; @@ -123,7 +124,7 @@ export class AttribPool implements IRelease { const size = spec.size; const stride = spec.stride!; const src = this.attribs[id]; - const dest = new TYPEDARRAY_CTORS[(asNativeType(spec.type))](n * size); + const dest = new TYPEDARRAY_CTORS[asNativeType(spec.type)](n * size); if (size > 1) { for (let i = 0, j = 0; i < n; i++, j += stride) { dest.set(src.subarray(j, j + size), i * size); @@ -247,9 +248,7 @@ export class AttribPool implements IRelease { () => (!isNum && a.size === (a.default).length) || (isNum && a.size === 1), - `attrib ${id}: incompatible default value, expected size ${ - a.size - }` + `attrib ${id}: incompatible default value, expected size ${a.size}` ); assert( a.byteOffset % size === 0, diff --git a/packages/vector-pools/src/convert.ts b/packages/vector-pools/src/convert.ts index 7b03f0863c..0e3116f423 100644 --- a/packages/vector-pools/src/convert.ts +++ b/packages/vector-pools/src/convert.ts @@ -1,5 +1,9 @@ -import { Type } from "@thi.ng/api"; -import { GL2TYPE, GLType, TYPE2GL } from "./api"; +import { + GL2TYPE, + GLType, + Type, + TYPE2GL +} from "@thi.ng/api"; /** * Returns canonical `Type` value of `type` by first attempting to diff --git a/packages/vector-pools/src/vec-pool.ts b/packages/vector-pools/src/vec-pool.ts index 22ffce9c1b..baf47b4575 100644 --- a/packages/vector-pools/src/vec-pool.ts +++ b/packages/vector-pools/src/vec-pool.ts @@ -1,8 +1,8 @@ -import { Type, TypedArray } from "@thi.ng/api"; +import { GLType, Type, TypedArray } from "@thi.ng/api"; import { isTypedArray } from "@thi.ng/checks"; import { MemPool, MemPoolOpts, MemPoolStats } from "@thi.ng/malloc"; import { StridedVec } from "@thi.ng/vectors"; -import { GLType, IVecPool } from "./api"; +import { IVecPool } from "./api"; import { asNativeType } from "./convert"; import { wrap } from "./wrap";