Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This version changes the types of functions so they return a specific type where as the old functions returned a union type old mat4.identity() -> Float32Array | Float64Array | number[] new mat4.identity() -> Float32Array But, these new funcitons will also return what you pass them mat4.identity([]) -> number[]; mat4.identity(new Float64Array(16)) -> Float64Array Further, they still take varied input mat4.lookAt( [4, 2, 9], // position [0, 0, 0], // target [0, 1, 0], // up ) -> Float32Array mat4.lookAt( someFloat64Array,, // position someFloat32Array, // target [0, 1, 0], // up ) -> Float32Array `setDefaultType` is removed. Instead there are 3 versions of every type and every API mat4 (generates Float32Array by default) mat4d (generates Float64Array by default) mat4n (generates number[] by default) similarly mat3, mat3d, mat3n vec4, vec4d, vec4n vec3, vec3d, vec3n vec2, vec2d, vec2n quad, quadd, quadn There are also types Mat4 = Float32Array Mat4d = Float64Array Mat4n = number[] And all the corresponding other types by default, if you use mat4, mat3, vec3, then they generate Float32Array which you means you can pass them directly to any function that takes a Float32Array like `device.queue.writeBuffer` etc... 1. ## Mat4, Vec3, etc are specific types You can't do this const position: Vec3 = [10, 20, 30]; // error, Vec3 is Float32Array You can do this const position: Vec3n = [10, 20, 30]; Or just don't type it const positon = [10, 20, 30]; 2. ## Bloat There's a ton of types and a ton of functions. The code isn't bigger. Only the names of the types and typed APIs and all their funcitons.
- Loading branch information