larry babby and threejs for glsl

This commit is contained in:
Sam
2024-06-24 21:24:00 +12:00
parent 87d5dc634d
commit 907ebae4c0
6474 changed files with 1279596 additions and 8 deletions

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _childState = require("../childState");
var _child = require("../child");
function _core() {
const data = require("@parcel/core");
_core = function () {
return data;
};
return data;
}
/* eslint-env worker*/
class WebChild {
constructor(onMessage, onExit) {
if (!(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)) {
throw new Error('Only create WebChild instances in a worker!');
}
this.onMessage = onMessage;
this.onExit = onExit;
self.addEventListener('message', ({
data
}) => {
if (data === 'stop') {
this.onExit(0);
self.postMessage('stopped');
}
// $FlowFixMe assume WorkerMessage as data
this.handleMessage(data);
});
self.postMessage('online');
}
handleMessage(data) {
this.onMessage((0, _core().restoreDeserializedObject)(data));
}
send(data) {
self.postMessage((0, _core().prepareForSerialization)(data));
}
}
exports.default = WebChild;
(0, _childState.setChild)(new _child.Child(WebChild));

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _core() {
const data = require("@parcel/core");
_core = function () {
return data;
};
return data;
}
function _utils() {
const data = require("@parcel/utils");
_utils = function () {
return data;
};
return data;
}
let id = 0;
class WebWorker {
constructor(execArgv, onMessage, onError, onExit) {
this.execArgv = execArgv;
this.onMessage = onMessage;
this.onError = onError;
this.onExit = onExit;
}
start() {
// $FlowFixMe[incompatible-call]
this.worker = new Worker(new URL('./WebChild.js', import.meta.url), {
name: `Parcel Worker ${id++}`,
type: 'module'
});
let {
deferred,
promise
} = (0, _utils().makeDeferredWithPromise)();
this.worker.onmessage = ({
data
}) => {
if (data === 'online') {
deferred.resolve();
return;
}
// $FlowFixMe assume WorkerMessage as data
this.handleMessage(data);
};
this.worker.onerror = this.onError;
// Web workers can't crash or intentionally stop on their own, apart from stop() below
// this.worker.on('exit', this.onExit);
return promise;
}
stop() {
if (!this.stopping) {
this.stopping = (async () => {
this.worker.postMessage('stop');
let {
deferred,
promise
} = (0, _utils().makeDeferredWithPromise)();
this.worker.addEventListener('message', ({
data
}) => {
if (data === 'stopped') {
deferred.resolve();
}
});
await promise;
this.worker.terminate();
this.onExit(0);
})();
}
return this.stopping;
}
handleMessage(data) {
this.onMessage((0, _core().restoreDeserializedObject)(data));
}
send(data) {
this.worker.postMessage((0, _core().prepareForSerialization)(data));
}
}
exports.default = WebWorker;