@oeave/bakery3 0.0.0-stage → 0.2.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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +562 -2
  3. package/dist/animation-B1h0Ryvj.d.ts +97 -0
  4. package/dist/bake/index.d.ts +369 -0
  5. package/dist/bake/index.js +9 -0
  6. package/dist/bake/index.js.map +1 -0
  7. package/dist/bake-DZ-CJR6f.d.ts +1364 -0
  8. package/dist/catalog/index.d.ts +100 -0
  9. package/dist/catalog/index.js +154 -0
  10. package/dist/catalog/index.js.map +1 -0
  11. package/dist/catalog.gen-BM-aNf7n.d.ts +733 -0
  12. package/dist/chunk-3G5QL4F4.js +145 -0
  13. package/dist/chunk-3G5QL4F4.js.map +1 -0
  14. package/dist/chunk-4E5VV4QY.js +12 -0
  15. package/dist/chunk-4E5VV4QY.js.map +1 -0
  16. package/dist/chunk-62M6XXNX.js +142 -0
  17. package/dist/chunk-62M6XXNX.js.map +1 -0
  18. package/dist/chunk-6FYI6AJM.js +1157 -0
  19. package/dist/chunk-6FYI6AJM.js.map +1 -0
  20. package/dist/chunk-6NYR73Y7.js +832 -0
  21. package/dist/chunk-6NYR73Y7.js.map +1 -0
  22. package/dist/chunk-APWUCEEB.js +118 -0
  23. package/dist/chunk-APWUCEEB.js.map +1 -0
  24. package/dist/chunk-HNMSWQU7.js +1709 -0
  25. package/dist/chunk-HNMSWQU7.js.map +1 -0
  26. package/dist/chunk-JFYUDERE.js +1412 -0
  27. package/dist/chunk-JFYUDERE.js.map +1 -0
  28. package/dist/chunk-KNUAOILG.js +551 -0
  29. package/dist/chunk-KNUAOILG.js.map +1 -0
  30. package/dist/chunk-KZLVTSBI.js +191 -0
  31. package/dist/chunk-KZLVTSBI.js.map +1 -0
  32. package/dist/chunk-LAKXC4WR.js +2028 -0
  33. package/dist/chunk-LAKXC4WR.js.map +1 -0
  34. package/dist/chunk-NXBAZGNB.js +1107 -0
  35. package/dist/chunk-NXBAZGNB.js.map +1 -0
  36. package/dist/chunk-QRCT5UGZ.js +3286 -0
  37. package/dist/chunk-QRCT5UGZ.js.map +1 -0
  38. package/dist/chunk-S4AJTLLN.js +23 -0
  39. package/dist/chunk-S4AJTLLN.js.map +1 -0
  40. package/dist/chunk-UWBP7B54.js +92 -0
  41. package/dist/chunk-UWBP7B54.js.map +1 -0
  42. package/dist/chunk-XK35ANPJ.js +346 -0
  43. package/dist/chunk-XK35ANPJ.js.map +1 -0
  44. package/dist/chunk-Z7IYVH22.js +4781 -0
  45. package/dist/chunk-Z7IYVH22.js.map +1 -0
  46. package/dist/chunk-ZEBVAIJJ.js +156 -0
  47. package/dist/chunk-ZEBVAIJJ.js.map +1 -0
  48. package/dist/devtools/index.d.ts +536 -0
  49. package/dist/devtools/index.js +15 -0
  50. package/dist/devtools/index.js.map +1 -0
  51. package/dist/environments/index.d.ts +93 -0
  52. package/dist/environments/index.js +382 -0
  53. package/dist/environments/index.js.map +1 -0
  54. package/dist/hotspots/index.d.ts +111 -0
  55. package/dist/hotspots/index.js +285 -0
  56. package/dist/hotspots/index.js.map +1 -0
  57. package/dist/index.d.ts +975 -0
  58. package/dist/index.js +15 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/node/index.cjs +5240 -0
  61. package/dist/node/index.cjs.map +1 -0
  62. package/dist/node/index.d.cts +4927 -0
  63. package/dist/node/index.d.ts +597 -0
  64. package/dist/node/index.js +1328 -0
  65. package/dist/node/index.js.map +1 -0
  66. package/dist/prepare-BtjY4G3q.d.ts +112 -0
  67. package/dist/presets/index.d.ts +562 -0
  68. package/dist/presets/index.js +14 -0
  69. package/dist/presets/index.js.map +1 -0
  70. package/dist/r3f/index.d.ts +159 -0
  71. package/dist/r3f/index.js +592 -0
  72. package/dist/r3f/index.js.map +1 -0
  73. package/dist/room-FS26KAPQ.js +9 -0
  74. package/dist/room-FS26KAPQ.js.map +1 -0
  75. package/dist/rooms.gen-DItzBR9k.d.ts +1462 -0
  76. package/dist/session-VCIQEO26.js +9 -0
  77. package/dist/session-VCIQEO26.js.map +1 -0
  78. package/dist/shapes/index.d.ts +222 -0
  79. package/dist/shapes/index.js +836 -0
  80. package/dist/shapes/index.js.map +1 -0
  81. package/dist/testRun-20OARnQr.d.ts +1139 -0
  82. package/dist/timeline-ChwgD7bT.d.ts +470 -0
  83. package/dist/tsl/index.d.ts +165 -0
  84. package/dist/tsl/index.js +310 -0
  85. package/dist/tsl/index.js.map +1 -0
  86. package/package.json +170 -4
