Skip to content

Commit

Permalink
Deploying to gh-pages from @ 0ca212e 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Sep 6, 2024
1 parent d921622 commit 4a308ef
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 171 deletions.
194 changes: 97 additions & 97 deletions dist/3.x/wgpu-matrix.d.ts

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions dist/3.x/wgpu-matrix.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/3.x/wgpu-matrix.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3.x/wgpu-matrix.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3.x/wgpu-matrix.min.js.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions dist/3.x/wgpu-matrix.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/3.x/wgpu-matrix.module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3.x/wgpu-matrix.module.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3.x/wgpu-matrix.module.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wgpu-matrix",
"version": "3.0.2",
"version": "3.0.3",
"description": "fast matrix math library for WebGPU",
"main": "dist/3.x/wgpu-matrix.module.js",
"module": "dist/3.x/wgpu-matrix.module.js",
Expand Down
30 changes: 15 additions & 15 deletions src/wgpu-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ function wgpuMatrixAPI<
Vec4Ctor: BaseCtor<Vec4>,
) {
return {
/** @namespace mat4 */
mat4: getMat4API<Mat3>(Mat3Ctor),
/** @namespace mat3 */
mat3: getMat3API<Mat4>(Mat4Ctor),
mat3: getMat3API<Mat3>(Mat3Ctor),
/** @namespace mat4 */
mat4: getMat4API<Mat4>(Mat4Ctor),
/** @namespace quat */
quat: getQuatAPI<Quat>(QuatCtor),
/** @namespace vec2 */
Expand All @@ -91,15 +91,15 @@ function wgpuMatrixAPI<

export const {
/**
* 4x4 Matrix functions that default to returning `Float32Array`
* 3x3 Matrix functions that default to returning `Float32Array`
* @namespace
*/
mat4,
mat3,
/**
* 3x3 Matrix functions that default to returning `Float32Array`
* 4x4 Matrix functions that default to returning `Float32Array`
* @namespace
*/
mat3,
mat4,
/**
* Quaternion functions that default to returning `Float32Array`
* @namespace
Expand All @@ -126,15 +126,15 @@ export const {

export const {
/**
* 4x4 Matrix functions that default to returning `Float64Array`
* 3x3 Matrix functions that default to returning `Float64Array`
* @namespace
*/
mat4: mat4d,
mat3: mat3d,
/**
* 3x3 Matrix functions that default to returning `Float64Array`
* 4x4 Matrix functions that default to returning `Float64Array`
* @namespace
*/
mat3: mat3d,
mat4: mat4d,
/**
* Quaternion functions that default to returning `Float64Array`
* @namespace
Expand All @@ -161,15 +161,15 @@ export const {

export const {
/**
* 4x4 Matrix functions that default to returning `number[]`
* 3x3 Matrix functions that default to returning `number[]`
* @namespace
*/
mat4: mat4n,
mat3: mat3n,
/**
* 3x3 Matrix functions that default to returning `number[]`
* 4x4 Matrix functions that default to returning `number[]`
* @namespace
*/
mat3: mat3n,
mat4: mat4n,
/**
* Quaternion functions that default to returning `number[]`
* @namespace
Expand Down
34 changes: 18 additions & 16 deletions test/tests/mat3-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,33 @@ function assertMat3EqualApproximately(a, b) {
}
}

function check(Type) {
function check(mat3, Type) {
describe('using ' + Type, () => {
const m = [
0, 1, 2, 0,
4, 5, 6, 0,
8, 9, 10, 0,
];

function createCopyOfType(v) {
return Type === Array ? new Type(...v) : new Type(v);
}

function testM3WithoutDest(func, expected, ...args) {
const d = func(...args);
assertMat3EqualApproximately(d, expected);
}

function testM3WithDest(func, expected, ...args) {
expected = new Float32Array(expected);
const d = new Float32Array(12);
expected = createCopyOfType(expected);
const d = new Type(12).fill(0);
const c = func(...args, d);
assertStrictEqual(c, d);
assertMat3EqualApproximately(c, expected);
}

function testMat3WithAndWithoutDest(func, expected, ...args) {
if (Type === Float32Array) {
expected = new Float32Array(expected);
}
expected = createCopyOfType(expected);
testM3WithoutDest(func, expected, ...args);
testM3WithDest(func, expected, ...args);
}
Expand All @@ -56,14 +58,14 @@ function check(Type) {
}

function testV2WithDest(func, expected) {
const d = new Float32Array(2);
const d = new Type(2).fill(0);
const c = func(d);
assertStrictEqual(c, d);
assertEqual(c, expected);
}

function testV2WithAndWithoutDest(func, expected) {
expected = new Float32Array(expected);
expected = createCopyOfType(expected);
testV2WithoutDest(func, expected);
testV2WithDest(func, expected);
}
Expand All @@ -90,9 +92,9 @@ function check(Type) {

it('should negate', () => {
const expected = [
-0, -1, -2, -3,
-4, -5, -6, -7,
-8, -9, -10, -11,
-0, -1, -2, 0,
-4, -5, -6, 0,
-8, -9, -10, 0,
];
testMat3WithAndWithoutDest((newDst) => {
return mat3.negate(m, newDst);
Expand Down Expand Up @@ -350,12 +352,12 @@ function check(Type) {

it('should get scaling', () => {
const m = [
1, 2, 3, 0,
2, 8, 3, 0,
5, 6, 7, 0,
9, 10, 11, 0,
];
const expected = [
Math.sqrt(1 * 1 + 2 * 2),
Math.sqrt(2 * 2 + 8 * 8),
Math.sqrt(5 * 5 + 6 * 6),
];
testV2WithAndWithoutDest((newDst) => {
Expand Down Expand Up @@ -491,8 +493,8 @@ function check(Type) {
}

describe('mat3', () => {
check(mat3n);
check(mat3);
check(mat3d);
check(mat3n, Array);
check(mat3, Float32Array);
check(mat3d, Float64Array);
});

1 change: 0 additions & 1 deletion test/tests/mat4-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {describe, it} from '../mocha-support.js';


function check(mat4, Type) {

describe('using ' + Type, () => {
const m = [
0, 1, 2, 3,
Expand Down

0 comments on commit 4a308ef

Please sign in to comment.