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 +1 -1
- package/src/Camera/parallel.js +9 -2
package/package.json
CHANGED
package/src/Camera/parallel.js
CHANGED
|
@@ -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
|
-
|
|
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 ? "." :
|
|
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;
|