Compare commits

..

No commits in common. "5368e52f0d9e5e1c659337d9f31a9e71cc347037" and "2c62987281991fe7e559a214e247476875f5909f" have entirely different histories.

2 changed files with 5 additions and 21 deletions

View File

@ -159,7 +159,7 @@ export default defineConfig(async ({mode, command}) => {
viteStaticCopy({ viteStaticCopy({
targets: [ targets: [
{ src: 'node_modules/@astral3d/engine/dist/libs/*', dest: 'assets/libs' }, { src: 'node_modules/@astral3d/engine/dist/libs/*', dest: 'assets/libs' },
{ src: 'node_modules/@astral3d/engine/dist/resource/**/*', dest: 'assets/resource' } { src: 'node_modules/@astral3d/engine/dist/resource/**/*', dest: 'resource' }
], ],
}), }),
...plugins ...plugins

View File

@ -964,11 +964,6 @@ export class Package {
unpackConfig.onProgress && unpackConfig.onProgress(0); unpackConfig.onProgress && unpackConfig.onProgress(0);
let totalZipNumber = 0, progress = 0; let totalZipNumber = 0, progress = 0;
// 每次解包前确保 loader 可用
if (!this.loader) {
this.loader = new ObjectLoader();
}
await this.initOfflineSource(unpackConfig); await this.initOfflineSource(unpackConfig);
if (!this.offlineZipMap && !this.offlineFlatPackages) { if (!this.offlineZipMap && !this.offlineFlatPackages) {
@ -1003,7 +998,8 @@ export class Package {
that.offlineFlatPackages = null; that.offlineFlatPackages = null;
that.offlineFlatEntryBase = null; that.offlineFlatEntryBase = null;
that.dataComponentMap = null; that.dataComponentMap = null;
// 不清除 loader避免连续导入时被上一轮异步收尾误清理 // @ts-ignore 清除loader
that.loader = undefined;
} }
const complete = () => { const complete = () => {
@ -1341,9 +1337,6 @@ export class Package {
//const db = window.VIEWPORT.modules["db"]; //const db = window.VIEWPORT.modules["db"];
//const dbTable = `${useProjectState.getState().sceneId}-${useProjectState.getState().info.id}`; //const dbTable = `${useProjectState.getState().sceneId}-${useProjectState.getState().info.id}`;
// 在调用时捕获 loader 引用,防止 done() 清除 this.loader 后重试路径报错
const loader = this.loader;
// map 存储 json 解析完成后执行的 function; key 为 uuid // map 存储 json 解析完成后执行的 function; key 为 uuid
const funcMap = new Map<string, Function>(); const funcMap = new Map<string, Function>();
@ -1440,13 +1433,7 @@ export class Package {
const parse = (json) => { const parse = (json) => {
if (check(json.object, json)) { if (check(json.object, json)) {
if (!loader) { this.loader.parse(json, (group) => {
// 防止早退导致 callFunNum 无法归零,进度卡住
this.callFunNum.value--;
return;
}
try {
loader.parse(json, (group) => {
const bones: Bone[] = []; const bones: Bone[] = [];
group.getObjectsByProperty("type", "Bone", bones); group.getObjectsByProperty("type", "Bone", bones);
if (bones.length > 0) { if (bones.length > 0) {
@ -1479,9 +1466,6 @@ export class Package {
func.call(this, uuid, group, rootGroupUuid); func.call(this, uuid, group, rootGroupUuid);
}) })
}) })
} catch (err) {
throw err;
}
} else { } else {
const timer = setTimeout(() => { const timer = setTimeout(() => {
clearTimeout(timer); clearTimeout(timer);