tela.js 1.2.21 → 1.2.23
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 -5
- package/package.json +1 -1
- package/src/Geometry/Mesh.js +1 -1
- package/src/Tela/README.md +9 -0
- package/src/Tela/Tela.js +2 -2
- package/src/Tela/parallel.js +2 -1
- package/src/Tela/telaWorker.js +4 -1
- package/src/Utils/Fonts.js +2 -1
package/README.md
CHANGED
|
@@ -148,18 +148,21 @@ You can find more examples of usage in:
|
|
|
148
148
|
|
|
149
149
|
# TODOs
|
|
150
150
|
|
|
151
|
+
- Read glb and gltf files
|
|
152
|
+
- Realtime light maps rendering in raster graphics
|
|
151
153
|
- Serialize meshes not only triangles
|
|
152
154
|
- Optimize data serialization in parallel ray tracer
|
|
153
155
|
- Refactor geometric objects to have shader function
|
|
154
|
-
- Refactor parallel raytracing to be just parallel canvas map
|
|
155
156
|
- Add Phong shading to raster graphics
|
|
156
|
-
- Read glb and gltf files
|
|
157
157
|
|
|
158
|
-
- Add lorentz attractors demo
|
|
159
|
-
- Add Iterated map fractals demo
|
|
160
158
|
- Add Volumetric fluid sim
|
|
159
|
+
- Add surface water tension sim
|
|
161
160
|
- Megaman rag doll physics
|
|
162
|
-
-
|
|
161
|
+
- Add lorentz attractors demo
|
|
162
|
+
- Add Iterated map fractals demo
|
|
163
|
+
- Quaternion julia sets
|
|
164
|
+
|
|
165
|
+
- Replicate some demos from https://oimo.io/works
|
|
163
166
|
|
|
164
167
|
|
|
165
168
|
[ffmpeg]: https://ffmpeg.org/
|
package/package.json
CHANGED
package/src/Geometry/Mesh.js
CHANGED
package/src/Tela/README.md
CHANGED
package/src/Tela/Tela.js
CHANGED
|
@@ -59,8 +59,8 @@ export default class Tela {
|
|
|
59
59
|
|
|
60
60
|
mapParallel(lambda, dependencies = []) {
|
|
61
61
|
return {
|
|
62
|
-
run: (vars = {}) => {
|
|
63
|
-
const workersPromises = parallelWorkers(this, lambda, dependencies, vars);
|
|
62
|
+
run: (vars = {}, memory = {}) => {
|
|
63
|
+
const workersPromises = parallelWorkers(this, lambda, dependencies, vars, memory);
|
|
64
64
|
return Promise
|
|
65
65
|
.allSettled(workersPromises)
|
|
66
66
|
.then(() => {
|
package/src/Tela/parallel.js
CHANGED
|
@@ -17,7 +17,7 @@ let isFirstTimeCounter = NUMBER_OF_CORES;
|
|
|
17
17
|
* */
|
|
18
18
|
//========================================================================================
|
|
19
19
|
|
|
20
|
-
export function parallelWorkers(tela, lambda, dependencies = [], vars = []) {
|
|
20
|
+
export function parallelWorkers(tela, lambda, dependencies = [], vars = [], memory = {}) {
|
|
21
21
|
// lazy loading workers
|
|
22
22
|
if (WORKERS.length === 0) {
|
|
23
23
|
WORKERS = [...Array(NUMBER_OF_CORES)]
|
|
@@ -48,6 +48,7 @@ export function parallelWorkers(tela, lambda, dependencies = [], vars = []) {
|
|
|
48
48
|
__startRow: k * ratio,
|
|
49
49
|
__endRow: Math.min(h, (k + 1) * ratio),
|
|
50
50
|
__dependencies: dependencies.map(d => d.toString()),
|
|
51
|
+
__memory: memory,
|
|
51
52
|
};
|
|
52
53
|
worker.postMessage(message);
|
|
53
54
|
if (isFirstTimeCounter > 0 && !IS_NODE) {
|
package/src/Tela/telaWorker.js
CHANGED
|
@@ -10,6 +10,7 @@ import Camera from "../Camera/Camera.js";
|
|
|
10
10
|
import Ray from "../Ray/Ray.js";
|
|
11
11
|
|
|
12
12
|
const parentPort = IS_NODE ? (await import("node:worker_threads")).parentPort : undefined;
|
|
13
|
+
let memory = {}
|
|
13
14
|
|
|
14
15
|
async function main(inputs) {
|
|
15
16
|
const {
|
|
@@ -20,7 +21,9 @@ async function main(inputs) {
|
|
|
20
21
|
__startRow,
|
|
21
22
|
__endRow,
|
|
22
23
|
__dependencies,
|
|
24
|
+
__memory,
|
|
23
25
|
} = inputs;
|
|
26
|
+
memory = {...memory, ...__memory };
|
|
24
27
|
const bufferSize = __width * (__endRow - __startRow + 1) * CHANNELS;
|
|
25
28
|
const image = new Float32Array(bufferSize);
|
|
26
29
|
let index = 0;
|
|
@@ -29,7 +32,7 @@ async function main(inputs) {
|
|
|
29
32
|
for (let i = __startRow; i < __endRow; i++) {
|
|
30
33
|
for (let x = 0; x < __width; x++) {
|
|
31
34
|
const y = __height - 1 - i;
|
|
32
|
-
const color = await func(x, y, __vars);
|
|
35
|
+
const color = await func(x, y, __vars, memory);
|
|
33
36
|
if (!color) continue;
|
|
34
37
|
image[index++] = color.red;
|
|
35
38
|
image[index++] = color.green;
|
package/src/Utils/Fonts.js
CHANGED
|
@@ -16,7 +16,8 @@ try {
|
|
|
16
16
|
fontImage = await or(
|
|
17
17
|
() => TELA.ofUrl(`../src/Utils/sdf_font.png`),
|
|
18
18
|
() => TELA.ofUrl(`./src/Utils/sdf_font.png`),
|
|
19
|
-
() => TELA.ofUrl(`./node_modules/tela.js/src/Utils/sdf_font.png`)
|
|
19
|
+
() => TELA.ofUrl(`./node_modules/tela.js/src/Utils/sdf_font.png`),
|
|
20
|
+
() => TELA.ofUrl(`https://cdn.jsdelivr.net/npm/tela.js/src/Utils/sdf_font.png`)
|
|
20
21
|
);
|
|
21
22
|
fontImageWidth = fontImage.width;
|
|
22
23
|
fontImageHeight = fontImage.height;
|