-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vector-pools): update AttribPool, add tests, update readme
- add AttribPool.setAttribs() - add opt start index arg for setAttribValues() - update AttribSpec to include opt. initial values - fix readme example - add missing deps
- Loading branch information
1 parent
6d8aad9
commit 33109d0
Showing
6 changed files
with
104 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,65 @@ | ||
import { AttribPool } from "../src/attrib-pool"; | ||
import { Type } from "@thi.ng/malloc"; | ||
// import * as assert from "assert"; | ||
import * as assert from "assert"; | ||
import { AttribPool } from "../src/attrib-pool"; | ||
|
||
describe("vector-pools", () => { | ||
it("attribs", () => { | ||
const pool = new AttribPool({ | ||
mem: { size: 0x100 }, | ||
num: 8, | ||
attribs: { | ||
pos: { type: Type.F32, default: [0, 0], size: 2, byteOffset: 0 }, | ||
id: { type: Type.U32, default: 0, size: 1, byteOffset: 8 }, | ||
index: { type: Type.U16, default: 0, size: 1, byteOffset: 12 }, | ||
col: { type: Type.I8, default: [0, 0, 0, 0], size: 4, byteOffset: 14 }, | ||
pos: { | ||
type: Type.F32, | ||
size: 2, // 8 bytes | ||
byteOffset: 0, | ||
data: [[1, 2], [3, 4]] | ||
}, | ||
id: { | ||
type: Type.U32, | ||
size: 1, // 4 bytes | ||
byteOffset: 8, | ||
data: [1, 2], | ||
index: 4 | ||
}, | ||
index: { | ||
type: Type.U16, | ||
size: 1, // 2 bytes | ||
byteOffset: 12, | ||
data: [10, 20] | ||
}, | ||
col: { | ||
type: Type.U8, | ||
size: 4, // 4 bytes | ||
byteOffset: 14, | ||
data: [[128, 129, 130, 131], [255, 254, 253, 252]], | ||
index: 6 | ||
} | ||
} | ||
}); | ||
pool.setAttribValue("pos", 0, [1, 2]); | ||
pool.setAttribValue("id", 0, 1); | ||
pool.setAttribValue("index", 0, 10); | ||
pool.setAttribValue("col", 0, [128, 129, 130, 131]); | ||
pool.setAttribValue("pos", 1, [3, 4]); | ||
pool.setAttribValue("id", 1, 2); | ||
pool.setAttribValue("index", 1, 20); | ||
pool.setAttribValue("col", 1, [255, 254, 253, 252]); | ||
assert.deepEqual( | ||
[...pool.attribValues("pos")], | ||
[[1, 2], [3, 4], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]] | ||
); | ||
assert.deepEqual( | ||
[...pool.attribValues("id")], | ||
[0, 0, 0, 0, 1, 2, 0, 0] | ||
); | ||
assert.deepEqual( | ||
[...pool.attribValues("index")], | ||
[10, 20, 0, 0, 0, 0, 0, 0] | ||
); | ||
assert.deepEqual( | ||
[...pool.attribValues("col")], | ||
[ | ||
[0, 0, 0, 0], | ||
[0, 0, 0, 0], | ||
[0, 0, 0, 0], | ||
[0, 0, 0, 0], | ||
[0, 0, 0, 0], | ||
[0, 0, 0, 0], | ||
[128, 129, 130, 131], | ||
[255, 254, 253, 252] | ||
] | ||
); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.