tela.js 1.2.11 → 1.2.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tela.js",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "author": "Pedroth",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "scripts": {
43
43
  "serve": "bunx http-server",
44
44
  "clean": "rm -fr node_modules; rm *.png *.jpeg *.ppm *.webm *.mp4",
45
- "pub": "npm version patch; npm publish"
45
+ "pub": "npm version patch; npm publish; git push; git push --tags"
46
46
  },
47
47
  "type": "module"
48
48
  }
@@ -1,15 +1,21 @@
1
1
  import Camera from "./Camera.js";
2
- import { memoize } from "../Utils/Utils.js";
2
+ import { memoize} from "../Utils/Utils.js";
3
+ import { clamp } from "../Utils/Math.js";
3
4
  import { CHANNELS, IS_NODE } from "../Utils/Constants.js";
4
5
  import { deserializeScene } from "../Scene/utils.js";
5
6
  import Color from "../Color/Color.js";
6
7
  import Box from "../Geometry/Box.js";
8
+ import Sphere from "../Geometry/Sphere.js";
7
9
  import Vec, { Vec2, Vec3 } from "../Vector/Vector.js";
8
10
  import Ray from "../Ray/Ray.js";
9
11
 
12
+ const Canvas = !IS_NODE ? (await import("../Tela/Canvas.js")).default : undefined;
13
+ const Image = IS_NODE ? (await import("../Tela/Image.js")).default : undefined;
14
+
10
15
  const parentPort = IS_NODE ? (await import("node:worker_threads")).parentPort : undefined;
11
16
 
12
17
  let scene = undefined;
18
+ let _memory_ = {}
13
19
 
14
20
  function getScene(serializedScene) {
15
21
  return deserializeScene(serializedScene).then(s => s.rebuild());
@@ -28,7 +34,7 @@ async function main(inputs) {
28
34
  camera: serializedCamera,
29
35
  } = inputs;
30
36
 
31
- scene = serializedScene ? (await getScene(serializedScene)).rebuild() : scene;
37
+ scene = serializedScene ? (await getScene(serializedScene)) : scene;
32
38
  const camera = Camera.deserialize(serializedCamera);
33
39
  const rayGen = camera.rayFromImage(width, height);
34
40
  const __lambda = getLambda(lambda, dependencies);
@@ -39,7 +45,7 @@ async function main(inputs) {
39
45
  for (let y = startRow; y < endRow; y++) {
40
46
  for (let x = 0; x < width; x++) {
41
47
  const ray = rayGen(x, height - 1 - y);
42
- const color = __lambda(ray, { ...vars, scene });
48
+ const color = await __lambda(ray, { ...vars, scene, _memory_});
43
49
  if(!color) continue;
44
50
  image[index++] = color.red;
45
51
  image[index++] = color.green;