feat(web): studio worlds, camera-view/offscreen environment parity, material and undo coverage
Environment lighting: - ship all eight desktop studiolights/world datasets (WBENV1 float32) and a shared loader used by both the main viewport and the offscreen worker - add the N-panel "studio 环境" selector - rotate the world background together with the environment (backgroundRotation/backgroundIntensity), so camera view and offscreen renders match the desktop Mapping-node behaviour Verification (Chromium, OPFS, NOT_CLAIMED): - environment lighting + 8 world pixel identity - camera-view rotation correspondence (camera matrices, 207 samples) - offscreen vs on-screen background parity after hiding geometry (1305 samples) - metals case extended with material-field OPFS roundtrip - material Principled edits and rename undo/redo - eight studio worlds: pairwise frame differences + luminance rank correlation - undo history depth capped at 64 steps and undo across OPFS save/reopen Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -109,14 +109,11 @@ test('B3 native quit cancel durable recovery Undo Save-Reopen', async ({ page },
|
||||
expect(firstOPFSCommit.head.current.path.startsWith('/browser/')).toBe(true); expect(firstOPFSCommit.head.current.path.endsWith('/quit.blend')).toBe(true);
|
||||
expect(firstOPFSCommit.actualBytes).toBe(firstOPFSCommit.head.current.bytes); expect(firstOPFSCommit.actualBytes).toBeGreaterThan(0); expect(firstOPFSCommit.actualSha256).toBe(firstOPFSCommit.head.current.sha256);
|
||||
record('opfsFirstCommit', firstOPFSCommit);
|
||||
await page.evaluate((filePath: string) => new Promise<void>((resolve, reject) => {
|
||||
const request = indexedDB.open('/browser'); request.onerror = () => reject(request.error); request.onupgradeneeded = () => { request.transaction?.abort(); reject(new Error('Expected existing legacy native-file database')); };
|
||||
request.onsuccess = () => {
|
||||
const db = request.result; let transaction: IDBTransaction; try { transaction = db.transaction('FILE_DATA', 'readwrite'); } catch (error) { db.close(); reject(error); return; } const store = transaction.objectStore('FILE_DATA'), existing = store.get(filePath);
|
||||
existing.onsuccess = () => { if (existing.result === undefined) { transaction.abort(); return; } store.delete(filePath); };
|
||||
transaction.oncomplete = () => { db.close(); resolve(); }; transaction.onerror = transaction.onabort = () => { db.close(); reject(transaction.error ?? new Error('Owned legacy quit deletion did not commit')); };
|
||||
};
|
||||
}), firstOPFSCommit.head.current.path); record('opfsRestorePrerequisite', { deletedOnlyLegacyQuit: firstOPFSCommit.head.current.path, retainedOPFS: firstOPFSCommit.head.current.sha256 });
|
||||
// `/browser` is a MEMFS tree persisted to OPFS, so no IndexedDB copy of the
|
||||
// quit file can exist: any restore after the Worker restart comes from OPFS.
|
||||
const legacyNativeFiles = await page.evaluate(async () => (await indexedDB.databases()).map((entry) => entry.name));
|
||||
expect(legacyNativeFiles).not.toContain('/browser');
|
||||
record('opfsRestorePrerequisite', { legacyIndexedDB: legacyNativeFiles, retainedOPFS: firstOPFSCommit.head.current.sha256 });
|
||||
await page.getByRole('button', { name: '重新打开 Blender', exact: true }).click();
|
||||
await expect(page.locator('canvas[aria-label="Blender desktop"]')).toHaveAttribute('data-native-input-ready', 'true', { timeout: 60000 }); await exposeWebTools(page); await switchNativeWorkspace(page, 'Scripting');
|
||||
const persisted = await queryNativeJSON(page, "import bpy,json,pathlib,hashlib\np=pathlib.Path(bpy.app.tempdir).parent/'quit.blend'\nprint(json.dumps({'path':str(p),'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()}))");
|
||||
@@ -219,14 +216,15 @@ test('B3 native quit cancel durable recovery Undo Save-Reopen', async ({ page },
|
||||
const engineWorker = page.workers().find(worker => worker.url().includes('web-engine.worker')); if (!engineWorker) throw new Error('Native Worker missing before quit failure case');
|
||||
const beforeFailedQuit = await readState(), failedQuitHistory = await readNativeHistory(page), requestStart = await page.evaluate(() => (window as any).__nativeWorkflowRequests.length);
|
||||
const clean = await queryNativeJSON(page, "import bpy,json\nprint(json.dumps({'dirty':bpy.data.is_dirty}))"); expect((clean.value as { dirty: boolean }).dirty).toBe(false);
|
||||
await engineWorker.evaluate(() => { const original = IDBObjectStore.prototype.put; (globalThis as any).__quitOriginalIDBPut = original; IDBObjectStore.prototype.put = function (this: IDBObjectStore, ...args: Parameters<typeof original>) { if (this.transaction.db.name === '/browser' && typeof args[1] === 'string' && args[1].endsWith('/quit.blend')) throw new DOMException('B3 quit persistence failure', 'QuotaExceededError'); return Reflect.apply(original, this, args); }; });
|
||||
// `/browser` writes land in OPFS, so the quota fault belongs on the writable.
|
||||
await engineWorker.evaluate(() => { const original = FileSystemFileHandle.prototype.createWritable; (globalThis as any).__quitOriginalBrowserWritable = original; FileSystemFileHandle.prototype.createWritable = function (this: FileSystemFileHandle, ...args: Parameters<typeof original>) { if (this.name === 'quit.blend') return Promise.reject(new DOMException('B3 quit persistence failure', 'QuotaExceededError')); return Reflect.apply(original, this, args); }; });
|
||||
try {
|
||||
await chooseNative('Quit Native WASM Session');
|
||||
const readQuitFailure = () => page.evaluate(start => { const w = window as any; const ids = new Set(w.__nativeWorkflowRequests.slice(start).filter((request: any) => request.type === 'shutdown').map((request: any) => request.requestId)); return w.__nativeWorkflowResponses.findLast((response: any) => ids.has(response.requestId)) ?? null; }, requestStart);
|
||||
await expect.poll(readQuitFailure, { timeout: 60000 }).toMatchObject({ ok: false, errorMessage: expect.stringContaining('NATIVE_FILES_PERSISTENCE_PENDING') });
|
||||
await expect(page.locator('[data-native-session-exit]')).toHaveAttribute('data-native-session-exit', 'idle'); expect(page.workers()).toContain(engineWorker);
|
||||
record('failedQuitPersistence', { response: await readQuitFailure(), currentWorkerRetained: true, expectedMain: beforeFailedQuit, expectedHistory: failedQuitHistory });
|
||||
} finally { await engineWorker.evaluate(() => { IDBObjectStore.prototype.put = (globalThis as any).__quitOriginalIDBPut; delete (globalThis as any).__quitOriginalIDBPut; }); }
|
||||
} finally { await engineWorker.evaluate(() => { FileSystemFileHandle.prototype.createWritable = (globalThis as any).__quitOriginalBrowserWritable; delete (globalThis as any).__quitOriginalBrowserWritable; }); }
|
||||
const stateAfterFailedQuit = await readState(), historyAfterFailedQuit = await readNativeHistory(page); expect(stateAfterFailedQuit).toEqual(beforeFailedQuit);
|
||||
expect(historyAfterFailedQuit.cursor).toBe(failedQuitHistory.cursor); expect(historyAfterFailedQuit.entries).toEqual(failedQuitHistory.entries);
|
||||
record('failedQuitRetainedState', { stateAfterFailedQuit, historyBefore: failedQuitHistory, historyAfter: historyAfterFailedQuit });
|
||||
|
||||
Reference in New Issue
Block a user