@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,310 @@
1
+ import { registerBuiltin, registerNodeObject, BAKERY_NODE_MARKER } from '../chunk-S4AJTLLN.js';
2
+ import { time, deltaTime, float, positionWorld, positionLocal, positionView, normalWorld, normalView, positionViewDirection, cameraPosition, mx_fractal_noise_float, sqrt, mx_worley_noise_float, sin, clamp, fract, smoothstep, mx_cell_noise_float, vec3, dot, pow, mix, vec4 } from 'three/tsl';
3
+
4
+ var asNode = (value) => ({
5
+ uuid: value?.uuid
6
+ });
7
+ registerBuiltin(asNode(positionWorld), {
8
+ op: "position",
9
+ params: () => ({ space: "world" })
10
+ });
11
+ registerBuiltin(asNode(positionLocal), {
12
+ op: "position",
13
+ params: () => ({ space: "local" })
14
+ });
15
+ registerBuiltin(asNode(positionView), {
16
+ op: "position",
17
+ params: () => ({ space: "view" })
18
+ });
19
+ registerBuiltin(asNode(normalWorld), {
20
+ op: "normal",
21
+ params: () => ({ space: "world" })
22
+ });
23
+ registerBuiltin(asNode(normalView), {
24
+ op: "normal",
25
+ params: () => ({ space: "view" })
26
+ });
27
+ registerBuiltin(asNode(positionViewDirection), { op: "view_direction" });
28
+ registerBuiltin(asNode(cameraPosition), { op: "camera_position" });
29
+ registerBuiltin(asNode(time), {
30
+ op: "uniform",
31
+ params: () => ({
32
+ value: time.value ?? 0,
33
+ type: "float",
34
+ name: "time"
35
+ })
36
+ });
37
+ registerBuiltin(asNode(deltaTime), {
38
+ op: "uniform",
39
+ params: () => ({
40
+ value: deltaTime.value ?? 0,
41
+ type: "float",
42
+ name: "deltaTime"
43
+ })
44
+ });
45
+ registerNodeObject((value) => {
46
+ return typeof value === "number" ? float(value) : value;
47
+ });
48
+ function mark(node, marker) {
49
+ node[BAKERY_NODE_MARKER] = marker;
50
+ return node;
51
+ }
52
+ var defaultCoord = () => positionLocal;
53
+ var params = (entries) => {
54
+ const out = {};
55
+ for (const [key, value] of Object.entries(entries)) {
56
+ if (value !== void 0) out[key] = value;
57
+ }
58
+ return out;
59
+ };
60
+ function bakeryNoiseTexture(coord, options = {}) {
61
+ const {
62
+ scale = 5,
63
+ detail = 2,
64
+ roughness = 0.5,
65
+ lacunarity = 2,
66
+ distortion = 0
67
+ } = options;
68
+ const p = (coord ?? defaultCoord()).mul(scale);
69
+ const preview = mx_fractal_noise_float(
70
+ p,
71
+ Math.max(1, Math.round(detail)),
72
+ lacunarity,
73
+ roughness
74
+ ).mul(0.5).add(0.5);
75
+ return mark(preview, {
76
+ op: "bk_noise_texture",
77
+ inputs: [coord ?? defaultCoord()],
78
+ params: params({
79
+ scale,
80
+ detail,
81
+ roughness,
82
+ lacunarity,
83
+ distortion,
84
+ dimensions: options.dimensions ?? 3
85
+ })
86
+ });
87
+ }
88
+ function bakeryVoronoiTexture(coord, options = {}) {
89
+ const { scale = 5, randomness = 1 } = options;
90
+ const p = (coord ?? defaultCoord()).mul(scale);
91
+ const preview = sqrt(mx_worley_noise_float(p, float(randomness)));
92
+ return mark(preview, {
93
+ op: "bk_voronoi_texture",
94
+ inputs: [coord ?? defaultCoord()],
95
+ params: params({
96
+ scale,
97
+ randomness,
98
+ feature: options.feature ?? "F1",
99
+ metric: options.metric ?? "EUCLIDEAN",
100
+ dimensions: options.dimensions ?? 3
101
+ })
102
+ });
103
+ }
104
+ function bakeryWaveTexture(coord, options = {}) {
105
+ const { scale = 5, phase = 0, direction = "X" } = options;
106
+ const p = (coord ?? defaultCoord()).mul(scale);
107
+ const axis = direction === "Y" ? p.y : direction === "Z" ? p.z : direction === "DIAGONAL" ? p.x.add(p.y).add(p.z) : p.x;
108
+ const preview = sin(axis.add(phase)).mul(0.5).add(0.5);
109
+ return mark(preview, {
110
+ op: "bk_wave_texture",
111
+ inputs: [coord ?? defaultCoord()],
112
+ params: params({
113
+ scale,
114
+ distortion: options.distortion ?? 0,
115
+ detail: options.detail ?? 2,
116
+ detail_scale: options.detailScale ?? 1,
117
+ detail_roughness: options.detailRoughness ?? 0.5,
118
+ phase,
119
+ type: options.type ?? "BANDS",
120
+ direction,
121
+ profile: options.profile ?? "SIN"
122
+ })
123
+ });
124
+ }
125
+ function bakeryMagicTexture(coord, options = {}) {
126
+ const { scale = 5, distortion = 1 } = options;
127
+ const p = (coord ?? defaultCoord()).mul(scale);
128
+ const preview = sin(p.x.add(sin(p.y.mul(distortion)))).mul(0.5).add(0.5);
129
+ return mark(preview, {
130
+ op: "bk_magic_texture",
131
+ inputs: [coord ?? defaultCoord()],
132
+ params: params({ scale, distortion, depth: options.depth ?? 2 })
133
+ });
134
+ }
135
+ function bakeryGradientTexture(coord, options = {}) {
136
+ const p = coord ?? defaultCoord();
137
+ const preview = clamp(p.x, 0, 1);
138
+ return mark(preview, {
139
+ op: "bk_gradient_texture",
140
+ inputs: [p],
141
+ params: params({ gradient_type: options.type ?? "LINEAR" })
142
+ });
143
+ }
144
+ function bakeryBrickTexture(coord, options = {}) {
145
+ const {
146
+ scale = 5,
147
+ mortarSize = 0.02,
148
+ rowHeight = 0.25,
149
+ brickWidth = 0.5
150
+ } = options;
151
+ const p = (coord ?? defaultCoord()).mul(scale);
152
+ const gx = fract(p.x.div(brickWidth));
153
+ const gy = fract(p.y.div(rowHeight));
154
+ const edge = float(1).sub(
155
+ smoothstep(
156
+ 0,
157
+ mortarSize * 4,
158
+ gx.min(float(1).sub(gx)).min(gy.min(float(1).sub(gy)))
159
+ )
160
+ );
161
+ return mark(edge, {
162
+ op: "bk_brick_texture",
163
+ inputs: [coord ?? defaultCoord()],
164
+ params: params({
165
+ offset: options.offset ?? 0.5,
166
+ offset_frequency: options.offsetFrequency ?? 2,
167
+ squash: options.squash ?? 1,
168
+ squash_frequency: options.squashFrequency ?? 2,
169
+ scale,
170
+ mortar_size: mortarSize,
171
+ mortar_smooth: options.mortarSmooth ?? 0.1,
172
+ bias: options.bias ?? 0,
173
+ brick_width: brickWidth,
174
+ row_height: rowHeight
175
+ })
176
+ });
177
+ }
178
+ function bakeryWhiteNoise(coord, options = {}) {
179
+ const p = coord ?? defaultCoord();
180
+ const preview = mx_cell_noise_float(p.mul(1024));
181
+ return mark(preview, {
182
+ op: "bk_white_noise",
183
+ inputs: [p],
184
+ params: params({ dimensions: options.dimensions ?? 3 })
185
+ });
186
+ }
187
+ function bakeryAmbientOcclusion(options = {}) {
188
+ const preview = float(1);
189
+ return mark(preview, {
190
+ op: "bk_ambient_occlusion",
191
+ params: params({
192
+ distance: options.distance ?? 1,
193
+ samples: options.samples ?? 16,
194
+ only_local: options.onlyLocal ?? false
195
+ })
196
+ });
197
+ }
198
+ function bakeryBevel(options = {}) {
199
+ const preview = normalWorld;
200
+ return mark(vec3(preview), {
201
+ op: "bk_bevel",
202
+ params: params({
203
+ radius: options.radius ?? 0.05,
204
+ samples: options.samples ?? 4
205
+ })
206
+ });
207
+ }
208
+ function bakeryPointiness() {
209
+ return mark(float(0.5), { op: "bk_pointiness" });
210
+ }
211
+ function bakeryWireframe(options = {}) {
212
+ return mark(float(0), {
213
+ op: "bk_wireframe",
214
+ params: params({
215
+ size: options.size ?? 0.01,
216
+ pixel_size: options.pixelSize ?? false
217
+ })
218
+ });
219
+ }
220
+ function bakeryFresnel(ior = 1.45) {
221
+ const f0 = ((1 - ior) / (1 + ior)) ** 2;
222
+ const facing = clamp(dot(normalView, positionViewDirection), 0, 1);
223
+ const preview = float(f0).add(
224
+ float(1 - f0).mul(pow(float(1).sub(facing), 5))
225
+ );
226
+ return mark(preview, { op: "bk_fresnel", inputs: [float(ior)] });
227
+ }
228
+ function bakeryLayerWeight(blend = 0.5, options = {}) {
229
+ const facing = float(1).sub(
230
+ clamp(dot(normalView, positionViewDirection), 0, 1)
231
+ );
232
+ return mark(facing, {
233
+ op: "bk_layer_weight",
234
+ inputs: [float(blend)],
235
+ params: params({ output: options.output ?? "FACING" })
236
+ });
237
+ }
238
+ function bakeryColorRamp(fac, stops, options = {}) {
239
+ if (stops.length < 1)
240
+ throw new Error("bakeryColorRamp needs at least one stop.");
241
+ const sorted = [...stops].sort((a, b) => a.position - b.position);
242
+ const rgba = (stop) => vec4(stop.color[0], stop.color[1], stop.color[2], stop.color[3] ?? 1);
243
+ let preview = rgba(sorted[0]);
244
+ for (let i = 1; i < sorted.length; i++) {
245
+ const previous = sorted[i - 1];
246
+ const current = sorted[i];
247
+ const span = Math.max(current.position - previous.position, 1e-5);
248
+ const t = (options.interpolation ?? "LINEAR") === "CONSTANT" ? smoothstep(current.position - 1e-5, current.position, fac) : clamp(fac.sub(previous.position).div(span), 0, 1);
249
+ preview = mix(preview, rgba(current), t);
250
+ }
251
+ const flat = [];
252
+ for (const stop of sorted) {
253
+ flat.push(
254
+ stop.position,
255
+ stop.color[0],
256
+ stop.color[1],
257
+ stop.color[2],
258
+ stop.color[3] ?? 1
259
+ );
260
+ }
261
+ return mark(preview, {
262
+ op: "bk_color_ramp",
263
+ inputs: [fac],
264
+ params: params({
265
+ interpolation: options.interpolation ?? "LINEAR",
266
+ stops: flat
267
+ })
268
+ });
269
+ }
270
+ function bakeryBlackbody(kelvin = 5e3) {
271
+ const t = smoothstep(2e3, 1e4, float(kelvin));
272
+ const preview = mix(vec3(1, 0.58, 0.27), vec3(0.78, 0.85, 1), t);
273
+ return mark(preview, {
274
+ op: "bk_blackbody",
275
+ inputs: [float(kelvin)]
276
+ });
277
+ }
278
+ function bakeryGamma(color, gamma = 1) {
279
+ const preview = pow(color, vec3(gamma, gamma, gamma));
280
+ return mark(preview, {
281
+ op: "bk_gamma",
282
+ inputs: [color, float(gamma)]
283
+ });
284
+ }
285
+ function bakeryBrightnessContrast(color, options = {}) {
286
+ const { brightness = 0, contrast = 0 } = options;
287
+ const a = 1 + contrast;
288
+ const b = brightness - contrast * 0.5;
289
+ const preview = clamp(color.mul(a).add(b), 0, 1e6);
290
+ return mark(preview, {
291
+ op: "bk_brightness_contrast",
292
+ inputs: [color, float(brightness), float(contrast)]
293
+ });
294
+ }
295
+ function bakeryHueSaturation(color, options = {}) {
296
+ const { hue = 0.5, saturation = 1, value = 1, fac = 1 } = options;
297
+ const scaled = color.mul(value);
298
+ const gray = dot(scaled, vec3(0.2126, 0.7152, 0.0722));
299
+ const adjusted = mix(vec3(gray, gray, gray), scaled, saturation);
300
+ const preview = mix(color, adjusted, fac);
301
+ return mark(preview, {
302
+ op: "bk_hsv",
303
+ inputs: [color],
304
+ params: params({ hue, saturation, value, fac })
305
+ });
306
+ }
307
+
308
+ export { bakeryAmbientOcclusion, bakeryBevel, bakeryBlackbody, bakeryBrickTexture, bakeryBrightnessContrast, bakeryColorRamp, bakeryFresnel, bakeryGamma, bakeryGradientTexture, bakeryHueSaturation, bakeryLayerWeight, bakeryMagicTexture, bakeryNoiseTexture, bakeryPointiness, bakeryVoronoiTexture, bakeryWaveTexture, bakeryWhiteNoise, bakeryWireframe };
309
+ //# sourceMappingURL=index.js.map
310
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/tsl/index.ts"],"names":[],"mappings":";;;AA6DA,IAAM,MAAA,GAAS,CAAC,KAAA,MAAoB;AAAA,EAClC,MAAO,KAAA,EAA6B;AACtC,CAAA,CAAA;AAEA,eAAA,CAAgB,MAAA,CAAO,aAAa,CAAA,EAAG;AAAA,EACrC,EAAA,EAAI,UAAA;AAAA,EACJ,MAAA,EAAQ,OAAO,EAAE,KAAA,EAAO,OAAA,EAAQ;AAClC,CAAC,CAAA;AACD,eAAA,CAAgB,MAAA,CAAO,aAAa,CAAA,EAAG;AAAA,EACrC,EAAA,EAAI,UAAA;AAAA,EACJ,MAAA,EAAQ,OAA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Two things happen here, and importing this module is what turns both on:\n *\n * 1. Registration. TSL's anonymous singletons (`positionWorld`, `time`,\n * `cameraPosition`) carry no recognizable structure, so the extractor can\n * only know them by being introduced. This module imports them from\n * `three/tsl` and registers them by uuid. It is its own entry point\n * because it needs three r170 (one of the nodes it imports is not\n * exported before that); the core SDK keeps working for anyone older.\n *\n * 2. Renderer-only nodes. The renderer has procedural textures and shading\n * inputs a browser cannot compute: traced ambient occlusion, shade-time\n * bevel, pointiness, the classic noise textures. Each function below\n * returns a real TSL node that draws an approximation in the WebGPU\n * viewport and carries a marker the extractor serializes exactly for the\n * render. The viewport is the sketch; the render is the real one.\n * `check()` reports their use as info, never as an error.\n *\n * Everything accepts plain numbers for its dials, and a TSL expression for\n * its coordinate input. Dials are baked into the manifest, so a dial driven\n * by another node is not accepted, rather than accepted and ignored.\n */\n\nimport {\n clamp,\n dot,\n float,\n fract,\n mix,\n mx_cell_noise_float,\n mx_fractal_noise_float,\n mx_worley_noise_float,\n normalView,\n normalWorld,\n positionLocal,\n positionView,\n positionViewDirection,\n positionWorld,\n cameraPosition,\n pow,\n sin,\n smoothstep,\n sqrt,\n time,\n deltaTime,\n vec3,\n vec4,\n} from 'three/tsl';\nimport {\n BAKERY_NODE_MARKER,\n registerBuiltin,\n registerNodeObject,\n type BakeryNodeMarker,\n} from '../shader/registry.js';\n\n// ---------------------------------------------------------------------------\n// Registration, on import\n// ---------------------------------------------------------------------------\n\nconst asNode = (value: unknown) => ({\n uuid: (value as { uuid?: string })?.uuid,\n});\n\nregisterBuiltin(asNode(positionWorld), {\n op: 'position',\n params: () => ({ space: 'world' }),\n});\nregisterBuiltin(asNode(positionLocal), {\n op: 'position',\n params: () => ({ space: 'local' }),\n});\nregisterBuiltin(asNode(positionView), {\n op: 'position',\n params: () => ({ space: 'view' }),\n});\nregisterBuiltin(asNode(normalWorld), {\n op: 'normal',\n params: () => ({ space: 'world' }),\n});\nregisterBuiltin(asNode(normalView), {\n op: 'normal',\n params: () => ({ space: 'view' }),\n});\nregisterBuiltin(asNode(positionViewDirection), { op: 'view_direction' });\nregisterBuiltin(asNode(cameraPosition), { op: 'camera_position' });\n// Time is a uniform like any other: baked to the moment of capture. Reading\n// `.value` lazily matters: import time is not capture time.\nregisterBuiltin(asNode(time), {\n op: 'uniform',\n params: () => ({\n value: (time as { value?: number }).value ?? 0,\n type: 'float',\n name: 'time',\n }),\n});\nregisterBuiltin(asNode(deltaTime), {\n op: 'uniform',\n params: () => ({\n value: (deltaTime as { value?: number }).value ?? 0,\n type: 'float',\n name: 'deltaTime',\n }),\n});\n\nregisterNodeObject((value) => {\n // `float()` runs plain numbers through TSL's own const-node machinery,\n // which is exactly what Fn expansion needs; nodes pass through untouched.\n return typeof value === 'number' ? float(value) : value;\n});\n\n// ---------------------------------------------------------------------------\n// The marker\n// ---------------------------------------------------------------------------\n\n// Every type here is derived from a `three/tsl` export, so the published\n// declarations name no file inside three's own source tree. Those paths are\n// one @types/three release's layout: a declaration that imported them would\n// fail to compile under `skipLibCheck: false` against any other. Derived\n// this way, a node type is whatever the developer's own @types/three says\n// `float()` and `vec3()` return.\ntype TSLExpr = ReturnType<typeof float>;\ntype Coord = TSLExpr | null | undefined;\n/** A float node: a mask, a factor, a texture's fac output. */\ntype FloatNode = ReturnType<typeof float>;\n/** A three-component node: a color or a normal. */\ntype Vec3Node = ReturnType<typeof vec3>;\n/** A color with alpha. */\ntype Vec4Node = ReturnType<typeof vec4>;\n\nfunction mark<T>(node: unknown, marker: BakeryNodeMarker): T {\n (node as Record<string, unknown>)[BAKERY_NODE_MARKER] = marker;\n return node as T;\n}\n\n/** The renderer's procedural textures default to object-space coordinates;\n * object-space position is the closest thing a live three scene has. */\nconst defaultCoord = () => positionLocal;\n\nconst params = (\n entries: Record<string, number | string | boolean | number[] | undefined>,\n): Record<string, number | string | boolean | number[]> => {\n const out: Record<string, number | string | boolean | number[]> = {};\n for (const [key, value] of Object.entries(entries)) {\n if (value !== undefined) out[key] = value;\n }\n return out;\n};\n\n// ---------------------------------------------------------------------------\n// Procedural textures\n// ---------------------------------------------------------------------------\n\nexport type NoiseTextureOptions = {\n scale?: number;\n detail?: number;\n roughness?: number;\n lacunarity?: number;\n distortion?: number;\n dimensions?: 2 | 3 | 4;\n};\n\n/**\n * The renderer's fractal noise texture. Preview: MaterialX fractal noise,\n * the same character on a different lattice.\n */\nexport function bakeryNoiseTexture(\n coord?: Coord,\n options: NoiseTextureOptions = {},\n): FloatNode {\n const {\n scale = 5,\n detail = 2,\n roughness = 0.5,\n lacunarity = 2,\n distortion = 0,\n } = options;\n const p = (coord ?? defaultCoord()).mul(scale);\n const preview = mx_fractal_noise_float(\n p,\n Math.max(1, Math.round(detail)),\n lacunarity,\n roughness,\n )\n .mul(0.5)\n .add(0.5);\n return mark<FloatNode>(preview, {\n op: 'bk_noise_texture',\n inputs: [coord ?? defaultCoord()],\n params: params({\n scale,\n detail,\n roughness,\n lacunarity,\n distortion,\n dimensions: options.dimensions ?? 3,\n }),\n });\n}\n\nexport type VoronoiTextureOptions = {\n scale?: number;\n randomness?: number;\n feature?: 'F1' | 'F2' | 'SMOOTH_F1' | 'DISTANCE_TO_EDGE';\n metric?: 'EUCLIDEAN' | 'MANHATTAN' | 'CHEBYCHEV';\n dimensions?: 2 | 3 | 4;\n};\n\n/** The renderer's Voronoi texture (distance output). Preview: MaterialX Worley. */\nexport function bakeryVoronoiTexture(\n coord?: Coord,\n options: VoronoiTextureOptions = {},\n): FloatNode {\n const { scale = 5, randomness = 1 } = options;\n const p = (coord ?? defaultCoord()).mul(scale);\n // three's Worley is the SQUARED distance; the renderer's Voronoi is the\n // distance itself.\n const preview = sqrt(mx_worley_noise_float(p, float(randomness)));\n return mark<FloatNode>(preview, {\n op: 'bk_voronoi_texture',\n inputs: [coord ?? defaultCoord()],\n params: params({\n scale,\n randomness,\n feature: options.feature ?? 'F1',\n metric: options.metric ?? 'EUCLIDEAN',\n dimensions: options.dimensions ?? 3,\n }),\n });\n}\n\nexport type WaveTextureOptions = {\n scale?: number;\n distortion?: number;\n detail?: number;\n detailScale?: number;\n detailRoughness?: number;\n phase?: number;\n type?: 'BANDS' | 'RINGS';\n direction?: 'X' | 'Y' | 'Z' | 'DIAGONAL';\n profile?: 'SIN' | 'SAW' | 'TRI';\n};\n\n/** The renderer's wave texture. Preview: a sine along the chosen axis. */\nexport function bakeryWaveTexture(\n coord?: Coord,\n options: WaveTextureOptions = {},\n): FloatNode {\n const { scale = 5, phase = 0, direction = 'X' } = options;\n const p = (coord ?? defaultCoord()).mul(scale);\n const axis =\n direction === 'Y'\n ? p.y\n : direction === 'Z'\n ? p.z\n : direction === 'DIAGONAL'\n ? p.x.add(p.y).add(p.z)\n : p.x;\n const preview = sin(axis.add(phase)).mul(0.5).add(0.5);\n return mark<FloatNode>(preview, {\n op: 'bk_wave_texture',\n inputs: [coord ?? defaultCoord()],\n params: params({\n scale,\n distortion: options.distortion ?? 0,\n detail: options.detail ?? 2,\n detail_scale: options.detailScale ?? 1,\n detail_roughness: options.detailRoughness ?? 0.5,\n phase,\n type: options.type ?? 'BANDS',\n direction,\n profile: options.profile ?? 'SIN',\n }),\n });\n}\n\nexport type MagicTextureOptions = {\n scale?: number;\n distortion?: number;\n depth?: number;\n};\n\n/** The renderer's interference \"magic\" texture. Preview: interfering sines,\n * the flavor and not the math. */\nexport function bakeryMagicTexture(\n coord?: Coord,\n options: MagicTextureOptions = {},\n): FloatNode {\n const { scale = 5, distortion = 1 } = options;\n const p = (coord ?? defaultCoord()).mul(scale);\n const preview = sin(p.x.add(sin(p.y.mul(distortion))))\n .mul(0.5)\n .add(0.5);\n return mark<FloatNode>(preview, {\n op: 'bk_magic_texture',\n inputs: [coord ?? defaultCoord()],\n params: params({ scale, distortion, depth: options.depth ?? 2 }),\n });\n}\n\nexport type GradientType =\n | 'LINEAR'\n | 'QUADRATIC'\n | 'EASING'\n | 'DIAGONAL'\n | 'SPHERICAL'\n | 'QUADRATIC_SPHERE'\n | 'RADIAL';\n\nexport type GradientTextureOptions = { type?: GradientType };\n\n/** The renderer's gradient texture. Preview: the linear ramp. */\nexport function bakeryGradientTexture(\n coord?: Coord,\n options: GradientTextureOptions = {},\n): FloatNode {\n const p = coord ?? defaultCoord();\n const preview = clamp(p.x, 0, 1);\n return mark<FloatNode>(preview, {\n op: 'bk_gradient_texture',\n inputs: [p],\n params: params({ gradient_type: options.type ?? 'LINEAR' }),\n });\n}\n\nexport type BrickTextureOptions = {\n offset?: number;\n offsetFrequency?: number;\n squash?: number;\n squashFrequency?: number;\n scale?: number;\n mortarSize?: number;\n mortarSmooth?: number;\n bias?: number;\n brickWidth?: number;\n rowHeight?: number;\n};\n\n/** The renderer's brick texture (fac output, the mortar mask). Preview: a grid. */\nexport function bakeryBrickTexture(\n coord?: Coord,\n options: BrickTextureOptions = {},\n): FloatNode {\n const {\n scale = 5,\n mortarSize = 0.02,\n rowHeight = 0.25,\n brickWidth = 0.5,\n } = options;\n const p = (coord ?? defaultCoord()).mul(scale);\n const gx = fract(p.x.div(brickWidth));\n const gy = fract(p.y.div(rowHeight));\n const edge = float(1).sub(\n smoothstep(\n 0,\n mortarSize * 4,\n gx.min(float(1).sub(gx)).min(gy.min(float(1).sub(gy))),\n ),\n );\n return mark<FloatNode>(edge, {\n op: 'bk_brick_texture',\n inputs: [coord ?? defaultCoord()],\n params: params({\n offset: options.offset ?? 0.5,\n offset_frequency: options.offsetFrequency ?? 2,\n squash: options.squash ?? 1,\n squash_frequency: options.squashFrequency ?? 2,\n scale,\n mortar_size: mortarSize,\n mortar_smooth: options.mortarSmooth ?? 0.1,\n bias: options.bias ?? 0,\n brick_width: brickWidth,\n row_height: rowHeight,\n }),\n });\n}\n\n/** White noise, a hash of the coordinate. Preview: cell noise. */\nexport function bakeryWhiteNoise(\n coord?: Coord,\n options: { dimensions?: 2 | 3 | 4 } = {},\n): FloatNode {\n const p = coord ?? defaultCoord();\n const preview = mx_cell_noise_float(p.mul(1024));\n return mark<FloatNode>(preview, {\n op: 'bk_white_noise',\n inputs: [p],\n params: params({ dimensions: options.dimensions ?? 3 }),\n });\n}\n\n// ---------------------------------------------------------------------------\n// Shading inputs the browser cannot compute\n// ---------------------------------------------------------------------------\n\n/**\n * Traced ambient occlusion. The browser has no rays, so the preview is plain\n * white, which is exactly what an unoccluded surface reads as. The render\n * traces the real thing.\n */\nexport function bakeryAmbientOcclusion(\n options: { distance?: number; samples?: number; onlyLocal?: boolean } = {},\n): FloatNode {\n const preview = float(1);\n return mark<FloatNode>(preview, {\n op: 'bk_ambient_occlusion',\n params: params({\n distance: options.distance ?? 1,\n samples: options.samples ?? 16,\n only_local: options.onlyLocal ?? false,\n }),\n });\n}\n\n/**\n * Shade-time edge rounding. Preview: the unrounded normal, so geometry looks\n * crisp in the viewport and gets the worn edge in the render.\n */\nexport function bakeryBevel(\n options: { radius?: number; samples?: number } = {},\n): Vec3Node {\n const preview = normalWorld;\n return mark<Vec3Node>(vec3(preview), {\n op: 'bk_bevel',\n params: params({\n radius: options.radius ?? 0.05,\n samples: options.samples ?? 4,\n }),\n });\n}\n\n/** Surface curvature: concave 0, flat 0.5, convex 1. Preview: flat 0.5. */\nexport function bakeryPointiness(): FloatNode {\n return mark<FloatNode>(float(0.5), { op: 'bk_pointiness' });\n}\n\n/** 1 on triangle edges. Preview: 0, no wires in the viewport. */\nexport function bakeryWireframe(\n options: { size?: number; pixelSize?: boolean } = {},\n): FloatNode {\n return mark<FloatNode>(float(0), {\n op: 'bk_wireframe',\n params: params({\n size: options.size ?? 0.01,\n pixel_size: options.pixelSize ?? false,\n }),\n });\n}\n\n/** Physically correct fresnel. Preview: Schlick's approximation, close enough\n * that the viewport and the render agree on where the rim light lives. */\nexport function bakeryFresnel(ior: number = 1.45): FloatNode {\n const f0 = ((1 - ior) / (1 + ior)) ** 2;\n const facing = clamp(dot(normalView, positionViewDirection), 0, 1);\n const preview = float(f0).add(\n float(1 - f0).mul(pow(float(1).sub(facing), 5)),\n );\n return mark<FloatNode>(preview, { op: 'bk_fresnel', inputs: [float(ior)] });\n}\n\n/** A facing/fresnel layer weight. Preview: the facing term it is built from. */\nexport function bakeryLayerWeight(\n blend: number = 0.5,\n options: { output?: 'FRESNEL' | 'FACING' } = {},\n): FloatNode {\n const facing = float(1).sub(\n clamp(dot(normalView, positionViewDirection), 0, 1),\n );\n return mark<FloatNode>(facing, {\n op: 'bk_layer_weight',\n inputs: [float(blend)],\n params: params({ output: options.output ?? 'FACING' }),\n });\n}\n\n// ---------------------------------------------------------------------------\n// Color tools\n// ---------------------------------------------------------------------------\n\nexport type ColorRampStop = {\n position: number;\n color: [number, number, number] | [number, number, number, number];\n};\n\n/**\n * A color ramp. Preview: the same ramp, rebuilt from mix chains; for LINEAR\n * and CONSTANT interpolation the viewport matches the render.\n */\nexport function bakeryColorRamp(\n fac: TSLExpr,\n stops: ColorRampStop[],\n options: { interpolation?: 'LINEAR' | 'CONSTANT' } = {},\n): Vec4Node {\n if (stops.length < 1)\n throw new Error('bakeryColorRamp needs at least one stop.');\n const sorted = [...stops].sort((a, b) => a.position - b.position);\n const rgba = (stop: ColorRampStop) =>\n vec4(stop.color[0], stop.color[1], stop.color[2], stop.color[3] ?? 1);\n\n let preview = rgba(sorted[0]!) as unknown as ReturnType<typeof mix>;\n for (let i = 1; i < sorted.length; i++) {\n const previous = sorted[i - 1]!;\n const current = sorted[i]!;\n const span = Math.max(current.position - previous.position, 1e-5);\n const t =\n (options.interpolation ?? 'LINEAR') === 'CONSTANT'\n ? smoothstep(current.position - 1e-5, current.position, fac)\n : clamp(fac.sub(previous.position).div(span), 0, 1);\n preview = mix(preview, rgba(current), t);\n }\n\n const flat: number[] = [];\n for (const stop of sorted) {\n flat.push(\n stop.position,\n stop.color[0],\n stop.color[1],\n stop.color[2],\n stop.color[3] ?? 1,\n );\n }\n return mark<Vec4Node>(preview, {\n op: 'bk_color_ramp',\n inputs: [fac],\n params: params({\n interpolation: options.interpolation ?? 'LINEAR',\n stops: flat,\n }),\n });\n}\n\n/** Blackbody temperature to color. Preview: a two-anchor tint, warm below\n * and cool above. */\nexport function bakeryBlackbody(kelvin: number = 5000): Vec3Node {\n const t = smoothstep(2000, 10000, float(kelvin));\n const preview = mix(vec3(1.0, 0.58, 0.27), vec3(0.78, 0.85, 1.0), t);\n return mark<Vec3Node>(preview, {\n op: 'bk_blackbody',\n inputs: [float(kelvin)],\n });\n}\n\n/** A gamma curve. The preview is the same math. */\nexport function bakeryGamma(color: TSLExpr, gamma: number = 1): Vec3Node {\n const preview = pow(color, vec3(gamma, gamma, gamma));\n return mark<Vec3Node>(preview, {\n op: 'bk_gamma',\n inputs: [color, float(gamma)],\n });\n}\n\n/** Brightness/contrast. Preview: the same formula the render uses. */\nexport function bakeryBrightnessContrast(\n color: TSLExpr,\n options: { brightness?: number; contrast?: number } = {},\n): Vec3Node {\n const { brightness = 0, contrast = 0 } = options;\n const a = 1 + contrast;\n const b = brightness - contrast * 0.5;\n const preview = clamp(color.mul(a).add(b), 0, 1e6);\n return mark<Vec3Node>(preview, {\n op: 'bk_brightness_contrast',\n inputs: [color, float(brightness), float(contrast)],\n });\n}\n\n/** Hue/saturation/value. Preview: value and saturation only; a hue rotation\n * in the viewport is not worth a hand-rolled HSV conversion. */\nexport function bakeryHueSaturation(\n color: TSLExpr,\n options: {\n hue?: number;\n saturation?: number;\n value?: number;\n fac?: number;\n } = {},\n): Vec3Node {\n const { hue = 0.5, saturation = 1, value = 1, fac = 1 } = options;\n const scaled = color.mul(value);\n const gray = dot(scaled, vec3(0.2126, 0.7152, 0.0722));\n const adjusted = mix(vec3(gray, gray, gray), scaled, saturation);\n const preview = mix(color, adjusted, fac);\n return mark<Vec3Node>(preview, {\n op: 'bk_hsv',\n inputs: [color],\n params: params({ hue, saturation, value, fac }),\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,172 @@
1
1
  {
2
2
  "name": "@oeave/bakery3",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Path trace the Three.js scene you're already rendering. One function call, studio-quality output.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": [
8
+ "./dist/tsl/index.js",
9
+ "./dist/shapes/index.js"
10
+ ],
11
+ "keywords": [
12
+ "three",
13
+ "threejs",
14
+ "react-three-fiber",
15
+ "r3f",
16
+ "raytracing",
17
+ "path-tracing",
18
+ "rendering",
19
+ "product-configurator",
20
+ "webgpu",
21
+ "tsl",
22
+ "lightmap",
23
+ "product-rendering"
24
+ ],
25
+ "homepage": "https://bakery3.com",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/oeave/bakery3.git"
29
+ },
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./r3f": {
36
+ "types": "./dist/r3f/index.d.ts",
37
+ "default": "./dist/r3f/index.js"
38
+ },
39
+ "./tsl": {
40
+ "types": "./dist/tsl/index.d.ts",
41
+ "default": "./dist/tsl/index.js"
42
+ },
43
+ "./environments": {
44
+ "types": "./dist/environments/index.d.ts",
45
+ "default": "./dist/environments/index.js"
46
+ },
47
+ "./shapes": {
48
+ "types": "./dist/shapes/index.d.ts",
49
+ "default": "./dist/shapes/index.js"
50
+ },
51
+ "./devtools": {
52
+ "types": "./dist/devtools/index.d.ts",
53
+ "default": "./dist/devtools/index.js"
54
+ },
55
+ "./presets": {
56
+ "types": "./dist/presets/index.d.ts",
57
+ "default": "./dist/presets/index.js"
58
+ },
59
+ "./bake": {
60
+ "types": "./dist/bake/index.d.ts",
61
+ "default": "./dist/bake/index.js"
62
+ },
63
+ "./hotspots": {
64
+ "types": "./dist/hotspots/index.d.ts",
65
+ "default": "./dist/hotspots/index.js"
66
+ },
67
+ "./node": {
68
+ "import": {
69
+ "types": "./dist/node/index.d.ts",
70
+ "default": "./dist/node/index.js"
71
+ },
72
+ "require": {
73
+ "types": "./dist/node/index.d.cts",
74
+ "default": "./dist/node/index.cjs"
75
+ }
76
+ },
77
+ "./catalog": {
78
+ "types": "./dist/catalog/index.d.ts",
79
+ "default": "./dist/catalog/index.js"
80
+ },
81
+ "./package.json": "./package.json"
82
+ },
83
+ "main": "./dist/index.js",
84
+ "module": "./dist/index.js",
85
+ "types": "./dist/index.d.ts",
86
+ "typesVersions": {
87
+ "*": {
88
+ "r3f": [
89
+ "./dist/r3f/index.d.ts"
90
+ ],
91
+ "tsl": [
92
+ "./dist/tsl/index.d.ts"
93
+ ],
94
+ "environments": [
95
+ "./dist/environments/index.d.ts"
96
+ ],
97
+ "shapes": [
98
+ "./dist/shapes/index.d.ts"
99
+ ],
100
+ "devtools": [
101
+ "./dist/devtools/index.d.ts"
102
+ ],
103
+ "presets": [
104
+ "./dist/presets/index.d.ts"
105
+ ],
106
+ "bake": [
107
+ "./dist/bake/index.d.ts"
108
+ ],
109
+ "hotspots": [
110
+ "./dist/hotspots/index.d.ts"
111
+ ],
112
+ "node": [
113
+ "./dist/node/index.d.ts"
114
+ ],
115
+ "catalog": [
116
+ "./dist/catalog/index.d.ts"
117
+ ]
118
+ }
119
+ },
120
+ "files": [
121
+ "dist",
122
+ "README.md",
123
+ "LICENSE"
124
+ ],
125
+ "publishConfig": {
126
+ "access": "public"
127
+ },
128
+ "engines": {
129
+ "node": ">=20"
130
+ },
131
+ "scripts": {
132
+ "build": "rm -rf dist && tsup",
133
+ "dev": "tsup --watch",
134
+ "test": "bun test",
135
+ "check-types": "tsc --noEmit",
136
+ "check:three": "bun scripts/check-three-floor.ts",
137
+ "format": "prettier --write .",
138
+ "format:check": "prettier --check .",
139
+ "check": "bun run format:check && bun run check-types && bun test",
140
+ "prepublishOnly": "bun run check && bun run build && bun run check:three",
141
+ "release": "npm publish"
142
+ },
143
+ "peerDependencies": {
144
+ "@react-three/fiber": "^8.18.0 || ^9.0.0",
145
+ "react": "^18.0.0 || ^19.0.0",
146
+ "three": ">=0.160.0"
147
+ },
148
+ "peerDependenciesMeta": {
149
+ "@react-three/fiber": {
150
+ "optional": true
151
+ },
152
+ "react": {
153
+ "optional": true
154
+ }
155
+ },
156
+ "devDependencies": {
157
+ "@react-three/fiber": "^9.0.0",
158
+ "@types/react": "19.2.2",
159
+ "@types/three": "^0.180.0",
160
+ "bun-types": "^1.3.14",
161
+ "esbuild": "^0.28.2",
162
+ "prettier": "^3.9.9",
163
+ "react": "19.2.4",
164
+ "three": "0.180.0",
165
+ "tsup": "^8.5.0",
166
+ "typescript": "5.9.2",
167
+ "vite": "^6.3.5"
168
+ },
169
+ "bugs": {
170
+ "url": "https://github.com/oeave/bakery3/issues"
171
+ }
172
+ }