depthview-r3f-bridge 0.1.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.
@@ -0,0 +1,454 @@
1
+ /**
2
+ * A "look": everything that makes a three.js scene read as real, as one plain JSON object.
3
+ * Colour management, render quality, the world (studio lighting as an environment map), soft
4
+ * shadows, surface materials, bevelled edges and lens effects. It mirrors the handful of
5
+ * Blender panels that decide realism, nothing else.
6
+ *
7
+ * Pure maths with no three.js import. The Depthview extension applies a look to the live page
8
+ * (with the page's own three.js classes), and `applyLook` in ./lookRuntime applies the same
9
+ * look in the developer's site, so what was tuned in the inspector is what ships.
10
+ */
11
+ export type Rgb = [number, number, number];
12
+ export type ToneMapping = 'site' | 'none' | 'linear' | 'reinhard' | 'cineon' | 'aces' | 'agx' | 'neutral';
13
+ /** three.js constants for each tone mapping. AgX needs r160, Neutral r162. */
14
+ export declare const TONE_MAPPING: Record<Exclude<ToneMapping, 'site'>, number>;
15
+ export declare const TONE_MAPPING_MIN_REVISION: Partial<Record<ToneMapping, number>>;
16
+ /** A rectangular studio light, placed on a sphere around the scene. Seen only in reflections and as soft light. */
17
+ export interface LightBox {
18
+ id: string;
19
+ name: string;
20
+ /** Degrees around the scene: 0 in front (+Z), 90 to the right (+X), 180 behind. */
21
+ azimuth: number;
22
+ /** Degrees above the horizon: 0 level, 90 straight overhead, negative from below. */
23
+ elevation: number;
24
+ /** Angular size in degrees. */
25
+ width: number;
26
+ height: number;
27
+ /** Brightness. 1 is a white wall, 5 a softbox, 15 a bare lamp. */
28
+ intensity: number;
29
+ /** "#rrggbb". */
30
+ color: string;
31
+ /** Edge softness, 0 (hard) to 1 (fades from the centre). */
32
+ softness: number;
33
+ }
34
+ export interface Sky {
35
+ /** "#rrggbb" at the zenith, the horizon and straight down. */
36
+ top: string;
37
+ horizon: string;
38
+ ground: string;
39
+ /** Brightness of the gradient. */
40
+ intensity: number;
41
+ }
42
+ export type WorldPreset = 'site' | 'studio' | 'softbox' | 'sunset' | 'overcast' | 'night';
43
+ export interface WorldLook {
44
+ /** "site": the scene keeps its own environment. Anything else replaces it. */
45
+ preset: WorldPreset;
46
+ /** Overall brightness of the environment. */
47
+ strength: number;
48
+ /** Turns the light boxes around the scene, degrees. */
49
+ rotation: number;
50
+ /** Also show the environment behind the scene. */
51
+ background: boolean;
52
+ sky: Sky;
53
+ boxes: LightBox[];
54
+ }
55
+ export interface ShadowLook {
56
+ /** "site": shadows are left as the site has them. */
57
+ mode: 'site' | 'on' | 'off';
58
+ /** Blur of the shadow edge, 0 to 10. */
59
+ softness: number;
60
+ /** Shadow map size: 1024, 2048 or 4096. */
61
+ resolution: number;
62
+ }
63
+ export type MaterialPreset = 'custom' | 'polished-metal' | 'brushed-metal' | 'gold' | 'car-paint' | 'glass' | 'plastic' | 'ceramic' | 'rubber';
64
+ export type DetailPattern = 'brushed' | 'rings' | 'hammered' | 'knurl' | 'text';
65
+ /**
66
+ * Fine surface detail as a generated normal map: grooves, a brushed finish, engraved text.
67
+ * Detail that would need thousands of triangles, and would shimmer as geometry, costs one
68
+ * texture and stays sharp.
69
+ */
70
+ export interface SurfaceDetail {
71
+ pattern: DetailPattern;
72
+ /** Depth of the relief, 0 to 2. */
73
+ strength: number;
74
+ /** How many times the pattern repeats across the surface: rings, streak density, grid size. */
75
+ scale: number;
76
+ /** For "text": engraved around the centre of the surface, like the legend of a coin. */
77
+ text?: string;
78
+ }
79
+ /** Surface settings of one object, the Principled BSDF subset three.js has. */
80
+ export interface MaterialLook {
81
+ /** Live object id. Not stable across reloads: `name` is what the saved file uses. */
82
+ uuid?: string;
83
+ name: string;
84
+ preset: MaterialPreset;
85
+ color?: string;
86
+ metalness?: number;
87
+ roughness?: number;
88
+ /** MeshPhysicalMaterial only. */
89
+ clearcoat?: number;
90
+ clearcoatRoughness?: number;
91
+ transmission?: number;
92
+ ior?: number;
93
+ thickness?: number;
94
+ /** How strongly the surface reflects the world. */
95
+ envMapIntensity?: number;
96
+ detail?: SurfaceDetail;
97
+ }
98
+ export interface BevelLook {
99
+ /** "all": every box and cylinder mesh. "selected": only `targets`. */
100
+ mode: 'off' | 'all' | 'selected';
101
+ /** Edge radius as a fraction of the object's smallest side, 0 to 0.5. */
102
+ amount: number;
103
+ /** Steps along the rounded edge, 1 to 8. */
104
+ segments: number;
105
+ targets: Array<{
106
+ uuid?: string;
107
+ name: string;
108
+ }>;
109
+ }
110
+ export interface EffectsLook {
111
+ /** Smooth edges: multisampling on the effect buffers plus SMAA. */
112
+ antialias: boolean;
113
+ ao: {
114
+ on: boolean;
115
+ intensity: number;
116
+ radius: number;
117
+ };
118
+ bloom: {
119
+ on: boolean;
120
+ strength: number;
121
+ threshold: number;
122
+ radius: number;
123
+ };
124
+ dof: {
125
+ on: boolean;
126
+ focus: number;
127
+ aperture: number;
128
+ maxBlur: number;
129
+ };
130
+ vignette: number;
131
+ grain: number;
132
+ }
133
+ export interface PerformanceLook {
134
+ /**
135
+ * On a device that cannot hold the target frame rate, the site steps the look down by itself
136
+ * (shadow detail, pixel ratio, then the heavier lens effects), the same steps `lighten` takes.
137
+ */
138
+ adaptive: boolean;
139
+ /** Frames per second the look should hold: 30, 45 or 60. */
140
+ targetFps: number;
141
+ }
142
+ /**
143
+ * How one model sits in the scene: its size, its height, and how strongly it reflects the world.
144
+ * Set by the adapt pass when a model arrives at the wrong scale or floats above the floor.
145
+ */
146
+ export interface ModelLook {
147
+ /** Live object id. Not stable across reloads: `name` is what the saved file uses. */
148
+ uuid?: string;
149
+ name: string;
150
+ /** Multiplies the model's own scale. */
151
+ scale?: number;
152
+ /** Moves the model up (or down, when negative), in world units. */
153
+ lift?: number;
154
+ /** Multiplies how strongly every surface of the model reflects the world. */
155
+ reflection?: number;
156
+ }
157
+ export interface AdaptLook {
158
+ /**
159
+ * When objects are added to or removed from the scene, everything that depends on them is
160
+ * fitted again: the shadow area, which meshes cast and receive, texture sharpness, surfaces
161
+ * and bevels found by name.
162
+ */
163
+ follow: boolean;
164
+ /**
165
+ * Colour textures are read as sRGB and data textures (normal, roughness, metalness) as plain
166
+ * numbers, whatever the loader set.
167
+ */
168
+ textures: boolean;
169
+ }
170
+ export interface Look {
171
+ version: 1;
172
+ color: {
173
+ toneMapping: ToneMapping;
174
+ /** null: the site's own exposure. */ exposure: number | null;
175
+ };
176
+ quality: {
177
+ /** Highest pixel ratio to render at (the screen's own is never exceeded). null: the site's. */
178
+ pixelRatio: number | null;
179
+ /** Sharp textures at glancing angles. */
180
+ anisotropy: boolean;
181
+ /**
182
+ * On screens with one device pixel per CSS pixel, render at 1.5× and let the browser scale
183
+ * it down: edges stop stair-stepping and thin lines stop shimmering. No effect on denser
184
+ * screens.
185
+ */
186
+ supersample: boolean;
187
+ };
188
+ world: WorldLook;
189
+ shadows: ShadowLook;
190
+ materials: MaterialLook[];
191
+ bevel: BevelLook;
192
+ effects: EffectsLook;
193
+ performance: PerformanceLook;
194
+ adapt: AdaptLook;
195
+ models: ModelLook[];
196
+ }
197
+ export declare const NEUTRAL_SKY: Sky;
198
+ /** The look that changes nothing: every section is "site". */
199
+ export declare function defaultLook(): Look;
200
+ /** World presets: a sky gradient and the studio lights around it. */
201
+ export declare const WORLD_PRESETS: Record<Exclude<WorldPreset, 'site'>, {
202
+ label: string;
203
+ hint: string;
204
+ sky: Sky;
205
+ boxes: LightBox[];
206
+ }>;
207
+ /** Surface presets. `physical` values only apply to MeshPhysicalMaterial. */
208
+ export declare const MATERIAL_PRESETS: Record<Exclude<MaterialPreset, 'custom'>, {
209
+ label: string;
210
+ values: Omit<MaterialLook, 'uuid' | 'name' | 'preset'>;
211
+ }>;
212
+ /** A sensible repeat for each pattern. */
213
+ export declare const DETAIL_SCALE: Record<DetailPattern, number>;
214
+ /** A depth at which each pattern reads as a finish, not as damage. */
215
+ export declare const DETAIL_STRENGTH: Record<DetailPattern, number>;
216
+ export declare const DETAIL_LABELS: Record<DetailPattern, string>;
217
+ /** Any input (a saved file, an agent's patch result) as a complete, clamped look. */
218
+ export declare function normalizeLook(input: unknown): Look;
219
+ /**
220
+ * A look with a partial change merged in, section by section. Arrays (light boxes, materials,
221
+ * bevel targets) are replaced whole. Choosing a world preset without boxes loads that preset's
222
+ * sky and boxes.
223
+ */
224
+ export declare function mergeLook(look: Look, patch: unknown): Look;
225
+ /** True when the look leaves the site exactly as it is. */
226
+ export declare function isNeutral(look: Look): boolean;
227
+ /** Sets or replaces the surface settings of one object. */
228
+ export declare function withMaterial(look: Look, material: MaterialLook): Look;
229
+ /** Sets or replaces how one model sits in the scene. */
230
+ export declare function withModel(look: Look, model: ModelLook): Look;
231
+ /** "#rrggbb" (sRGB) as linear RGB, 0..1. */
232
+ export declare function hexToLinear(hex: string): Rgb;
233
+ /** Direction of a light box centre. Azimuth 0 is +Z (in front of a default camera), 90 is +X. */
234
+ export declare function boxDirection(azimuth: number, elevation: number): Rgb;
235
+ /**
236
+ * The world as a linear-light equirectangular image, RGBA floats, row 0 at the bottom (the
237
+ * layout three.js expects for a DataTexture with EquirectangularReflectionMapping).
238
+ * Strength and rotation are baked in, so it works with every three.js version.
239
+ */
240
+ export declare function environmentPixels(world: WorldLook, width?: number, height?: number): Float32Array;
241
+ /** One float as a 16-bit half float (the texture type every WebGL2 device can filter). */
242
+ export declare function toHalf(value: number): number;
243
+ export declare function toHalfFloats(data: Float32Array): Uint16Array;
244
+ /**
245
+ * The relief of a detail pattern as heights 0..1 over a square image (row 0 at v = 0).
246
+ * `mask` is the rasterised text for the "text" pattern: one byte per pixel, 255 where a letter is.
247
+ */
248
+ export declare function detailHeight(detail: SurfaceDetail, size: number, mask?: Uint8Array | null): Float32Array;
249
+ /** A height field as a tangent-space normal map, RGBA bytes. */
250
+ export declare function heightToNormal(height: Float32Array, size: number, strength: number): Uint8Array;
251
+ /**
252
+ * Every smaller version of a square normal map, down to 1×1, the base level first. Made here
253
+ * instead of asking the GPU: it is the same on every three.js version, and the normals are
254
+ * renormalised at each level, so distant detail fades to flat instead of shimmering.
255
+ */
256
+ export declare function normalMipmaps(base: Uint8Array, size: number): Uint8Array[];
257
+ /** The size the detail maps are generated at. */
258
+ export declare const DETAIL_SIZE = 1024;
259
+ export interface GeometryData {
260
+ /** Three floats per vertex, three vertices per triangle (no index). */
261
+ position: Float32Array;
262
+ normal: Float32Array;
263
+ /** Two floats per vertex. */
264
+ uv: Float32Array;
265
+ }
266
+ /**
267
+ * A box with rounded edges and corners, centred on the origin. `scale` is the object's world
268
+ * scale: the rounding is made even in world space and the result is given back in the object's
269
+ * own space, so a stretched box still has round, not squashed, edges.
270
+ */
271
+ export declare function roundedBox(width: number, height: number, depth: number, radius: number, segments: number, scale?: Rgb): GeometryData;
272
+ /**
273
+ * A cylinder (or prism, with few sides) whose top and bottom rims are rounded, centred on the
274
+ * origin, laid out like three.js's CylinderGeometry. With 12 sides or fewer the sides stay
275
+ * flat facets, as a prism should.
276
+ */
277
+ export declare function roundedCylinder(radius: number, height: number, radialSegments: number, bevel: number, segments: number): GeometryData;
278
+ /**
279
+ * The next lighter version of a look: one step down a fixed ladder, ordered so that what costs
280
+ * the most frame time for the least visible difference goes first. Null when nothing is left to
281
+ * give up. The inspector uses it to bring a look back under its frame budget, and `applyLook`
282
+ * uses it on devices that cannot keep up (`performance.adaptive`).
283
+ */
284
+ export declare function lighten(look: Look): {
285
+ look: Look;
286
+ step: string;
287
+ } | null;
288
+ /** The parts of a look that cost frame time, each with the look that leaves it out. */
289
+ export declare function costlyParts(look: Look): Array<{
290
+ id: string;
291
+ label: string;
292
+ without: Look;
293
+ }>;
294
+ /** What the inspector measures on the live page. */
295
+ export interface LookFacts {
296
+ revision: number | null;
297
+ /** three.js constant, or null when unknown. */
298
+ toneMapping: number | null;
299
+ exposure: number | null;
300
+ /** True when the renderer writes sRGB to the screen. */
301
+ srgbOutput: boolean | null;
302
+ pixelRatio: number;
303
+ devicePixelRatio: number;
304
+ /** The drawing buffer has multisampling. */
305
+ antialias: boolean | null;
306
+ hasEnvironment: boolean;
307
+ lights: number;
308
+ /** Standard/physical materials: the ones that react to a world. */
309
+ pbrMaterials: number;
310
+ /** Basic, Lambert, Phong, Toon materials on meshes. */
311
+ simpleMaterials: number;
312
+ /** Fully metallic materials (they are black without something to reflect). */
313
+ metals: number;
314
+ shadowsEnabled: boolean;
315
+ shadowLights: number;
316
+ /** Lights that could cast a shadow (directional and spot). */
317
+ shadowCapableLights: number;
318
+ /** Box and cylinder meshes with perfectly sharp edges. */
319
+ hardEdgeMeshes: number;
320
+ /** Round shapes built from so few sides that the outline shows corners. */
321
+ lowPolyRound: number;
322
+ textures: number;
323
+ texturesWithoutAnisotropy: number;
324
+ /** camera.far / camera.near. */
325
+ depthRatio: number | null;
326
+ /** The site already draws through its own effect passes. */
327
+ sitePostProcessing: boolean;
328
+ /** The project's dev bridge is on the page, so lens effects can be previewed. */
329
+ effectsAvailable: boolean;
330
+ /** Measured frames per second with the look on, and of the site alone. Absent until measured. */
331
+ fps?: number | null;
332
+ siteFps?: number | null;
333
+ }
334
+ export interface LookIssue {
335
+ id: string;
336
+ severity: 'high' | 'medium' | 'low';
337
+ title: string;
338
+ /** Why it matters and what the fix does, in one or two sentences. */
339
+ detail: string;
340
+ /** Points this costs out of 100. */
341
+ weight: number;
342
+ /** A change to the look that fixes it (merge with mergeLook), when one exists. */
343
+ fix?: Record<string, unknown>;
344
+ fixLabel?: string;
345
+ }
346
+ export interface LookAudit {
347
+ /** 0 to 100: how many of the realism basics are in place. */
348
+ score: number;
349
+ issues: LookIssue[];
350
+ passed: string[];
351
+ }
352
+ declare const effectsOn: (e: EffectsLook) => boolean;
353
+ /**
354
+ * Checks the live scene, with the look applied on top, against the basics that make a render
355
+ * read as real. Each issue carries a one-click fix where the inspector can make it.
356
+ */
357
+ export declare function auditLook(facts: LookFacts, look: Look): LookAudit;
358
+ /** Every one-click fix of an audit, merged into the look. */
359
+ export declare function fixAll(look: Look, audit: LookAudit, ids?: string[]): Look;
360
+ /** One model (a top-level object and everything under it), measured on the live page. */
361
+ export interface ModelFacts {
362
+ uuid: string;
363
+ name: string;
364
+ /** It appeared after the inspector first looked at the scene. */
365
+ added: boolean;
366
+ meshes: number;
367
+ triangles: number;
368
+ /** Width, height and depth in world units. */
369
+ size: Rgb;
370
+ center: Rgb;
371
+ /** Its largest side over the typical largest side of the other models. Null when it is alone. */
372
+ relativeSize: number | null;
373
+ /**
374
+ * Height of its lowest point above the surface under it, in world units. Negative: it is sunk
375
+ * into that surface. Null: nothing is under it.
376
+ */
377
+ gap: number | null;
378
+ /** The gap was measured against the triangles of the surface, not only its bounding box. */
379
+ gapExact: boolean;
380
+ /** Name of the surface under it. */
381
+ support: string | null;
382
+ /** From the camera to its centre. */
383
+ distance: number | null;
384
+ /** Where it is on screen: left, top, right, bottom as fractions of the view. Null: out of view. */
385
+ screen: [number, number, number, number] | null;
386
+ castsShadow: boolean;
387
+ receivesShadow: boolean;
388
+ pbrMaterials: number;
389
+ /** Material types on it that ignore the world lighting (Basic, Lambert, Phong, Toon). */
390
+ simpleMaterials: string[];
391
+ textures: number;
392
+ /** Widest texture, in pixels. */
393
+ largestTexture: number;
394
+ /** Total texture pixels, a measure of GPU memory. */
395
+ texturePixels: number;
396
+ /** Textures whose colour space does not fit the slot they are used in. */
397
+ wrongColorSpace: number;
398
+ texturesWithoutAnisotropy: number;
399
+ }
400
+ export interface SceneMeasure {
401
+ /** Radius of everything drawn, in world units. */
402
+ radius: number;
403
+ models: ModelFacts[];
404
+ }
405
+ export interface AdaptChange {
406
+ id: string;
407
+ /** What was changed. */
408
+ label: string;
409
+ /** The measurement behind it. */
410
+ detail: string;
411
+ }
412
+ export interface AdaptAdvice {
413
+ id: string;
414
+ /** Uuid of the model it is about. */
415
+ model: string;
416
+ title: string;
417
+ detail: string;
418
+ /** The adapt pass can do it when asked: pass this option. */
419
+ option?: {
420
+ ground: true;
421
+ } | {
422
+ scale: number;
423
+ };
424
+ optionLabel?: string;
425
+ }
426
+ export interface AdaptResult {
427
+ look: Look;
428
+ changes: AdaptChange[];
429
+ advice: AdaptAdvice[];
430
+ }
431
+ /** Triangles above which one model is heavy for a web page. */
432
+ export declare const HEAVY_TRIANGLES = 300000;
433
+ /** Texture pixels above which one model is heavy: four 2048 px maps. */
434
+ export declare const HEAVY_TEXTURE_PIXELS: number;
435
+ /**
436
+ * Fits a look to the models in a scene, from measurements alone. What can be decided from the
437
+ * numbers is changed (shadows, texture colour and sharpness, a world to reflect, focus distance,
438
+ * occlusion radius). What depends on intent (is it meant to float? how big is it really?) comes
439
+ * back as advice with the measured value, and is done only when `options` asks.
440
+ *
441
+ * `targets` are the models to fit (all of `scene.models` when empty).
442
+ */
443
+ export declare function adaptLook(look: Look, facts: LookFacts, scene: SceneMeasure, targets?: ModelFacts[], options?: {
444
+ ground?: boolean;
445
+ scale?: number;
446
+ }): AdaptResult;
447
+ /** The look as saved to a project: no live ids, no sections left at "site". */
448
+ export declare function lookFile(look: Look): Look;
449
+ export declare function lookJson(look: Look): string;
450
+ /** How to use a saved look, for the developer or their AI agent. */
451
+ export declare function lookSnippet(file?: string): string;
452
+ /** One line per section that differs from the site, for messages and tool results. */
453
+ export declare function describeLook(look: Look): string[];
454
+ export { effectsOn };
@@ -0,0 +1,110 @@
1
+ import { type GeometryData, type Look, type LookFacts, type SceneMeasure } from './look';
2
+ /**
3
+ * Applies a look to a three.js renderer and scene, and puts everything back again.
4
+ *
5
+ * No three.js import: every object here is one the page (or the app) already made, and the few
6
+ * new ones (the world texture, bevelled geometry) come from a `LookKit`. The Depthview
7
+ * extension builds its kit from the page's own classes; `applyLook` in ./lookRuntime builds it
8
+ * from the app's `three`. One implementation, so the preview and the shipped site match.
9
+ */
10
+ type Loose = Record<string, any>;
11
+ export interface LookKit {
12
+ /** An equirectangular, linear, half-float RGBA texture, or null when one cannot be made here. */
13
+ texture(data: Uint16Array, width: number, height: number): unknown | null;
14
+ /**
15
+ * A square, linear RGBA byte texture (a normal map) from its mipmap levels, base level first,
16
+ * or null.
17
+ */
18
+ image(levels: Uint8Array[], size: number): unknown | null;
19
+ /** A BufferGeometry with position, normal and uv, or null when one cannot be made here. */
20
+ geometry(data: GeometryData): unknown | null;
21
+ dispose(resource: unknown): void;
22
+ devicePixelRatio(): number;
23
+ }
24
+ export interface LookTarget {
25
+ renderer: Loose;
26
+ scene: Loose;
27
+ camera?: Loose | null;
28
+ }
29
+ /** Size of the generated world image. The reflection cube three.js builds from it is a quarter as wide. */
30
+ export declare const WORLD_SIZE: {
31
+ width: number;
32
+ height: number;
33
+ };
34
+ export declare class LookApplier {
35
+ readonly target: LookTarget;
36
+ private kit;
37
+ private applied;
38
+ private undo;
39
+ /** Site values of things the look has replaced, so the realism check still sees the site. */
40
+ private site;
41
+ notes: string[];
42
+ /** Notes of each part of the look, so fitting one part again keeps what the others said. */
43
+ private partNotes;
44
+ private part;
45
+ /** Which meshes and lights the scene held when the look was last fitted. */
46
+ private fitted;
47
+ /** Checks in a row that found the scene changed. */
48
+ private churn;
49
+ private seen;
50
+ /** Meshes seen so far: a model made only of others arrived later. */
51
+ private known;
52
+ /** Generated detail maps, kept while a look uses them: a slider drag must not redraw them. */
53
+ private detailMaps;
54
+ constructor(target: LookTarget, kit: LookKit);
55
+ private note;
56
+ private revision;
57
+ private restore;
58
+ private touchMaterials;
59
+ /** Applies the look. Sections that did not change since the last call are left alone. */
60
+ apply(look: Look | null): string[];
61
+ /**
62
+ * True when the scene gained or lost meshes or lights since the last call. The parts of the
63
+ * look that depend on them are then fitted again (`adapt.follow`). Cheap enough to call twice
64
+ * a second: one walk over the scene.
65
+ */
66
+ follow(): boolean;
67
+ /** Which meshes and lights the scene holds, as one short string. */
68
+ private signature;
69
+ private fit;
70
+ /** Puts the site back exactly as it was. */
71
+ reset(): void;
72
+ private color;
73
+ private quality;
74
+ private anisotropy;
75
+ private world;
76
+ private shadows;
77
+ private find;
78
+ /** The normal map of a detail pattern, made once per distinct setting. */
79
+ private detailMap;
80
+ private materials;
81
+ /** Size, height and reflection strength of whole models. */
82
+ private models;
83
+ private reflection;
84
+ /** Colour maps as sRGB, data maps as plain numbers (`adapt.textures`). */
85
+ private textures;
86
+ /**
87
+ * The models of the scene: its top-level objects, looking through wrapper groups that hold
88
+ * everything.
89
+ */
90
+ private roots;
91
+ /**
92
+ * Measures every model: size, triangles, textures, how it sits on what is under it, where it
93
+ * is on screen. `acknowledge` then counts the models seen as no longer new.
94
+ */
95
+ measure(acknowledge?: boolean): SceneMeasure;
96
+ /**
97
+ * The surface under a model: straight down from the middle and the four quarters of its
98
+ * footprint, against the triangles of everything that is not the model itself.
99
+ */
100
+ private ground;
101
+ /** Meshes the bevel can round: all of them, or the chosen ones. */
102
+ bevelCandidates(): Loose[];
103
+ private bevel;
104
+ /** What the realism check needs to know about the site as it is without the look. */
105
+ facts(extra: {
106
+ sitePostProcessing: boolean;
107
+ effectsAvailable: boolean;
108
+ }): LookFacts;
109
+ }
110
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Text drawn around a circle, as on the rim of a coin, for the "text" surface detail.
3
+ * Uses a 2D canvas, so it only works in a browser: null anywhere else.
4
+ * Returns one byte per pixel (255 inside a letter), row 0 at the bottom (v = 0).
5
+ */
6
+ export declare function rasterRingText(text: string, size: number): Uint8Array | null;
@@ -0,0 +1,16 @@
1
+ import { type Look } from './lookRuntime';
2
+ export type { Look } from './lookRuntime';
3
+ /**
4
+ * Applies a look saved from Depthview inside <Canvas>:
5
+ *
6
+ * import look from './depthview-look.json';
7
+ * <DepthviewLook look={look} />
8
+ *
9
+ * When the look has lens effects it takes over drawing (render priority 1), the way an
10
+ * EffectComposer does. Meant for production: it is the site's own look, not a dev tool.
11
+ */
12
+ export declare function useDepthviewLook(look: Look | unknown): void;
13
+ /** Component form of useDepthviewLook. */
14
+ export declare function DepthviewLook({ look }: {
15
+ look: Look | unknown;
16
+ }): null;
@@ -0,0 +1,49 @@
1
+ import * as THREE from 'three';
2
+ import { type EffectsLook, type Look } from './look';
3
+ import { type LookKit } from './lookApply';
4
+ export { defaultLook, effectsOn, isNeutral, lighten, mergeLook, normalizeLook } from './look';
5
+ export type { BevelLook, EffectsLook, LightBox, Look, MaterialLook, MaterialPreset, PerformanceLook, SurfaceDetail, ShadowLook, Sky, ToneMapping, WorldLook, WorldPreset, } from './look';
6
+ export { LookApplier, type LookKit, type LookTarget } from './lookApply';
7
+ /**
8
+ * A look in the developer's own site: `applyLook` reproduces what was tuned in the Depthview
9
+ * inspector, with the app's own three.js. Lens effects use the passes that ship with three.js
10
+ * (three/examples/jsm), so nothing else has to be installed. Needs three >= 0.160.
11
+ */
12
+ /** True when this renderer was made by the same copy of three.js this module uses. */
13
+ export declare const sameThree: (renderer: unknown) => boolean;
14
+ export interface EffectsHandle {
15
+ /** New settings (null: no effects). */
16
+ set(effects: EffectsLook | null): void;
17
+ /** True while there is something to draw: call `render` in place of renderer.render. */
18
+ readonly active: boolean;
19
+ render(scene: THREE.Scene, camera: THREE.Camera): void;
20
+ dispose(): void;
21
+ }
22
+ /** Lens effects for one renderer: ambient occlusion, bloom, depth of field, vignette, grain, smooth edges. */
23
+ export declare function createEffects(renderer: THREE.WebGLRenderer): EffectsHandle;
24
+ /** Makes the textures and geometry of a look with the app's three.js. */
25
+ export declare function threeKit(): LookKit;
26
+ export interface AppliedLook {
27
+ /** Draws one frame with the look's lens effects. Use it in place of renderer.render. */
28
+ render(scene?: THREE.Scene, camera?: THREE.Camera): void;
29
+ /** Swap in a changed look. */
30
+ update(look: Look | unknown): string[];
31
+ /** Things the look asked for that this scene cannot do, in plain words. */
32
+ readonly notes: string[];
33
+ /** Steps the look took down on this device to hold its frame rate (`performance.adaptive`). */
34
+ readonly lightened: string[];
35
+ /** Puts the renderer and scene back as they were. */
36
+ dispose(): void;
37
+ }
38
+ /**
39
+ * Applies a look saved from Depthview:
40
+ *
41
+ * import look from './depthview-look.json';
42
+ * const applied = applyLook({ renderer, scene, camera }, look);
43
+ * renderer.setAnimationLoop(() => applied.render());
44
+ */
45
+ export declare function applyLook(target: {
46
+ renderer: THREE.WebGLRenderer;
47
+ scene: THREE.Scene;
48
+ camera: THREE.Camera;
49
+ }, look: Look | unknown): AppliedLook;
@@ -25,8 +25,16 @@ export interface PathPose {
25
25
  target: Vec3;
26
26
  fov: number;
27
27
  }
