@oeave/bakery3 0.2.0 → 0.3.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 (46) hide show
  1. package/dist/bake/index.js +3 -3
  2. package/dist/catalog/index.js +1 -1
  3. package/dist/{chunk-KNUAOILG.js → chunk-3T3FJOSD.js} +4 -4
  4. package/dist/{chunk-KNUAOILG.js.map → chunk-3T3FJOSD.js.map} +1 -1
  5. package/dist/{chunk-6FYI6AJM.js → chunk-6FAMQZXB.js} +7 -7
  6. package/dist/{chunk-6FYI6AJM.js.map → chunk-6FAMQZXB.js.map} +1 -1
  7. package/dist/{chunk-QRCT5UGZ.js → chunk-CSSJRP5W.js} +9 -6
  8. package/dist/chunk-CSSJRP5W.js.map +1 -0
  9. package/dist/{chunk-APWUCEEB.js → chunk-EN4ROBYQ.js} +3 -3
  10. package/dist/{chunk-APWUCEEB.js.map → chunk-EN4ROBYQ.js.map} +1 -1
  11. package/dist/{chunk-JFYUDERE.js → chunk-NEK5TBEH.js} +2 -2
  12. package/dist/chunk-NEK5TBEH.js.map +1 -0
  13. package/dist/chunk-OPM2L63B.js +253 -0
  14. package/dist/chunk-OPM2L63B.js.map +1 -0
  15. package/dist/{chunk-UWBP7B54.js → chunk-R5IUPOWI.js} +3 -3
  16. package/dist/{chunk-UWBP7B54.js.map → chunk-R5IUPOWI.js.map} +1 -1
  17. package/dist/{chunk-HNMSWQU7.js → chunk-STRK4SZN.js} +3 -3
  18. package/dist/{chunk-HNMSWQU7.js.map → chunk-STRK4SZN.js.map} +1 -1
  19. package/dist/{chunk-Z7IYVH22.js → chunk-WLEFNUOH.js} +30 -279
  20. package/dist/chunk-WLEFNUOH.js.map +1 -0
  21. package/dist/{chunk-NXBAZGNB.js → chunk-X6GW43EX.js} +3 -3
  22. package/dist/{chunk-NXBAZGNB.js.map → chunk-X6GW43EX.js.map} +1 -1
  23. package/dist/devtools/index.js +7 -6
  24. package/dist/hotspots/index.d.ts +237 -31
  25. package/dist/hotspots/index.js +1013 -118
  26. package/dist/hotspots/index.js.map +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +7 -6
  29. package/dist/node/index.cjs +1 -1
  30. package/dist/node/index.cjs.map +1 -1
  31. package/dist/node/index.js +2 -2
  32. package/dist/presets/index.js +2 -2
  33. package/dist/r3f/index.js +9 -8
  34. package/dist/r3f/index.js.map +1 -1
  35. package/dist/{room-FS26KAPQ.js → room-BM7Z7NKG.js} +4 -4
  36. package/dist/{room-FS26KAPQ.js.map → room-BM7Z7NKG.js.map} +1 -1
  37. package/dist/session-NPVBESWA.js +9 -0
  38. package/dist/{session-VCIQEO26.js.map → session-NPVBESWA.js.map} +1 -1
  39. package/dist/tsl/index.d.ts +14 -1
  40. package/dist/tsl/index.js +8 -2
  41. package/dist/tsl/index.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-JFYUDERE.js.map +0 -1
  44. package/dist/chunk-QRCT5UGZ.js.map +0 -1
  45. package/dist/chunk-Z7IYVH22.js.map +0 -1
  46. package/dist/session-VCIQEO26.js +0 -9
@@ -1,10 +1,11 @@
1
1
  import { captureCamera } from './chunk-62M6XXNX.js';
2
- import { protocolVersionFor, SDK_VERSION, QUALITY } from './chunk-UWBP7B54.js';
2
+ import { protocolVersionFor, SDK_VERSION, QUALITY } from './chunk-R5IUPOWI.js';
3
3
  import { BAKERY_NODE_MARKER, builtinFor, tslRuntimeRegistered, toNodeObject } from './chunk-S4AJTLLN.js';
4
4
  import { sha256, environmentSourceFor, isPresetEnvironment } from './chunk-KZLVTSBI.js';
