@oeave/bakery3 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +562 -2
- package/dist/animation-B1h0Ryvj.d.ts +97 -0
- package/dist/bake/index.d.ts +369 -0
- package/dist/bake/index.js +9 -0
- package/dist/bake/index.js.map +1 -0
- package/dist/bake-DaOlenyx.d.ts +1357 -0
- package/dist/catalog/index.d.ts +100 -0
- package/dist/catalog/index.js +154 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/catalog.gen-BM-aNf7n.d.ts +733 -0
- package/dist/chunk-25ZXSVQ3.js +1107 -0
- package/dist/chunk-25ZXSVQ3.js.map +1 -0
- package/dist/chunk-3G5QL4F4.js +145 -0
- package/dist/chunk-3G5QL4F4.js.map +1 -0
- package/dist/chunk-4E5VV4QY.js +12 -0
- package/dist/chunk-4E5VV4QY.js.map +1 -0
- package/dist/chunk-54WJDN5R.js +3286 -0
- package/dist/chunk-54WJDN5R.js.map +1 -0
- package/dist/chunk-6NYR73Y7.js +832 -0
- package/dist/chunk-6NYR73Y7.js.map +1 -0
- package/dist/chunk-6YVQANMW.js +1463 -0
- package/dist/chunk-6YVQANMW.js.map +1 -0
- package/dist/chunk-AF5BIELI.js +70 -0
- package/dist/chunk-AF5BIELI.js.map +1 -0
- package/dist/chunk-APBOWWSV.js +92 -0
- package/dist/chunk-APBOWWSV.js.map +1 -0
- package/dist/chunk-ARMTTZXZ.js +1157 -0
- package/dist/chunk-ARMTTZXZ.js.map +1 -0
- package/dist/chunk-CX4WTVGH.js +4492 -0
- package/dist/chunk-CX4WTVGH.js.map +1 -0
- package/dist/chunk-HQTUFVMM.js +1412 -0
- package/dist/chunk-HQTUFVMM.js.map +1 -0
- package/dist/chunk-MD2U6S4N.js +1952 -0
- package/dist/chunk-MD2U6S4N.js.map +1 -0
- package/dist/chunk-S4AJTLLN.js +23 -0
- package/dist/chunk-S4AJTLLN.js.map +1 -0
- package/dist/chunk-TGFNQBKC.js +551 -0
- package/dist/chunk-TGFNQBKC.js.map +1 -0
- package/dist/chunk-V3QINEEG.js +87 -0
- package/dist/chunk-V3QINEEG.js.map +1 -0
- package/dist/chunk-W6WQ5UP7.js +91 -0
- package/dist/chunk-W6WQ5UP7.js.map +1 -0
- package/dist/chunk-WBIAFIHV.js +346 -0
- package/dist/chunk-WBIAFIHV.js.map +1 -0
- package/dist/chunk-ZEBVAIJJ.js +156 -0
- package/dist/chunk-ZEBVAIJJ.js.map +1 -0
- package/dist/devtools/index.d.ts +536 -0
- package/dist/devtools/index.js +15 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/environments/index.d.ts +93 -0
- package/dist/environments/index.js +382 -0
- package/dist/environments/index.js.map +1 -0
- package/dist/hotspots/index.d.ts +111 -0
- package/dist/hotspots/index.js +285 -0
- package/dist/hotspots/index.js.map +1 -0
- package/dist/index.d.ts +944 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/node/index.cjs +5115 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +4862 -0
- package/dist/node/index.d.ts +576 -0
- package/dist/node/index.js +1279 -0
- package/dist/node/index.js.map +1 -0
- package/dist/prepare-C5qVvaw4.d.ts +112 -0
- package/dist/presets/index.d.ts +526 -0
- package/dist/presets/index.js +14 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/r3f/index.d.ts +159 -0
- package/dist/r3f/index.js +592 -0
- package/dist/r3f/index.js.map +1 -0
- package/dist/room-S5TLCK4F.js +9 -0
- package/dist/room-S5TLCK4F.js.map +1 -0
- package/dist/rooms.gen-vhj6sFW5.d.ts +1434 -0
- package/dist/session-YCQS4MRH.js +9 -0
- package/dist/session-YCQS4MRH.js.map +1 -0
- package/dist/shapes/index.d.ts +222 -0
- package/dist/shapes/index.js +836 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/testRun-BIPXaVPb.d.ts +1130 -0
- package/dist/timeline-ChwgD7bT.d.ts +470 -0
- package/dist/tsl/index.d.ts +165 -0
- package/dist/tsl/index.js +310 -0
- package/dist/tsl/index.js.map +1 -0
- package/package.json +170 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/presets/hdr.ts","../src/presets/library.ts","../src/presets/room.ts"],"names":["DataTexture","RGBAFormat","LinearSRGBColorSpace","surface","Color","sharedLoader","GLTFLoader","SRGBColorSpace","Group","Vector3","DoubleSide","MeshStandardMaterial","MathUtils","MeshPhysicalMaterial","Matrix4"],"mappings":";;;;;;;;;;;;AAkCA,IAAM,QAAA,GAAW,KAAA;AAGV,SAAS,kBAAkB,MAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,MAAM,CAAA;AACnC,EAAA,IAAI,GAAA,GAAM,CAAA;AACV,EAAA,MAAM,OAAO,MAAqB;AAChC,IAAA,MAAM,GAAA,GAAM,KAAA,CAAM,OAAA,CAAQ,EAAA,EAAM,GAAG,CAAA;AACnC,IAAA,IAAI,GAAA,GAAM,GAAG,OAAO,IAAA;AACpB,IAAA,IAAI,IAAA,GAAO,EAAA;AACX,IAAA,KAAA,IAAS,CAAA,GAAI,GAAA,EAAK,CAAA,GAAI,GAAA,EAAK,CAAA,EAAA,UAAa,MAAA,CAAO,YAAA,CAAa,KAAA,CAAM,CAAC,CAAE,CAAA;AACrE,IAAA,GAAA,GAAM,GAAA,GAAM,CAAA;AACZ,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AACA,EAAA,MAAM,SAAS,CAAC,GAAA,KACd,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,GAAG,CAAA,EAAA,CAAI,CAAA;AAExE,EAAA,MAAM,QAAQ,IAAA,EAAK;AACnB,EAAA,IAAI,CAAC,SAAS,CAAC,SAAA,CAAU,KAAK,KAAK,CAAA,EAAG,MAAM,MAAA,CAAO,cAAc,CAAA;AACjE,EAAA,IAAI,MAAA,GAAS,KAAA;AACb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\n * three has one, under two names: `RGBELoader` until r179, `HDRLoader` from\n * r180, with `RGBELoader` left behind as a deprecated subclass that warns\n * and will be removed. No single import of either resolves across the range\n * the SDK supports (r160 onwards), and a bundler resolves every literal\n * `import()` it sees, the one in a `catch` included, so a fallback between\n * the two fails the build of whoever is on the other side of r180. The\n * format is small enough to read here: a text header, then scanlines of\n * RGBE pixels, flat or run-length encoded.\n *\n * The texture it makes is the one three's loader made: half float RGBA,\n * linear, filtered without mipmaps, flipped, with the same mantissa scale\n * (`byte / 255 · 2^(e − 128)`), so a preview reads exactly as it did.\n */\n\nimport {\n DataTexture,\n DataUtils,\n FileLoader,\n HalfFloatType,\n LinearFilter,\n LinearSRGBColorSpace,\n RGBAFormat,\n} from 'three';\n\nexport type RadianceImage = {\n width: number;\n height: number;\n /** Half floats, RGBA, rows top-down. */\n data: Uint16Array;\n};\n\nconst HALF_MAX = 65504;\n\n/** Parse a Radiance file. Throws on anything three's loader would refuse. */\nexport function decodeRadianceHdr(buffer: ArrayBuffer): RadianceImage {\n const bytes = new Uint8Array(buffer);\n let pos = 0;\n const line = (): string | null => {\n const end = bytes.indexOf(0x0a, pos);\n if (end < 0) return null;\n let text = '';\n for (let i = pos; i < end; i++) text += String.fromCharCode(bytes[i]!);\n pos = end + 1;\n return text;\n };\n const refuse = (why: string) =>\n new Error(`@oeave/bakery3/presets: not a readable .hdr file (${why}).`);\n\n const magic = line();\n if (!magic || !/^#\\?\\S+/.test(magic)) throw refuse('no #? header');\n let format = false;\n let width = 0;\n let height = 0;\n for (let text = line(); text !== null; text = line()) {\n if (text.startsWith('#')) continue;\n if (/^\\s*FORMAT=32-bit_rle_rgbe\\s*$/.test(text)) format = true;\n const size = /^\\s*-Y\\s+(\\d+)\\s+\\+X\\s+(\\d+)\\s*$/.exec(text);\n if (size) {\n height = Number(size[1]);\n width = Number(size[2]);\n break;\n }\n }\n if (!format) throw refuse('missing FORMAT=32-bit_rle_rgbe');\n if (!(width > 0 && height > 0)) throw refuse('missing -Y h +X w');\n\n const rgbe = scanlines(bytes.subarray(pos), width, height, refuse);\n const data = new Uint16Array(width * height * 4);\n const one = DataUtils.toHalfFloat(1);\n for (let i = 0; i < width * height; i++) {\n const o = i * 4;\n const e = rgbe[o + 3]!;\n const scale = e ? Math.pow(2, e - 128) / 255 : 0;\n data[o] = DataUtils.toHalfFloat(Math.min(rgbe[o]! * scale, HALF_MAX));\n data[o + 1] = DataUtils.toHalfFloat(\n Math.min(rgbe[o + 1]! * scale, HALF_MAX),\n );\n data[o + 2] = DataUtils.toHalfFloat(\n Math.min(rgbe[o + 2]! * scale, HALF_MAX),\n );\n data[o + 3] = one;\n }\n return { width, height, data };\n}\n\n/** The pixels as interleaved RGBE bytes, from flat or new-style RLE scanlines. */\nfunction scanlines(\n body: Uint8Array,\n width: number,\n height: number,\n refuse: (why: string) => Error,\n): Uint8Array {\n const flat =\n width < 8 ||\n width > 0x7fff ||\n body[0] !== 2 ||\n body[1] !== 2 ||\n (body[2]! & 0x80) !== 0;\n if (flat) {\n if (body.length < width * height * 4) throw refuse('file is cut short');\n return body.subarray(0, width * height * 4);\n }\n const out = new Uint8Array(width * height * 4);\n const planes = new Uint8Array(width * 4);\n let pos = 0;\n for (let row = 0; row < height; row++) {\n if (pos + 4 > body.length) throw refuse('file is cut short');\n if (\n body[pos] !== 2 ||\n body[pos + 1] !== 2 ||\n ((body[pos + 2]! << 8) | body[pos + 3]!) !== width\n )\n throw refuse('bad scanline header');\n pos += 4;\n let ptr = 0;\n while (ptr < planes.length) {\n if (pos >= body.length) throw refuse('file is cut short');\n let count = body[pos++]!;\n const run = count > 128;\n if (run) count -= 128;\n if (count === 0 || ptr + count > planes.length)\n throw refuse('bad scanline data');\n if (run) {\n planes.fill(body[pos++]!, ptr, ptr + count);\n } else {\n planes.set(body.subarray(pos, pos + count), ptr);\n pos += count;\n }\n ptr += count;\n }\n const base = row * width * 4;\n for (let col = 0; col < width; col++) {\n const o = base + col * 4;\n out[o] = planes[col]!;\n out[o + 1] = planes[width + col]!;\n out[o + 2] = planes[2 * width + col]!;\n out[o + 3] = planes[3 * width + col]!;\n }\n }\n return out;\n}\n\n/**\n * Load a `.hdr` as three's own loader did: through `FileLoader`, so the\n * default `LoadingManager` (and any progress UI on it) sees the request.\n */\nexport async function loadRadianceHdr(url: string): Promise<DataTexture> {\n const buffer = (await new FileLoader()\n .setResponseType('arraybuffer')\n .loadAsync(url)) as ArrayBuffer;\n const image = decodeRadianceHdr(buffer);\n const texture = new DataTexture(\n image.data,\n image.width,\n image.height,\n RGBAFormat,\n HalfFloatType,\n );\n texture.colorSpace = LinearSRGBColorSpace;\n texture.minFilter = LinearFilter;\n texture.magFilter = LinearFilter;\n texture.generateMipmaps = false;\n texture.flipY = true;\n texture.needsUpdate = true;\n return texture;\n}\n","/**\n * The implementation behind `@oeave/bakery3/presets`: materials, HDR\n * environments, the parametric room and pedestals. `index.ts` lists what is\n * public.\n */\n\nimport {\n BoxGeometry,\n Color,\n DataTexture,\n FloatType,\n LinearSRGBColorSpace,\n RGBAFormat,\n Vector3,\n Quaternion,\n Matrix4,\n Euler,\n DirectionalLight,\n DoubleSide,\n EquirectangularReflectionMapping,\n Group,\n MathUtils,\n Mesh,\n MeshPhysicalMaterial,\n MeshStandardMaterial,\n Object3D,\n Path,\n PlaneGeometry,\n RepeatWrapping,\n Shape,\n ShapeGeometry,\n SRGBColorSpace,\n TextureLoader,\n BufferGeometry,\n type ColorRepresentation,\n type Texture,\n} from 'three';\nimport { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';\nimport { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';\nimport { rememberEnvironmentSource } from '../capture/environmentSource.js';\nimport { Bakery3Error } from '../errors.js';\nimport {\n HDRI_PRESETS,\n MATERIAL_PRESETS,\n PEDESTAL_PRESETS,\n PRESETS_VERSION,\n type HdriPresetName,\n type MaterialPresetName,\n type PedestalPresetName,\n type PresetMapName,\n type PresetTextureSize,\n} from './catalog.gen.js';\nimport { presetBaseUrl } from './baseUrl.js';\nimport { loadRadianceHdr } from './hdr.js';\n\nexport function presetTextureUrl(\n name: MaterialPresetName,\n map: PresetMapName,\n size: PresetTextureSize = '2k',\n base: string = presetBaseUrl(),\n): string {\n return `${base}/v${PRESETS_VERSION}/materials/${name}/${size}/${MATERIAL_PRESETS[name].files[map]}`;\n}\n\nexport function pedestalUrl(\n name: PedestalPresetName,\n base: string = presetBaseUrl(),\n): string {\n return `${base}/v${PRESETS_VERSION}/objects/${name}.glb`;\n}\n\nexport type PresetEnvironmentAsset = 'preview' | 'render';\n\nexport function presetEnvironmentUrl(\n name: HdriPresetName,\n asset: PresetEnvironmentAsset = 'preview',\n base: string = presetBaseUrl(),\n): string {\n const file = asset === 'preview' ? 'preview.hdr' : 'render.exr';\n return `${base}/v${PRESETS_VERSION}/hdri/${name}/${file}`;\n}\n\nexport type PresetEnvironmentOptions = {\n /** Override the preset CDN, primarily for a local development server. */\n baseUrl?: string;\n};\n\n/**\n * Load the lightweight HDR preview while registering the EXR render master\n * with the core SDK. Assign the returned texture to `scene.environment` (and\n * optionally `scene.background`); render with\n * `background: { type: 'environment' }` when the rendered output should show it.\n * captureScene sends only the master URL, so the browser never downloads or\n * uploads the EXR.\n */\nexport async function loadPresetEnvironment(\n name: HdriPresetName,\n options: PresetEnvironmentOptions = {},\n): Promise<Texture> {\n const base = options.baseUrl ?? presetBaseUrl();\n const texture = await loadPresetHdr(name, base);\n rememberEnvironmentSource(\n texture,\n presetEnvironmentUrl(name, 'render', base),\n { preset: true },\n );\n return texture;\n}\n\n/**\n * The lightweight preview of an HDRI preset as an equirectangular texture,\n * and nothing else: not registered as the scene's environment, so the\n * capture never mistakes it for one. `createPresetRoom` puts it on the dome\n * outside a room's windows; `loadPresetEnvironment` is this plus the\n * registration of the 4k master.\n */\nexport async function loadPresetHdr(\n name: HdriPresetName,\n base: string = presetBaseUrl(),\n): Promise<Texture> {\n if (!HDRI_PRESETS[name]) {\n throw new Error(\n `'${String(name)}' is not an HDRI preset. Known: ${Object.keys(HDRI_PRESETS).join(', ')}.`,\n );\n }\n const texture = await loadRadianceHdr(\n presetEnvironmentUrl(name, 'preview', base),\n );\n texture.mapping = EquirectangularReflectionMapping;\n texture.userData.bakery3Preset = {\n kind: 'hdri',\n name,\n version: PRESETS_VERSION,\n previewResolution: HDRI_PRESETS[name].preview.resolution,\n renderResolution: HDRI_PRESETS[name].render.resolution,\n };\n return texture;\n}\n\n// ---------------------------------------------------------------------------\n// Sky\n// ---------------------------------------------------------------------------\n\nexport type SkyEnvironmentOptions = {\n /** Straight overhead. Default a deep clear-day blue. */\n zenith?: ColorRepresentation;\n /**\n * At the horizon, where most of the light that comes through a window\n * comes from. Default a saturated sky blue: a paler, more physical horizon\n * vanishes against a room's sun.\n */\n horizon?: ColorRepresentation;\n /** Below the horizon: the ground's bounce. Default a warm gray. */\n ground?: ColorRepresentation;\n /**\n * Multiplies the whole dome. 1 is a clear sky at exposure 0 seen through\n * the window; a room that is also lit by a sun of 3 to 4 wants 4 to 6\n * here before its shade turns cool, because the physical ratio between\n * sun and sky is far larger than a single exposure can hold.\n */\n intensity?: number;\n /** Equirect width in pixels; height is half. A gradient needs no more than the default 128. */\n width?: number;\n};\n\n/**\n * A sky to put outside the windows.\n *\n * A room with windows lit by a studio probe is lit by a studio through its\n * windows, and it shows: the light that comes in is neutral, and the cool\n * cast a real window throws (the blue of the sky against the warmth of the\n * sun) is missing. This is a generated equirectangular gradient (blue\n * overhead, paling to the horizon, a warm ground below) as an ordinary\n * `DataTexture`, so `scene.environment = createSkyEnvironment()` lights the\n * preview through PMREM like any HDRI, and the SDK ships the same pixels to\n * the render as a small Radiance file: no download, no CDN.\n *\n * It is a sky, not a sun: pair it with `createRoom({ sun })`, which carries\n * the crisp shadows. A room with a closed ceiling only ever sees this\n * through its openings, which is the point.\n */\nexport function createSkyEnvironment(\n options: SkyEnvironmentOptions = {},\n): DataTexture {\n const zenith = new Color(options.zenith ?? 0x2f6fd0);\n const horizon = new Color(options.horizon ?? 0x9cc4f5);\n const ground = new Color(options.ground ?? 0x8f8679);\n const intensity = options.intensity ?? 1;\n const width = Math.max(8, Math.round(options.width ?? 128));\n const height = width / 2;\n\n // Rows top-down like a Radiance file (zenith first); `flipY` puts the\n // zenith at v = 1 for the GPU, which is where equirect sampling looks for it.\n const data = new Float32Array(width * height * 4);\n const color = new Color();\n for (let row = 0; row < height; row++) {\n const elevation = (0.5 - (row + 0.5) / height) * Math.PI;\n if (elevation >= 0) {\n // Blue overhead, paling quickly toward the horizon: the shape of a\n // clear sky's brightness, not a physical sky model.\n color.copy(zenith).lerp(horizon, Math.pow(1 - Math.sin(elevation), 2.2));\n } else {\n // A soft band at the horizon, then ground.\n color\n .copy(horizon)\n .lerp(ground, Math.min(1, -elevation / MathUtils.degToRad(3)));\n }\n for (let col = 0; col < width; col++) {\n const i = (row * width + col) * 4;\n data[i] = color.r * intensity;\n data[i + 1] = color.g * intensity;\n data[i + 2] = color.b * intensity;\n data[i + 3] = 1;\n }\n }\n\n const texture = new DataTexture(data, width, height, RGBAFormat, FloatType);\n texture.mapping = EquirectangularReflectionMapping;\n texture.colorSpace = LinearSRGBColorSpace;\n texture.flipY = true;\n texture.needsUpdate = true;\n texture.userData.bakery3Preset = { kind: 'sky', ...options };\n rememberEnvironmentSource(texture, encodeRadianceHdr(data, width, height));\n return texture;\n}\n\n/**\n * Linear float RGBA, rows top-down, as a Radiance `.hdr`: the format the\n * SDK ships environments in, so a generated sky travels the same road as a\n * loaded one. New-style RLE scanlines written as literal runs: every reader\n * handles them, and a gradient is too small to be worth compressing.\n */\nexport function encodeRadianceHdr(\n data: Float32Array,\n width: number,\n height: number,\n): ArrayBuffer {\n if (width < 8 || width > 0x7fff) {\n throw new Error(\n `@oeave/bakery3/presets: a Radiance scanline is 8 to 32767 pixels wide, not ${width}.`,\n );\n }\n const header = new TextEncoder().encode(\n `#?RADIANCE\\nFORMAT=32-bit_rle_rgbe\\n\\n-Y ${height} +X ${width}\\n`,\n );\n const chunks = Math.ceil(width / 128);\n const scanline = 4 + 4 * (width + chunks);\n const out = new Uint8Array(header.length + height * scanline);\n out.set(header, 0);\n let o = header.length;\n const planes = new Uint8Array(width * 4);\n for (let row = 0; row < height; row++) {\n for (let col = 0; col < width; col++) {\n const i = (row * width + col) * 4;\n const r = data[i]!;\n const g = data[i + 1]!;\n const b = data[i + 2]!;\n const max = Math.max(r, g, b);\n if (max < 1e-32) {\n planes[col] = planes[width + col] = planes[2 * width + col] = 0;\n planes[3 * width + col] = 0;\n continue;\n }\n // frexp: max = m · 2^e with m in [0.5, 1).\n let e = Math.ceil(Math.log2(max));\n let m = max / Math.pow(2, e);\n if (m >= 1) {\n m /= 2;\n e += 1;\n } else if (m < 0.5) {\n m *= 2;\n e -= 1;\n }\n const scale = (m * 256) / max;\n planes[col] = Math.min(255, Math.floor(r * scale));\n planes[width + col] = Math.min(255, Math.floor(g * scale));\n planes[2 * width + col] = Math.min(255, Math.floor(b * scale));\n planes[3 * width + col] = e + 128;\n }\n out[o++] = 2;\n out[o++] = 2;\n out[o++] = (width >> 8) & 0xff;\n out[o++] = width & 0xff;\n for (let plane = 0; plane < 4; plane++) {\n for (let start = 0; start < width; start += 128) {\n const n = Math.min(128, width - start);\n out[o++] = n; // a literal run of n bytes\n out.set(\n planes.subarray(plane * width + start, plane * width + start + n),\n o,\n );\n o += n;\n }\n }\n }\n return out.buffer;\n}\n\n/** texture.repeat that makes UVs-in-meters physically correct. */\nexport function presetRepeat(name: MaterialPresetName): number {\n return 1 / MATERIAL_PRESETS[name].tileMeters;\n}\n\nexport type PresetMaterialOptions = {\n /** Texture resolution to load. 2k is the web default; 4k for close-ups. */\n size?: PresetTextureSize;\n /** Override the CDN base for this material only. */\n baseUrl?: string;\n /** Extra multiplier on the physical repeat (2 = pattern twice as dense). */\n repeat?: number;\n /** Skip the AO map (it needs a second render bounce to matter less). */\n ao?: boolean;\n anisotropy?: number;\n};\n\nconst textureCache = new Map<string, Texture>();\nlet sharedLoader: TextureLoader | undefined;\n\nfunction loadTexture(\n url: string,\n srgb: boolean,\n repeat: number,\n anisotropy: number,\n): Texture {\n // Shareable only when nothing instance-specific differs; repeat lives on\n // the texture in three.js, so the cache key must include it.\n const key = `${url}#${repeat}`;\n const cached = textureCache.get(key);\n if (cached) return cached;\n sharedLoader ??= new TextureLoader();\n const texture = sharedLoader.load(url);\n texture.wrapS = texture.wrapT = RepeatWrapping;\n texture.repeat.set(repeat, repeat);\n if (srgb) texture.colorSpace = SRGBColorSpace;\n texture.anisotropy = anisotropy;\n textureCache.set(key, texture);\n return texture;\n}\n\n/**\n * A MeshStandardMaterial wired to a preset's baked maps. Returns\n * synchronously; textures stream in and the material fills out as they\n * arrive (use loadPresetMaterial to await them). Tint `matte_paint`, or\n * any preset, with `material.color`.\n */\nexport function createPresetMaterial(\n name: MaterialPresetName,\n options: PresetMaterialOptions = {},\n): MeshStandardMaterial {\n const info = MATERIAL_PRESETS[name];\n const size = options.size ?? '2k';\n const base = options.baseUrl ?? presetBaseUrl();\n const repeat = presetRepeat(name) * (options.repeat ?? 1);\n const anisotropy = options.anisotropy ?? 8;\n const url = (map: PresetMapName) => presetTextureUrl(name, map, size, base);\n\n const material = new MeshStandardMaterial({\n metalness: info.metalness,\n roughness: 1,\n map: loadTexture(url('albedo'), true, repeat, anisotropy),\n normalMap: loadTexture(url('normal'), false, repeat, anisotropy),\n roughnessMap: loadTexture(url('roughness'), false, repeat, anisotropy),\n });\n if (options.ao !== false) {\n material.aoMap = loadTexture(url('ao'), false, repeat, anisotropy);\n }\n material.normalScale.setScalar(info.normalScale);\n material.userData.bakery3Preset = { name, size };\n return material;\n}\n\n/** createPresetMaterial, resolved once every map has actually loaded. */\nexport async function loadPresetMaterial(\n name: MaterialPresetName,\n options: PresetMaterialOptions = {},\n): Promise<MeshStandardMaterial> {\n const material = createPresetMaterial(name, options);\n const maps = [\n material.map,\n material.normalMap,\n material.roughnessMap,\n material.aoMap,\n ];\n // Textures may be cache hits from an earlier material and already loading;\n // TextureLoader keeps no per-texture promise, so poll for the decoded\n // image; it settles within a frame of the network finishing.\n await Promise.all(\n maps\n .filter((t): t is Texture => t !== null)\n .map((t) => textureReady(t, name)),\n );\n return material;\n}\n\nfunction textureReady(texture: Texture, presetName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n if (texture.source.data) return resolve();\n const started = Date.now();\n const poll = setInterval(() => {\n if (texture.source.data) {\n clearInterval(poll);\n resolve();\n } else if (Date.now() - started > 30_000) {\n clearInterval(poll);\n reject(\n new Error(\n `@oeave/bakery3/presets: timed out loading a map for '${presetName}'`,\n ),\n );\n }\n }, 50);\n });\n}\n\n/** UVs in meters: the geometry every preset surface uses. */\nfunction planeMeters(width: number, height: number): BufferGeometry {\n const geometry = new PlaneGeometry(width, height);\n const uv = geometry.attributes.uv!;\n for (let i = 0; i < uv.count; i++) {\n uv.setXY(i, uv.getX(i) * width, uv.getY(i) * height);\n }\n return geometry;\n}\n\n// ---------------------------------------------------------------------------\n// Windows\n// ---------------------------------------------------------------------------\n//\n// A window is a real hole in the wall, not a texture trick, because its whole\n// point is what passes through it: put a sun (or an HDRI) outside and the\n// render traces actual daylight falling into the room, and the WebGL preview\n// agrees, because every room surface casts shadows too. The wall face is a\n// shape-with-holes; each opening gets reveal surfaces exposing the wall's\n// thickness, an optional painted frame, and optional glass. Glass is off by\n// default on purpose: an open window lights the scene identically and a\n// transmission surface between the sun and the room just costs render noise.\n\nexport type WindowSpec = {\n /**\n * Meters along the wall from its center; positive is to your right as you\n * face the wall from inside the room. Default 0 (centered).\n */\n offset?: number;\n /** Opening width in meters. Default 1.2. */\n width?: number;\n /** Opening height in meters. Default 1.4. */\n height?: number;\n /** Meters from the floor to the bottom of the opening. Default 0.9. */\n sill?: number;\n /** Painted frame in the opening. Default true. */\n frame?: boolean;\n /** Glass pane (MeshPhysicalMaterial, transmission 1). Default false. */\n glass?: boolean;\n /**\n * Leaves outside the opening, so sun through it arrives dappled rather\n * than as one hard rectangle, the way a window with something outside it\n * does. Default true. Ordinary leaf geometry: it shows through the glass\n * and traces like any other mesh.\n */\n foliage?: boolean;\n};\n\nexport type RoomWallName = 'north' | 'south' | 'west' | 'east';\n\nexport type RoomWindowOpening = {\n /** Opening bounds in wall-local meters: x across the wall from its center, y up from the floor. */\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n frame: boolean;\n glass: boolean;\n foliage: boolean;\n};\n\nconst WINDOW_DEFAULTS = {\n offset: 0,\n width: 1.2,\n height: 1.4,\n sill: 0.9,\n frame: true,\n glass: false,\n foliage: true,\n};\n\n/** Structure a window must keep clear of corners and ceiling, meters. */\nconst WINDOW_MARGIN = 0.05;\n\n/**\n * Validate window specs against a wall and return concrete openings.\n * Refuses loudly: a window that silently vanished or clipped through a\n * corner would surface as a wrong render, which is worse than an error.\n */\nexport function resolveWindows(\n wall: RoomWallName,\n specs: WindowSpec | readonly WindowSpec[] | undefined,\n wallWidth: number,\n roomHeight: number,\n): RoomWindowOpening[] {\n const list =\n specs === undefined\n ? []\n : Array.isArray(specs)\n ? specs\n : [specs as WindowSpec];\n const openings = list.map((spec, index) => {\n const { offset, width, height, sill, frame, glass, foliage } = {\n ...WINDOW_DEFAULTS,\n ...spec,\n };\n const label = `@oeave/bakery3/presets: ${wall} window ${index}`;\n if (width <= 0 || height <= 0) {\n throw new Error(\n `${label} has a non-positive size (${width} × ${height} m).`,\n );\n }\n if (sill < 0) {\n throw new Error(\n `${label} has its sill ${sill} m below the floor. Use sill: 0 or higher.`,\n );\n }\n const opening: RoomWindowOpening = {\n x0: offset - width / 2,\n x1: offset + width / 2,\n y0: sill,\n y1: sill + height,\n frame,\n glass,\n foliage,\n };\n const limit = wallWidth / 2 - WINDOW_MARGIN;\n if (opening.x0 < -limit || opening.x1 > limit) {\n throw new Error(\n `${label} (offset ${offset}, width ${width}) does not fit the ${wallWidth} m wall. ` +\n `Keep it ${WINDOW_MARGIN} m clear of the corners.`,\n );\n }\n if (opening.y1 > roomHeight - WINDOW_MARGIN) {\n throw new Error(\n `${label} reaches ${opening.y1} m but the room is ${roomHeight} m tall. ` +\n `Lower the sill or shrink the height.`,\n );\n }\n return opening;\n });\n for (let i = 0; i < openings.length; i++) {\n for (let j = i + 1; j < openings.length; j++) {\n const a = openings[i]!;\n const b = openings[j]!;\n if (a.x0 < b.x1 && b.x0 < a.x1 && a.y0 < b.y1 && b.y0 < a.y1) {\n throw new Error(\n `@oeave/bakery3/presets: ${wall} windows ${i} and ${j} overlap. Separate their offsets.`,\n );\n }\n }\n }\n return openings;\n}\n\n/**\n * The wall's inner face: a rectangle in wall-local meters (x from -width/2,\n * y from 0 at the floor) with one hole per opening. ShapeGeometry keeps the\n * raw coordinates as UVs, so the meters-per-UV convention survives holes.\n */\nexport function wallFaceGeometry(\n width: number,\n height: number,\n openings: readonly RoomWindowOpening[],\n): BufferGeometry {\n const shape = new Shape();\n shape.moveTo(-width / 2, 0);\n shape.lineTo(width / 2, 0);\n shape.lineTo(width / 2, height);\n shape.lineTo(-width / 2, height);\n shape.closePath();\n for (const opening of openings) {\n const hole = new Path();\n hole.moveTo(opening.x0, opening.y0);\n hole.lineTo(opening.x0, opening.y1);\n hole.lineTo(opening.x1, opening.y1);\n hole.lineTo(opening.x1, opening.y0);\n hole.closePath();\n shape.holes.push(hole);\n }\n return new ShapeGeometry(shape);\n}\n\nconst FRAME_MEMBER = 0.055;\nconst FRAME_DEPTH = 0.045;\n\nfunction buildWindow(\n opening: RoomWindowOpening,\n index: number,\n thickness: number,\n materials: {\n wall: MeshStandardMaterial;\n frame: MeshStandardMaterial;\n glass: MeshPhysicalMaterial;\n foliage: { leaf: MeshStandardMaterial; twig: MeshStandardMaterial };\n },\n): Group {\n const { x0, x1, y0, y1 } = opening;\n const w = x1 - x0;\n const h = y1 - y0;\n const cx = (x0 + x1) / 2;\n const cy = (y0 + y1) / 2;\n const z = -thickness / 2; // into the wall; local +z faces the room\n\n const group = new Group();\n group.name = `window-${index}`;\n\n // Reveals: the four surfaces of the opening, facing inward, painted with\n // the wall material at meter scale like everything else.\n const reveal = (\n geometry: BufferGeometry,\n position: [number, number, number],\n rotation: [number, number, number],\n name: string,\n ) => {\n const mesh = new Mesh(geometry, materials.wall);\n mesh.name = name;\n mesh.position.set(...position);\n mesh.rotation.set(...rotation);\n mesh.castShadow = true;\n mesh.receiveShadow = true;\n group.add(mesh);\n };\n reveal(\n planeMeters(thickness, h),\n [x0, cy, z],\n [0, Math.PI / 2, 0],\n 'reveal-left',\n );\n reveal(\n planeMeters(thickness, h),\n [x1, cy, z],\n [0, -Math.PI / 2, 0],\n 'reveal-right',\n );\n reveal(\n planeMeters(w, thickness),\n [cx, y1, z],\n [Math.PI / 2, 0, 0],\n 'reveal-top',\n );\n reveal(\n planeMeters(w, thickness),\n [cx, y0, z],\n [-Math.PI / 2, 0, 0],\n 'reveal-sill',\n );\n\n if (opening.frame) {\n const bar = (\n bw: number,\n bh: number,\n position: [number, number, number],\n ) => {\n const mesh = new Mesh(\n new BoxGeometry(bw, bh, FRAME_DEPTH),\n materials.frame,\n );\n mesh.name = 'frame';\n mesh.position.set(...position);\n mesh.castShadow = true;\n mesh.receiveShadow = true;\n group.add(mesh);\n };\n bar(w, FRAME_MEMBER, [cx, y0 + FRAME_MEMBER / 2, z]);\n bar(w, FRAME_MEMBER, [cx, y1 - FRAME_MEMBER / 2, z]);\n bar(FRAME_MEMBER, h - 2 * FRAME_MEMBER, [x0 + FRAME_MEMBER / 2, cy, z]);\n bar(FRAME_MEMBER, h - 2 * FRAME_MEMBER, [x1 - FRAME_MEMBER / 2, cy, z]);\n // Wide sashes get a center mullion so they read as a window, not a hole.\n if (w > 1.05) bar(FRAME_MEMBER * 0.7, h - 2 * FRAME_MEMBER, [cx, cy, z]);\n }\n\n if (opening.glass) {\n const pane = new Mesh(planeMeters(w, h), materials.glass);\n pane.name = 'glass';\n pane.position.set(cx, cy, z + FRAME_DEPTH / 2 + 0.002);\n group.add(pane);\n }\n\n if (opening.foliage) {\n group.add(buildFoliage(opening, index, thickness, materials.foliage));\n }\n\n return group;\n}\n\n/**\n * A canopy of leaves outside a window.\n *\n * Sun through a bare opening lands as one hard rectangle, and nothing says\n * \"computer\" faster. Real windows have something outside them, and what that\n * something does to the light (clumps of shadow with clean shafts between)\n * is most of what makes a traced interior read as a photograph. So: leaf\n * shapes in clumps, with gaps, hung outside the opening where the sun has\n * to come through them on its way to the floor.\n *\n * Real geometry, deliberately. A shadow-only card with a noise alpha would\n * need a node material the render cannot carry; a few hundred leaf shapes\n * merged into one mesh (and their twigs into another) travel through glTF\n * like any other mesh, cast the same shadows in the preview and in the\n * trace, and are simply greenery through the glass when the camera looks\n * that way. Seeded from the opening, so the same room grows the same leaves\n * on every load: a capture has to be reproducible.\n */\nfunction buildFoliage(\n opening: RoomWindowOpening,\n index: number,\n thickness: number,\n materials: { leaf: MeshStandardMaterial; twig: MeshStandardMaterial },\n): Group {\n const { x0, x1, y0, y1 } = opening;\n const w = x1 - x0;\n const h = y1 - y0;\n const cx = (x0 + x1) / 2;\n const cy = (y0 + y1) / 2;\n const random = mulberry32(\n Math.round((x0 * 73 + y0 * 151 + x1 * 271 + y1 * 397) * 1000) +\n index * 7919,\n );\n\n // The band the sun has to cross. Rays that reach the floor inside come\n // through the lower part of the opening, and at the canopy's distance\n // outside they are higher still, so the canopy spans the opening sideways\n // with a margin and reaches from just above the sill to well over the head.\n // Laid out as a jittered grid of clumps with cells left empty on purpose:\n // the gaps are the clean shafts, and a shaft beside a dapple is what reads\n // as sun through a tree.\n const depth = -(thickness + 0.7);\n const cell = 0.5;\n const xStart = x0 - 0.35;\n const xEnd = x1 + 0.35;\n const yStart = y0 + h * 0.15;\n const yEnd = y1 + 0.7;\n const cols = Math.max(2, Math.round((xEnd - xStart) / cell));\n const rows = Math.max(2, Math.round((yEnd - yStart) / cell));\n\n const leaves: BufferGeometry[] = [];\n const twigs: BufferGeometry[] = [];\n const position = new Vector3();\n const rotation = new Quaternion();\n const unit = new Vector3(1, 1, 1);\n const matrix = new Matrix4();\n const euler = new Euler();\n const place = (\n geometry: BufferGeometry,\n x: number,\n y: number,\n z: number,\n rx: number,\n ry: number,\n rz: number,\n ) => {\n position.set(x, y, z);\n euler.set(rx, ry, rz);\n rotation.setFromEuler(euler);\n matrix.compose(position, rotation, unit);\n geometry.applyMatrix4(matrix);\n return geometry;\n };\n\n for (let row = 0; row < rows; row++) {\n for (let col = 0; col < cols; col++) {\n if (random() < 0.3) continue; // a gap\n const clumpX =\n xStart +\n ((col + 0.5) * (xEnd - xStart)) / cols +\n (random() - 0.5) * cell * 0.6;\n const clumpY =\n yStart +\n ((row + 0.5) * (yEnd - yStart)) / rows +\n (random() - 0.5) * cell * 0.6;\n const clumpZ = depth + (random() - 0.5) * 0.3;\n const radius = 0.24 + random() * 0.14;\n\n // A few twigs through the clump, so it hangs off something.\n for (let t = 0; t < 3; t++) {\n twigs.push(\n place(\n new BoxGeometry(0.008, 0.008, radius * 1.7),\n clumpX + (random() - 0.5) * radius * 0.5,\n clumpY + (random() - 0.5) * radius * 0.5,\n clumpZ,\n (random() - 0.5) * 0.8,\n (random() - 0.5) * 3.2,\n (random() - 0.5) * 0.8,\n ),\n );\n }\n\n const count = Math.round(radius * radius * Math.PI * 210);\n for (let i = 0; i < count; i++) {\n leaves.push(\n place(\n leafGeometry(0.08 + random() * 0.06),\n clumpX + (random() + random() - 1) * radius,\n clumpY + (random() + random() - 1) * radius * 0.85,\n clumpZ + (random() - 0.5) * 0.2,\n (random() - 0.5) * 1.4,\n (random() - 0.5) * 1.4,\n random() * Math.PI * 2,\n ),\n );\n }\n }\n }\n\n const merge = (\n parts: BufferGeometry[],\n name: string,\n material: MeshStandardMaterial,\n ) => {\n const geometry = mergeGeometries(parts, false) ?? new BufferGeometry();\n for (const part of parts) part.dispose();\n geometry.computeVertexNormals();\n const mesh = new Mesh(geometry, material);\n mesh.name = name;\n mesh.castShadow = true;\n mesh.receiveShadow = false;\n return mesh;\n };\n\n const group = new Group();\n group.name = 'foliage';\n group.add(\n merge(leaves, 'leaves', materials.leaf),\n merge(twigs, 'twigs', materials.twig),\n );\n return group;\n}\n\n/** One leaf: a pointed oval in the XY plane, base at the origin. */\nfunction leafGeometry(length: number): ShapeGeometry {\n const half = length * 0.34;\n const shape = new Shape();\n shape.moveTo(0, 0);\n shape.quadraticCurveTo(half, length * 0.45, 0, length);\n shape.quadraticCurveTo(-half, length * 0.55, 0, 0);\n return new ShapeGeometry(shape, 5);\n}\n\n/** A small seeded generator, so a room's foliage is the same every load. */\nfunction mulberry32(seed: number): () => number {\n let a = seed >>> 0;\n return () => {\n a = (a + 0x6d2b79f5) >>> 0;\n let t = a;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport type SunOptions = {\n /** Degrees above the horizon. Default 32. */\n elevation?: number;\n /**\n * Degrees clockwise from north (the −z wall) as seen from above. Default\n * 0: straight through a north-wall window.\n */\n azimuth?: number;\n /** Light intensity. Default 3.5. */\n intensity?: number;\n color?: ColorRepresentation;\n /**\n * Angular diameter in degrees: how crisp the shadows trace. Default 0.53,\n * the real sun: a leaf two meters outside still draws a leaf on the floor.\n * Without it the renderer's default is a studio-soft 12°, which turns sun\n * through a window into a glow and a canopy into mottling.\n */\n angleDeg?: number;\n};\n\nexport type RoomOptions = {\n /** Meters. Defaults: 4 × 4 × 2.7. */\n width?: number;\n depth?: number;\n height?: number;\n floor?: MaterialPresetName;\n walls?: MaterialPresetName;\n /** Pass null for an open ceiling (studio lighting from above). */\n ceiling?: MaterialPresetName | null;\n /** Wall thickness in meters: the depth of window reveals. Default 0.15. */\n wallThickness?: number;\n /**\n * Window openings per wall. north is the −z wall; offsets are measured to\n * your right as you face each wall from inside.\n */\n windows?: Partial<Record<RoomWallName, WindowSpec | readonly WindowSpec[]>>;\n /**\n * Add a shadow-casting sun outside the room. Aim it through a window\n * (azimuth 0 = through the north wall) and the render traces real daylight\n * falling in; the WebGL preview shows the same shafts, because every\n * room surface casts shadows.\n */\n sun?: SunOptions | true;\n materialOptions?: PresetMaterialOptions;\n};\n\n/**\n * An interior shell: floor at y = 0, centered on the origin, every surface\n * facing inward (from outside the walls are backface-culled, which makes\n * orbiting and debugging pleasant, but they still block light: traced\n * geometry is two-sided, and the preview shadow pass renders both sides).\n *\n * Structure, all by name so surfaces can be restyled or removed:\n * floor, ceiling: meshes\n * wall-north (−z), wall-south, wall-west, wall-east: groups holding a\n * 'face' mesh plus 'window-N' groups (reveal-*, frame and glass\n * meshes, and a 'foliage' group, the canopy outside, on by default)\n * sun: when requested, a group holding 'sun-light' and its aim target\n */\nexport function createRoom(options: RoomOptions = {}): Group {\n const width = options.width ?? 4;\n const depth = options.depth ?? 4;\n const height = options.height ?? 2.7;\n const thickness = options.wallThickness ?? 0.15;\n const materialFor = (name: MaterialPresetName) => {\n const material = createPresetMaterial(name, options.materialOptions);\n // The sun stands outside; walls must occlude it from either side or the\n // preview's light would pour straight through the back of a wall.\n material.shadowSide = DoubleSide;\n return material;\n };\n\n const room = new Group();\n room.name = 'bakery3-room';\n room.userData.bakery3Preset = {\n room: { width, depth, height, windows: options.windows ?? null },\n };\n\n const surface = (\n name: string,\n geometry: BufferGeometry,\n material: MeshStandardMaterial,\n position: [number, number, number],\n rotation: [number, number, number],\n parent: Group = room,\n ) => {\n const mesh = new Mesh(geometry, material);\n mesh.name = name;\n mesh.position.set(...position);\n mesh.rotation.set(...rotation);\n mesh.castShadow = true;\n mesh.receiveShadow = true;\n parent.add(mesh);\n return mesh;\n };\n\n const floor = materialFor(options.floor ?? 'oak_floor');\n surface(\n 'floor',\n planeMeters(width, depth),\n floor,\n [0, 0, 0],\n [-Math.PI / 2, 0, 0],\n );\n\n if (options.ceiling !== null) {\n const ceiling = materialFor(options.ceiling ?? 'matte_paint');\n surface(\n 'ceiling',\n planeMeters(width, depth),\n ceiling,\n [0, height, 0],\n [Math.PI / 2, 0, 0],\n );\n }\n\n const wallMaterial = materialFor(options.walls ?? 'white_plaster');\n const frameMaterial = new MeshStandardMaterial({\n color: 0xf4f3f0,\n roughness: 0.5,\n metalness: 0,\n });\n const glassMaterial = new MeshPhysicalMaterial({\n roughness: 0.04,\n metalness: 0,\n transmission: 1,\n ior: 1.52,\n thickness: 0.006,\n side: DoubleSide,\n });\n const leafMaterial = new MeshStandardMaterial({\n color: 0x3a5a2a,\n roughness: 0.7,\n metalness: 0,\n side: DoubleSide,\n });\n leafMaterial.name = 'foliage-leaf';\n const twigMaterial = new MeshStandardMaterial({\n color: 0x4a3a2c,\n roughness: 0.9,\n metalness: 0,\n });\n twigMaterial.name = 'foliage-twig';\n\n const buildWall = (\n name: RoomWallName,\n wallWidth: number,\n position: [number, number, number],\n rotationY: number,\n ) => {\n const openings = resolveWindows(\n name,\n options.windows?.[name],\n wallWidth,\n height,\n );\n const wall = new Group();\n wall.name = `wall-${name}`;\n wall.position.set(...position);\n wall.rotation.y = rotationY;\n surface(\n 'face',\n wallFaceGeometry(wallWidth, height, openings),\n wallMaterial,\n [0, 0, 0],\n [0, 0, 0],\n wall,\n );\n openings.forEach((opening, index) => {\n wall.add(\n buildWindow(opening, index, thickness, {\n wall: wallMaterial,\n frame: frameMaterial,\n glass: glassMaterial,\n foliage: { leaf: leafMaterial, twig: twigMaterial },\n }),\n );\n });\n room.add(wall);\n };\n buildWall('north', width, [0, 0, -depth / 2], 0);\n buildWall('south', width, [0, 0, depth / 2], Math.PI);\n buildWall('west', depth, [-width / 2, 0, 0], Math.PI / 2);\n buildWall('east', depth, [width / 2, 0, 0], -Math.PI / 2);\n\n if (options.sun) {\n room.add(\n createRoomSun(\n options.sun === true ? {} : options.sun,\n width,\n depth,\n height,\n ),\n );\n }\n\n return room;\n}\n\n/**\n * A sun for the room: a plain DirectionalLight, which the render pipeline\n * translates to a sun lamp like any other scene light. Positioned well\n * outside the shell with a shadow camera sized to cover it. Returned as a\n * group ('sun') holding the light and its aim target; the target must live\n * in room space, not under the light, or moving one would move the other.\n */\nfunction createRoomSun(\n options: SunOptions,\n width: number,\n depth: number,\n height: number,\n): Group {\n const elevation = MathUtils.degToRad(options.elevation ?? 32);\n const azimuth = MathUtils.degToRad(options.azimuth ?? 0);\n const reach = Math.hypot(width, depth, height);\n\n const group = new Group();\n group.name = 'sun';\n\n const sun = new DirectionalLight(\n options.color ?? 0xfff2df,\n options.intensity ?? 3.5,\n );\n sun.name = 'sun-light';\n const horizontal = 2 * reach * Math.cos(elevation);\n sun.position.set(\n horizontal * Math.sin(azimuth),\n 2 * reach * Math.sin(elevation) + height / 2,\n -horizontal * Math.cos(azimuth),\n );\n const target = new Object3D();\n target.name = 'sun-target';\n target.position.set(0, height / 2, 0);\n group.add(sun, target);\n sun.target = target;\n\n sun.userData.bakery3 = { angleDeg: options.angleDeg ?? 0.53 };\n sun.castShadow = true;\n sun.shadow.mapSize.set(2048, 2048);\n sun.shadow.camera.left = sun.shadow.camera.bottom = -reach;\n sun.shadow.camera.right = sun.shadow.camera.top = reach;\n sun.shadow.camera.near = 0.1;\n sun.shadow.camera.far = 6 * reach;\n sun.shadow.bias = -0.0003;\n return group;\n}\n\nexport type PedestalOptions = {\n /** Which pedestal. Default `pedestal_block`; or pass the name first. */\n type?: PedestalPresetName;\n material?: MaterialPresetName;\n materialOptions?: PresetMaterialOptions;\n baseUrl?: string;\n};\n\n/**\n * A pedestal from `createPedestal()`: a plain three.js `Group`, with what a\n * page needs from it typed on `userData`. Anything else on `userData` is\n * yours, as on any object.\n */\nexport interface PresetPedestal extends Group {\n userData: {\n /**\n * The resting height for what it displays, in meters:\n * `product.position.y = pedestal.userData.topY`.\n */\n topY: number;\n /**\n * Resolves with the pedestal once its model is in. Await it before a\n * render: one started earlier gets an empty group.\n */\n ready: Promise<PresetPedestal>;\n // The rest of `userData` is as open as three's own.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n };\n}\n\nlet sharedGltfLoader: GLTFLoader | undefined;\nconst gltfCache = new Map<string, Promise<Group>>();\n\nfunction loadGlb(url: string): Promise<Group> {\n let pending = gltfCache.get(url);\n if (!pending) {\n sharedGltfLoader ??= new GLTFLoader();\n pending = sharedGltfLoader.loadAsync(url).then((gltf) => gltf.scene);\n gltfCache.set(url, pending);\n }\n return pending;\n}\n\n/**\n * A pedestal with a preset material, base at y = 0. Returns a Group\n * immediately; the mesh streams in (await `userData.ready` to know when).\n * `userData.topY` is the resting height for whatever it displays:\n * `product.position.y = pedestal.userData.topY` and the product sits on it.\n *\n * createPedestal('pedestal_column', { material: 'carrara_marble' });\n * createPedestal({ type: 'pedestal_column', material: 'carrara_marble' });\n */\nexport function createPedestal(\n type: PedestalPresetName,\n options?: Omit<PedestalOptions, 'type'>,\n): PresetPedestal;\nexport function createPedestal(options?: PedestalOptions): PresetPedestal;\nexport function createPedestal(\n typeOrOptions: PedestalPresetName | PedestalOptions = {},\n more: Omit<PedestalOptions, 'type'> = {},\n): PresetPedestal {\n const options: PedestalOptions =\n typeof typeOrOptions === 'string'\n ? { ...more, type: typeOrOptions }\n : (typeOrOptions ?? {});\n const type = options.type ?? 'pedestal_block';\n const info = PEDESTAL_PRESETS[type];\n if (!info) {\n throw new Bakery3Error({\n code: 'InvalidRequest',\n message: `\"${String(type)}\" is not a pedestal.`,\n fix: `Use one of: ${Object.keys(PEDESTAL_PRESETS).join(', ')}.`,\n docs: 'https://bakery3.com/docs/presets',\n });\n }\n const material = createPresetMaterial(\n options.material ?? info.defaultMaterial,\n {\n baseUrl: options.baseUrl,\n ...options.materialOptions,\n },\n );\n const pedestal = new Group();\n pedestal.name = `bakery3-${type}`;\n pedestal.userData.topY = info.size.y;\n pedestal.userData.bakery3Preset = { object: type };\n pedestal.userData.ready = loadGlb(\n pedestalUrl(type, options.baseUrl ?? presetBaseUrl()),\n ).then((glb) => {\n const instance = glb.clone();\n instance.traverse((node) => {\n if (!(node as Mesh).isMesh) return;\n const mesh = node as Mesh;\n // The loader cache owns the source geometry. Each instance gets its own\n // clone so disposing one pedestal cannot poison the next.\n mesh.geometry = mesh.geometry.clone();\n mesh.material = material;\n mesh.castShadow = true;\n mesh.receiveShadow = true;\n });\n pedestal.add(instance);\n return pedestal as PresetPedestal;\n });\n return pedestal as PresetPedestal;\n}\n","/**\n * Room presets: a staged interior around the product, in one call.\n *\n * import { createPresetRoom, applyPresetRoomCamera } from '@oeave/bakery3/presets';\n *\n * const room = createPresetRoom('loft_golden', {\n * walls: { material: 'white_plaster', color: '#e9dfd0' },\n * pedestal: 'pedestal_column',\n * });\n * scene.add(room);\n * product.position.copy(room.userData.stand); // on the pedestal\n * applyPresetRoomCamera(camera, room); // the published framing\n * renderer.toneMappingExposure = room.userData.exposure; // as bright as designed\n *\n * What the browser gets is a stand-in: one compressed GLB from the preset\n * CDN (a few MB: furniture with 1k textures, the shell wearing the same\n * preset materials `createPresetMaterial` serves, a sun and a hemisphere\n * fill). It is there so the product can be framed inside the room. None of\n * it is captured. The manifest carries a small record instead (which room,\n * which build, which lighting, which surfaces, which stand, the group's\n * matrix) and the render worker rebuilds the whole set from its own\n * full-resolution copy: 4k maps, the full geometry, the foliage outside the\n * glass that dapples the sun, the light fixtures, the portals, the haze. A\n * product in a room therefore uploads exactly what a bare product uploads.\n *\n * Two things follow. The foliage and the light rig are never in the\n * preview, so the traced image is meant to be richer than the viewport, not\n * identical to it, and the compatibility report says so once, as an info\n * item, at capture. And a room's lights and sky replace the scene's\n * environment for the render: the room owns its daylight.\n */\n\nimport {\n Float32BufferAttribute,\n type BufferGeometry,\n Box3,\n Color,\n DirectionalLight,\n DoubleSide,\n Group,\n HemisphereLight,\n MathUtils,\n Matrix4,\n Mesh,\n MeshBasicMaterial,\n MeshPhysicalMaterial,\n MeshStandardMaterial,\n Object3D,\n PerspectiveCamera,\n PointLight,\n SpotLight,\n SRGBColorSpace,\n Texture,\n Vector3,\n type Camera,\n} from 'three';\nimport { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';\nimport { GroundedSkybox } from 'three/addons/objects/GroundedSkybox.js';\nimport { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';\nimport type { RoomPresetSpec } from '../protocol/index.js';\nimport { Bakery3Error } from '../errors.js';\nimport { sha256 } from '../capture/hash.js';\nimport {\n HDRI_PRESETS,\n MATERIAL_PRESETS,\n PEDESTAL_PRESETS,\n type HdriPresetName,\n type MaterialPresetName,\n type PedestalPresetName,\n} from './catalog.gen.js';\nimport {\n ROOM_PRESETS,\n type RoomPresetLighting,\n type RoomPresetName,\n} from './rooms.gen.js';\nimport { roomPresetSpecOf, type PresetRoomState } from './roomState.js';\nimport { applyRoomPrebake, type PresetRoomPrebake } from './roomPrebake.js';\nimport {\n createPedestal,\n createPresetMaterial,\n loadPresetHdr,\n type PresetMaterialOptions,\n} from './library.js';\nimport { presetBaseUrl } from './baseUrl.js';\n\n// The full generated record, for the SDK's own code. The public\n// `ROOM_PRESETS` is `roomCatalog.ts`: the same object, typed as a developer\n// reads it.\nexport {\n ROOM_PRESETS,\n type RoomPresetLighting,\n type RoomPresetName,\n} from './rooms.gen.js';\n\n/** A preset material, optionally tinted (plaster and paint take a tint well). */\nexport type RoomSurfaceOption =\n MaterialPresetName | { material: MaterialPresetName; color?: string };\n\nexport type PresetRoomOptions = {\n /** Day, golden, overcast or night. Defaults to the mode the room was designed under. */\n lighting?: RoomPresetLighting;\n floor?: RoomSurfaceOption;\n walls?: RoomSurfaceOption;\n ceiling?: RoomSurfaceOption;\n /** Window sills: stone or timber. Never tinted. */\n sill?: MaterialPresetName;\n /**\n * What the product stands on: a pedestal preset, or `null` for the floor.\n * Defaults to the room's own stand.\n */\n pedestal?: PedestalPresetName | null;\n /** The pedestal's material. A room whose own stand is a table keeps the\n * table's finish. */\n pedestalMaterial?: MaterialPresetName;\n /**\n * Preview lights: the room's sun through its windows, a hemisphere fill,\n * whatever fixtures the published rig had. Default true. Off, the group is\n * geometry only, for an app that lights its own viewport.\n */\n lights?: boolean;\n /**\n * Make the room bakeable. The stand-in's surfaces (floor, walls, ceiling,\n * sills, the stand, the furniture) then ship in the capture like any mesh,\n * so `bake()` lists them and the bake lightmaps the room itself:\n * contact shadows under the product, bounce on the walls. The renderer\n * still owns the light (sky, sun, portals, foliage, fixtures) and builds no\n * shell of its own around the shipped one. Off by default: a plain render\n * of a room uploads only the product.\n */\n bake?: boolean;\n /**\n * What is outside the windows. By default the map the room was published\n * with for its mode: its 1k preview on a dome projected onto the ground,\n * so the view through the glass has a horizon and a floor, turned so the\n * map's sun sits where the room's sun is. Name another `HDRI_PRESETS`\n * entry to put that one there instead (the render turns it to the room's\n * sun the same way), or `false` for nothing outside: the mode's plain sky,\n * in the viewport and in the render alike.\n * The dome never ships; the render builds its own from the 4k master.\n *\n * The dome is 60 m out, so the camera's `far` must reach past it (100 is\n * plenty) or the sky is clipped to black. The console says so once.\n * The render also lays aerial perspective over the distance when the room\n * was published with air; the stand-in shows the map as shot.\n */\n hdri?: HdriPresetName | false;\n /**\n * Let the room ask a bake to stand in for its own heavy pieces: a box\n * where a shelf of books is, a low-poly planter and a flat card where a\n * plant is. Default true, and it only ever applies to a bake that is\n * covering the room's own surfaces.\n *\n * It is the room's geometry, so the room says how it would like to be\n * stood in for. `false` bakes every piece as it is, which is what a bundle\n * shared between pages wants: a card is drawn from one side, and a bundle\n * everybody downloads has to hold up from all of them.\n */\n simplify?: boolean;\n /**\n * Your own images in the room's frames, one per picture it hangs, in the\n * order it hangs them (`ROOM_PRESETS[name].pictures` lists them). A URL\n * the page can fetch, or a `Blob` you already have; `null` leaves that\n * frame as published, and a short list leaves the rest.\n *\n * The frame stays where it is and the image is cropped to fill it, the\n * way `object-fit: cover` fills a box, so a portrait photograph in a\n * landscape frame is centred and cropped rather than letterboxed.\n */\n pictures?: ReadonlyArray<PresetRoomPicture | null>;\n /**\n * Light the room with its prebaked lightmaps, when the library has them\n * for this lighting mode (`ROOM_PRESETS[name].prebaked`). Default true.\n * They arrive after `userData.ready`, and `userData.prebaked` resolves\n * when they are on (or `null` when there are none). The room must be\n * unmodified: another floor, walls, ceiling, sill, map outside or stand is\n * other light, so the room keeps its preview lights. `false` never\n * downloads them; `setPresetRoomPrebaked(room, false)` turns them off.\n */\n prebaked?: boolean;\n baseUrl?: string;\n materialOptions?: PresetMaterialOptions;\n};\n\n/**\n * A room from `createPresetRoom()`: a plain three.js `Group`, with what a\n * page needs from it typed on `userData`. Anything else on `userData` is\n * yours, as on any object.\n */\nexport interface PresetRoom extends Group {\n userData: {\n /**\n * Where the product goes: the top of the stand, in the room's own\n * frame. `product.position.copy(room.userData.stand)`.\n */\n stand: Vector3;\n /** The height of `stand`, in meters. */\n topY: number;\n /**\n * The `toneMappingExposure` the room was designed under. Set the\n * renderer to it and the room is as bright as its published pictures.\n */\n exposure: number;\n /**\n * Resolves with the room once its stand-in is in. Await it before a\n * render: one started earlier gets an empty room.\n */\n ready: Promise<PresetRoom>;\n /**\n * Resolves when the room's own traced light is on (see the `prebaked`\n * option), or with `null` when there is none for this room as it is.\n */\n prebaked: Promise<PresetRoomPrebake | null>;\n // The rest of `userData` is as open as three's own.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n };\n}\n\n/** The dome's radius: past any room and any camera that frames one. */\nconst DOME_RADIUS = 60;\n/** The outside ground sits this far below the floor, or the two fight for the same pixels. */\nconst GROUND_DROP = 0.05;\n\n/** What the group remembers of the choices: the manifest's record minus the matrix. */\nexport type { PresetRoomState, PresetRoomFacts } from './roomState.js';\n\nexport function presetRoomUrl(\n name: RoomPresetName,\n base: string = presetBaseUrl(),\n): string {\n const info = ROOM_PRESETS[name];\n return `${base.replace(/\\/$/, '')}/v${info.presetsVersion}/${info.preview.glb}`;\n}\n\n/**\n * The accent spot: the renderer's IES lamp lands about 0.006 W/sr per lamp\n * watt on axis, whatever the beam, and the cone is where the IES profile\n * falls to a tenth.\n */\nconst IES_PEAK_PER_WATT = 0.006;\n/**\n * The emission strength a downlight's visible face carries. It is the number\n * the renderer designs its cans at: the stand-in's disc is the only one in\n * the scene, so it has to be the designed one.\n */\nconst FIXTURE_GLOW_STRENGTH = 5;\n/**\n * A can, from the exported candela back to its spec watts and on to the\n * viewport: a room hangs a can at `watts × DOWNLIGHT_SCALE` lamp watts and\n * the exporter writes a point lamp as `W × 683 / 4π` candela; the stand-in\n * draws a can at `CAN_FULL_WATTS` or more as the mode's `point` cap, and a\n * dimmer one in proportion.\n */\nconst DOWNLIGHT_SCALE = 9.0;\nconst CANDELA_PER_WATT = 683 / (4 * Math.PI);\nconst CAN_FULL_WATTS = 20;\nconst ACCENT_BEAM = {\n narrow: { angleDeg: 17.5, penumbra: 0.5 },\n medium: { angleDeg: 31.6, penumbra: 0.5 },\n wide: { angleDeg: 48.6, penumbra: 0.5 },\n} as const;\n\n/**\n * The look of each lighting mode in WebGL. The GLB's lights arrive with\n * photometric values (a sun in W/m², cans in thousands of candela), which\n * blow a viewport out; these renormalizations make the stand-in read the\n * way a competent three.js scene of the room would.\n *\n * `sky` and `ground` are the hemisphere fill's levels. Its hue is the\n * room's, not the mode's: `previewFill` in the catalog carries the color of\n * the light that room's own openings and fixtures deliver, and\n * `hemisphereFill` wears it without changing how much light the fill gives,\n * so a skylit room's fill is blue and a golden loft's warm.\n */\nconst MODE_LOOK: Record<\n RoomPresetLighting,\n { hemi: number; sun: number; point: number; sky: string; ground: string }\n> = {\n day: { hemi: 0.55, sun: 0.42, point: 10, sky: '#e9eef4', ground: '#6a5f52' },\n golden: { hemi: 0.4, sun: 0.5, point: 10, sky: '#f1dcc2', ground: '#6a5f52' },\n overcast: {\n hemi: 0.8,\n sun: 0.3,\n point: 10,\n sky: '#dfe3e8',\n ground: '#6a5f52',\n },\n night: { hemi: 0.06, sun: 0.3, point: 4, sky: '#2a3550', ground: '#1a1712' },\n};\n\n/** Relative luminance of an sRGB hex, linear: the level a fill color carries. */\nfunction hexLuminance(hex: string): number {\n const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());\n if (!m) return 1;\n const channel = (i: number) => {\n const v = parseInt(m[1]!.slice(i, i + 2), 16) / 255;\n return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4);\n}\n\n/**\n * The mode's fill wearing the room's own hue: two colors and the factor\n * the intensity must carry so the light delivered is unchanged.\n *\n * `previewFill`'s triples are at luminance 1, so the level lives entirely in\n * the mode's own `sky`/`ground`. Those are near-white, which leaves no gamut\n * room for a saturated hue, so the hue goes in the color at whatever\n * saturation it needs and the level moves into the intensity. A room\n * published without `previewFill` keeps the mode's pair exactly.\n */\nfunction hemisphereFill(\n look: { sky: string; ground: string },\n fill: { sky: readonly number[]; ground: readonly number[] } | undefined,\n): { sky: Color; ground: Color; intensity: number } {\n if (!fill?.sky || !fill?.ground) {\n return {\n sky: new Color(look.sky),\n ground: new Color(look.ground),\n intensity: 1,\n };\n }\n const skyLevel = hexLuminance(look.sky);\n const groundLevel = hexLuminance(look.ground);\n const peak = (rgb: readonly number[]) => Math.max(rgb[0]!, rgb[1]!, rgb[2]!);\n const scale = Math.max(\n skyLevel * peak(fill.sky),\n groundLevel * peak(fill.ground),\n 1e-6,\n );\n const color = (rgb: readonly number[], level: number) =>\n new Color().setRGB(\n (rgb[0]! * level) / scale,\n (rgb[1]! * level) / scale,\n (rgb[2]! * level) / scale,\n );\n return {\n sky: color(fill.sky, skyLevel),\n ground: color(fill.ground, groundLevel),\n intensity: scale,\n };\n}\n\nlet sharedLoader: GLTFLoader | undefined;\nconst glbCache = new Map<string, Promise<Group>>();\n\nfunction loadRoomGlb(url: string): Promise<Group> {\n let pending = glbCache.get(url);\n if (!pending) {\n if (!sharedLoader) {\n sharedLoader = new GLTFLoader();\n // The preview is meshopt-compressed; the decoder ships inside three.\n sharedLoader.setMeshoptDecoder(MeshoptDecoder);\n }\n pending = sharedLoader.loadAsync(url).then((gltf) => gltf.scene);\n glbCache.set(url, pending);\n }\n return pending;\n}\n\nconst surface = (option: RoomSurfaceOption | undefined) =>\n option === undefined\n ? undefined\n : typeof option === 'string'\n ? { material: option }\n : {\n material: option.material,\n ...(option.color ? { color: option.color } : {}),\n };\n\n/**\n * The parts of a potted plant that are the planter rather than the plant.\n * Every plant in the library is split this way (`<preset>_<part>`), and a\n * part nobody has listed is treated as foliage, because a pot that came\n * through as a card is a worse mistake than leaves that came through as\n * geometry.\n */\nconst PLANTER_PARTS = new Set([\n 'pot',\n 'base',\n 'gravel',\n 'pebbles',\n 'ground',\n 'dirt',\n]);\n\n/** How many stand-ins a room may ask for before it stops asking. */\nconst ROOM_STAND_INS = 12;\n\n/**\n * What the room would like a bake to replace, written onto its own meshes as\n * `userData.bakery3.simplify`, the same field a developer would set by hand.\n *\n * The books: one box per compartment. A shelf with no depth in it stops\n * reading as a shelf, so the carcass stays exactly as it is and only what\n * fills it is stood in for, which is also where the objects are (thirty book\n * meshes in one room, each otherwise a lightmap of its own). One box per\n * compartment and not one for the whole case, so the shelf boards are still\n * in front of something rather than buried inside it.\n *\n * The plants: a low-poly planter and a card for the foliage. A whole plant\n * as one card goes wrong on the floor: the shadow a plant lays down is a\n * pool the width of its leaves, and a card has no width, so half that pool\n * comes out in front of the plant. A planter is not the cheap half of a\n * plant either (a ribbed pot can run to a hundred thousand triangles), so it\n * is reduced rather than left alone, and as a solid it gives the shadow\n * something to sit around. The card carries the leaves, which is the part a\n * card is good at.\n */\nexport function stampRoomStandIns(\n root: Object3D,\n roomPlants: readonly string[],\n): number {\n // Longest first: `potted_monstera_02` must win over `potted_monstera_0`.\n const plants = [...roomPlants].sort((a, b) => b.length - a.length);\n\n const wanted: Array<{\n mesh: Mesh;\n to: 'box' | 'lowpoly' | 'billboard';\n group: string;\n }> = [];\n const groups = new Set<string>();\n root.traverse((node) => {\n const mesh = node as Mesh;\n if (!mesh.isMesh) return;\n const hint = plantPart(mesh, plants) ?? bookPart(mesh.name);\n if (!hint) return;\n wanted.push({ mesh, ...hint });\n groups.add(hint.group);\n });\n // A room with more pieces than this is one where the saving is not worth\n // the refusal a bake would raise; it bakes as it stands.\n if (groups.size > ROOM_STAND_INS) return 0;\n for (const { mesh, to, group } of wanted) {\n const existing = (mesh.userData.bakery3 ?? {}) as Record<string, unknown>;\n // A developer who said what they wanted keeps it.\n if (existing.simplify !== undefined) continue;\n mesh.userData.bakery3 = { ...existing, simplify: { to, group } };\n }\n return groups.size;\n}\n\n/** `book.<element>.<bay>.<column>.<color>`: one box per compartment. */\nfunction bookPart(name: string): { to: 'box'; group: string } | null {\n const parts = name.split('.');\n if (parts[0] !== 'book' || parts.length < 4) return null;\n return { to: 'box', group: `room:books/${parts[1]}.${parts[2]}.${parts[3]}` };\n}\n\n/** `<plant preset>_<part>`: the planter reduced, the rest on a card. */\nfunction plantPart(\n mesh: Mesh,\n plants: string[],\n): { to: 'lowpoly' | 'billboard'; group: string } | null {\n const preset = plants.find((presetName) =>\n mesh.name.startsWith(`${presetName}_`),\n );\n if (!preset) return null;\n const part = mesh.name.slice(preset.length + 1).split('.')[0] ?? '';\n // Per PLANT, not per preset: a room may stand the same palm in two\n // corners, and one card across both would be a card across the room.\n const where = `${mesh.parent?.name ?? 'room'}/${preset}`;\n return PLANTER_PARTS.has(part)\n ? { to: 'lowpoly', group: `room:planter/${where}` }\n : { to: 'billboard', group: `room:foliage/${where}` };\n}\n\n/**\n * A stable `bakery3Id` on every mesh of a room, from the room's name and the\n * mesh's own name in it. Returns how many were named.\n *\n * A bake addresses everything by `objectId`, and without a declared one that\n * is the three uuid, minted afresh on every reload: a room baked before a\n * refresh would match nothing after it. None of this geometry is the\n * developer's to name, so the SDK names it. The same stable ids are what let\n * a prebaked room exist: a bundle baked once and served to every page can\n * only find the floor if the floor has the same id in each of them.\n *\n * Called with the room fully built, after the stand has been resolved,\n * because a pedestal the caller chose is a different mesh from the one the\n * GLB shipped. A developer who named something themselves keeps their name.\n */\nexport function stampRoomIds(root: Object3D, name: string): number {\n const seen = new Map<string, number>();\n let named = 0;\n root.traverse((node) => {\n if (!(node as Mesh).isMesh) return;\n if (typeof node.userData.bakery3Id === 'string' && node.userData.bakery3Id)\n return;\n const base = `room:${name}/${node.name || node.type}`;\n const before = seen.get(base) ?? 0;\n seen.set(base, before + 1);\n // A GLB may repeat a name across nodes; the suffix keeps ids unique in\n // the order the tree is walked, which is stable for one file.\n node.userData.bakery3Id = before === 0 ? base : `${base}#${before}`;\n named++;\n });\n return named;\n}\n\n/**\n * GLTFLoader strips `.` from node names and the room names its pieces with\n * dots and underscores, so pieces are matched with neither.\n */\nconst plainName = (object: Object3D) =>\n object.name.toLowerCase().replace(/[._]/g, '');\n\n// ---------------------------------------------------------------------------\n// The developer's own pictures in the room's frames\n// ---------------------------------------------------------------------------\n\n/** An image to hang: a URL the page can fetch, or bytes you already have. */\nexport type PresetRoomPicture = string | Blob;\n\n/** One hung picture, kept on the group so the capture can upload it. */\nexport type PresetRoomPictureAsset = {\n hash: string;\n contentType: string;\n data: ArrayBuffer;\n name: string;\n};\n\n/**\n * Put the developer's images in the room's frames, cropped to fill.\n *\n * Cover, not contain, and the frame never moves. A picture's moulding, its\n * passepartout and the opening they leave were all built to the shape of the\n * image the room was published with, and that is the geometry the browser is\n * already drawing while the developer frames their shot. Resizing the frame\n * to a replacement's shape would make the render disagree with the viewport\n * about where the picture is on the wall. So the opening stays and the image\n * is cropped into it, centred, exactly as `object-fit: cover` fills a box.\n *\n * The bytes are hashed here and carried on the group. A plain render sends\n * none of the room's geometry (the render worker rebuilds it), so the image\n * travels as an ordinary content-addressed asset with its hash in the\n * record, or the render would hang the published picture while the viewport\n * showed the developer's.\n */\nasync function hangPictures(\n instance: Object3D,\n pictures: ReadonlyArray<PresetRoomPicture | null | undefined>,\n roomName: string,\n): Promise<{ hashes: (string | null)[]; assets: PresetRoomPictureAsset[] }> {\n // `picture.<element index>.art`, sorted by that index, which is the order\n // the room hangs them and the order this list fills them.\n const frames: Mesh[] = [];\n instance.traverse((node) => {\n const mesh = node as Mesh;\n if (mesh.isMesh && /^picture\\.\\d+\\.art$/.test(mesh.name)) frames.push(mesh);\n });\n frames.sort(\n (a, b) => Number(a.name.split('.')[1]) - Number(b.name.split('.')[1]),\n );\n\n if (pictures.length > frames.length) {\n throw new Bakery3Error({\n code: 'InvalidRequest',\n message: `${roomName} hangs ${frames.length} picture${frames.length === 1 ? '' : 's'}, and ${pictures.length} were given.`,\n why: \"Pictures fill the room's own frames in order; there is no wall to hang a spare on.\",\n fix: `ROOM_PRESETS['${roomName}'].pictures says how many there are and which walls they are on.`,\n docs: 'https://bakery3.com/docs/presets#pictures',\n });\n }\n\n const hashes: (string | null)[] = [];\n const assets: PresetRoomPictureAsset[] = [];\n for (const [index, picture] of pictures.entries()) {\n if (!picture) {\n hashes.push(null);\n continue;\n }\n const frame = frames[index]!;\n const { hash, data, contentType, texture } = await loadPicture(picture);\n coverFit(texture, frame);\n const material = (\n Array.isArray(frame.material) ? frame.material[0]! : frame.material\n ) as MeshStandardMaterial;\n const replacement = material.clone();\n replacement.map = texture;\n replacement.needsUpdate = true;\n frame.material = replacement;\n hashes.push(hash);\n assets.push({ hash, data, contentType, name: `picture-${index}` });\n }\n return { hashes, assets };\n}\n\nasync function loadPicture(picture: PresetRoomPicture): Promise<{\n hash: string;\n data: ArrayBuffer;\n contentType: string;\n texture: Texture;\n}> {\n let blob: Blob;\n if (typeof picture === 'string') {\n const response = await fetch(picture);\n if (!response.ok) {\n throw new Bakery3Error({\n code: 'InvalidRequest',\n message: `The picture at ${picture} could not be loaded (${response.status} ${response.statusText}).`,\n why: 'The page fetches it, so it has to be reachable from the browser and CORS-readable.',\n fix: 'Serve it from your own origin, or with an Access-Control-Allow-Origin header.',\n docs: 'https://bakery3.com/docs/presets#pictures',\n });\n }\n blob = await response.blob();\n } else {\n blob = picture;\n }\n const data = await blob.arrayBuffer();\n const hash = await sha256(data);\n // No flip. glTF puts uv (0,0) at the image's top-left and GLTFLoader sets\n // `flipY = false` to match; a bitmap decoded in file order is top row\n // first, so the two agree and the published picture and a replacement sit\n // the same way up in the same frame.\n const bitmap = await createImageBitmap(\n new Blob([data], { type: blob.type || 'image/jpeg' }),\n );\n const texture = new Texture(bitmap as unknown as HTMLImageElement);\n texture.flipY = false;\n texture.colorSpace = SRGBColorSpace;\n texture.needsUpdate = true;\n return { hash, data, contentType: blob.type || 'image/jpeg', texture };\n}\n\n/**\n * `object-fit: cover`, as a uv transform: the image fills the opening and\n * the overflow is cropped off both ends of the long axis.\n */\nexport function coverFit(texture: Texture, frame: Mesh): void {\n const image = texture.image as { width: number; height: number };\n if (!image?.width || !image?.height) return;\n if (!frame.geometry.boundingBox) frame.geometry.computeBoundingBox();\n const box = frame.geometry.boundingBox;\n if (!box) return;\n // A picture hangs on a wall, so its height is its Y extent and its width\n // is whichever of X and Z the wall runs along. The quad is built in the\n // room's own coordinates and hangs with no transform of its own.\n const height = box.max.y - box.min.y;\n const width = Math.max(box.max.x - box.min.x, box.max.z - box.min.z);\n if (!(height > 0) || !(width > 0)) return;\n const opening = width / height;\n const picture = image.width / image.height;\n // Fill the opening and crop the overflow off both ends of the long axis.\n // uv' = repeat * uv + offset, and three leaves uvs clamped at the edge.\n if (picture > opening) texture.repeat.set(opening / picture, 1);\n else texture.repeat.set(1, picture / opening);\n texture.offset.set((1 - texture.repeat.x) / 2, (1 - texture.repeat.y) / 2);\n}\n\n/** The default material for shelves and a bookcase carcass. */\nconst SHELF_MATERIAL = 'oak_veneer_05';\n\n/**\n * The preset material a piece was built with, for a piece that arrives\n * without one.\n *\n * A preset material's maps are not embedded in the room GLB (the SDK\n * rebuilds them from the same library the renderer uses), so the exporter\n * clears the slot and writes the name into the node's extras\n * (`bakery3Material`). A mesh with no material at all is a glTF default\n * material: white, rough and fully metallic, which has no diffuse, so it\n * renders near black in the viewport and bakes to a black lightmap. A room\n * published without the name carries nothing here and falls back to the\n * name chain in `createPresetRoom`.\n */\nfunction strippedPreset(\n mesh: Mesh,\n): { material: string; color?: string } | null {\n const name = mesh.userData?.bakery3Material;\n if (typeof name !== 'string' || !name) return null;\n const color = mesh.userData?.bakery3MaterialColor;\n return {\n material: name,\n ...(typeof color === 'string' && color && color.toLowerCase() !== '#ffffff'\n ? { color }\n : {}),\n };\n}\n\n/**\n * The last line against a black surface: a material that is still the glTF\n * default is one nothing above claimed, so it is a stripped preset this\n * version does not know the name of. Left alone it is a black object in the\n * viewport and a black lightmap in a bake; made plain it is at worst the\n * wrong shade of a real surface, which is recoverable and says so.\n */\nfunction coerceDefaultMaterial(mesh: Mesh): void {\n const materials = Array.isArray(mesh.material)\n ? mesh.material\n : [mesh.material];\n for (const material of materials) {\n const standard = material as MeshStandardMaterial;\n if (!standard.isMeshStandardMaterial) continue;\n const bare =\n standard.metalness === 1 &&\n standard.roughness === 1 &&\n !standard.map &&\n standard.color.getHex() === 0xffffff;\n if (!bare) continue;\n standard.metalness = 0;\n standard.roughness = 0.6;\n standard.color.set('#b9b2a6');\n warnBareMaterial(mesh.name);\n }\n}\n\nconst warnedBare = new Set<string>();\nfunction warnBareMaterial(name: string): void {\n if (warnedBare.has(name)) return;\n warnedBare.add(name);\n console.warn(\n `[bakery3] \"${name}\" arrived with no material and has been given a plain one. ` +\n 'Republish the room so it carries the preset material it was built with.',\n );\n}\n\n/**\n * A staged room around the origin: floor at y = 0, north wall at −z. Returns\n * a Group immediately; the stand-in streams in (`userData.ready` resolves\n * when it has). `userData.stand` is where the product goes (the top of the\n * pedestal, in the room's own frame) and `userData.topY` is its height.\n * `userData.exposure` is the `toneMappingExposure` the room was designed\n * under: the render honors whatever the renderer is set to, so a scene that\n * adopts it gets the room as bright as its published pictures, and one that\n * keeps exposure 1 gets a faithful picture about a stop darker.\n *\n * Every choice is remembered on `userData.bakery3Preset.roomPreset`, which is\n * what the capture reads; move or rotate the group freely, the render\n * rebuilds the room at its world matrix.\n */\nexport function createPresetRoom(\n name: RoomPresetName,\n options: PresetRoomOptions = {},\n): PresetRoom {\n const info = ROOM_PRESETS[name];\n if (!info) {\n throw new Error(\n `'${String(name)}' is not a room preset. Known rooms: ${Object.keys(ROOM_PRESETS).join(', ') || 'none'}.`,\n );\n }\n const lighting = options.lighting ?? info.lighting;\n const materialOptions: PresetMaterialOptions = {\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n ...options.materialOptions,\n };\n\n // The stand: the room's own unless told otherwise.\n const standType: string | null =\n options.pedestal === undefined ? info.stand.type : options.pedestal;\n if (options.pedestal && !(options.pedestal in PEDESTAL_PRESETS)) {\n throw new Bakery3Error({\n code: 'InvalidRequest',\n message: `\"${String(options.pedestal)}\" is not a pedestal.`,\n fix: `Use one of: ${Object.keys(PEDESTAL_PRESETS).join(', ')}, or null for the floor.`,\n docs: 'https://bakery3.com/docs/presets',\n });\n }\n const standInfo = standType\n ? PEDESTAL_PRESETS[standType as PedestalPresetName]\n : undefined;\n // A room's own stand may be a piece of furniture (a table); it stays as\n // the stand-in has it.\n const standBaked = Boolean(standInfo);\n const standMaterial: string | null =\n !standType || !standBaked\n ? null\n : (options.pedestalMaterial ??\n (options.pedestal === undefined\n ? info.stand.material\n : (standInfo?.defaultMaterial ?? null)));\n const topY = !standType\n ? 0\n : options.pedestal === undefined\n ? info.stand.top\n : standInfo!.size.y;\n\n // The map outside: the published one for this mode, another, or none.\n // A published map that the SDK's catalog no longer lists is treated as\n // none rather than a broken URL.\n const published = ((info as { hdri?: Record<string, unknown> }).hdri?.[\n lighting\n ] ?? null) as {\n name: string;\n rotationDeg: number;\n groundHeight: number;\n } | null;\n const hdriName: HdriPresetName | null =\n options.hdri === false\n ? null\n : (options.hdri ??\n (published && published.name in HDRI_PRESETS\n ? (published.name as HdriPresetName)\n : null));\n const hdriChoice: {\n name: HdriPresetName;\n rotationDeg: number;\n groundHeight: number;\n exposure: number;\n } | null = hdriName\n ? {\n name: hdriName,\n // Turned so its sun sits at the room's, as the render will turn\n // it: the published map's turn is the room's sun minus that\n // map's sun, so another map's turn is the same sum with its own.\n rotationDeg: options.hdri\n ? hdriTurn(hdriName, published, lighting)\n : published!.rotationDeg,\n groundHeight: HDRI_PRESETS[hdriName].groundHeight,\n // Shown at the room's own exposure: what this mode's sky delivers\n // over what the map's does. The render exposes its dome by the same\n // ratio.\n exposure: hdriExposure(\n info.skyIrradiance[lighting],\n HDRI_PRESETS[hdriName].skyIrradiance,\n ),\n }\n : null;\n\n const state: PresetRoomState = {\n name,\n build: info.build,\n lighting,\n ...(options.bake ? { standIn: true } : {}),\n ...(options.hdri === false\n ? { hdri: null }\n : options.hdri\n ? { hdri: options.hdri }\n : {}),\n ...(options.floor || options.walls || options.ceiling || options.sill\n ? {\n surfaces: {\n ...(options.floor ? { floor: surface(options.floor)! } : {}),\n ...(options.walls ? { walls: surface(options.walls)! } : {}),\n ...(options.ceiling ? { ceiling: surface(options.ceiling)! } : {}),\n ...(options.sill ? { sill: { material: options.sill } } : {}),\n },\n }\n : {}),\n ...(options.pedestal === undefined\n ? {}\n : options.pedestal === null\n ? { pedestal: null }\n : {\n pedestal: {\n type: options.pedestal,\n ...(standMaterial ? { material: standMaterial } : {}),\n },\n }),\n };\n\n const room = new Group();\n room.name = `bakery3-room-${name}`;\n room.userData.bakery3Preset = {\n roomPreset: state,\n // For the capture's compatibility note, so it never opens the catalog.\n roomFacts: { label: info.label, triangles: info.preview.triangles },\n };\n room.userData.topY = topY;\n room.userData.stand = new Vector3(info.stand.x, topY, info.stand.z);\n // The exposure the room was designed under: set `renderer.toneMappingExposure`\n // to it and the viewport and the render both show the room as bright as\n // its published comparisons. Left as advice, not applied: the renderer\n // is the developer's, and the manifest carries whatever they set.\n room.userData.exposure = info.exposure[lighting];\n\n // The effective surfaces, for the stand-in's materials.\n const floor = surface(options.floor) ?? info.surfaces.floor;\n const walls = surface(options.walls) ?? info.surfaces.walls;\n const ceiling = surface(options.ceiling) ?? info.surfaces.ceiling;\n const sill = options.sill ?? info.surfaces.sill.material;\n\n const cache = new Map<string, MeshStandardMaterial>();\n const preset = (material: string, color?: string): MeshStandardMaterial => {\n const key = `${material}|${color ?? ''}`;\n let made = cache.get(key);\n if (!made) {\n if (!(material in MATERIAL_PRESETS)) {\n throw new Error(`'${material}' is not a preset material.`);\n }\n made = createPresetMaterial(\n material as MaterialPresetName,\n materialOptions,\n );\n // The walls occlude the preview sun from either side.\n made.shadowSide = DoubleSide;\n if (color && color.toLowerCase() !== '#ffffff') made.color.set(color);\n cache.set(key, made);\n }\n return made;\n };\n const plain = (color: string, roughness = 0.5) =>\n new MeshStandardMaterial({ color, roughness });\n\n const domeReady: Promise<Object3D | null> = hdriChoice\n ? loadPresetHdr(hdriChoice.name, options.baseUrl ?? presetBaseUrl()).then(\n (map) => {\n // three's GroundedSkybox: a sphere flattened under the horizon at\n // the map's camera height, lifted by that height so the flat part is\n // the ground at y = 0, the same dome the render builds from the\n // same numbers. Positive Y rotation turns the map counter-clockwise\n // on the compass; `rotationDeg` is clockwise.\n const dome = new GroundedSkybox(\n map,\n hdriChoice.groundHeight,\n DOME_RADIUS,\n );\n dome.name = 'hdri.dome';\n dome.position.y = hdriChoice.groundHeight - GROUND_DROP;\n dome.rotation.y = -MathUtils.degToRad(hdriChoice.rotationDeg);\n dome.castShadow = false;\n dome.receiveShadow = false;\n // The numbers this dome was built from, written down rather than left\n // to be read back off the mesh. A baked embed has to rebuild the same\n // dome from the same map, and `exposure` is the one that cannot be\n // recovered from `material.color`: that carries exposure times the\n // viewport's own renormalization, which is the wrong scale for a\n // scene whose surfaces are carrying full traced irradiance.\n dome.userData.bakery3Dome = {\n name: hdriChoice.name,\n exposure: hdriChoice.exposure,\n rotationDeg: hdriChoice.rotationDeg,\n groundHeight: hdriChoice.groundHeight,\n radius: DOME_RADIUS,\n };\n // The render builds its own dome from the 4k master; the record\n // already says which map. This one is the viewport's.\n dome.userData.bakery3 = { exclude: true };\n checkDomeReachOnce(dome);\n return dome;\n },\n )\n : Promise.resolve(null);\n\n room.userData.ready = Promise.all([\n loadRoomGlb(presetRoomUrl(name, options.baseUrl)),\n domeReady,\n ]).then(async ([glb, dome]) => {\n if (dome) room.add(dome);\n const instance = glb.clone();\n const look = MODE_LOOK[lighting];\n const glass = new MeshPhysicalMaterial({\n transmission: 1,\n roughness: 0.05,\n ior: 1.45,\n thickness: 0.01,\n });\n // A fixture's face is the color of its own lamp. A room builds the\n // emissive and the light from one kelvin, so the GLB's own cans say\n // what that is: a 2700 K room glows warm and a 4000 K one glows cool,\n // instead of every room wearing the same amber. (A room with no cans\n // has no glow meshes either; the fallback is only ever a safety net.)\n let glowColor: Color | null = null;\n instance.traverse((node) => {\n const lamp = node as PointLight;\n if (\n !glowColor &&\n (lamp.isPointLight || (node as SpotLight).isSpotLight) &&\n !/^accent\\./.test(node.name)\n ) {\n glowColor = lamp.color.clone();\n }\n });\n // Emissive, at the strength the room designs its cans for, so this one\n // mesh is right in the viewport, right in the trace, and right in a\n // baked embed. (A MeshBasicMaterial would read to the renderer as an\n // emitter at 1.) The renderer drops its own disc when a stand-in ships,\n // so this is the only one in the scene.\n const glow = new MeshStandardMaterial({\n color: 0x000000,\n emissive: glowColor ?? new Color('#ffd9a8'),\n emissiveIntensity: FIXTURE_GLOW_STRENGTH,\n roughness: 1,\n });\n\n instance.traverse((node) => {\n const mesh = node as Mesh;\n if (mesh.isMesh) {\n // The loader cache owns the source geometry; an instance gets its own.\n // A bakeable room ships it, so it is also made plain: the preview is\n // meshopt-quantized (int16 positions, interleaved), and the render\n // worker reads a shipped mesh back by its float positions to carry\n // the unwrap onto the developer's geometry.\n mesh.geometry = options.bake\n ? plainFloatGeometry(mesh.geometry.clone())\n : mesh.geometry.clone();\n mesh.castShadow = true;\n mesh.receiveShadow = true;\n const n = plainName(mesh);\n if (n.startsWith('wall'))\n mesh.material = preset(walls.material, walls.color);\n else if (n.startsWith('floor'))\n mesh.material = preset(floor.material, floor.color);\n else if (n.startsWith('ceiling'))\n mesh.material = preset(ceiling.material, ceiling.color);\n else if (n.startsWith('sill')) mesh.material = preset(sill);\n else if (n.startsWith('glass') || n.startsWith('skylightglass')) {\n mesh.material = glass;\n mesh.castShadow = false;\n // Preview glass never ships: a transmissive pane would stop the\n // sun and the sky at the window in a path tracer that traces no\n // caustics. The renderer keeps its own panes, which let shadow and\n // diffuse rays through, even when the rest of the stand-in ships.\n mesh.userData.bakery3 = {\n ...(mesh.userData.bakery3 ?? {}),\n exclude: true,\n };\n } else if (n.startsWith('fixtureglow')) {\n mesh.material = glow;\n // A light's own face, not a surface light lands on: it ships (a\n // baked room with holes where its downlights are is the bug this\n // replaced) but it is never a bake candidate.\n mesh.userData.bakery3 = {\n ...(mesh.userData.bakery3 ?? {}),\n bake: false,\n };\n } else if (n.startsWith('covestrip')) {\n mesh.material = glow;\n // The cove's LED channel. Unlike a can's face this one is\n // concealed (a cove is built so the room sees a lit recess and\n // never the diode), so nothing is lost by leaving it out, and the\n // renderer's own strip is the designed one.\n mesh.userData.bakery3 = {\n ...(mesh.userData.bakery3 ?? {}),\n exclude: true,\n };\n } else if (n.startsWith('fixturebezel'))\n mesh.material = plain('#1a1a1c', 0.4);\n else if (\n n.startsWith('frame') ||\n n.startsWith('baseboard') ||\n n.startsWith('skylightcurb') ||\n n.startsWith('coveledge')\n ) {\n mesh.material = plain('#eeeae2', 0.35);\n } else if (n.startsWith('shelf') || n.startsWith('bookcase')) {\n const wore = strippedPreset(mesh);\n mesh.material = preset(wore?.material ?? SHELF_MATERIAL, wore?.color);\n } else if (n.startsWith('rug')) {\n mesh.material = new MeshPhysicalMaterial({\n color: '#8a7a68',\n roughness: 0.95,\n sheen: 1,\n sheenRoughness: 0.4,\n });\n } else if (n.startsWith('pedestal')) {\n mesh.material = info.stand.material\n ? preset(info.stand.material)\n : plain('#d9d6d0');\n } else {\n // A piece whose preset material was stripped for export says which\n // one it wore, and gets it back. Anything else keeps the material\n // it came with; only the clone is ours.\n const wore = strippedPreset(mesh);\n if (wore) mesh.material = preset(wore.material, wore.color);\n else {\n const materials = Array.isArray(mesh.material)\n ? mesh.material\n : [mesh.material];\n const cloned = materials.map((m) => m.clone());\n mesh.material = Array.isArray(mesh.material) ? cloned : cloned[0]!;\n coerceDefaultMaterial(mesh);\n }\n }\n }\n });\n\n // The stand. The published one travels in the GLB under a group named\n // 'stand'; a different choice replaces its contents with that pedestal,\n // placed the way the room places it: footprint centered, base on the floor.\n const standGroup = instance.getObjectByName('stand');\n if (standGroup && options.pedestal !== undefined) {\n for (const child of [...standGroup.children]) standGroup.remove(child);\n standGroup.position.set(0, 0, 0);\n standGroup.rotation.set(0, 0, 0);\n if (standType) {\n const object = createPedestal({\n type: standType as PedestalPresetName,\n ...(standMaterial\n ? { material: standMaterial as MaterialPresetName }\n : {}),\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n materialOptions,\n });\n object.rotation.y = MathUtils.degToRad(info.stand.rotationDeg);\n object.position.set(info.stand.x, 0, info.stand.z);\n standGroup.add(object);\n }\n } else if (standGroup && standMaterial) {\n // The published baked pedestal, wearing its published material; the\n // GLB carries none (preset materials are stripped before export).\n standGroup.traverse((node) => {\n if ((node as Mesh).isMesh)\n (node as Mesh).material = preset(standMaterial);\n });\n }\n\n // Lights, renormalized for a viewport (see MODE_LOOK), then the whole\n // rig scaled by the room's published preview brightness: a skylit room\n // gets most of its light from bounce the viewport cannot compute, so\n // one fill per mode reads as a cave in one room and a whiteout in the\n // next. The number is published per mode, and the render never sees it.\n const brightness = info.previewBrightness[lighting];\n // The dome at this rig's scale: every lamp is its W/m² times look.sun\n // times the knob, so the map is the same multiple of its radiance and\n // the view through the glass keeps the render's ratio to the sunlit floor.\n if (dome && hdriChoice) {\n ((dome as Mesh).material as MeshBasicMaterial).color.setScalar(\n hdriChoice.exposure * look.sun * brightness,\n );\n }\n const lights: Object3D[] = [];\n instance.traverse((node) => {\n if ((node as DirectionalLight).isLight) lights.push(node);\n });\n // Whatever ships of the stand-in, its lights never do: they are the\n // viewport's renormalized stand-ins for a rig the renderer builds itself.\n for (const light of lights)\n light.userData.bakery3 = {\n ...(light.userData.bakery3 ?? {}),\n exclude: true,\n };\n if (options.lights === false) {\n for (const light of lights) light.parent?.remove(light);\n } else {\n const reach = Math.max(info.size.width, info.size.depth);\n for (const light of lights) {\n if ((light as DirectionalLight).isDirectionalLight) {\n const sun = light as DirectionalLight;\n // A night or overcast room has no sun; the rig in the GLB is the\n // published mode's, so the sun is simply switched off for those.\n sun.visible = lighting === 'day' || lighting === 'golden';\n sun.intensity = 3.5 * look.sun * brightness;\n sun.castShadow = true;\n sun.shadow.mapSize.set(2048, 2048);\n sun.shadow.camera.left = -reach;\n sun.shadow.camera.right = reach;\n sun.shadow.camera.top = reach;\n sun.shadow.camera.bottom = -reach;\n sun.shadow.camera.far = 60;\n sun.shadow.bias = -0.0002;\n sun.shadow.normalBias = 0.02;\n if (sun.target && !sun.target.parent) instance.add(sun.target);\n } else if (\n /^accent\\./.test(light.name) &&\n ((light as PointLight).isPointLight ||\n (light as SpotLight).isSpotLight)\n ) {\n // The accent: the room's one IES spot over the centerpiece, which\n // the GLB can only carry as a bare point light; capped like a can\n // it would flood the room with light the render never has. Swap in\n // a spot where it hangs, aimed the way it was (glTF lights point\n // down local -Z), its beam from its name, its level from the\n // exported candela put back into watts and through the sun's\n // W to viewport scale.\n const lamp = light as PointLight;\n const beam =\n ACCENT_BEAM[light.name.split('.')[1] as keyof typeof ACCENT_BEAM] ??\n ACCENT_BEAM.narrow;\n const watts = (lamp.intensity * 4 * Math.PI) / 683;\n const spot = new SpotLight(\n lamp.color,\n watts * IES_PEAK_PER_WATT * look.sun * brightness,\n );\n spot.name = light.name;\n spot.angle = MathUtils.degToRad(beam.angleDeg);\n spot.penumbra = beam.penumbra;\n spot.decay = 2;\n spot.distance = 0;\n spot.castShadow = true;\n spot.shadow.mapSize.set(1024, 1024);\n spot.shadow.bias = -0.0002;\n spot.shadow.normalBias = 0.02;\n spot.position.copy(lamp.position);\n spot.target.position\n .copy(lamp.position)\n .add(new Vector3(0, 0, -2).applyQuaternion(lamp.quaternion));\n spot.userData.bakery3 = { exclude: true };\n spot.target.userData.bakery3 = { exclude: true };\n const parent = lamp.parent ?? instance;\n parent.remove(lamp);\n parent.add(spot, spot.target);\n } else if (\n (light as PointLight).isPointLight ||\n (light as SpotLight).isSpotLight\n ) {\n const lamp = light as PointLight;\n const watts = lamp.intensity / CANDELA_PER_WATT / DOWNLIGHT_SCALE;\n lamp.intensity =\n look.point * Math.min(1, watts / CAN_FULL_WATTS) * brightness;\n lamp.decay = 2;\n lamp.distance = 0;\n lamp.castShadow = false;\n }\n }\n const colors = hemisphereFill(look, info.previewFill?.[lighting]);\n const fill = new HemisphereLight(\n colors.sky,\n colors.ground,\n look.hemi * brightness * colors.intensity,\n );\n fill.name = 'fill';\n fill.userData.bakery3 = { exclude: true };\n instance.add(fill);\n }\n\n // The exporter's camera rides along in the GLB; the developer has their own.\n for (const camera of instance.children.filter(\n (c) => (c as PerspectiveCamera).isCamera,\n )) {\n instance.remove(camera);\n }\n room.add(instance);\n\n // The developer's own pictures in the room's frames. Last, because the\n // material chain above has just given every mesh its material and this\n // replaces one of them; and awaited, because `userData.ready` is what\n // the whole page waits on before it frames a shot.\n if (options.pictures?.length) {\n const hung = await hangPictures(instance, options.pictures, name);\n // A list of nothing but nulls changed no frame, so it says nothing in\n // the record either: the record is in the render cache key, and an\n // empty choice must not re-address a render.\n if (hung.hashes.some(Boolean)) {\n state.pictures = hung.hashes;\n room.userData.bakery3Preset = {\n ...(room.userData.bakery3Preset as object),\n roomPreset: state,\n pictureAssets: hung.assets,\n };\n }\n }\n\n if (options.simplify !== false) stampRoomStandIns(instance, info.plants);\n stampRoomIds(room, name);\n return room;\n });\n\n // The room's own traced light, from the library, once the stand-in is in.\n // Not part of `ready`: a page frames its shot without waiting on tens of\n // megabytes of lightmaps. A stand in another finish is another stand, so\n // that is a change the record does not show and this has to check itself.\n room.userData.prebaked =\n options.prebaked === false || options.pedestalMaterial\n ? Promise.resolve(null)\n : (room.userData.ready as Promise<Group>).then(\n () =>\n applyRoomPrebake(\n room,\n state,\n options.baseUrl ?? presetBaseUrl(),\n info.presetsVersion,\n ),\n () => null,\n );\n\n return room as PresetRoom;\n}\n\n/**\n * The room's sky over the map's, luminance only, so a map keeps its color\n * and gains the room's brightness. 1 for a map never measured.\n */\nfunction hdriExposure(roomSky: number, mapSky: number): number {\n if (!(mapSky > 0) || !(roomSky > 0)) return 1;\n return Math.round((roomSky / mapSky) * 1000) / 1000;\n}\n\n/**\n * The dome's sky is a sphere DOME_RADIUS out, well past the near ground, so\n * a camera whose `far` stops short of it draws the grass through the window\n * and clips everything above the horizon to black, with nothing in the\n * console to say why. Checked once, on the dome's first draw, after which\n * the hook removes itself and three's no-op shows through again.\n */\nfunction checkDomeReachOnce(dome: Object3D): void {\n dome.onBeforeRender = (_renderer, _scene, camera: Camera) => {\n delete (dome as Partial<Pick<Object3D, 'onBeforeRender'>>).onBeforeRender;\n const far = (camera as { far?: number }).far;\n if (typeof far !== 'number') return;\n const reach =\n DOME_RADIUS * dome.matrixWorld.getMaxScaleOnAxis() +\n camera\n .getWorldPosition(new Vector3())\n .distanceTo(dome.getWorldPosition(new Vector3()));\n if (far >= reach || typeof console === 'undefined') return;\n console.warn(\n [\n `[bakery3] The map outside this preset room hangs on a dome ${Math.round(reach)} m from the camera, but camera.far is ${far}:`,\n 'the sky through the windows is clipped to black. Set camera.far to 100 or more (then',\n 'camera.updateProjectionMatrix()), or pass hdri: false to createPresetRoom() for no map outside.',\n 'https://bakery3.com/docs/presets#room-presets',\n ].join('\\n'),\n );\n };\n}\n\n/**\n * The clockwise turn another map needs to put its sun where the room's is.\n * The published turn is `room sun − published map's sun`; the catalog does\n * not carry the maps' suns, so the render worker's rule is followed instead:\n * an unmeasured or non-daylit map is not turned, and a daylit one is turned\n * to the room's sun. Without the published map to read the room's sun from,\n * the map stays as shot; the render, which knows every map's sun, still\n * aims it.\n */\nfunction hdriTurn(\n name: HdriPresetName,\n published: { name: string; rotationDeg: number } | null,\n lighting: RoomPresetLighting,\n): number {\n const category = HDRI_PRESETS[name].category;\n if (category !== 'day' && category !== 'golden') return 0;\n if (\n published &&\n HDRI_PRESETS[published.name as HdriPresetName]?.category === category\n )\n return published.rotationDeg;\n return lighting === 'day' || lighting === 'golden'\n ? (published?.rotationDeg ?? 0)\n : 0;\n}\n\n/**\n * The same geometry with every attribute a dense Float32 array. A meshopt\n * preview arrives with normalized int16 positions and normals in one\n * interleaved buffer; three draws that fine, but it is not what a mesh the\n * developer wrote looks like, and the render worker matches a shipped mesh\n * back to the browser's by its float positions. Reading through the\n * attribute's own accessors applies the normalization, so the values are\n * the ones three uses.\n */\nexport function plainFloatGeometry(geometry: BufferGeometry): BufferGeometry {\n for (const name of Object.keys(geometry.attributes)) {\n const attribute = geometry.getAttribute(name);\n const plain =\n (attribute as { isInterleavedBufferAttribute?: boolean })\n .isInterleavedBufferAttribute === undefined &&\n attribute.array instanceof Float32Array &&\n !attribute.normalized;\n if (plain) continue;\n const size = attribute.itemSize;\n const out = new Float32Array(attribute.count * size);\n const get = [\n attribute.getX,\n attribute.getY,\n attribute.getZ,\n attribute.getW,\n ] as Array<(i: number) => number>;\n for (let i = 0; i < attribute.count; i++) {\n for (let c = 0; c < size; c++)\n out[i * size + c] = get[c]!.call(attribute, i);\n }\n geometry.setAttribute(name, new Float32BufferAttribute(out, size));\n }\n return geometry;\n}\n\nexport {\n findPresetRooms,\n roomPresetFactsOf,\n roomPresetSpecOf,\n} from './roomState.js';\n\n/** A room's camera: a 36 mm horizontal sensor, so the vertical FOV follows the aspect. */\nexport function roomLensFovDeg(lensMm: number, aspect: number): number {\n const sensorV = aspect >= 1 ? 36 / aspect : 36;\n return MathUtils.radToDeg(2 * Math.atan(sensorV / (2 * lensMm)));\n}\n\n/**\n * Put `camera` where the room was published from (its own framing, aimed at\n * the stand), in world space, wherever the group sits.\n */\nexport function applyPresetRoomCamera(\n camera: PerspectiveCamera,\n room: Object3D,\n): void {\n const state = roomPresetSpecOf(room);\n if (!state)\n throw new Error(\n 'applyPresetRoomCamera needs a group made by createPresetRoom().',\n );\n const info = ROOM_PRESETS[state.name as RoomPresetName];\n const world = new Matrix4().fromArray(state.matrix);\n const position = new Vector3(...info.camera.position).applyMatrix4(world);\n const target = new Vector3(...info.camera.target).applyMatrix4(world);\n camera.position.copy(position);\n camera.lookAt(target);\n camera.fov = roomLensFovDeg(info.camera.lensMm, camera.aspect || 1);\n camera.updateProjectionMatrix();\n}\n\n/** The room's footprint in its own frame: handy for clamping an orbit inside it. */\nexport function presetRoomBounds(name: RoomPresetName): Box3 {\n const { width, height, depth } = ROOM_PRESETS[name].size;\n return new Box3(\n new Vector3(-width / 2, 0, -depth / 2),\n new Vector3(width / 2, height, depth / 2),\n );\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Bakery3Error } from './chunk-3G5QL4F4.js';
|
|
2
|
+
|
|
3
|
+
// src/capture/hash.ts
|
|
4
|
+
async function sha256(bytes) {
|
|
5
|
+
const subtle = globalThis.crypto?.subtle;
|
|
6
|
+
if (!subtle) {
|
|
7
|
+
throw new Bakery3Error({
|
|
8
|
+
code: "CaptureFailed",
|
|
9
|
+
message: "Content hashing needs crypto.subtle, which this page does not have.",
|
|
10
|
+
why: "crypto.subtle is only exposed on secure origins (https, or localhost).",
|
|
11
|
+
fix: "Serve your dev app over https or from localhost. Next.js: `next dev --experimental-https`.",
|
|
12
|
+
docs: "https://bakery3.com/docs/troubleshooting#secure-origin"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const view = bytes instanceof Uint8Array ? (
|
|
16
|
+
// A Uint8Array can be a window onto a larger buffer; hashing the whole
|
|
17
|
+
// buffer would silently hash bytes that are not part of this asset.
|
|
18
|
+
bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? bytes.buffer : bytes.slice().buffer
|
|
19
|
+
) : bytes;
|
|
20
|
+
const digest = await subtle.digest("SHA-256", view);
|
|
21
|
+
return `sha256:${toHex(new Uint8Array(digest))}`;
|
|
22
|
+
}
|
|
23
|
+
function toHex(bytes) {
|
|
24
|
+
let out = "";
|
|
25
|
+
for (const byte of bytes) out += byte.toString(16).padStart(2, "0");
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/presets/roomState.ts
|
|
30
|
+
function remembered(object) {
|
|
31
|
+
return object.userData?.bakery3Preset;
|
|
32
|
+
}
|
|
33
|
+
function roomPresetSpecOf(object) {
|
|
34
|
+
const state = remembered(object)?.roomPreset;
|
|
35
|
+
if (!state) return null;
|
|
36
|
+
object.updateMatrixWorld(true);
|
|
37
|
+
return { ...state, matrix: object.matrixWorld.toArray() };
|
|
38
|
+
}
|
|
39
|
+
function roomPresetFactsOf(object) {
|
|
40
|
+
return remembered(object)?.roomFacts ?? null;
|
|
41
|
+
}
|
|
42
|
+
function findPresetRooms(root) {
|
|
43
|
+
const found = [];
|
|
44
|
+
root.traverse((object) => {
|
|
45
|
+
if (remembered(object)?.roomPreset) found.push(object);
|
|
46
|
+
});
|
|
47
|
+
return found;
|
|
48
|
+
}
|
|
49
|
+
function roomPresetAssetsOf(object) {
|
|
50
|
+
return remembered(object)?.pictureAssets ?? [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/capture/environmentSource.ts
|
|
54
|
+
var ENVIRONMENT_SOURCES = /* @__PURE__ */ new WeakMap();
|
|
55
|
+
var PRESET_SOURCES = /* @__PURE__ */ new WeakSet();
|
|
56
|
+
function rememberEnvironmentSource(texture, source, options = {}) {
|
|
57
|
+
ENVIRONMENT_SOURCES.set(texture, source);
|
|
58
|
+
if (options.preset) PRESET_SOURCES.add(texture);
|
|
59
|
+
else PRESET_SOURCES.delete(texture);
|
|
60
|
+
}
|
|
61
|
+
function environmentSourceFor(texture) {
|
|
62
|
+
return ENVIRONMENT_SOURCES.get(texture);
|
|
63
|
+
}
|
|
64
|
+
function isPresetEnvironment(texture) {
|
|
65
|
+
return PRESET_SOURCES.has(texture);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { environmentSourceFor, findPresetRooms, isPresetEnvironment, rememberEnvironmentSource, roomPresetAssetsOf, roomPresetFactsOf, roomPresetSpecOf, sha256 };
|
|
69
|
+
//# sourceMappingURL=chunk-AF5BIELI.js.map
|
|
70
|
+
//# sourceMappingURL=chunk-AF5BIELI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/capture/hash.ts","../src/presets/roomState.ts","../src/capture/environmentSource.ts"],"names":[],"mappings":";;;AAcA,eAAsB,OAAO,KAAA,EAAkD;AAC7E,EAAA,MAAM,MAAA,GAAS,WAAW,MAAA,EAAQ,MAAA;AAClC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,YAAA,CAAa;AAAA,MACrB,IAAA,EAAM,eAAA;AAAA,MACN,OAAA,EACE,qEAAA;AAAA,MACF,GAAA,EAAK,wEAAA;AAAA,MACL,GAAA,EAAK,4FAAA;AAAA,MACL,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,MAAM,OACJ,KAAA,YAAiB,UAAA;AAAA;AAAA;AAAA,IAGb,KAAA,CAAM,UAAA,KAAe,CAAA,IAAK,KAAA,CAAM,UAAA,KAAe,KAAA,CAAM,MAAA,CAAO,UAAA,GAC1D,KAAA,CAAM,MAAA,GACN,KAAA,CAAM,KAAA,EAAM,CAAE;AAAA,MAChB,KAAA;AACN,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,MAAA,CAAO,WAAW,IAAmB,CAAA;AACjE,EAAA,OAAO,UAAU,KAAA,CAAM,IAAI,UAAA,CAAW,MAAM,CAAC,CAAC,CAAA,CAAA;AAChD;AAEA,SAAS,MAAM,KAAA,EAA2B;AACxC,EAAA,IAAI,GAAA,GAAM,EAAA;AACV,EAAA,KAAA,MAAW,IAAA,IAAQ,OAAO,GAAA,IAAO,IAAA,CAAK,SAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,EAAG,GAAG,CAAA;AAClE,EAAA,OAAO,GAAA;AACT;;;ACTA,SAAS,WAAW,MAAA,EAA0C;AAC5D,EAAA,OAAO,OAAO,QAAA,EAAU,aAAA;AAC1B;AAGO,SAAS,i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AAe,IAAI,OAAO,CAAA;AACnC","file":"chunk-AF5BIELI.js","sourcesContent":["/**\n * Content hashing.\n *\n * SHA-256 over the exact bytes, so the same GLB produced twice is uploaded\n * once and the second render of a scene uploads only the manifest.\n *\n * `crypto.subtle` is only available on a secure origin. That is a real\n * constraint on `http://192.168.x.x:3000`, which is exactly how a developer\n * tests a configurator on their phone, so the failure says so instead of\n * reading as a browser bug.\n */\n\nimport { Bakery3Error } from '../errors.js';\n\nexport async function sha256(bytes: ArrayBuffer | Uint8Array): Promise<string> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) {\n throw new Bakery3Error({\n code: 'CaptureFailed',\n message:\n 'Content hashing needs crypto.subtle, which this page does not have.',\n why: 'crypto.subtle is only exposed on secure origins (https, or localhost).',\n fix: 'Serve your dev app over https or from localhost. Next.js: `next dev --experimental-https`.',\n docs: 'https://bakery3.com/docs/troubleshooting#secure-origin',\n });\n }\n const view =\n bytes instanceof Uint8Array\n ? // A Uint8Array can be a window onto a larger buffer; hashing the whole\n // buffer would silently hash bytes that are not part of this asset.\n bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength\n ? bytes.buffer\n : bytes.slice().buffer\n : bytes;\n const digest = await subtle.digest('SHA-256', view as ArrayBuffer);\n return `sha256:${toHex(new Uint8Array(digest))}`;\n}\n\nfunction toHex(bytes: Uint8Array): string {\n let out = '';\n for (const byte of bytes) out += byte.toString(16).padStart(2, '0');\n return out;\n}\n","/**\n * What a preset room group remembers about itself, and how to read it back.\n *\n * Its own module because the capture reads it on every render, and the\n * capture must not import the room builder to do so: the builder pulls\n * GLTFLoader, GroundedSkybox and the whole room catalog out of three/addons,\n * and an app that never stands a product in a room should neither bundle them\n * nor need a three new enough to have them.\n */\n\nimport type { Object3D } from 'three';\nimport type { RoomPresetSpec } from '../protocol/index.js';\n\n/** A room's choices, as they travel in the manifest, without its placement. */\nexport type PresetRoomState = Omit<RoomPresetSpec, 'matrix'>;\n\n/** What the compatibility report says about a room, copied from its catalog entry when it is built. */\nexport type PresetRoomFacts = { label: string; triangles: number };\n\n/** A picture the developer hung, hashed and kept so the capture can upload it. */\nexport type PresetRoomAsset = {\n hash: string;\n contentType: string;\n data: ArrayBuffer;\n name: string;\n};\n\ntype Remembered = {\n roomPreset?: PresetRoomState;\n roomFacts?: PresetRoomFacts;\n pictureAssets?: PresetRoomAsset[];\n};\n\nfunction remembered(object: Object3D): Remembered | undefined {\n return object.userData?.bakery3Preset as Remembered | undefined;\n}\n\n/** The record the capture writes for a room group, or null for any other object. */\nexport function roomPresetSpecOf(object: Object3D): RoomPresetSpec | null {\n const state = remembered(object)?.roomPreset;\n if (!state) return null;\n object.updateMatrixWorld(true);\n return { ...state, matrix: object.matrixWorld.toArray() };\n}\n\n/** The label and preview size a room group was built with, when it recorded them. */\nexport function roomPresetFactsOf(object: Object3D): PresetRoomFacts | null {\n return remembered(object)?.roomFacts ?? null;\n}\n\n/** The room preset groups under `root`. Usually one; more than one is a capture error. */\nexport function findPresetRooms(root: Object3D): Object3D[] {\n const found: Object3D[] = [];\n root.traverse((object) => {\n if (remembered(object)?.roomPreset) found.push(object);\n });\n return found;\n}\n\n/**\n * The images the developer hung in this room, as bytes to upload.\n *\n * A plain render sends none of a room's geometry (the render worker rebuilds\n * it from the published definition), so a picture of the developer's own is\n * the one thing about a room that has to travel as an asset. Its hash is in\n * the record; these are the bytes behind it.\n */\nexport function roomPresetAssetsOf(object: Object3D): PresetRoomAsset[] {\n return remembered(object)?.pictureAssets ?? [];\n}\n","import type { Texture } from 'three';\n\n/**\n * The environment's full-quality source, remembered when its lightweight\n * three.js texture is loaded.\n *\n * By the time an HDRI is on `scene.environment` it may have been through\n * PMREM and no longer expose the original equirectangular pixels. A preset\n * environment also previews a small map while the render uses the full one.\n */\nconst ENVIRONMENT_SOURCES = new WeakMap<Texture, string | ArrayBuffer>();\n/** Textures whose source is a URL in the preset library, which the renderer\n * has and a manifest may name. */\nconst PRESET_SOURCES = new WeakSet<Texture>();\n\nexport function rememberEnvironmentSource(\n texture: Texture,\n source: string | ArrayBuffer,\n options: { preset?: boolean } = {},\n): void {\n ENVIRONMENT_SOURCES.set(texture, source);\n if (options.preset) PRESET_SOURCES.add(texture);\n else PRESET_SOURCES.delete(texture);\n}\n\nexport function environmentSourceFor(\n texture: Texture,\n): string | ArrayBuffer | undefined {\n return ENVIRONMENT_SOURCES.get(texture);\n}\n\n/** Whether that source is a preset environment, as opposed to a URL of the\n * developer's own. */\nexport function isPresetEnvironment(texture: Texture): boolean {\n return PRESET_SOURCES.has(texture);\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/protocol/manifest.ts
|
|
2
|
+
var PROTOCOL_VERSION = "5.0";
|
|
3
|
+
var PROTOCOL_VERSION_ROOM = "4.0";
|
|
4
|
+
var PROTOCOL_VERSION_ANIMATED = "3.0";
|
|
5
|
+
var PROTOCOL_VERSION_STILL = "2.0";
|
|
6
|
+
function protocolVersionFor(manifest) {
|
|
7
|
+
if (manifest.environment?.fog) return PROTOCOL_VERSION;
|
|
8
|
+
if (manifest.room) return PROTOCOL_VERSION_ROOM;
|
|
9
|
+
return manifest.animation ? PROTOCOL_VERSION_ANIMATED : PROTOCOL_VERSION_STILL;
|
|
10
|
+
}
|
|
11
|
+
var VIDEO_FORMATS = ["mp4", "webm"];
|
|
12
|
+
var SEQUENCE_FORMATS = ["png-sequence"];
|
|
13
|
+
function isVideoFormat(format) {
|
|
14
|
+
return VIDEO_FORMATS.includes(format);
|
|
15
|
+
}
|
|
16
|
+
function isSequenceFormat(format) {
|
|
17
|
+
return SEQUENCE_FORMATS.includes(format);
|
|
18
|
+
}
|
|
19
|
+
function isClipFormat(format) {
|
|
20
|
+
return format !== void 0 && (isVideoFormat(format) || isSequenceFormat(format));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/protocol/quality.ts
|
|
24
|
+
var QUALITY = {
|
|
25
|
+
/**
|
|
26
|
+
* "Show me roughly what this will look like." Cheap enough to sit inside a
|
|
27
|
+
* click, noisy enough that nobody will ship it.
|
|
28
|
+
*
|
|
29
|
+
* No denoiser, since version 3 (2026-10-03): with it, 32 samples of a
|
|
30
|
+
* product came out close to a studio render, so the cheapest tier was a
|
|
31
|
+
* finished image at half the price. The grain says draft, every choice a
|
|
32
|
+
* preview is for (framing, light, materials, color) still reads through
|
|
33
|
+
* it, and most of a preview's time was the denoiser.
|
|
34
|
+
*/
|
|
35
|
+
preview: {
|
|
36
|
+
version: 3,
|
|
37
|
+
samples: 32,
|
|
38
|
+
adaptiveThreshold: 0.08,
|
|
39
|
+
maxBounces: 4,
|
|
40
|
+
diffuseBounces: 2,
|
|
41
|
+
glossyBounces: 4,
|
|
42
|
+
transmissionBounces: 4,
|
|
43
|
+
denoise: false,
|
|
44
|
+
defaultLongEdge: 1024,
|
|
45
|
+
preview: false,
|
|
46
|
+
previewSamples: 16
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* The default. Deep enough on glossy and transmission to carry glaze,
|
|
50
|
+
* metal and glass, which is where a product shot lives, and shallow on
|
|
51
|
+
* diffuse, which buys almost nothing on a product against a transparent
|
|
52
|
+
* background. The threshold ends most pixels well before the ceiling; the
|
|
53
|
+
* denoiser carries the noisiest ones.
|
|
54
|
+
*/
|
|
55
|
+
studio: {
|
|
56
|
+
version: 2,
|
|
57
|
+
samples: 256,
|
|
58
|
+
adaptiveThreshold: 0.02,
|
|
59
|
+
maxBounces: 8,
|
|
60
|
+
diffuseBounces: 3,
|
|
61
|
+
glossyBounces: 8,
|
|
62
|
+
transmissionBounces: 8,
|
|
63
|
+
denoise: true,
|
|
64
|
+
defaultLongEdge: 2048,
|
|
65
|
+
preview: true,
|
|
66
|
+
previewSamples: 24
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* For the hero image that goes on the homepage. Roughly 8x studio's sample
|
|
70
|
+
* ceiling and a much stricter threshold.
|
|
71
|
+
*/
|
|
72
|
+
ultra: {
|
|
73
|
+
version: 1,
|
|
74
|
+
samples: 2048,
|
|
75
|
+
adaptiveThreshold: 5e-3,
|
|
76
|
+
maxBounces: 16,
|
|
77
|
+
diffuseBounces: 6,
|
|
78
|
+
glossyBounces: 16,
|
|
79
|
+
transmissionBounces: 16,
|
|
80
|
+
denoise: true,
|
|
81
|
+
defaultLongEdge: 4096,
|
|
82
|
+
preview: true,
|
|
83
|
+
previewSamples: 32
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/version.ts
|
|
88
|
+
var SDK_VERSION = "0.1.0";
|
|
89
|
+
|
|
90
|
+
export { QUALITY, SDK_VERSION, isClipFormat, isVideoFormat, protocolVersionFor };
|
|
91
|
+
//# sourceMappingURL=chunk-APBOWWSV.js.map
|
|
92
|
+
//# sourceMappingURL=chunk-APBOWWSV.js.map
|