Files
workinf_Blender_Wasm/web/app/src/platform/capabilities.ts
mes123456 63db6caf1f
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
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>
2026-11-23 09:27:47 +08:00

58 lines
2.0 KiB
TypeScript

import {
type WasmThreadingCapabilities,
} from "../../../protocol/engine-variant";
export { gateWasmThreadingCapability, selectWebEngineVariant } from "../../../protocol/engine-variant";
export type { WasmThreadingCapabilities } from "../../../protocol/engine-variant";
export interface BrowserCapabilities extends WasmThreadingCapabilities {
webgl2: boolean;
offscreenCanvas: boolean;
opfs: boolean;
wasm: boolean;
wasmSimd: boolean;
wasmThreads: boolean;
storageEstimate: boolean;
}
function supportsWasmFeature(feature: "simd" | "threads"): boolean {
if (typeof WebAssembly === "undefined") return false;
const modules: Record<typeof feature, Uint8Array> = {
simd: new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x0a, 0x0b, 0x01, 0x09, 0x00, 0xfd,
0x00, 0x00, 0x0b,
]),
threads: new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
0x00, 0x00, 0x05, 0x04, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x04, 0x01, 0x02,
0x00, 0x0b,
]),
};
try {
return WebAssembly.validate(modules[feature] as BufferSource);
} catch {
return false;
}
}
export function detectBrowserCapabilities(): BrowserCapabilities {
const canvas = typeof document === "undefined" ? undefined : document.createElement("canvas");
const webgl2 = Boolean(canvas?.getContext("webgl2"));
const storage = typeof navigator === "undefined" ? undefined : navigator.storage;
return {
crossOriginIsolated: globalThis.crossOriginIsolated === true,
webgl2,
offscreenCanvas: typeof OffscreenCanvas !== "undefined",
opfs: Boolean(storage?.getDirectory),
sharedArrayBuffer: typeof SharedArrayBuffer !== "undefined",
worker: typeof Worker !== "undefined",
wasm: typeof WebAssembly !== "undefined",
wasmSimd: supportsWasmFeature("simd"),
wasmThreads: supportsWasmFeature("threads"),
storageEstimate: Boolean(storage?.estimate),
};
}