5
- import { idOf, shouldExclude, captureFog, scenePath, captureLights, captureRuntime, stampIds, captureEnvironmentSettings, excludedItself, readUserData, bakeCandidates, resolveProbe, defaultIncludeIds, quantizeBakeView, bakeBounds, isBakeWrittenUv, ID_KEY } from './chunk-JFYUDERE.js';
6
- import { findPresetRooms, roomShownBaked, roomPresetFactsOf, roomPresetSpecOf, roomPresetAssetsOf, MAX_BAKE_OBJECTS, MAX_BAKE_TEXELS, roomIsPrebaked, roomPrebakeChanges, MAX_BAKE_SIMPLIFY, BAKE_TEXTURE_SIZES, MAX_BAKE_SIMPLIFY_TRIANGLES, BAKE_ATLAS_SIZES } from './chunk-APWUCEEB.js';
5
+ import { idOf, shouldExclude, captureFog, scenePath, captureLights, captureRuntime, stampIds, captureEnvironmentSettings, excludedItself, readUserData, bakeCandidates, resolveProbe, defaultIncludeIds, quantizeBakeView, bakeBounds, isBakeWrittenUv, ID_KEY } from './chunk-NEK5TBEH.js';
6
+ import { findPresetRooms, roomShownBaked, roomPresetFactsOf, roomPresetSpecOf, roomPresetAssetsOf, MAX_BAKE_OBJECTS, MAX_BAKE_TEXELS, roomIsPrebaked, roomPrebakeChanges, MAX_BAKE_SIMPLIFY, BAKE_TEXTURE_SIZES, MAX_BAKE_SIMPLIFY_TRIANGLES, BAKE_ATLAS_SIZES } from './chunk-EN4ROBYQ.js';
7
7
  import { Bakery3Error } from './chunk-3G5QL4F4.js';
8
+ import { readCameraLookAt, propertyDefinition, CAMERA_PROPERTIES, OBJECT_PROPERTIES, hexToLinear } from './chunk-OPM2L63B.js';
8
9
  import { Vector3, Vector2, Matrix4, Quaternion, Color, MeshPhysicalMaterial, MeshStandardMaterial, LinearSRGBColorSpace } from 'three';
9
10
  import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';
10
11
 
@@ -163,256 +164,6 @@ function normalize(v) {
163
164
  return length === 0 ? [0, 0, 0] : [v[0] / length, v[1] / length, v[2] / length];
164
165
  }
165
166
 
