From 548682e43929f3845400c7c5f2484bb0c24ae0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8B=87=E6=95=A2=E7=9A=84=E8=8F=A0=E8=90=9D=F0=9F=8D=8D?= <3653161641@qq.com> Date: Sun, 22 Nov 2026 15:04:44 +0800 Subject: [PATCH] feat(sb3): runtime.lazyAssetInstall flag to open projects before non-current assets load When gui sets runtime.lazyAssetInstall = true, the project load path passes installWithCurrentCostume to parseScratchObject, so a project opens as soon as its current costume is ready; remaining costumes/sounds keep loading in the background and announce themselves via requestTargetsUpdate(). Co-authored-by: PYC5635 <3653161641@qq.com> --- src/serialization/sb3.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index b65e6ccc26..bf2456ec31 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -2153,7 +2153,12 @@ const deserialize = async function (json, runtime, zip, isSingleSprite) { }) .then(assets => Promise.all(targetObjects .map((target, index) => - parseScratchObject(target, runtime, extensions, zip, assets[index], isSingleSprite)))) + // 极致懒加载(lazy asset install): +// gui 侧设置 runtime.lazyAssetInstall = true 时,项目打开只等当前造型就绪, +// 其余造型/声音沿用 installWithCurrentCostume 路径后台装载, +// 到达后经 requestTargetsUpdate 通知 GUI 刷新。 + parseScratchObject(target, runtime, extensions, zip, assets[index], + isSingleSprite || runtime.lazyAssetInstall === true)))) .then(targets => targets // Re-sort targets back into original sprite-pane ordering .map((t, i) => { // Add layer order property to deserialized targets.