feat(character): add option to use the ZAM CDN for the model viewer assets (#22)

This commit is contained in:
Axel Cocat 2022-05-14 22:19:21 +02:00 committed by GitHub
parent a98f9b4658
commit 905f1549fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 2 deletions

View file

@ -154,6 +154,12 @@
viewer?.destroy();
viewer = new ZamModelViewer(characterModel);
const isLoadedInterval = setInterval(() => {
if (viewer.method("isLoaded")) {
clearInterval(isLoadedInterval);
setBackground("background.png");
}
}, 100);
}
function setSlotVisible(slot, visible) {
@ -290,6 +296,18 @@
createViewer();
}
function setBackground(file) {
if (!viewer) {
return;
}
const originalContentPath = viewer.options.contentPath;
viewer.options.contentPath = "{{websiteRoot}}/data/";
viewer.options.background = file;
viewer.renderer.loadBackground();
viewer.options.contentPath = originalContentPath;
}
if (charData.mounts.length === 0) {
$("#mounts-container").hide();
} else {
@ -352,8 +370,7 @@
const characterModel = {
type: ZamModelViewer.WOW,
contentPath: "{{websiteRoot}}/data/",
background: "background.png",
contentPath: "{{ contentPath }}",
container: $model,
hd: true,
aspect: $model.outerWidth() / $model.outerHeight(),