tela.js 1.1.5 → 1.1.7

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  Experimental graphic library from scratch(software-only), with reference implementation of computer graphics algorithms.
4
4
 
5
+ ![](/tela.png)
6
+
5
7
  ## Purpose
6
8
 
7
9
  The purpose of this graphic engine is to be able to generate images in a computational way, with minimal dependencies, such that the readable graphical algorithms shine instead of opaque graphical APIs. The engine should also be capable to create videos and interactive demos or games.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tela.js",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "author": "Pedroth",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,11 @@ const __Worker = IS_NODE ? (await import("node:worker_threads")).Worker : Worker
12
12
  class MyWorker {
13
13
  constructor(path) {
14
14
  this.path = path;
15
- this.worker = new __Worker(path, { type: 'module' });
15
+ try {
16
+ this.worker = new __Worker(path, { type: 'module' });
17
+ } catch (e) {
18
+ console.log("Caught error while importing worker", e);
19
+ }
16
20
  }
17
21
 
18
22
  onMessage(lambda) {
@@ -41,8 +45,11 @@ let prevSceneHash = undefined;
41
45
  export function parallelWorkers(camera, scene, canvas, params = {}) {
42
46
  // lazy loading workers
43
47
  if (WORKERS.length === 0) {
48
+ // needs to be here...
49
+ const isGithub = typeof window !== "undefined" && (window.location.host || window.LOCATION_HOST) === "pedroth.github.io";
50
+ const SOURCE = isGithub ? "/tela.js" : ""
44
51
  WORKERS = [...Array(NUMBER_OF_CORES)]
45
- .map(() => new MyWorker(`${IS_NODE ? "." : ""}/src/Camera/rayTraceWorker.js`));
52
+ .map(() => new MyWorker(`${IS_NODE ? "." : SOURCE}/src/Camera/rayTraceWorker.js`));
46
53
  }
47
54
  const w = canvas.width;
48
55
  const h = canvas.height;
@@ -130,7 +130,7 @@ export default class Mesh {
130
130
  })
131
131
  }
132
132
 
133
- asPoints(radius = RADIUS) {
133
+ asSpheres(radius = RADIUS) {
134
134
  const points = {};
135
135
  for (let i = 0; i < this.faces.length; i++) {
136
136
  const texCoordIndexes = this