Skip to content

Commit

Permalink
Updated to wtd-core / wtd-three-ext 2.4.0-next.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Salmen committed Nov 3, 2023
1 parent a0d1678 commit 55eec92
Show file tree
Hide file tree
Showing 8 changed files with 1,079 additions and 586 deletions.
1,599 changes: 1,047 additions & 552 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@react-three/fiber": "~8.15.9",
"wwobjloader2": "~6.2.0-next.1",
"wwobjloader2": "~6.2.0-next.3",
"lil-gui": "~0.19.0",
"react": "~18.2.0",
"react-dom": "~18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class OBJLoader2BasicExampleOffscreen {
window.addEventListener('resize', () => resize(), false);

const initMessage = new WorkerTaskMessage({ name: taskName });
const resultInit = await workerTask.initWorker(initMessage);
const resultInit = await workerTask.initWorker({ message: initMessage });
console.log(`initTaskType then: ${resultInit}`);

// once the init Promise returns enqueue the execution
Expand Down
20 changes: 10 additions & 10 deletions packages/examples/src/worker/BasicExampleOffscreenWorker.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {
DataPayload,
WorkerTaskDefaultWorker,
WorkerTaskMessageType,
pack,
comRouting,
createFromExisting,
pack
DataPayload,
WorkerTaskCommandResponse,
WorkerTaskWorker,
WorkerTaskMessageType
} from 'wtd-core';
import { OBJLoader2BasicExample } from '../examples/OBJLoader2BasicExample.js';
import { executeExample, resizeDisplayGL } from '../examples/ExampleCommons.js';

declare const self: DedicatedWorkerGlobalScope;

export class HelloWorlThreedWorker extends WorkerTaskDefaultWorker {
export class HelloWorlThreedWorker implements WorkerTaskWorker {

private objLoader2BasicExample?: OBJLoader2BasicExample;

init(message: WorkerTaskMessageType) {
console.log(`HelloWorldWorker#init: name: ${message.name} id: ${message.id} cmd: ${message.cmd} workerId: ${message.workerId}`);

const initComplete = createFromExisting(message, 'initComplete');
const initComplete = createFromExisting(message, WorkerTaskCommandResponse.INIT_COMPLETE);
self.postMessage(initComplete);
}

Expand All @@ -33,7 +33,7 @@ export class HelloWorlThreedWorker extends WorkerTaskDefaultWorker {
resizeDisplayGL(this.objLoader2BasicExample.getSetup());
}
if (dataPayload.message.params?.$type === 'terminate') {
const execComplete = createFromExisting(message, 'execComplete');
const execComplete = createFromExisting(message, WorkerTaskCommandResponse.EXECUTE_COMPLETE);
const transferables = pack(execComplete.payloads, false);
self.postMessage(execComplete, transferables);
}
Expand All @@ -56,4 +56,4 @@ export class HelloWorlThreedWorker extends WorkerTaskDefaultWorker {
}

const worker = new HelloWorlThreedWorker();
self.onmessage = message => worker.comRouting(message);
self.onmessage = message => comRouting(worker, message);
6 changes: 3 additions & 3 deletions packages/objloader2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wwobjloader2",
"version": "6.2.0-next.1",
"version": "6.2.0-next.3",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down Expand Up @@ -70,8 +70,8 @@
},
"dependencies": {
"three": "~0.158.0",
"wtd-core": "~2.4.0-next.1",
"wtd-three-ext": "~2.4.0-next.1"
"wtd-core": "~2.4.0-next.3",
"wtd-three-ext": "~2.4.0-next.3"
},
"peerDependencies": {
"three": ">= 0.137.5 < 1"
Expand Down
4 changes: 2 additions & 2 deletions packages/objloader2/src/OBJLoader2Parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class OBJLoader2Parallel extends OBJLoader2 {
};

initMessage.addPayload(dataPayload);
return this.workerTask!.initWorker(initMessage);
return this.workerTask!.initWorker({ message: initMessage });
}

private async executeWorker(objToParse: ArrayBuffer) {
Expand Down Expand Up @@ -219,7 +219,7 @@ export class OBJLoader2Parallel extends OBJLoader2 {
console.error('Received intermediate message without a proper payload');
}
}
else if (wtm.cmd === 'execComplete') {
else if (wtm.cmd === WorkerTaskCommandResponse.EXECUTE_COMPLETE) {
this._onLoad();
}
else {
Expand Down
28 changes: 13 additions & 15 deletions packages/objloader2/src/worker/OBJLoader2Worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {
WorkerTaskDefaultWorker,
WorkerTaskMessage,
DataPayload,
WorkerTaskMessageType,
AssociatedArrayType,
pack,
createFromExisting,
applyProperties,
comRouting,
createFromExisting,
pack,
unpack,
WorkerTaskCommandResponse
AssociatedArrayType,
DataPayload,
WorkerTaskCommandResponse,
WorkerTaskMessage,
WorkerTaskMessageType,
WorkerTaskWorker
} from 'wtd-core';
import {
OBJLoader2Parser
Expand All @@ -21,7 +22,7 @@ type LocalData = {
materialNames: Set<string>;
}

class OBJLoader2Worker extends WorkerTaskDefaultWorker {
class OBJLoader2Worker implements WorkerTaskWorker {

private localData: LocalData = {
params: {},
Expand Down Expand Up @@ -66,7 +67,7 @@ class OBJLoader2Worker extends WorkerTaskDefaultWorker {

parser._onLoad = () => {
const execMessage = new WorkerTaskMessage({ id });
execMessage.cmd = 'execComplete';
execMessage.cmd = WorkerTaskCommandResponse.EXECUTE_COMPLETE;
// no packing required as no Transferables here
self.postMessage(execMessage);
};
Expand All @@ -87,7 +88,7 @@ class OBJLoader2Worker extends WorkerTaskDefaultWorker {
console.log(`OBJLoader2Worker#init: name: ${message.name} id: ${message.id} cmd: ${message.cmd} workerId: ${message.workerId}`);
}

const initComplete = createFromExisting(wtm, 'initComplete');
const initComplete = createFromExisting(wtm, WorkerTaskCommandResponse.INIT_COMPLETE);
self.postMessage(initComplete);
}

Expand Down Expand Up @@ -140,7 +141,4 @@ class OBJLoader2Worker extends WorkerTaskDefaultWorker {
}

const worker = new OBJLoader2Worker();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
self.onmessage = (message: MessageEvent<any>) => {
worker.comRouting(message);
};
self.onmessage = message => comRouting(worker, message);
4 changes: 2 additions & 2 deletions scripts/UpdateVersions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import shell from 'shelljs';

const versionPattern = '.*[0-9]\\.[0-9]\\.[0-9].*';

const version_wtd_core_real = '~2.4.0-next.1';
const version_wtd_core_real = '~2.4.0-next.3';
const version_wtd_core_dev = '../../../wtd/packages/wtd-core';

const version_wtd_three_ext_real = '~2.4.0-next.1';
const version_wtd_three_ext_real = '~2.4.0-next.3';
const version_wtd_three_ext_dev = '../../../wtd/packages/wtd-three-ext';

const what = process.argv[2];
Expand Down

0 comments on commit 55eec92

Please sign in to comment.