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 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
- - Black hole demo
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tela.js",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "author": "Pedroth",
5
5
  "repository": {
6
6
  "type": "git",
@@ -260,7 +260,7 @@ export default class Mesh {
260
260
  }
261
261
  if (type === "f") {
262
262
  triangulate(spaces.slice(1))
263
- .forEach(triangleIdx => {
263
+ ?.forEach(triangleIdx => {
264
264
  faces.push(parseFace(triangleIdx))
265
265
  })
266
266
  continue;
@@ -97,3 +97,12 @@ $$\lfloor \text{index} / CW \rfloor = \lfloor(C(Wx+y)+z) / CW \rfloor$$
97
97
 
98
98
  $$\lfloor \text{index} / CW \rfloor = x$$
99
99
 
100
+
101
+ In the end we need to put the variables as the first diagram:
102
+
103
+ $$
104
+ x' = y\\
105
+ y' = H - 1 - x
106
+
107
+ $$
108
+
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(() => {
@@ -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) {
@@ -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;
@@ -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;