@wonderlandengine/ar-provider-zappar 1.2.0 → 1.2.1
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.
|
@@ -209,8 +209,8 @@ export class ZapparProvider extends ARProvider {
|
|
|
209
209
|
if (ZapparProvider._cvWorkerConfigured)
|
|
210
210
|
return;
|
|
211
211
|
// Hard-coded paths for local development
|
|
212
|
-
const workerUrl = './zappar-cv
|
|
213
|
-
const wasmUrl = './zappar-cv
|
|
212
|
+
const workerUrl = './zappar-cv.worker.js';
|
|
213
|
+
const wasmUrl = './zappar-cv.wasm';
|
|
214
214
|
const debugWorker = this.isVerboseDebugLoggingEnabled;
|
|
215
215
|
if (debugWorker) {
|
|
216
216
|
console.log('[ZapparProvider] configureCvWorkerIfNeeded()', {
|
|
@@ -284,12 +284,18 @@ export class ZapparProvider extends ARProvider {
|
|
|
284
284
|
}, 5000);
|
|
285
285
|
}
|
|
286
286
|
if (wasmUrl) {
|
|
287
|
+
const resolvedWasmUrl = new URL(wasmUrl, window.location.href).toString();
|
|
287
288
|
if (debugWorker) {
|
|
288
|
-
console.log('[ZapparProvider]
|
|
289
|
+
console.log('[ZapparProvider] Compiling WASM for worker:', resolvedWasmUrl);
|
|
289
290
|
}
|
|
291
|
+
// The worker's instantiateWasm callback expects a pre-compiled
|
|
292
|
+
// WebAssembly.Module (not just a URL). Compile it on the main
|
|
293
|
+
// thread so it can be structured-cloned into the worker.
|
|
294
|
+
const compiledModule = await WebAssembly.compileStreaming(fetch(resolvedWasmUrl));
|
|
290
295
|
worker.postMessage({
|
|
291
296
|
t: 'wasm',
|
|
292
|
-
url:
|
|
297
|
+
url: resolvedWasmUrl,
|
|
298
|
+
module: compiledModule,
|
|
293
299
|
});
|
|
294
300
|
}
|
|
295
301
|
await zapparSetOptions({ worker });
|
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -107,7 +107,12 @@ function main() {
|
|
|
107
107
|
const zapparCvLibDir = path.join(zapparCvRoot, 'lib');
|
|
108
108
|
|
|
109
109
|
const projectRoot = resolveProjectRoot();
|
|
110
|
-
const outDir = path.resolve(projectRoot, 'static'
|
|
110
|
+
const outDir = path.resolve(projectRoot, 'static');
|
|
111
|
+
// Face/CV model files (.zbin) are fetched by the Zappar runtime from the
|
|
112
|
+
// hardcoded path "zappar-cv/<filename>" relative to the page origin, so
|
|
113
|
+
// they must live in a zappar-cv/ subdirectory even though the worker and
|
|
114
|
+
// wasm sit at the static root.
|
|
115
|
+
const modelsDir = path.resolve(projectRoot, 'static', 'zappar-cv');
|
|
111
116
|
|
|
112
117
|
// -------------------------------------------------------------------------
|
|
113
118
|
// Detect package layout.
|
|
@@ -155,13 +160,11 @@ function main() {
|
|
|
155
160
|
const wasmDest = path.join(outDir, wasmBasename);
|
|
156
161
|
copyOrThrow(wasmSource, wasmDest);
|
|
157
162
|
safeLinkOrCopy(wasmDest, path.join(outDir, 'zappar-cv.wasm'));
|
|
158
|
-
// Also copy wasm to static root so the bundled worker can find it at /zappar-cv.wasm.
|
|
159
|
-
copyOrThrow(wasmSource, path.join(path.dirname(outDir), 'zappar-cv.wasm'));
|
|
160
163
|
|
|
161
164
|
for (const entry of listFiles(umdDir)) {
|
|
162
165
|
if (!entry.isFile()) continue;
|
|
163
166
|
if (!entry.name.endsWith('.zbin')) continue;
|
|
164
|
-
copyOrThrow(path.join(umdDir, entry.name), path.join(
|
|
167
|
+
copyOrThrow(path.join(umdDir, entry.name), path.join(modelsDir, entry.name));
|
|
165
168
|
}
|
|
166
169
|
} else {
|
|
167
170
|
// ---- Modern (>= 4.x) path ----
|
|
@@ -211,8 +214,6 @@ function main() {
|
|
|
211
214
|
warn('Could not find zappar-cv.wasm at', wasmSrc);
|
|
212
215
|
} else {
|
|
213
216
|
copyOrThrow(wasmSrc, path.join(outDir, 'zappar-cv.wasm'));
|
|
214
|
-
// Also copy wasm to static root so the bundled worker can find it at /zappar-cv.wasm.
|
|
215
|
-
copyOrThrow(wasmSrc, path.join(path.dirname(outDir), 'zappar-cv.wasm'));
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
|
|
@@ -225,7 +226,7 @@ function main() {
|
|
|
225
226
|
|
|
226
227
|
for (const filename of requiredFaceModelFiles) {
|
|
227
228
|
const src = path.join(zapparCvLibDir, filename);
|
|
228
|
-
const dest = path.join(
|
|
229
|
+
const dest = path.join(modelsDir, filename);
|
|
229
230
|
if (!fs.existsSync(src)) {
|
|
230
231
|
warn('Could not locate required Zappar face model:', filename);
|
|
231
232
|
warn('Looked under:', zapparCvLibDir);
|