Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize basis using WasmModule #5489

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 10 additions & 16 deletions src/framework/handlers/basis.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WasmModule } from "../../core/wasm-module.js";
import { Debug } from '../../core/debug.js';
import { PIXELFORMAT_RGB565, PIXELFORMAT_RGBA4 } from '../../platform/graphics/constants.js';
import { BasisWorker } from './basis-worker.js';
Expand Down Expand Up @@ -275,23 +276,16 @@ function basisInitialize(config) {
return;
}

// if any URLs are not specified in the config, take them from the global PC config structure
// if any URLs are not specified in the config, take them from WasmModule config
if (!config.glueUrl || !config.wasmUrl || !config.fallbackUrl) {
const modules = (window.config ? window.config.wasmModules : window.PRELOAD_MODULES) || [];
const wasmModule = modules.find(function (m) {
return m.moduleName === 'BASIS';
});
if (wasmModule) {
const urlBase = window.ASSET_PREFIX || '';
if (!config.glueUrl) {
config.glueUrl = urlBase + wasmModule.glueUrl;
}
if (!config.wasmUrl) {
config.wasmUrl = urlBase + wasmModule.wasmUrl;
}
if (!config.fallbackUrl) {
config.fallbackUrl = urlBase + wasmModule.fallbackUrl;
}
const moduleConfig = WasmModule.getConfig('BASIS');
if (moduleConfig) {
config = {
glueUrl: moduleConfig.glueUrl,
wasmUrl: moduleConfig.wasmUrl,
fallbackUrl: moduleConfig.fallbackUrl,
numWorkers: moduleConfig.numWorkers
};
}
}

Expand Down