166
- // src/timeline/properties.ts
167
- function hemisphereOf(object) {
168
- const light = object;
169
- return light.isHemisphereLight ? light : void 0;
170
- }
171
- function sceneOf(object) {
172
- const scene = object;
173
- return scene.isScene ? scene : void 0;
174
- }
175
- function aimedLight(object) {
176
- const light = object;
177
- return (light.isDirectionalLight || light.isSpotLight) && light.target ? light : void 0;
178
- }
179
- function materialOf(object) {
180
- const material = object.material;
181
- if (!material) return void 0;
182
- return Array.isArray(material) ? material[0] : material;
183
- }
184
- function readVector(v) {
185
- return v ? [v.x, v.y, v.z] : void 0;
186
- }
187
- function scalar(get, set) {
188
- return {
189
- size: 1,
190
- read(object) {
191
- const material = materialOf(object);
192
- const value = material ? get(material) : void 0;
193
- return typeof value === "number" ? [value] : void 0;
194
- },
195
- write(object, value) {
196
- const material = materialOf(object);
197
- if (material) set(material, value[0]);
198
- }
199
- };
200
- }
201
- function colorProperty(pick) {
202
- return {
203
- size: 3,
204
- color: true,
205
- read(object) {
206
- const target = pick(object);
207
- return target ? [target.r, target.g, target.b] : void 0;
208
- },
209
- write(object, value) {
210
- const target = pick(object);
211
- if (!target) return;
212
- if (target.setRGB) target.setRGB(value[0], value[1], value[2]);
213
- else Object.assign(target, { r: value[0], g: value[1], b: value[2] });
214
- }
215
- };
216
- }
217
- var OBJECT_PROPERTIES = {
218
- position: {
219
- size: 3,
220
- read: (object) => readVector(object.position),
221
- write: (object, value) => object.position.set(value[0], value[1], value[2])
222
- },
223
- rotation: {
224
- size: 3,
225
- channel: "quaternion",
226
- read: (object) => readVector(
227
- object.rotation
228
- ),
229
- write: (object, value) => object.rotation.set(value[0], value[1], value[2])
230
- },
231
- scale: {
232
- size: 3,
233
- read: (object) => readVector(object.scale),
234
- write: (object, value) => object.scale.set(value[0], value[1], value[2])
235
- },
236
- // A light's own color (the worker drives the lamp, or for an ambient or
237
- // hemisphere light the dome), and a mesh's material's.
238
- color: colorProperty(
239
- (object) => object.isLight ? object.color : materialOf(object)?.color
240
- ),
241
- emissive: colorProperty((object) => materialOf(object)?.emissive),
242
- emissiveIntensity: scalar(
243
- (material) => material.emissiveIntensity,
244
- (material, value) => {
245
- material.emissiveIntensity = value;
246
- }
247
- ),
248
- roughness: scalar(
249
- (material) => material.roughness,
250
- (material, value) => {
251
- material.roughness = value;
252
- }
253
- ),
254
- metalness: scalar(
255
- (material) => material.metalness,
256
- (material, value) => {
257
- material.metalness = value;
258
- }
259
- ),
260
- opacity: scalar(
261
- (material) => material.opacity,
262
- (material, value) => {
263
- material.opacity = value;
264
- if (value < 1 && !material.transparent) {
265
- material.transparent = true;
266
- material.needsUpdate = true;
267
- }
268
- }
269
- ),
270
- intensity: {
271
- size: 1,
272
- read(object) {
273
- const light = object;
274
- return light.isLight && typeof light.intensity === "number" ? [light.intensity] : void 0;
275
- },
276
- write(object, value) {
277
- const light = object;
278
- if (light.isLight) light.intensity = value[0];
279
- }
280
- },
281
- /** A HemisphereLight's color from below. Its `color` is the sky. */
282
- groundColor: {
283
- ...colorProperty((object) => hemisphereOf(object)?.groundColor),
284
- appliesTo: (object) => hemisphereOf(object) !== void 0
285
- },
286
- /**
287
- * The scene's own `environmentIntensity`, on the Scene as a target: the
288
- * environment's `intensity` channel. It scales the HDRI only, as in three.
289
- */
290
- environmentIntensity: {
291
- size: 1,
292
- appliesTo: (object) => sceneOf(object) !== void 0,
293
- read(object) {
294
- const value = sceneOf(object)?.environmentIntensity;
295
- return typeof value === "number" ? [value] : void 0;
296
- },
297
- write(object, value) {
298
- const scene = sceneOf(object);
299
- if (scene) scene.environmentIntensity = value[0];
300
- }
301
- },
302
- /**
303
- * The scene's `environmentRotation`, radians, XYZ, as three holds it: the
304
- * environment's `rotation` channel. Unlike an object's rotation it stays
305
- * an euler on the wire, because that is what the environment carries.
306
- */
307
- environmentRotation: {
308
- size: 3,
309
- appliesTo: (object) => sceneOf(object) !== void 0,
310
- read: (object) => readVector(sceneOf(object)?.environmentRotation),
311
- write(object, value) {
312
- sceneOf(object)?.environmentRotation?.set(
313
- value[0],
314
- value[1],
315
- value[2]
316
- );
317
- }
318
- },
319
- /**
320
- * Where a directional or spot light aims: its `target`'s WORLD position,
321
- * which is what three aims it at and what the channel carries. Written
322
- * back through the target's parent, if it has one, so the light points at
323
- * the same place in the viewport as in the render.
324
- */
325
- target: {
326
- size: 3,
327
- appliesTo: (object) => aimedLight(object) !== void 0,
328
- read(object) {
329
- const target = aimedLight(object)?.target;
330
- if (!target) return void 0;
331
- target.updateMatrixWorld();
332
- const e = target.matrixWorld.elements;
333
- return [e[12], e[13], e[14]];
334
- },
335
- write(object, value) {
336
- const target = aimedLight(object)?.target;
337
- if (!target) return;
338
- target.position.set(value[0], value[1], value[2]);
339
- target.parent?.worldToLocal(target.position);
340
- target.updateMatrixWorld();
341
- }
342
- }
343
- };
344
- var CAMERA_PROPERTIES = {
345
- position: OBJECT_PROPERTIES.position,
346
- lookAt: {
347
- size: 3,
348
- // There is no live "lookAt" to read; the timeline supplies its own center
349
- // when a keyframe is captured. Returning undefined keeps the panel from
350
- // offering a capture button that would silently record the wrong thing.
351
- read: () => void 0,
352
- // Applied together with position by the timeline, never alone: aiming at a
353
- // point before moving to the position it was computed for produces one
354
- // frame of visible swing.
355
- write: () => void 0
356
- },
357
- fov: {
358
- size: 1,
359
- read(object) {
360
- const camera = object;
361
- return typeof camera.fov === "number" ? [camera.fov] : void 0;
362
- },
363
- write(object, value) {
364
- const camera = object;
365
- if (typeof camera.fov !== "number") return;
366
- camera.fov = value[0];
367
- camera.updateProjectionMatrix?.();
368
- }
369
- }
370
- };
371
- function propertyDefinition(target, property) {
372
- return target === "camera" ? CAMERA_PROPERTIES[property] : OBJECT_PROPERTIES[property];
373
- }
374
- function readCameraLookAt(camera, center) {
375
- camera.updateMatrixWorld();
376
- const e = camera.matrixWorld.elements;
377
- const position = [e[12], e[13], e[14]];
378
- const forward = normalize2([-e[8], -e[9], -e[10]]);
379
- const distance = Math.hypot(
380
- position[0] - center[0],
381
- position[1] - center[1],
382
- position[2] - center[2]
383
- ) || 1;
384
- return [
385
- position[0] + forward[0] * distance,
386
- position[1] + forward[1] * distance,
387
- position[2] + forward[2] * distance
388
- ];
389
- }
390
- function normalize2(v) {
391
- const length = Math.hypot(v[0], v[1], v[2]);
392
- return length === 0 ? [0, 0, -1] : [v[0] / length, v[1] / length, v[2] / length];
393
- }
394
- function hexToLinear(hex) {
395
- const value = hex.trim().replace(/^#/, "");
396
- const full = value.length === 3 ? value.split("").map((c) => c + c).join("") : value;
397
- const int = Number.parseInt(full, 16);
398
- if (!Number.isFinite(int)) return [1, 1, 1];
399
- return [
400
- srgbToLinear((int >> 16 & 255) / 255),
401
- srgbToLinear((int >> 8 & 255) / 255),
402
- srgbToLinear((int & 255) / 255)
403
- ];
404
- }
405
- function srgbToLinear(c) {
406
- return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
407
- }
408
- function linearToSrgbHex(value) {
409
- const channel = (v) => {
410
- const srgb = v < 31308e-7 ? v * 12.92 : 1.055 * Math.pow(Math.max(v, 0), 0.41666) - 0.055;
411
- return Math.round(Math.max(0, Math.min(1, srgb)) * 255).toString(16).padStart(2, "0");
412
- };
413
- return `#${channel(value[0] ?? 0)}${channel(value[1] ?? 0)}${channel(value[2] ?? 0)}`;
414
- }
415
-
416
167
  // src/protocol/animation.ts
417
168
  var ENVIRONMENT_CHANNEL_SIZES = {
418
169
  intensity: 1,
@@ -1317,7 +1068,7 @@ var Timeline = class _Timeline {
1317
1068
  const { at, end } = this.span(options);
1318
1069
  for (const [property, raw] of Object.entries(props)) {
1319
1070
  const track = this.track(target, property);
1320
- const value = normalize3(raw, track.size, property);
1071
+ const value = normalize2(raw, track.size, property);
1321
1072
  this.anchor(track, at);
1322
1073
  this.insert(track, {
1323
1074
  time: end,
@@ -1337,14 +1088,14 @@ var Timeline = class _Timeline {
1337
1088
  if (start !== void 0) {
1338
1089
  this.insert(track, {
1339
1090
  time: at,
1340
- value: normalize3(start, track.size, property)
1091
+ value: normalize2(start, track.size, property)
1341
1092
  });
1342
1093
  } else {
1343
1094
  this.anchor(track, at);
1344
1095
  }
1345
1096
  this.insert(track, {
1346
1097
  time: end,
1347
- value: normalize3(raw, track.size, property),
1098
+ value: normalize2(raw, track.size, property),
1348
1099
  ...options.easing ? { easing: options.easing } : {}
1349
1100
  });
1350
1101
  }
@@ -1452,7 +1203,7 @@ var Timeline = class _Timeline {
1452
1203
  */
1453
1204
  keyframe(target, property, time = this._time, value) {
1454
1205
  const track = this.track(target, property);
1455
- const resolved = value !== void 0 ? normalize3(value, track.size, property) : this.live(target, property) ?? this.valueAt(track, time);
1206
+ const resolved = value !== void 0 ? normalize2(value, track.size, property) : this.live(target, property) ?? this.valueAt(track, time);
1456
1207
  if (!resolved) {
1457
1208
  throw new Bakery3Error({
1458
1209
  code: "InvalidRequest",
@@ -1925,7 +1676,7 @@ function noCamera(what, bound) {
1925
1676
  function createTimeline(options = {}) {
1926
1677
  return new Timeline(options);
1927
1678
  }
1928
- function normalize3(value, size, property) {
1679
+ function normalize2(value, size, property) {
1929
1680
  const flat = flatten(value, size, property);
1930
1681
  if (flat && flat.length === size && flat.every((n) => Number.isFinite(n)))
1931
1682
  return flat;
@@ -2936,7 +2687,7 @@ function staticProperties(material) {
2936
2687
  properties[key] = `#${value.getHexString()}`;
2937
2688
  }
2938
2689
  };
2939
- const scalar2 = (key, prop) => {
2690
+ const scalar = (key, prop) => {
2940
2691
  const value = material[prop];
2941
2692
  if (typeof value === "number" && Number.isFinite(value)) {
2942
2693
  properties[key] = value;
@@ -2947,23 +2698,23 @@ function staticProperties(material) {
2947
2698
  color("sheenColor", "sheenColor");
2948
2699
  color("specularColor", "specularColor");
2949
2700
  color("attenuationColor", "attenuationColor");
2950
- scalar2("roughness", "roughness");
2951
- scalar2("metalness", "metalness");
2952
- scalar2("emissiveIntensity", "emissiveIntensity");
2953
- scalar2("opacity", "opacity");
2954
- scalar2("alphaTest", "alphaTest");
2955
- scalar2("ior", "ior");
2956
- scalar2("transmission", "transmission");
2957
- scalar2("thickness", "thickness");
2958
- scalar2("attenuationDistance", "attenuationDistance");
2959
- scalar2("clearcoat", "clearcoat");
2960
- scalar2("clearcoatRoughness", "clearcoatRoughness");
2961
- scalar2("sheen", "sheen");
2962
- scalar2("sheenRoughness", "sheenRoughness");
2963
- scalar2("specularIntensity", "specularIntensity");
2964
- scalar2("iridescence", "iridescence");
2965
- scalar2("iridescenceIOR", "iridescenceIOR");
2966
- scalar2("anisotropy", "anisotropy");
2701
+ scalar("roughness", "roughness");
2702
+ scalar("metalness", "metalness");
2703
+ scalar("emissiveIntensity", "emissiveIntensity");
2704
+ scalar("opacity", "opacity");
2705
+ scalar("alphaTest", "alphaTest");
2706
+ scalar("ior", "ior");
2707
+ scalar("transmission", "transmission");
2708
+ scalar("thickness", "thickness");
2709
+ scalar("attenuationDistance", "attenuationDistance");
2710
+ scalar("clearcoat", "clearcoat");
2711
+ scalar("clearcoatRoughness", "clearcoatRoughness");
2712
+ scalar("sheen", "sheen");
2713
+ scalar("sheenRoughness", "sheenRoughness");
2714
+ scalar("specularIntensity", "specularIntensity");
2715
+ scalar("iridescence", "iridescence");
2716
+ scalar("iridescenceIOR", "iridescenceIOR");
2717
+ scalar("anisotropy", "anisotropy");
2967
2718
  if (material.transparent === true) properties.transparent = true;
2968
2719
  if (material.side === 2) properties.doubleSided = true;
2969
2720
  return properties;
@@ -4776,6 +4527,6 @@ function resolveInclude(candidates, settings) {
4776
4527
  return resolved;
4777
4528
  }
4778
4529
 
4779
- export { OBJECT_PROPERTIES, Timeline, analyzeScene, aspectOf, bakeQuoteOf, bindTimelineContext, captureScene, createTimeline, extractMaterialShader, isNodeMaterial, linearToSrgbHex, outputSize, prepareBake, quoteBake, resolveOutput, sceneComplexity, timelineFromGsap, timelineFromTheatre, tracedTriangles };
4780
- //# sourceMappingURL=chunk-Z7IYVH22.js.map
4781
- //# sourceMappingURL=chunk-Z7IYVH22.js.map
4530
+ export { Timeline, analyzeScene, aspectOf, bakeQuoteOf, bindTimelineContext, captureScene, createTimeline, extractMaterialShader, isNodeMaterial, outputSize, prepareBake, quoteBake, resolveOutput, sceneComplexity, timelineFromGsap, timelineFromTheatre, tracedTriangles };
4531
+ //# sourceMappingURL=chunk-WLEFNUOH.js.map
4532
+ //# sourceMappingURL=chunk-WLEFNUOH.js.map