@soonspacejs/plugin-sbmz-loader
Version:
Sbmz-loader plugin for SoonSpace.js
41 lines (40 loc) • 806 B
JavaScript
class m {
ssp;
modelData = [];
modelList = [];
constructor(s) {
this.ssp = s;
}
async load(s) {
const { fetchFile: i } = this.ssp.utils, r = await i(`${s}/metadata.json`, "json");
this.modelData = r.items;
const d = `${s}_group`;
this.ssp.createGroup({
id: d
});
const l = await this.ssp.addModelForGroup(d, this.modelData.map(({ name: c, position: t, rotation: a, scale: o, path: e }, p) => ({
id: `${p}${e}`,
name: c,
url: `${s}/${e}`,
position: {
x: t[0],
y: t[1],
z: t[2]
},
rotation: {
x: a[0],
y: a[1],
z: a[2]
},
scale: {
x: o[0],
y: o[1],
z: o[2]
}
})));
this.modelList = l?.children;
}
}
export {
m as default
};