28
+ /**
29
+ * The keys of a camera path from anything that holds them: a `camera-path.json` as imported
30
+ * (whose arrays TypeScript sees as number[], not as [x, y, z]), or a list of keys. Entries that
31
+ * are not a complete key are dropped.
32
+ */
33
+ export declare function pathKeys(input: unknown): PathKey[];
28
34
  /** Keys in page order, without duplicates of the same percent. */
29
35
  export declare function sortKeys(keys: PathKey[]): PathKey[];
36
+ /** Same camera position, look-at point and lens: between two such keys the camera holds. */
37
+ export declare function samePose(a: PathPose, b: PathPose): boolean;
30
38
  /**
31
39
  * The camera pose at a scroll position. The curve passes through every key; before the first
32
40
  * key and after the last one the camera holds that key's pose.
@@ -2,9 +2,16 @@ import type { Plugin } from 'vite';
2
2
  export interface DepthviewViteOptions {
3
3
  /** Files to transform. Defaults to .jsx and .tsx outside node_modules. */
4
4
  include?: RegExp;
5
+ /**
6
+ * Add the look client to every page of the dev server, so the Depthview inspector can preview
7
+ * lens effects (ambient occlusion, bloom, depth of field, smooth edges) with the project's own
8
+ * three.js. Nothing is loaded until the inspector asks. Default true.
9
+ */
10
+ look?: boolean;
5
11
  }
6
12
  /**
7
- * Vite plugin: adds source-location metadata to JSX three elements.
13
+ * Vite plugin: adds source-location metadata to JSX three elements, and the look client the
14
+ * Depthview inspector previews lens effects through.
8
15
  * `apply: 'serve'` means it only exists in the dev server; `vite build` never loads it.
9
16
  * It runs before the React plugin so line/column numbers match the file on disk.
10
17
  */