@konfigure/sdk 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.
- package/LICENSE +41 -0
- package/README.md +325 -2
- package/THIRD_PARTY_NOTICES.md +283 -0
- package/dist/chunk-MJ67XJWM.js +1 -0
- package/dist/chunk-OOVVLYAY.js +482 -0
- package/dist/chunk-XUSV3KOD.js +1 -0
- package/dist/configurator-6ISAZiAx.d.ts +468 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +4 -0
- package/dist/src-GJ5RXX7G.js +3811 -0
- package/dist/view.d.ts +674 -0
- package/dist/view.js +801 -0
- package/package.json +46 -4
package/dist/view.d.ts
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import { Scene, PerspectiveCamera, WebGLRenderer, Vector3Tuple, Material, Mesh } from 'three';
|
|
2
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
+
import { a as Configurator } from './configurator-6ISAZiAx.js';
|
|
4
|
+
|
|
5
|
+
declare const ScenePreset: {
|
|
6
|
+
readonly ROOM: "room";
|
|
7
|
+
readonly WALL: "wall";
|
|
8
|
+
readonly SURROUND_LIGHT: "surround_light";
|
|
9
|
+
readonly SURROUND_LIGHT_WALL: "surround_light_wall";
|
|
10
|
+
/** Wall mounting, framed close — for products measured in centimetres. */
|
|
11
|
+
readonly WALL_CLOSE: "wall_close";
|
|
12
|
+
/** Seamless studio backdrop, no wall or floor — the catalogue shot of a
|
|
13
|
+
* centimetre-scale product. */
|
|
14
|
+
readonly STUDIO_CLOSE: "studio_close";
|
|
15
|
+
/** ROOM with a key light and a stronger environment, and a camera that can
|
|
16
|
+
* come closer: a single piece of furniture whose materials should read. */
|
|
17
|
+
readonly ROOM_LIT: "room_lit";
|
|
18
|
+
/** ROOM_LIT's light with a room-sized camera: walk-in booths and rows of them. */
|
|
19
|
+
readonly ROOM_LIT_WIDE: "room_lit_wide";
|
|
20
|
+
};
|
|
21
|
+
type ScenePreset = (typeof ScenePreset)[keyof typeof ScenePreset];
|
|
22
|
+
|
|
23
|
+
type BakedLightingStats = {
|
|
24
|
+
triangles: number;
|
|
25
|
+
vertices: number;
|
|
26
|
+
floorWidth: number;
|
|
27
|
+
floorHeight: number;
|
|
28
|
+
/** Main-thread time: collecting the meshes, and taking the BVH back from the worker. */
|
|
29
|
+
mainThreadMs: number;
|
|
30
|
+
/** From the start of the bake to its BVH being ready to trace. */
|
|
31
|
+
buildMs: number;
|
|
32
|
+
/** From the start of the bake to it being ready to show. */
|
|
33
|
+
bakeMs: number;
|
|
34
|
+
/** Samples each vertex took (see VERTEX_SAMPLE_BUDGET). */
|
|
35
|
+
vertexSamples: number;
|
|
36
|
+
};
|
|
37
|
+
type BakeRequest = 'redraw' | 'work' | null;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this device can show baked lighting: `available`, or why not —
|
|
40
|
+
* no WebGL 2 or float render targets (`unsupported`), a software renderer
|
|
41
|
+
* standing in for a GPU (`software`), a GPU too slow to trace (`too-slow`), or,
|
|
42
|
+
* for the configuration on screen only, one too large to trace in time
|
|
43
|
+
* (`too-complex`, see JUDGE_AFTER_MS).
|
|
44
|
+
*/
|
|
45
|
+
type BakeAvailability = 'available' | 'unsupported' | 'software' | 'too-slow' | 'too-complex';
|
|
46
|
+
type BakePhase = 'off' | 'idle' | 'settling' | 'building' | 'tracing' | 'reading' | 'fading' | 'skipped';
|
|
47
|
+
type BakedLighting = {
|
|
48
|
+
/** Bake, or leave the floor to the contact decals and the product unshaded. */
|
|
49
|
+
setEnabled: (enabled: boolean) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Before a frame is drawn. Gives meshes that just appeared what the shade
|
|
52
|
+
* needs (see shade.ts) BEFORE their first draw, so their materials compile
|
|
53
|
+
* once rather than twice.
|
|
54
|
+
*/
|
|
55
|
+
beforeRender: (changed: boolean) => void;
|
|
56
|
+
/**
|
|
57
|
+
* After a frame is drawn, when every world matrix is current. `changed` says
|
|
58
|
+
* whether anything invalidated this frame: on frames that only move the
|
|
59
|
+
* camera the scene cannot have changed, and the check is skipped. Says
|
|
60
|
+
* what it wants next: `redraw` while fading (the picture changes), `work`
|
|
61
|
+
* while tracing (it needs the tick, but nothing on screen moves, so the
|
|
62
|
+
* scene need not be drawn again), null when idle. Waits that are not
|
|
63
|
+
* frames (settling, the worker, a readback) call `requestTick` when they end.
|
|
64
|
+
* While `cameraMoving`, tracing goes on with a smaller share of the frame:
|
|
65
|
+
* the scene is being redrawn too, and the orbit must stay smooth.
|
|
66
|
+
*/
|
|
67
|
+
update: (changed: boolean, cameraMoving?: boolean) => BakeRequest;
|
|
68
|
+
/**
|
|
69
|
+
* Stop looking for changes: the bake on screen stays on screen, however the
|
|
70
|
+
* meshes move, until released. For an animation that moves a product into a
|
|
71
|
+
* configuration that has ALREADY been baked — a piece dropping into the place
|
|
72
|
+
* the bake was traced with it in. Every frame of that move is a new signature,
|
|
73
|
+
* and without this each would hand the floor back to the decals and start
|
|
74
|
+
* over, so the bake would flicker out for exactly as long as the move lasts.
|
|
75
|
+
* Released, the next frame is compared as usual; if the product came to rest
|
|
76
|
+
* where it was baked, nothing has changed.
|
|
77
|
+
*/
|
|
78
|
+
setHeld: (held: boolean) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Draw the floor as a mix of the previous bake's shadow and the current
|
|
81
|
+
* one's, 0 = all previous, 1 = all current (the default).
|
|
82
|
+
*
|
|
83
|
+
* For a piece arriving into a configuration that is already baked: its
|
|
84
|
+
* shadow should arrive with it, and a floor map covers every piece at once,
|
|
85
|
+
* so the only way to grow one piece's shadow is to cross from the map made
|
|
86
|
+
* without it to the map made with it. `fromNothing` crosses from no shadow
|
|
87
|
+
* at all — the first piece onto an empty stage, where whatever was shown
|
|
88
|
+
* before is not the configuration it came from.
|
|
89
|
+
*
|
|
90
|
+
* "Previous" is whatever bake was on screen before the current one, so this
|
|
91
|
+
* means something only when the configurations are visited in order, as a
|
|
92
|
+
* render visits them.
|
|
93
|
+
*/
|
|
94
|
+
setFloorCrossfade: (amount: number, fromNothing?: boolean) => void;
|
|
95
|
+
/** What the bake is doing, for measuring. */
|
|
96
|
+
readonly phase: BakePhase;
|
|
97
|
+
/** Whether this device can show it at all (see BakeAvailability). */
|
|
98
|
+
readonly availability: BakeAvailability;
|
|
99
|
+
/**
|
|
100
|
+
* Draw the next pass as if there were no bake — plain light on the product,
|
|
101
|
+
* the full decals on the floor — and return what puts it back. For one side
|
|
102
|
+
* of a split comparison; the bake itself carries on.
|
|
103
|
+
*/
|
|
104
|
+
hide: () => () => void;
|
|
105
|
+
/** Timings of the last finished bake, for measuring. */
|
|
106
|
+
readonly stats: BakedLightingStats | null;
|
|
107
|
+
dispose: () => void;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** One side of a split view: what to change for its pass, and whether it shows the baked lighting. */
|
|
111
|
+
type SplitSide = {
|
|
112
|
+
/** Change the scene for this side's pass; returns what puts it back. */
|
|
113
|
+
apply?: () => () => void;
|
|
114
|
+
/** False draws this side without the baked lighting (default: as the scene is). */
|
|
115
|
+
bakedLighting?: boolean;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Two looks of the same scene either side of a vertical line, each its own
|
|
119
|
+
* pass of the same frame. For comparing materials and lighting.
|
|
120
|
+
*/
|
|
121
|
+
type SplitView = {
|
|
122
|
+
/** Where the line is, 0 (left edge) → 1 (right edge). */
|
|
123
|
+
at: number;
|
|
124
|
+
left: SplitSide;
|
|
125
|
+
right: SplitSide;
|
|
126
|
+
};
|
|
127
|
+
type SceneEngine = {
|
|
128
|
+
readonly scene: Scene;
|
|
129
|
+
readonly camera: PerspectiveCamera;
|
|
130
|
+
readonly renderer: WebGLRenderer;
|
|
131
|
+
readonly controls: OrbitControls;
|
|
132
|
+
setSize(w: number, h: number): void;
|
|
133
|
+
setColorMode(mode: 'dark' | 'light' | string): void;
|
|
134
|
+
setScenePreset(preset: ScenePreset | null): void;
|
|
135
|
+
/** Override the preset's backdrop colour (`sceneColor`), or null to go back to it.
|
|
136
|
+
*
|
|
137
|
+
* The backdrop is also what the far floor fades into, so it is the horizon a
|
|
138
|
+
* tall frame looks up at. A clip meant to sit beside white stills wants that
|
|
139
|
+
* horizon to be the stills' white rather than the preset's grey. */
|
|
140
|
+
setSceneColor(color: string | null): void;
|
|
141
|
+
/** Initial camera position + orbit target from the active scene preset. */
|
|
142
|
+
getInitialView(): {
|
|
143
|
+
cameraPosition: Vector3Tuple;
|
|
144
|
+
target: Vector3Tuple;
|
|
145
|
+
};
|
|
146
|
+
setPaused(paused: boolean): void;
|
|
147
|
+
setWallVisible(visible: boolean): void;
|
|
148
|
+
/** Show or hide the floor and the shadow it takes. On by default for presets with a floor. */
|
|
149
|
+
setFloorVisible(visible: boolean): void;
|
|
150
|
+
/** How far the wall reaches past the product, in metres: each side, and above
|
|
151
|
+
* it. Default 0.5 and 0.3. Applies at the next updateWallMesh. */
|
|
152
|
+
setWallSurround(surround: {
|
|
153
|
+
side?: number;
|
|
154
|
+
top?: number;
|
|
155
|
+
}): void;
|
|
156
|
+
setWallThickness(thickness: number | undefined): boolean;
|
|
157
|
+
setWallPositionOffset(offset: number | undefined): boolean;
|
|
158
|
+
updateLighting(): void;
|
|
159
|
+
updateWallMesh(): void;
|
|
160
|
+
applyWallMaterial(material: Material): void;
|
|
161
|
+
applyFloorMaterial(material: Material): void;
|
|
162
|
+
/** Visible wall meshes — for point-occlusion raycasting. */
|
|
163
|
+
getOcclusionColliders(): Mesh[];
|
|
164
|
+
/** Request the next animation tick to render. Cheap; safe to call often. */
|
|
165
|
+
invalidate(): void;
|
|
166
|
+
/** Render every frame instead of only on invalidation. On-demand rendering
|
|
167
|
+
* drops frames that nothing invalidated, which reads as a stutter in a
|
|
168
|
+
* screen recording — capture tooling turns this on for the duration of a
|
|
169
|
+
* take and back off afterwards. */
|
|
170
|
+
setForceRender(force: boolean): void;
|
|
171
|
+
/** Hand camera control to an external driver. While a driver is set the
|
|
172
|
+
* engine stops calling controls.update(), so OrbitControls' polar clamp and
|
|
173
|
+
* damping can't fight whatever the driver writes to camera.position.
|
|
174
|
+
*
|
|
175
|
+
* Handoff is symmetric and needs no resync: OrbitControls re-derives its
|
|
176
|
+
* spherical state from camera.position on every update(), so clearing the
|
|
177
|
+
* driver resumes orbiting from wherever the camera was left. */
|
|
178
|
+
setCameraDriver(driver: ((deltaTime: number) => void) | null): void;
|
|
179
|
+
/** Bury the scene in fog, 0 (as composed) → 1 (nothing but the fog colour).
|
|
180
|
+
*
|
|
181
|
+
* A dissolve done in the SCENE rather than over it. Fading or scaling the
|
|
182
|
+
* canvas is a picture of a product being faded out; pulling the fog in is the
|
|
183
|
+
* product receding into distance and haze, which is the same move the eye
|
|
184
|
+
* reads as something leaving rather than something being switched off. It
|
|
185
|
+
* also composites correctly against a solid backdrop, where a CSS fade shows
|
|
186
|
+
* whatever is behind the canvas through the product on its way out.
|
|
187
|
+
*
|
|
188
|
+
* `color` is where the whole frame ends up — pass the colour of whatever
|
|
189
|
+
* lands next so the dissolve hands over with no cut. */
|
|
190
|
+
setFogVeil(amount: number, color?: string): void;
|
|
191
|
+
/** Trace the floor shadow and the product's occlusion once per configuration
|
|
192
|
+
* instead of drawing contact decals — see bakedLighting/bake. Off by default. */
|
|
193
|
+
setBakedLighting(enabled: boolean): void;
|
|
194
|
+
/** Draw a split comparison (see SplitView), or the scene alone with null. */
|
|
195
|
+
setSplitView(split: SplitView | null): void;
|
|
196
|
+
/** The baked lighting, once enabled — for measuring it. */
|
|
197
|
+
readonly bakedLighting: BakedLighting | null;
|
|
198
|
+
/** Resolves after the next frame on which renderer.render() actually ran.
|
|
199
|
+
*
|
|
200
|
+
* For callers that have to know the canvas holds a given state before
|
|
201
|
+
* reading its pixels. Screenshotting is the case that needs it: rendering is
|
|
202
|
+
* on-demand and driven by rAF, so a camera move written synchronously is not
|
|
203
|
+
* yet on the canvas when the caller's next line runs, and a capture taken
|
|
204
|
+
* there returns the PREVIOUS frame. Invalidates on subscribe, so a caller
|
|
205
|
+
* that awaits this while nothing else is dirtying the scene still gets a
|
|
206
|
+
* frame rather than waiting forever. */
|
|
207
|
+
nextRender(): Promise<void>;
|
|
208
|
+
/** Draw one frame immediately instead of waiting for requestAnimationFrame.
|
|
209
|
+
*
|
|
210
|
+
* For offline capture. rAF in a headless browser is paced by the compositor,
|
|
211
|
+
* which a screenshot then waits on as well — so a capture loop that waits for
|
|
212
|
+
* rAF before screenshotting pays that wait twice a frame. */
|
|
213
|
+
renderNow(): void;
|
|
214
|
+
start(): void;
|
|
215
|
+
stop(): void;
|
|
216
|
+
dispose(): void;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
type CapturedPhoto = {
|
|
220
|
+
name: string;
|
|
221
|
+
label: string;
|
|
222
|
+
dataUrl: string;
|
|
223
|
+
};
|
|
224
|
+
type PhotoCaptureLabels = {
|
|
225
|
+
front: string;
|
|
226
|
+
back: string;
|
|
227
|
+
left: string;
|
|
228
|
+
right: string;
|
|
229
|
+
top: string;
|
|
230
|
+
isometric: string;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
type EnvironmentName = 'legacy' | 'neutral' | 'surround' | 'studio';
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Lighting for product photos, the way a photographer describes it.
|
|
237
|
+
*
|
|
238
|
+
* A light is placed RELATIVE TO THE CAMERA, not to the room: "key 40° to the
|
|
239
|
+
* left, 40° up". Every angle of a set (front, side, three-quarter…) is then lit
|
|
240
|
+
* the same way, which is what makes a set of photos read as one shoot — the
|
|
241
|
+
* photographer walks round the product with the stands, not past them.
|
|
242
|
+
*/
|
|
243
|
+
type PhotoLightId = 'key' | 'fill' | 'rim';
|
|
244
|
+
type PhotoLight = {
|
|
245
|
+
id: PhotoLightId;
|
|
246
|
+
enabled: boolean;
|
|
247
|
+
/** Degrees around the product from the camera: 0 = beside the lens, 90 = camera's right, ±180 = behind. */
|
|
248
|
+
azimuth: number;
|
|
249
|
+
/** Degrees above the horizon. */
|
|
250
|
+
elevation: number;
|
|
251
|
+
/** Light falling on the product (a DirectionalLight's intensity). */
|
|
252
|
+
intensity: number;
|
|
253
|
+
/** 0 = a bare bulb (hard shadow), 1 = a large softbox (soft, wrapping shadow). */
|
|
254
|
+
softness: number;
|
|
255
|
+
/** Colour temperature in kelvin; 5600 is daylight-balanced, lower is warmer. */
|
|
256
|
+
temperature: number;
|
|
257
|
+
};
|
|
258
|
+
type PhotoSetup = {
|
|
259
|
+
id: string;
|
|
260
|
+
/** The room the reflections and the ambient come from. */
|
|
261
|
+
environment: EnvironmentName;
|
|
262
|
+
environmentIntensity: number;
|
|
263
|
+
/** Degrees; turns the room, and with it where the reflections sit. */
|
|
264
|
+
environmentRotation: number;
|
|
265
|
+
/** Stops of exposure applied by the tone curve (0 = none). */
|
|
266
|
+
exposure: number;
|
|
267
|
+
/** The sweep behind and under the product. */
|
|
268
|
+
backdrop: string;
|
|
269
|
+
/**
|
|
270
|
+
* How much of the product's shadow the floor shows, 0–1 (1 = all of it, as
|
|
271
|
+
* lit). Only the floor's: the product's own shading is never touched.
|
|
272
|
+
*/
|
|
273
|
+
floorShadow: number;
|
|
274
|
+
lights: PhotoLight[];
|
|
275
|
+
/**
|
|
276
|
+
* No studio at all: the configurator's own scene — its lights, its floor,
|
|
277
|
+
* the baked lighting and the contact shadows — photographed as the viewport
|
|
278
|
+
* shows it. The lights, environment and floor shadow above do not apply;
|
|
279
|
+
* `backdrop` empty keeps the configurator's own background.
|
|
280
|
+
*/
|
|
281
|
+
live?: boolean;
|
|
282
|
+
};
|
|
283
|
+
declare const PHOTO_SETUP_IDS: readonly ["configurator", "catalogue", "daylight", "dramatic", "dark"];
|
|
284
|
+
type PhotoSetupId = (typeof PHOTO_SETUP_IDS)[number];
|
|
285
|
+
/**
|
|
286
|
+
* The authored setups. Each one is a complete starting point; the per-light
|
|
287
|
+
* controls in the photo dialog adjust a copy, never these.
|
|
288
|
+
*/
|
|
289
|
+
declare const PHOTO_SETUPS: Record<PhotoSetupId, PhotoSetup>;
|
|
290
|
+
/** A setup to edit: its lights are copies, so adjusting one never touches the authored setup. */
|
|
291
|
+
declare function clonePhotoSetup(setup: PhotoSetup): PhotoSetup;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Where the camera stands for one photo, in the terms a photographer uses.
|
|
295
|
+
*
|
|
296
|
+
* The product sits at the origin of this description: `azimuth` walks around
|
|
297
|
+
* it (0° is the front, positive is round to the product's right, as seen from
|
|
298
|
+
* above), `elevation` lifts the camera off the floor plane, `fov` is the lens
|
|
299
|
+
* (a smaller angle is a longer lens: flatter, more flattering) and `zoom`
|
|
300
|
+
* scales the framing distance — 1 frames the whole product with the usual
|
|
301
|
+
* padding, 0.6 moves in for a detail. Framing itself is always computed from
|
|
302
|
+
* the product's bounds, so a shot reads the same on a stool and a six-seat
|
|
303
|
+
* sofa.
|
|
304
|
+
*
|
|
305
|
+
* The six classic angles the configurator has always photographed are presets
|
|
306
|
+
* here, in exactly the positions `buildCameraPositions` used, so a photo asked
|
|
307
|
+
* for by its old name is the photo it was.
|
|
308
|
+
*/
|
|
309
|
+
type PhotoShot = {
|
|
310
|
+
name: string;
|
|
311
|
+
/** Degrees around the product: 0 front, 90 right side, 180 back, -90 (or 270) left side. */
|
|
312
|
+
azimuth: number;
|
|
313
|
+
/** Degrees above the floor plane: 0 at eye level with the floor, 90 straight down. */
|
|
314
|
+
elevation: number;
|
|
315
|
+
/** Vertical field of view in degrees. Default 30; 20–24 is a long lens, 40+ wide. */
|
|
316
|
+
fov?: number;
|
|
317
|
+
/** Framing distance multiplier: 1 shows the whole product, below 1 moves in. */
|
|
318
|
+
zoom?: number;
|
|
319
|
+
};
|
|
320
|
+
declare const PHOTO_SHOT_PRESETS: {
|
|
321
|
+
readonly front: {
|
|
322
|
+
readonly name: "front";
|
|
323
|
+
readonly azimuth: 0;
|
|
324
|
+
readonly elevation: number;
|
|
325
|
+
};
|
|
326
|
+
readonly back: {
|
|
327
|
+
readonly name: "back";
|
|
328
|
+
readonly azimuth: 180;
|
|
329
|
+
readonly elevation: number;
|
|
330
|
+
};
|
|
331
|
+
readonly left: {
|
|
332
|
+
readonly name: "left";
|
|
333
|
+
readonly azimuth: -90;
|
|
334
|
+
readonly elevation: number;
|
|
335
|
+
};
|
|
336
|
+
readonly right: {
|
|
337
|
+
readonly name: "right";
|
|
338
|
+
readonly azimuth: 90;
|
|
339
|
+
readonly elevation: number;
|
|
340
|
+
};
|
|
341
|
+
readonly top: {
|
|
342
|
+
readonly name: "top";
|
|
343
|
+
readonly azimuth: 0;
|
|
344
|
+
readonly elevation: 89.4;
|
|
345
|
+
readonly zoom: 1.2;
|
|
346
|
+
};
|
|
347
|
+
readonly isometric: {
|
|
348
|
+
readonly name: "isometric";
|
|
349
|
+
readonly azimuth: 45;
|
|
350
|
+
readonly elevation: number;
|
|
351
|
+
readonly zoom: 1.1;
|
|
352
|
+
};
|
|
353
|
+
/** The catalogue's three-quarter view: a little round to the right, a little above. */
|
|
354
|
+
readonly threeQuarter: {
|
|
355
|
+
readonly name: "threeQuarter";
|
|
356
|
+
readonly azimuth: 35;
|
|
357
|
+
readonly elevation: 18;
|
|
358
|
+
};
|
|
359
|
+
readonly threeQuarterLeft: {
|
|
360
|
+
readonly name: "threeQuarterLeft";
|
|
361
|
+
readonly azimuth: -35;
|
|
362
|
+
readonly elevation: 18;
|
|
363
|
+
};
|
|
364
|
+
/** Low and long-lensed: the product looms, the way a hero image wants it. */
|
|
365
|
+
readonly hero: {
|
|
366
|
+
readonly name: "hero";
|
|
367
|
+
readonly azimuth: 30;
|
|
368
|
+
readonly elevation: 7;
|
|
369
|
+
readonly fov: 22;
|
|
370
|
+
};
|
|
371
|
+
/** Straight on with a long lens: an elevation drawing with light on it. */
|
|
372
|
+
readonly profile: {
|
|
373
|
+
readonly name: "profile";
|
|
374
|
+
readonly azimuth: 90;
|
|
375
|
+
readonly elevation: 4;
|
|
376
|
+
readonly fov: 20;
|
|
377
|
+
};
|
|
378
|
+
/** In close on the seat and its fabric. */
|
|
379
|
+
readonly closeUp: {
|
|
380
|
+
readonly name: "closeUp";
|
|
381
|
+
readonly azimuth: 25;
|
|
382
|
+
readonly elevation: 14;
|
|
383
|
+
readonly fov: 24;
|
|
384
|
+
readonly zoom: 0.55;
|
|
385
|
+
};
|
|
386
|
+
/** Looking down into the configuration: how the modules join. */
|
|
387
|
+
readonly overhead: {
|
|
388
|
+
readonly name: "overhead";
|
|
389
|
+
readonly azimuth: 20;
|
|
390
|
+
readonly elevation: 62;
|
|
391
|
+
readonly zoom: 1.1;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
type PhotoShotPreset = keyof typeof PHOTO_SHOT_PRESETS;
|
|
395
|
+
declare const PHOTO_SHOT_PRESET_NAMES: PhotoShotPreset[];
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Product photos from a lit studio: a live preview while the lighting is
|
|
399
|
+
* adjusted, then the photos themselves — rasterised ("fast") or path traced
|
|
400
|
+
* ("best"). A "best" photo path traces only the light, small and briefly, and
|
|
401
|
+
* rebuilds the full-size photo around the rasterised texture (reconstruct.ts):
|
|
402
|
+
* a few seconds a photo instead of a minute.
|
|
403
|
+
*
|
|
404
|
+
* The studio is opened when the photo dialog opens and closed when it closes;
|
|
405
|
+
* in between the live scene IS the studio (see stage.ts), so the caller must
|
|
406
|
+
* keep the configurator from drawing over it (pause its render loop).
|
|
407
|
+
*/
|
|
408
|
+
type PhotoAngle = keyof PhotoCaptureLabels;
|
|
409
|
+
declare const PHOTO_ANGLES: PhotoAngle[];
|
|
410
|
+
type PhotoQuality = 'fast' | 'best';
|
|
411
|
+
type StudioCaptureOptions = {
|
|
412
|
+
setup: PhotoSetup;
|
|
413
|
+
quality: PhotoQuality;
|
|
414
|
+
transparent: boolean;
|
|
415
|
+
/** On a transparent background, keep the product's shadow on the floor. */
|
|
416
|
+
shadow: boolean;
|
|
417
|
+
width: number;
|
|
418
|
+
height: number;
|
|
419
|
+
/** The photos to take: classic angles by name, presets, or shots composed by hand (shots.ts). */
|
|
420
|
+
angles: (PhotoAngle | PhotoShotPreset | PhotoShot)[];
|
|
421
|
+
/** Most path-traced samples per pixel ("best"); fewer if the time runs out. */
|
|
422
|
+
samples?: number;
|
|
423
|
+
/** Time to spend sampling one photo, in ms ("best"). */
|
|
424
|
+
timeLimit?: number;
|
|
425
|
+
signal?: AbortSignal;
|
|
426
|
+
/** `fraction` is how far the current photo is, 0–1. */
|
|
427
|
+
onProgress?: (progress: {
|
|
428
|
+
index: number;
|
|
429
|
+
count: number;
|
|
430
|
+
/** The shot's name — a classic angle, a preset, or whatever the shot was called. */
|
|
431
|
+
angle: string;
|
|
432
|
+
label: string;
|
|
433
|
+
fraction: number;
|
|
434
|
+
}) => void;
|
|
435
|
+
};
|
|
436
|
+
type PhotoStudio = {
|
|
437
|
+
/** Whether this device can path trace (float render targets). */
|
|
438
|
+
readonly canPathTrace: boolean;
|
|
439
|
+
/** A quick rasterised look at one angle, at a small size — instant, for while sliders move. */
|
|
440
|
+
preview: (setup: PhotoSetup, angle: PhotoAngle, options: PreviewOptions) => ImageData | null;
|
|
441
|
+
/**
|
|
442
|
+
* The same look as a "best" photo will have — path traced through the very
|
|
443
|
+
* pipeline the photo takes, small and in well under a second. The raster
|
|
444
|
+
* preview cannot match the final's exposure (it has no bounce light and no
|
|
445
|
+
* occlusion), so this is what the user judges the photo by.
|
|
446
|
+
*/
|
|
447
|
+
refine: (setup: PhotoSetup, angle: PhotoAngle, options: PreviewOptions & {
|
|
448
|
+
signal?: AbortSignal;
|
|
449
|
+
}) => Promise<ImageData | null>;
|
|
450
|
+
capture: (options: StudioCaptureOptions) => Promise<CapturedPhoto[]>;
|
|
451
|
+
dispose: () => void;
|
|
452
|
+
};
|
|
453
|
+
type PreviewOptions = {
|
|
454
|
+
transparent: boolean;
|
|
455
|
+
shadow: boolean;
|
|
456
|
+
width: number;
|
|
457
|
+
height: number;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
declare global {
|
|
461
|
+
interface Window {
|
|
462
|
+
webkit?: any;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
declare const ARMode: {
|
|
466
|
+
readonly QUICK_LOOK: "quick-look";
|
|
467
|
+
readonly SCENE_VIEWER: "scene-viewer";
|
|
468
|
+
/** In-browser AR through WebXR `immersive-ar` (Android Chrome, on ARCore). */
|
|
469
|
+
readonly WEBXR: "webxr";
|
|
470
|
+
readonly NONE: "none";
|
|
471
|
+
};
|
|
472
|
+
type ARModeValue = (typeof ARMode)[keyof typeof ARMode];
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* The whole AR flow as plain functions and plain state: device detection,
|
|
476
|
+
* export / upload / convert, launch, and failure detection. `useAR()` in
|
|
477
|
+
* `@konfigure/ar/vue` is this controller with its state mirrored into refs;
|
|
478
|
+
* @konfigure/sdk's view drives it directly.
|
|
479
|
+
*/
|
|
480
|
+
declare const DEFAULT_AR_MESSAGES: {
|
|
481
|
+
scanHint: string;
|
|
482
|
+
placedHint: string;
|
|
483
|
+
close: string;
|
|
484
|
+
quickLook: string;
|
|
485
|
+
sceneViewer: string;
|
|
486
|
+
/** Scene Viewer opened and closed again within seconds — it crashed. */
|
|
487
|
+
sceneViewerClosed: string;
|
|
488
|
+
webxr: string;
|
|
489
|
+
};
|
|
490
|
+
/** Every user-facing string of the AR flow; override any of them (e.g. for i18n). */
|
|
491
|
+
type ARMessages = Partial<typeof DEFAULT_AR_MESSAGES>;
|
|
492
|
+
type ARFailureKind = 'quickLook' | 'sceneViewer' | 'sceneViewerClosed' | 'webxr';
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* AR for the view: @konfigure/ar's controller (the flow `useAR()` runs in the
|
|
496
|
+
* configurator) with the view's current module as the model — exported the
|
|
497
|
+
* way the configurator exports it (`buildExportObject3D`: finishes on, mirrors
|
|
498
|
+
* baked, in metres, so it stands at its real size), posed as it is on screen.
|
|
499
|
+
*
|
|
500
|
+
* - Android: WebXR in Chrome (nothing to prepare); Scene Viewer where WebXR is
|
|
501
|
+
* missing, which needs the GLB uploaded to the instance first.
|
|
502
|
+
* - iOS: AR Quick Look with a USDZ built in the page.
|
|
503
|
+
*
|
|
504
|
+
* Scene Viewer only opens from a tap with no `await` before it, and building a
|
|
505
|
+
* USDZ can take longer than iOS keeps a tap's permission. So for those two
|
|
506
|
+
* modes the view builds the file in the background once the picture has
|
|
507
|
+
* settled, and `start()` launches it synchronously when it is current.
|
|
508
|
+
*/
|
|
509
|
+
type ARSupport = {
|
|
510
|
+
supported: boolean;
|
|
511
|
+
/** `webxr` / `scene-viewer` (Android), `quick-look` (iOS), or `none`. */
|
|
512
|
+
mode: ARModeValue;
|
|
513
|
+
/** Why not: `device` (a desktop — show a QR code) or `browser` (switch browser). */
|
|
514
|
+
reason: 'device' | 'browser' | null;
|
|
515
|
+
};
|
|
516
|
+
type ARFailure = {
|
|
517
|
+
kind: ARFailureKind;
|
|
518
|
+
message: string;
|
|
519
|
+
};
|
|
520
|
+
type ViewAROptions = {
|
|
521
|
+
/** Every user-facing string of the AR flow, e.g. translated. English by default. */
|
|
522
|
+
messages?: ARMessages;
|
|
523
|
+
/** Title shown in Scene Viewer. */
|
|
524
|
+
title?: string;
|
|
525
|
+
/** Where Scene Viewer's GLB is uploaded. Default `<instance>/api/ar/upload-model`. */
|
|
526
|
+
uploadEndpoint?: string;
|
|
527
|
+
/** Build the AR file in the background after each change (Quick Look, Scene Viewer). Default true. */
|
|
528
|
+
prepareInBackground?: boolean;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
/** The photos' names, as `CapturedPhoto.label` carries them. English by default. */
|
|
532
|
+
declare const DEFAULT_PHOTO_LABELS: PhotoCaptureLabels;
|
|
533
|
+
type StudioOptions = {
|
|
534
|
+
/** The angles' names on the photos, e.g. translated. */
|
|
535
|
+
labels?: Partial<PhotoCaptureLabels>;
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* @konfigure/sdk/view — the configurator drawn with the product's own engine:
|
|
540
|
+
* the same module/part builders and catalogue adapter the app and the
|
|
541
|
+
* marketing hero run, finishes built by the app's material code, the scene
|
|
542
|
+
* from `createScene`. It follows the configurator: every `change` rebuilds the
|
|
543
|
+
* module from the new state.
|
|
544
|
+
*
|
|
545
|
+
* Browser only. Import it lazily (`await import('@konfigure/sdk/view')`) so
|
|
546
|
+
* SSR never evaluates three.js.
|
|
547
|
+
*/
|
|
548
|
+
/**
|
|
549
|
+
* Where the camera looks from. `back` is the other side of `front` — for a
|
|
550
|
+
* window drawn with its room side to the front (BL 70 slim), the street side.
|
|
551
|
+
*/
|
|
552
|
+
type CameraPreset = 'front' | 'threeQuarter' | 'left' | 'right' | 'top' | 'back';
|
|
553
|
+
/** How a window (or door) opens: turned on its hinges, or tilted in at the top. */
|
|
554
|
+
type OpenMode = 'turn' | 'tilt';
|
|
555
|
+
/** The view's open state: a mode, or closed. */
|
|
556
|
+
type OpenState = OpenMode | 'closed';
|
|
557
|
+
type ViewEvents = {
|
|
558
|
+
/** The open modes the drawn model supports changed (after a rebuild); `[]` for a fixed pane. */
|
|
559
|
+
openmodes: OpenMode[];
|
|
560
|
+
/** The open state the view is heading to or holds changed. */
|
|
561
|
+
open: OpenState;
|
|
562
|
+
/** AR state changed (detected, preparing, prepared, launched). */
|
|
563
|
+
ar: {
|
|
564
|
+
mode: ARSupport['mode'];
|
|
565
|
+
loading: boolean;
|
|
566
|
+
prepared: boolean;
|
|
567
|
+
};
|
|
568
|
+
/** An AR launch failed; `message` is ready to show (see `ar.messages`). */
|
|
569
|
+
arfailure: ARFailure;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
type MountViewOptions = {
|
|
573
|
+
/** Where the camera starts. Default `front`. */
|
|
574
|
+
camera?: CameraPreset;
|
|
575
|
+
/** The scene preset; the product line's own by default (`wall` for windows). */
|
|
576
|
+
scenePreset?: string | null;
|
|
577
|
+
/**
|
|
578
|
+
* Set the product into a wall, on a `wall` preset (windows, doors): the
|
|
579
|
+
* reveal around it and, under a window, the parapet. Default true. `false`
|
|
580
|
+
* shows the product on its own.
|
|
581
|
+
*/
|
|
582
|
+
wall?: boolean;
|
|
583
|
+
/**
|
|
584
|
+
* Show the floor and the shadow on it. Default: on, except on a `wall`
|
|
585
|
+
* preset with `wall: false` — a window without its wall would hang above
|
|
586
|
+
* the floor, with the horizon running behind its glass.
|
|
587
|
+
*/
|
|
588
|
+
floor?: boolean;
|
|
589
|
+
/** Backdrop colour, e.g. your page background. Default: the preset's. */
|
|
590
|
+
background?: string;
|
|
591
|
+
/** `light` (default) or `dark` scene styling. */
|
|
592
|
+
colorMode?: 'light' | 'dark';
|
|
593
|
+
/** Let the visitor orbit and zoom. Default true. */
|
|
594
|
+
interactive?: boolean;
|
|
595
|
+
/** Turn slowly until the visitor grabs it. Default false. */
|
|
596
|
+
autoRotate?: boolean;
|
|
597
|
+
/** Where the Draco decoder lives (only for Draco-compressed GLBs). Default: three.js's CDN. */
|
|
598
|
+
dracoDecoderPath?: string;
|
|
599
|
+
/** Called when a rebuild fails (a missing model, a network error). */
|
|
600
|
+
onError?: (error: unknown) => void;
|
|
601
|
+
/** Show the dimension lines from the start (`setDimensions` toggles them). Default false. */
|
|
602
|
+
dimensions?: boolean;
|
|
603
|
+
/** Units of the dimension labels. Default `mm`. */
|
|
604
|
+
dimensionUnit?: 'mm' | 'cm';
|
|
605
|
+
/** AR settings: messages, Scene Viewer title, background preparation. */
|
|
606
|
+
ar?: ViewAROptions;
|
|
607
|
+
};
|
|
608
|
+
/**
|
|
609
|
+
* Draw `configurator` into `container`. A `<canvas>` is drawn into directly;
|
|
610
|
+
* any other element gets a canvas filling it. The view resizes with the
|
|
611
|
+
* element and redraws on every configurator change.
|
|
612
|
+
*/
|
|
613
|
+
declare function mountView(container: HTMLElement, configurator: Configurator, options?: MountViewOptions): Promise<{
|
|
614
|
+
/** Resolves once the latest change is on screen. */
|
|
615
|
+
whenReady: () => Promise<void>;
|
|
616
|
+
/** Move the camera to a preset, framed on the product. */
|
|
617
|
+
setCamera(preset: CameraPreset): void;
|
|
618
|
+
/** Listen to a view event; returns the unsubscribe function. */
|
|
619
|
+
on<K extends keyof ViewEvents>(event: K, listener: (payload: ViewEvents[K]) => void): () => void;
|
|
620
|
+
/** How the drawn model opens: `['turn', 'tilt']`, `['turn']`, or `[]` for a fixed pane. */
|
|
621
|
+
openModes: () => OpenMode[];
|
|
622
|
+
/** The open state the view holds or is heading to. */
|
|
623
|
+
openState: () => OpenState;
|
|
624
|
+
/**
|
|
625
|
+
* Open the window (every sash that opens that way, together) or close it.
|
|
626
|
+
* Resolves when it has arrived, or when a later call took over. A mode the
|
|
627
|
+
* model doesn't support is ignored. Switching from one mode to the other
|
|
628
|
+
* closes the first one before the second starts.
|
|
629
|
+
*/
|
|
630
|
+
setOpen(state: OpenState): Promise<void>;
|
|
631
|
+
/**
|
|
632
|
+
* Show or hide the dimension lines (width × height × depth). The camera
|
|
633
|
+
* steps back to make room for them, from the angle it is at.
|
|
634
|
+
*/
|
|
635
|
+
setDimensions(on: boolean): void;
|
|
636
|
+
dimensionsVisible: () => boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Turn the view into the configurator's photo studio (the engine behind its
|
|
639
|
+
* product-photo dialog), photographing what is on screen: the model, its
|
|
640
|
+
* finishes and its open state. Until `studio.dispose()` the view stops
|
|
641
|
+
* drawing and taking input — the scene is the studio's — then comes back
|
|
642
|
+
* as it was. One at a time: a second `openStudio` throws `studio_open`.
|
|
643
|
+
* Configurator changes made meanwhile are drawn when the studio closes;
|
|
644
|
+
* `setOpen` throws `studio_open`.
|
|
645
|
+
*/
|
|
646
|
+
openStudio: (studioOptions?: StudioOptions) => PhotoStudio;
|
|
647
|
+
/** Whether a photo studio is open on the view. */
|
|
648
|
+
studioOpen: () => boolean;
|
|
649
|
+
/** Whether this device can show AR, and how. Desktop: `{ supported: false, reason: 'device' }`. */
|
|
650
|
+
arSupport: () => Promise<ARSupport>;
|
|
651
|
+
/**
|
|
652
|
+
* Build the AR file for what is on screen now (Quick Look's USDZ, Scene
|
|
653
|
+
* Viewer's uploaded GLB). The view does this by itself a moment after
|
|
654
|
+
* every change; call it to be sure before showing an AR button.
|
|
655
|
+
*/
|
|
656
|
+
prepareAR: () => Promise<boolean>;
|
|
657
|
+
/**
|
|
658
|
+
* Launch AR for what is on screen — model, finishes and open state, at
|
|
659
|
+
* real size. Call it directly from a click handler (no `await` before it).
|
|
660
|
+
* Resolves true when AR was launched.
|
|
661
|
+
*/
|
|
662
|
+
startAR: () => Promise<boolean>;
|
|
663
|
+
/** The drawn model as a file, as AR gets it: `glb`, or `usdz` (Quick Look). */
|
|
664
|
+
exportModel: (format: "glb" | "usdz") => Promise<Blob>;
|
|
665
|
+
/** The current frame as a PNG data URL. */
|
|
666
|
+
capture(): string;
|
|
667
|
+
/** The underlying scene engine — an escape hatch; not a stable API. */
|
|
668
|
+
engine: SceneEngine;
|
|
669
|
+
/** Stop following the configurator and free the GPU. */
|
|
670
|
+
dispose(): void;
|
|
671
|
+
}>;
|
|
672
|
+
type KonfigureView = Awaited<ReturnType<typeof mountView>>;
|
|
673
|
+
|
|
674
|
+
export { type ARFailure, type ARSupport, type CameraPreset, type CapturedPhoto, DEFAULT_PHOTO_LABELS, type KonfigureView, type MountViewOptions, type OpenMode, type OpenState, PHOTO_ANGLES, PHOTO_SETUPS, PHOTO_SETUP_IDS, PHOTO_SHOT_PRESET_NAMES, type PhotoAngle, type PhotoCaptureLabels, type PhotoLight, type PhotoLightId, type PhotoQuality, type PhotoSetup, type PhotoSetupId, type PhotoShot, type PhotoShotPreset, type PhotoStudio, type PreviewOptions, type StudioCaptureOptions, type StudioOptions, type ViewAROptions, type ViewEvents, clonePhotoSetup, mountView };
|