more missing code, module adaptations

This commit is contained in:
Stewart Allen 2025-06-14 11:11:20 -04:00
commit 3ba4e3c5ec
17 changed files with 172 additions and 82 deletions

View file

@ -150,7 +150,7 @@ const client = {
if (self.createWorker) {
return self.createWorker();
} else {
return new Worker(workurl = url);
return new Worker(workurl = url, { type: 'module' });
}
},
@ -188,9 +188,14 @@ const client = {
let worker = client.spawn(workurl);
worker.run = null;
worker.index = i;
worker.onerror = function(e) {
console.log({ worker_error: e });
}
worker.onmessageerror = function(e) {
console.log({ worker_message_error: e });
}
worker.onmessage = function(e) {
let reply = e.data;
// handle special case for task binding
if (reply.bind) {
client.bind(reply.bind);

View file

@ -7,3 +7,4 @@ const terms = {
};
export const license = terms;
export const version = terms.VERSION;

View file

@ -1,8 +1,7 @@
// code for a ServiceWorker that provides support for running cached/offline
import { license } from './license.js';
import { version } from './license.js';
const version = license.version;
const origin = self.location.origin;
const stats = {
hit: 0,

View file

@ -15,8 +15,8 @@ const {
const nav = navigator;
let WIN = window,
DOC = document,
let WIN = self.window || {},
DOC = self.document,
SCENE = new Scene(),
WORLD = new Group(),
PI = Math.PI,
@ -130,25 +130,27 @@ let WIN = window,
hiddenKey,
vizChange,
docVisible = true,
antiAlias = window.devicePixelRatio <= 1,
antiAlias = WIN.devicePixelRatio <= 1,
lastAction = Date.now(),
renderTime = 0,
fps = 0;
if (typeof DOC.hidden !== "undefined") {
hiddenKey = "hidden";
vizChange = "visibilitychange";
} else if (typeof DOC.msHidden !== "undefined") {
hiddenKey = "msHidden";
vizChange = "msvisibilitychange";
} else if (typeof DOC.webkitHidden !== "undefined") {
hiddenKey = "webkitHidden";
vizChange = "webkitvisibilitychange";
}
if (DOC) {
if (typeof DOC.hidden !== "undefined") {
hiddenKey = "hidden";
vizChange = "visibilitychange";
} else if (typeof DOC.msHidden !== "undefined") {
hiddenKey = "msHidden";
vizChange = "msvisibilitychange";
} else if (typeof DOC.webkitHidden !== "undefined") {
hiddenKey = "webkitHidden";
vizChange = "webkitvisibilitychange";
}
DOC.addEventListener(vizChange, () => {
docVisible = DOC[hiddenKey] ? false : true;
}, false);
DOC.addEventListener(vizChange, () => {
docVisible = DOC[hiddenKey] ? false : true;
}, false);
}
function updateLastAction() {
lastAction = Date.now();
@ -172,7 +174,7 @@ WORLD.contains = (obj) => {
******************************************************************* */
function tweenit() {
TWEEN.update();
self.TWEEN?.update();
setTimeout(tweenit, tweenDelay);
}