@@ -0,0 +1,369 @@
1
+ export { B as BakeSimplifyInput, P as PrepareBakeSettings } from '../prepare-BtjY4G3q.js';
2
+ import { Mesh, Object3D, Texture, Scene } from 'three';
3
+ import { j as BakeBundle } from '../bake-DZ-CJR6f.js';
4
+ export { r as BAKE_TEXTURE_SIZES, a as BakeQuality, i as BakeSettings, e as BakeSpec, B as BakeTextureSize, s as MAX_BAKE_OBJECTS, t as MAX_BAKE_TEXELS } from '../bake-DZ-CJR6f.js';
5
+ import '../animation-B1h0Ryvj.js';
6
+
7
+ /**
8
+ * Which of your meshes can take a lightmap, and, for the ones that cannot,
9
+ * why and what to do about it.
10
+ *
11
+ * The SDK decides this, not the render worker: the worker sees a GLB, which
12
+ * has already flattened a `MeshPhysicalNodeMaterial` into something plausible
13
+ * and lost the fact that it was transmissive. The SDK is looking at the live
14
+ * material. So `bake.include` leaves the browser explicit and authoritative,
15
+ * and every mesh that did not make the list carries a `reason` the panel can
16
+ * show in place: never a silent skip.
17
+ *
18
+ * Two different verdicts live here:
19
+ *
20
+ * `bakeable: false`: a lightmap cannot be applied to this at all. The
21
+ * checkbox is disabled and the reason says why.
22
+ * `defaultInclude: false`: it would work, but baking it is probably not
23
+ * what you meant (glass, a hidden variant, something you opted out of).
24
+ * The checkbox is off and you can turn it on.
25
+ */
26
+
27
+ /** A refusal, per object, with the same fields as `BakeSkip` and
28
+ * `PreflightIssue`, so a reason from here and one from the render worker
29
+ * read identically in the panel. */
30
+ type BakeCandidateReason = {
31
+ code: string;
32
+ message: string;
33
+ why?: string;
34
+ fix?: string;
35
+ };
36
+ type BakeCandidate = {
37
+ /** The id this object travels under: `userData.bakery3Id` or its uuid. */
38
+ objectId: string;
39
+ object: Mesh;
40
+ /** For humans: the three name, falling back to the graph path. */
41
+ name: string;
42
+ /** Where in the scene graph it lives, for a tooltip. */
43
+ path: string;
44
+ /** Can a lightmap be applied to this mesh at all? */
45
+ bakeable: boolean;
46
+ /** Present whenever there is something to say: on a refusal and on a
47
+ * bakeable object that is off by default. */
48
+ reason?: BakeCandidateReason;
49
+ /** Whether the checkbox starts ticked. Always false when `!bakeable`. */
50
+ defaultInclude: boolean;
51
+ };
52
+ /**
53
+ * Every mesh in the scene, classified.
54
+ *
55
+ * Excluded objects (helpers, gizmos, `userData.bakery3.exclude`) are not
56
+ * listed at all: they never reach the renderer, so there is nothing to
57
+ * explain. Everything else appears, including the things that cannot be
58
+ * baked, because a list that quietly omits the instanced chairs is exactly
59
+ * the list that makes a developer think the bake covered them.
60
+ */
61
+ declare function bakeCandidates(options: {
62
+ scene: Object3D;
63
+ }): BakeCandidate[];
64
+
65
+ /**
66
+ * How a lightmap is combined with the lights that are still running.
67
+ *
68
+ * three adds a lightmap to everything else that lights a surface, which is
69
+ * right when only the bounce was baked and wrong here: a Bakery3 lightmap is
70
+ * the whole diffuse answer (direct light, bounce, ambient and the
71
+ * environment's diffuse) in one texture, so adding it to a scene whose lamps
72
+ * are still on counts everything twice. Muting the lights
73
+ * (`session.muteLights`) fixes the diffuse and breaks the specular: the
74
+ * highlight a lamp puts on a glossy floor is not in a lightmap, and an
75
+ * environment map cannot be muted without losing its reflections.
76
+ *
77
+ * So this module leaves every light on and changes what the diffuse lobe
78
+ * listens to: the lightmap alone. Specular keeps hearing the lamps and the
79
+ * environment map, which is the closest a rasterizer gets to the traced
80
+ * frame, with the lights exactly as you left them.
81
+ *
82
+ * Two renderers, one material. WebGLRenderer compiles GLSL from chunks, and
83
+ * `onBeforeCompile` inserts a few lines after the chunk that samples the
84
+ * lightmap: direct diffuse is discarded and the indirect irradiance is
85
+ * replaced by the lightmap's, routed through a physical material's
86
+ * energy-conserving path so a metal stays dark. WebGPURenderer (and its WebGL
87
+ * backend) builds node materials, and converts a classic material by copying
88
+ * its own properties across, which is what lets `setupLightMap` and
89
+ * `setupLightingModel`, assigned here as own properties, arrive on the node
90
+ * side and wrap the lighting model the same way. Nothing is imported from the
91
+ * node system, so an app that never touches WebGPU never downloads it.
92
+ *
93
+ * Reversible, like everything else in the bake: each hook records the
94
+ * property descriptor it replaced (your own `onBeforeCompile`, or nothing)
95
+ * and `off()` puts it back. Your own `onBeforeCompile` keeps running first,
96
+ * and your cache key is folded into ours, so two materials that differed
97
+ * before still compile to two programs after.
98
+ */
99
+
100
+ /**
101
+ * `'replace'`: the lightmap is the diffuse lighting, and lamps, ambient and
102
+ * the environment contribute specular only. The default, because it is what
103
+ * makes a baked scene match its traced still.
104
+ *
105
+ * `'add'`: three's stock behavior, the lightmap added on top of whatever else
106
+ * lights the surface. For a bake that deliberately contains only part of the
107
+ * lighting.
108
+ */
109
+ type BakeShading = 'replace' | 'add';
110
+
111
+ /**
112
+ * Putting the lightmaps on, and taking them off again.
113
+ *
114
+ * A bake is applied to your live meshes, in a running application, next to
115
+ * your r3f component graph and event handlers. That is only acceptable if it
116
+ * is exactly reversible, so nothing here mutates anything without first
117
+ * recording the reference or the value it replaced, and every mutation is a
118
+ * pair (`on`/`off`) over that record. `off()` restores references, not
119
+ * equivalents: the same `BufferAttribute` object, the same `Material` object,
120
+ * the same `lightMapIntensity` number. That pairing is also what makes
121
+ * hold-to-compare instant: it is `off()` then `on()` on a patch that is
122
+ * already built, so it flips within a frame.
123
+ *
124
+ * Three cases decide whether your geometry is touched:
125
+ *
126
+ * 1. `uv: { values }` and nobody else uses this geometry: the second UV set
127
+ * is written straight onto the existing geometry as `uv1`. Your
128
+ * `BufferGeometry` object survives, which matters in r3f, where a swapped
129
+ * geometry is a prop React does not know changed.
130
+ * 2. `uv: { topology }`: the unwrap split vertices, so a new geometry is
131
+ * built by gathering every original attribute (custom ones included)
132
+ * through `vertexSource`, and the mesh points at it. The original is kept,
133
+ * untouched, for revert.
134
+ * 3. The geometry is shared by another mesh that needs a different unwrap:
135
+ * the same rebuild, per mesh, because one geometry cannot hold two
136
+ * `uv1`s. Shared geometry whose sharers all got the same unwrap (25
137
+ * spheres from one `SphereGeometry`) is written once, in place.
138
+ *
139
+ * Materials follow the same logic: a material used by one mesh is mutated in
140
+ * place (its `lightMap` and `lightMapIntensity` saved first); one shared with
141
+ * another mesh is cloned, because two objects have two lightmaps and one
142
+ * material holds one.
143
+ */
144
+
145
+ /** A per-object refusal, with the same fields as the render worker's
146
+ * `BakeSkip`, so a skip that happened here and one that happened on the
147
+ * worker render the same way in the panel. */
148
+ type BakeApplySkip = {
149
+ objectId: string;
150
+ name?: string;
151
+ code: string;
152
+ message: string;
153
+ why?: string;
154
+ fix?: string;
155
+ };
156
+
157
+ /**
158
+ * A lightmap URI becomes a `THREE.Texture`, with the settings that make it
159
+ * land the right way up on the right UV set.
160
+ *
161
+ * Orientation is a contract, not a guess: the render worker encodes the flip
162
+ * at bake time, so the pixels and the UV values it ships are already correct
163
+ * for `EXRLoader`'s defaults. This module changes nothing: `flipY = false` on
164
+ * both the EXR and the PNG path, so an LDR fallback lands identically to the
165
+ * HDR one.
166
+ *
167
+ * The bake's unwrap is a second UV set (your own `uv` still maps your
168
+ * albedo). In three the second set is the `uv1` attribute, and
169
+ * `texture.channel = 1` is how a map selects it, under WebGLRenderer and
170
+ * WebGPURenderer alike.
171
+ *
172
+ * No mipmaps: a lightmap atlas is islands separated by a dilation margin, and
173
+ * mipping it averages across island boundaries, which shows as light leaking
174
+ * round the silhouette of every object at distance. Linear filtering with no
175
+ * mips is the right trade for a map that is already low-frequency.
176
+ */
177
+
178
+ type BakeTextureSource = {
179
+ /** Already resolved against the bundle's own location. */
180
+ url: string;
181
+ format: 'exr' | 'png';
182
+ /** For error messages: which object's lightmap this is. */
183
+ objectId: string;
184
+ size: number;
185
+ /** What the texture is for. A lightmap (the default) is configured by
186
+ * `configureLightmap`; the reflection probe by `configureProbe`. A factory
187
+ * of your own may ignore this: the session applies the probe's mapping
188
+ * itself either way. */
189
+ role?: 'lightmap' | 'probe' | 'color' | 'normal' | 'billboard' | 'shadow';
190
+ };
191
+ /**
192
+ * How a lightmap URI becomes a texture.
193
+ *
194
+ * Injectable for two reasons: a test wants a `DataTexture` and no
195
+ * network, and an application that already has a loading manager, a CDN
196
+ * rewrite or an auth header wants its own fetch in the loop.
197
+ */
198
+ type BakeTextureFactory = (source: BakeTextureSource) => Promise<Texture>;
199
+ /**
200
+ * Apply the settings above to a texture from any source.
201
+ *
202
+ * Exported because a caller supplying their own `BakeTextureFactory` still
203
+ * wants the channel, the color space and the filtering to be the ones the
204
+ * bake was authored against: those are part of the format, not of the
205
+ * loader.
206
+ */
207
+ declare function configureLightmap(texture: Texture, format: 'exr' | 'png'): Texture;
208
+
209
+ /**
210
+ * A bake session: generations of lighting you can step through, over one
211
+ * live scene.
212
+ *
213
+ * The session is the thing a panel binds to. It owns three pieces of state
214
+ * and nothing else: which bundles it knows about, which one is currently
215
+ * applied (`-1` means "your scene, untouched"), and whether the realtime
216
+ * lights are muted. Everything visible follows from those.
217
+ *
218
+ * Generations do not stack: `apply(i)` reverts to live first, every time.
219
+ * Applying generation 2 over generation 1 would leave generation 1's cloned
220
+ * materials and rebuilt geometries in the scene under generation 2's
221
+ * textures, and the second revert would restore the first bake rather than
222
+ * your scene.
223
+ *
224
+ * Generations are evicted: twelve objects at 2048² of half-float RGBA is
225
+ * around 400 MB of VRAM per generation, so only the applied generation and
226
+ * the most recent few keep their textures. The rest are disposed and
227
+ * reloaded on demand.
228
+ */
229
+
230
+ type BakeGeneration = {
231
+ /** Stable index into `session.generations`; generations are append-only. */
232
+ index: number;
233
+ /** What the stepper shows: `1024 · standard` unless the host names it. */
234
+ label: string;
235
+ bundle: BakeBundle;
236
+ baseUrl?: string;
237
+ /** When `addGeneration` was called, for "2m ago". */
238
+ createdAt: number;
239
+ /** True while this generation's textures are resident. */
240
+ loaded: boolean;
241
+ };
242
+ /**
243
+ * What one `apply()` actually managed to do.
244
+ *
245
+ * Reported rather than thrown, because a generation that no longer perfectly
246
+ * matches the scene is the normal case the moment you edit anything, and
247
+ * "applied 10 of 12, here are the other two" is more useful than either a
248
+ * failure or a lie.
249
+ */
250
+ type BakeApplyReport = {
251
+ /** The generation this report is about, or -1 for your scene untouched. */
252
+ generation: number;
253
+ /** objectIds whose lightmap landed. */
254
+ applied: string[];
255
+ /** Baked objects with nothing in the scene answering to their id. */
256
+ unmatched: string[];
257
+ /** Bakeable meshes in the scene this generation has no lightmap for. */
258
+ unbaked: string[];
259
+ /** Objects the apply refused, each with a reason and a fix. */
260
+ skipped: BakeApplySkip[];
261
+ /** objectIds that received the bake's reflection probe as `envMap`: the
262
+ * meshes the bake did not light (the product, the glass beside it). */
263
+ probed: string[];
264
+ /** Stand-ins that went into the scene, by their place in the request. */
265
+ standIns: number[];
266
+ /** objectIds out of sight because a stand-in took their place. */
267
+ replaced: string[];
268
+ /** Whether the bake's shadow plane is in the scene. */
269
+ shadow: boolean;
270
+ /**
271
+ * The prebaked preset room applied under this generation, and how many of
272
+ * its surfaces found a mesh. A bake in `room: 'preset'` mode covers only
273
+ * the product; this is where the rest of the light came from.
274
+ */
275
+ room?: {
276
+ name: string;
277
+ lighting: string;
278
+ applied: number;
279
+ unmatched: number;
280
+ };
281
+ /** Why the prebaked room is not on: it was wanted and did not load. The
282
+ * product's own lightmaps applied regardless. */
283
+ roomError?: string;
284
+ /** Why the bundle's probe is on nothing: it was wanted and did not load.
285
+ * The lightmaps applied regardless: a probe costs the product its
286
+ * reflections of the room and nothing else. */
287
+ probeError?: string;
288
+ };
289
+ type BakeSessionOptions = {
290
+ scene: Scene | Object3D;
291
+ /**
292
+ * Where the preset library lives, for a bundle that stands its objects in
293
+ * a prebaked room (`BakeBundle.room`). Defaults to the CDN the SDK ships
294
+ * with; a test points it somewhere else.
295
+ */
296
+ presetBaseUrl?: string;
297
+ /**
298
+ * How a lightmap uri becomes a texture. Defaults to EXRLoader/TextureLoader
299
+ * with the channel, color space and filtering the format requires.
300
+ * Injected by tests, and by applications that need their own fetch.
301
+ */
302
+ textureFactory?: BakeTextureFactory;
303
+ /** `lightMapIntensity` to write. Default 1: the bake is already in the
304
+ * scene's own light units. */
305
+ intensity?: number;
306
+ /**
307
+ * How the lightmap meets the lights that keep running. `'replace'` (the
308
+ * default) makes it the only diffuse lighting while lamps and the
309
+ * environment still supply specular, the combination that matches the
310
+ * traced still. `'add'` is three's stock behavior, for a bake that
311
+ * deliberately holds only part of the light. See shading.ts.
312
+ */
313
+ shading?: BakeShading;
314
+ /**
315
+ * Put the bake's reflection probe on the objects it did not light, as
316
+ * `envMap`, so a product kept live in a baked room reflects that room
317
+ * rather than the scene's own environment. Default `true`; `false` leaves
318
+ * every material's environment as you set it. See probe.ts.
319
+ */
320
+ probe?: boolean;
321
+ /** How many generations keep their textures. Default 3. */
322
+ residentGenerations?: number;
323
+ };
324
+ type BakeSession = {
325
+ readonly generations: readonly BakeGeneration[];
326
+ /** Index of the applied generation, or -1 when none is (see `revert()`). */
327
+ readonly current: number;
328
+ /** The last apply's report, for the panel's "what didn't match" line. */
329
+ readonly lastReport: BakeApplyReport | null;
330
+ /** True while `compare(true)` is showing the live scene under an applied
331
+ * generation: the applied state is still there, just switched off. */
332
+ readonly comparing: boolean;
333
+ readonly lightsMuted: boolean;
334
+ /** Whether an applied bake puts its reflection probe on the objects it did
335
+ * not light. The `probe` option, until `setProbe` changes it. */
336
+ readonly probe: boolean;
337
+ /** Which meshes could be baked, and why the others could not. */
338
+ candidates(): BakeCandidate[];
339
+ /** Remember a bundle. Textures are not fetched until it is applied. */
340
+ addGeneration(bundle: BakeBundle, options?: {
341
+ baseUrl?: string;
342
+ label?: string;
343
+ }): number;
344
+ /** Revert to live, then apply generation `index`. `revert()` goes back to live. */
345
+ apply(index: number): Promise<BakeApplyReport>;
346
+ /** Back to your scene, exactly. */
347
+ revert(): void;
348
+ /** Hold-to-compare: `true` shows live, `false` puts the bake back. Neither
349
+ * loses the applied patch, so both are instant and lossless. */
350
+ compare(showLive: boolean): void;
351
+ /**
352
+ * The reflection probe on or off. With a generation applied this re-applies
353
+ * it, so the change shows at once and the report says which objects carry
354
+ * the probe; turning it on for the first time fetches the file.
355
+ */
356
+ setProbe(on: boolean): Promise<BakeApplyReport>;
357
+ /**
358
+ * Realtime lights to zero and back. Under the default `'replace'` shading
359
+ * the lamps only add specular, so this shows the bake's diffuse on its own;
360
+ * under `'add'` it is what stops the lamps being counted twice.
361
+ */
362
+ muteLights(on: boolean): void;
363
+ on(event: 'change', listener: (session: BakeSession) => void): () => void;
364
+ /** Revert, drop every texture, restore the lights. */
365
+ dispose(): void;
366
+ };
367
+ declare function createBakeSession(options: BakeSessionOptions): BakeSession;
368
+
369
+ export { type BakeApplyReport, type BakeApplySkip, BakeBundle, type BakeCandidate, type BakeCandidateReason, type BakeGeneration, type BakeSession, type BakeSessionOptions, type BakeShading, type BakeTextureFactory, type BakeTextureSource, bakeCandidates, configureLightmap, createBakeSession };
@@ -0,0 +1,9 @@
1
+ export { configureLightmap, createBakeSession } from '../chunk-KNUAOILG.js';
2
+ export { bakeCandidates } from '../chunk-JFYUDERE.js';
3
+ import '../chunk-4E5VV4QY.js';
4
+ export { BAKE_TEXTURE_SIZES, MAX_BAKE_OBJECTS, MAX_BAKE_TEXELS } from '../chunk-APWUCEEB.js';
5
+ import '../chunk-6NYR73Y7.js';
6
+ import '../chunk-LAKXC4WR.js';
7
+ import '../chunk-3G5QL4F4.js';
8
+ //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}