Compare commits
4 Commits
2c62987281
...
5368e52f0d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5368e52f0d | ||
|
|
83684b4c7b | ||
|
|
6720a3e730 | ||
|
|
e78afc73f3 |
@ -159,7 +159,7 @@ export default defineConfig(async ({mode, command}) => {
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
{ src: 'node_modules/@astral3d/engine/dist/libs/*', dest: 'assets/libs' },
|
||||
{ src: 'node_modules/@astral3d/engine/dist/resource/**/*', dest: 'resource' }
|
||||
{ src: 'node_modules/@astral3d/engine/dist/resource/**/*', dest: 'assets/resource' }
|
||||
],
|
||||
}),
|
||||
...plugins
|
||||
|
||||
@ -964,6 +964,11 @@ export class Package {
|
||||
unpackConfig.onProgress && unpackConfig.onProgress(0);
|
||||
let totalZipNumber = 0, progress = 0;
|
||||
|
||||
// 每次解包前确保 loader 可用
|
||||
if (!this.loader) {
|
||||
this.loader = new ObjectLoader();
|
||||
}
|
||||
|
||||
await this.initOfflineSource(unpackConfig);
|
||||
|
||||
if (!this.offlineZipMap && !this.offlineFlatPackages) {
|
||||
@ -998,8 +1003,7 @@ export class Package {
|
||||
that.offlineFlatPackages = null;
|
||||
that.offlineFlatEntryBase = null;
|
||||
that.dataComponentMap = null;
|
||||
// @ts-ignore 清除loader
|
||||
that.loader = undefined;
|
||||
// 不清除 loader,避免连续导入时被上一轮异步收尾误清理
|
||||
}
|
||||
|
||||
const complete = () => {
|
||||
@ -1337,6 +1341,9 @@ export class Package {
|
||||
//const db = window.VIEWPORT.modules["db"];
|
||||
//const dbTable = `${useProjectState.getState().sceneId}-${useProjectState.getState().info.id}`;
|
||||
|
||||
// 在调用时捕获 loader 引用,防止 done() 清除 this.loader 后重试路径报错
|
||||
const loader = this.loader;
|
||||
|
||||
// map 存储 json 解析完成后执行的 function; key 为 uuid
|
||||
const funcMap = new Map<string, Function>();
|
||||
|
||||
@ -1433,7 +1440,13 @@ export class Package {
|
||||
|
||||
const parse = (json) => {
|
||||
if (check(json.object, json)) {
|
||||
this.loader.parse(json, (group) => {
|
||||
if (!loader) {
|
||||
// 防止早退导致 callFunNum 无法归零,进度卡住
|
||||
this.callFunNum.value--;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loader.parse(json, (group) => {
|
||||
const bones: Bone[] = [];
|
||||
group.getObjectsByProperty("type", "Bone", bones);
|
||||
if (bones.length > 0) {
|
||||
@ -1465,7 +1478,10 @@ export class Package {
|
||||
funcMap.forEach((func, uuid) => {
|
||||
func.call(this, uuid, group, rootGroupUuid);
|
||||
})
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
const timer = setTimeout(() => {
|
||||
clearTimeout(timer);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user