@thi.ng/soa 1.0.52 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/aos.js +2 -2
- package/package.json +8 -8
- package/serialize.js +2 -2
- package/soa.js +6 -6
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 211 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -91,7 +91,7 @@ For Node.js REPL:
|
|
|
91
91
|
const soa = await import("@thi.ng/soa");
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
94
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.44 KB
|
|
95
95
|
|
|
96
96
|
## Dependencies
|
|
97
97
|
|
|
@@ -105,14 +105,15 @@ Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
|
|
|
105
105
|
|
|
106
106
|
## Usage examples
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
Three projects in this repo's
|
|
109
109
|
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
|
|
110
110
|
directory are using this package:
|
|
111
111
|
|
|
112
|
-
| Screenshot | Description
|
|
113
|
-
|
|
114
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/soa-ecs-100k.png" width="240"/> | Entity Component System w/ 100k 3D particles
|
|
115
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cube.png" width="240"/> |
|
|
112
|
+
| Screenshot | Description | Live demo | Source |
|
|
113
|
+
|:--------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------|:----------------------------------------------------|:---------------------------------------------------------------------------------|
|
|
114
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/soa-ecs-100k.png" width="240"/> | Entity Component System w/ 100k 3D particles | [Demo](https://demo.thi.ng/umbrella/soa-ecs/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/soa-ecs) |
|
|
115
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cube.png" width="240"/> | 3D arcball controller to rotate the camera view of a colored cube | [Demo](https://demo.thi.ng/umbrella/webgl-arcball/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-arcball) |
|
|
116
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cube.png" width="240"/> | WebGL multi-colored cube mesh | [Demo](https://demo.thi.ng/umbrella/webgl-cube/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-cube) |
|
|
116
117
|
|
|
117
118
|
## API
|
|
118
119
|
|
package/aos.js
CHANGED
|
@@ -7,7 +7,7 @@ const aos = (num, specs, buf, byteOffset = 0) => {
|
|
|
7
7
|
let maxSize = 0;
|
|
8
8
|
const offsets = {};
|
|
9
9
|
const soaSpecs = {};
|
|
10
|
-
for (
|
|
10
|
+
for (const id in specs) {
|
|
11
11
|
const spec = prepareSpec(specs[id]);
|
|
12
12
|
const tsize = SIZEOF[spec.type];
|
|
13
13
|
maxSize = Math.max(maxSize, tsize);
|
|
@@ -18,7 +18,7 @@ const aos = (num, specs, buf, byteOffset = 0) => {
|
|
|
18
18
|
}
|
|
19
19
|
total = align(total, maxSize);
|
|
20
20
|
buf = buf || new ArrayBuffer(total * num + byteOffset);
|
|
21
|
-
for (
|
|
21
|
+
for (const id in soaSpecs) {
|
|
22
22
|
const spec = soaSpecs[id];
|
|
23
23
|
const tsize = SIZEOF[spec.type];
|
|
24
24
|
spec.stride = total / tsize;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/soa",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.54",
|
|
4
4
|
"description": "SOA & AOS memory mapped structured views with optional & extensible serialization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/api": "^8.12.
|
|
43
|
-
"@thi.ng/binary": "^3.
|
|
44
|
-
"@thi.ng/errors": "^2.5.
|
|
45
|
-
"@thi.ng/transducers-binary": "^2.1.
|
|
46
|
-
"@thi.ng/vectors": "^8.6.
|
|
42
|
+
"@thi.ng/api": "^8.12.10",
|
|
43
|
+
"@thi.ng/binary": "^3.5.0",
|
|
44
|
+
"@thi.ng/errors": "^2.5.50",
|
|
45
|
+
"@thi.ng/transducers-binary": "^2.1.191",
|
|
46
|
+
"@thi.ng/vectors": "^8.6.16"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@thi.ng/equiv": "^2.1.
|
|
49
|
+
"@thi.ng/equiv": "^2.1.100",
|
|
50
50
|
"esbuild": "^0.27.0",
|
|
51
51
|
"typedoc": "^0.28.14",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"status": "alpha",
|
|
108
108
|
"year": 2019
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "8625a1c6383737a8fdbe7a3f96ea3cbabc957fa6\n"
|
|
111
111
|
}
|
package/serialize.js
CHANGED
|
@@ -34,14 +34,14 @@ const utf8z = (maxLen) => ({
|
|
|
34
34
|
const serializer = (specs) => ({
|
|
35
35
|
decode(tuple) {
|
|
36
36
|
const res = {};
|
|
37
|
-
for (
|
|
37
|
+
for (const id in tuple) {
|
|
38
38
|
res[id] = specs[id].decode(tuple[id]);
|
|
39
39
|
}
|
|
40
40
|
return res;
|
|
41
41
|
},
|
|
42
42
|
encode: (tuple) => {
|
|
43
43
|
const res = {};
|
|
44
|
-
for (
|
|
44
|
+
for (const id in tuple) {
|
|
45
45
|
res[id] = specs[id].encode(tuple[id]);
|
|
46
46
|
}
|
|
47
47
|
return res;
|
package/soa.js
CHANGED
|
@@ -65,7 +65,7 @@ class SOA {
|
|
|
65
65
|
const stride = this.specs[id].stride;
|
|
66
66
|
const end = this.length * stride;
|
|
67
67
|
let i = from * stride;
|
|
68
|
-
for (
|
|
68
|
+
for (const v of vals) {
|
|
69
69
|
buf.set(v, i);
|
|
70
70
|
i += stride;
|
|
71
71
|
if (i >= end) break;
|
|
@@ -84,7 +84,7 @@ class SOA {
|
|
|
84
84
|
res[id] = this.attribValueUnsafe(id, i2);
|
|
85
85
|
}
|
|
86
86
|
} else {
|
|
87
|
-
for (
|
|
87
|
+
for (const id in this.specs) {
|
|
88
88
|
res[id] = this.attribValueUnsafe(id, i);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -92,19 +92,19 @@ class SOA {
|
|
|
92
92
|
}
|
|
93
93
|
setIndex(i, vals) {
|
|
94
94
|
ensureIndex(i, 0, this.length);
|
|
95
|
-
for (
|
|
95
|
+
for (const id in vals) {
|
|
96
96
|
this.setAttribValue(id, i, vals[id]);
|
|
97
97
|
}
|
|
98
98
|
return this;
|
|
99
99
|
}
|
|
100
100
|
setIndexUnsafe(i, vals) {
|
|
101
|
-
for (
|
|
101
|
+
for (const id in vals) {
|
|
102
102
|
this.setAttribValueUnsafe(id, i, vals[id]);
|
|
103
103
|
}
|
|
104
104
|
return this;
|
|
105
105
|
}
|
|
106
106
|
setValues(vals, from = 0) {
|
|
107
|
-
for (
|
|
107
|
+
for (const id in vals) {
|
|
108
108
|
this.setAttribValues(id, vals[id], from);
|
|
109
109
|
}
|
|
110
110
|
return this;
|
|
@@ -126,7 +126,7 @@ class SOA {
|
|
|
126
126
|
}
|
|
127
127
|
addSpecs(specs) {
|
|
128
128
|
const num = this.length;
|
|
129
|
-
for (
|
|
129
|
+
for (const id in specs) {
|
|
130
130
|
assert(!this.specs[id], `attrib ${id} already exists`);
|
|
131
131
|
const spec = prepareSpec(specs[id]);
|
|
132
132
|
this.validateSpec(id, spec);
|