tela.js 1.1.5 → 1.1.6

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.1.5",
3
+ "version": "1.1.6",
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;