feat(web): studio worlds, camera-view/offscreen environment parity, material and undo coverage
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

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:
mes123456
2026-11-23 09:27:47 +08:00
parent f96654b158
commit 63db6caf1f
325 changed files with 20004 additions and 762 deletions

View File

@@ -4,8 +4,8 @@ import { pythonReply } from './wasm-console-workflow';
import { finiteLocation } from './console-main-workflow';
import { performNativeAction } from './native-ui-workflow';
import type { WebEngineHistory, WebEngineRequest } from '../../protocol/web-engine';
export async function nativeRequest(page: Page, command: WebEngineRequest['command']) {
const response = await page.evaluate(command => new Promise<any>((resolve, reject) => {
export async function nativeRequest(page: Page, command: WebEngineRequest['command'], timeoutMs = 60000) {
const response = await page.evaluate(({ command, timeoutMs }) => new Promise<any>((resolve, reject) => {
const worker = (window as any).__nativeWorkflowEngine as Worker, requestId = `web-engine-oracle-${crypto.randomUUID()}`;
if (!worker) throw new Error('Native Worker is unavailable');
const listener = ({ data }: MessageEvent) => {
@@ -15,12 +15,12 @@ export async function nativeRequest(page: Page, command: WebEngineRequest['comma
if (file !== undefined && (!(file instanceof ArrayBuffer) || file.byteLength > 64 * 1024 * 1024)) { reject(new Error('Native file readback must be an ArrayBuffer within 64 MiB')); return; }
resolve({ ...data, blendBytes: blend === undefined ? undefined : Array.from(new Uint8Array(blend)), fileBytes: file === undefined ? undefined : Array.from(new Uint8Array(file)) });
};
const timer = setTimeout(() => { worker.removeEventListener('message', listener); reject(new Error('Native readback timed out')); }, 60000); worker.addEventListener('message', listener); worker.postMessage({ requestId, command });
}), command);
const timer = setTimeout(() => { worker.removeEventListener('message', listener); reject(new Error('Native readback timed out')); }, timeoutMs); worker.addEventListener('message', listener); worker.postMessage({ requestId, command });
}), { command, timeoutMs });
expect(response.ok, response.error?.message).toBe(true); return response;
}
export async function queryNativeJSON(page: Page, source: string) {
const response = await nativeRequest(page, { type: 'jsonCommand', cmd: 'pythonExec', params: { source: `exec(${JSON.stringify(source)}, {'__name__': '__wbv2_readback__'})`, filename: 'B2MainReadback.py', console: false } });
export async function queryNativeJSON(page: Page, source: string, timeoutMs = 60000) {
const response = await nativeRequest(page, { type: 'jsonCommand', cmd: 'pythonExec', params: { source: `exec(${JSON.stringify(source)}, {'__name__': '__wbv2_readback__'})`, filename: 'B2MainReadback.py', console: false } }, timeoutMs);
const reply = await pythonReply(page); expect(reply).not.toBeNull(); expect(reply!.requestId).toBe(response.requestId);
expect(reply!.state, reply!.output).toBe('DONE'); expect(reply!.changed).toBe(false); return { revision: reply!.revision, value: JSON.parse(reply!.output) };
}
@@ -100,7 +100,12 @@ export async function focusNativeViewport(page: Page) {
const area = await page.evaluate(() => (window as any).__nativeWorkflowAreas?.find((area: any) => area.editor === 'VIEW_3D' && area.regions.some((region: any) => region.kind === 'MAIN' && region.visible))); expect(area).toBeDefined();
const { x, y, width, height } = area.rect; for (const value of [x, y, width, height]) { expect(typeof value).toBe('number'); expect(Number.isFinite(value)).toBe(true); } expect(width).toBeGreaterThan(0); expect(height).toBeGreaterThan(0);
const bounds = await canvas.boundingBox(); expect(bounds).not.toBeNull(); const point = { x: bounds!.x + (x + width / 2) * bounds!.width, y: bounds!.y + (1 - y - height / 2) * bounds!.height };
await expect(canvas).toHaveAttribute('data-native-input-ready', 'true', { timeout: 15000 });
/* The idle frame pump stops publishing readiness, and republishing requires two consecutive
* acknowledged frames, so keep feeding pointer input until it flips back to ready. */
await expect.poll(async () => {
await page.mouse.move(point.x + Math.random(), point.y);
return canvas.getAttribute('data-native-input-ready');
}, { timeout: 15000 }).toBe('true');
await page.mouse.move(point.x, point.y); await canvas.focus();
await waitNativeModal(page, false); await expect(canvas).toBeFocused(); return { canvas, point };
}