lecodes-sdk 2.4.6 → 2.4.8
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/dist/global.d.ts +7 -0
- package/dist/types/gl/Camera.d.ts +100 -13
- package/dist/types/gl/Lightmap.d.ts +25 -4
- package/dist/types/gl/Model.d.ts +4 -4
- package/dist/types/gl/Node.d.ts +13 -0
- package/dist/types/gl/ReflectionProbe.d.ts +87 -0
- package/dist/types/gl/RenderTexture.d.ts +29 -0
- package/dist/types/gl/Scene.d.ts +21 -0
- package/dist/types/inject.d.ts +4 -0
- package/dist/types/scene/defineScene.d.ts +15 -2
- package/dist/types/ui/tree.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/src/bridges/gl.d.ts +72 -17
- package/src/gl/Camera.ts +198 -25
- package/src/gl/Lightmap.ts +127 -48
- package/src/gl/Model.ts +4 -4
- package/src/gl/Node.ts +61 -0
- package/src/gl/ReflectionProbe.ts +141 -0
- package/src/gl/RenderTexture.ts +93 -0
- package/src/gl/Scene.ts +54 -2
- package/src/inject.ts +4 -0
- package/src/math/vec.ts +1 -1
- package/src/scene/defineScene.ts +28 -13
- package/src/ui/tree.ts +1 -0
- package/src/version.ts +1 -1
package/dist/global.d.ts
CHANGED
|
@@ -102,6 +102,8 @@ declare global {
|
|
|
102
102
|
const RTCVideoView: typeof SDK.RTCVideoView
|
|
103
103
|
const Ragdoll: typeof SDK.Ragdoll
|
|
104
104
|
const Ray: typeof SDK.Ray
|
|
105
|
+
const ReflectionProbe: typeof SDK.ReflectionProbe
|
|
106
|
+
const RenderTexture: typeof SDK.RenderTexture
|
|
105
107
|
const Replicated: typeof SDK.Replicated
|
|
106
108
|
const Router: typeof SDK.Router
|
|
107
109
|
const RpcError: typeof SDK.RpcError
|
|
@@ -293,6 +295,7 @@ declare global {
|
|
|
293
295
|
type CameraFollow = SDK.CameraFollow
|
|
294
296
|
type CameraMove = SDK.CameraMove
|
|
295
297
|
type CameraNodeDef = SDK.CameraNodeDef
|
|
298
|
+
type CameraOptions = SDK.CameraOptions
|
|
296
299
|
type CameraPlace = SDK.CameraPlace
|
|
297
300
|
type CameraView = SDK.CameraView
|
|
298
301
|
type Canvas = SDK.Canvas
|
|
@@ -521,6 +524,10 @@ declare global {
|
|
|
521
524
|
type RecordOptions = SDK.RecordOptions
|
|
522
525
|
type RecorderState = SDK.RecorderState
|
|
523
526
|
type Recording = SDK.Recording
|
|
527
|
+
type ReflectionProbe = SDK.ReflectionProbe
|
|
528
|
+
type ReflectionProbeOptions = SDK.ReflectionProbeOptions
|
|
529
|
+
type RenderTexture = SDK.RenderTexture
|
|
530
|
+
type RenderToTextureOptions = SDK.RenderToTextureOptions
|
|
524
531
|
type Replicated = SDK.Replicated
|
|
525
532
|
type Resource<T> = SDK.Resource<T>
|
|
526
533
|
type ReverbParams = SDK.ReverbParams
|
|
@@ -1,26 +1,61 @@
|
|
|
1
1
|
import { Vec3 } from "../math/vec";
|
|
2
2
|
import { Node, type NodeTweenProps } from "./Node";
|
|
3
3
|
import { Ray } from "./Ray";
|
|
4
|
+
import { RenderTexture } from "./RenderTexture";
|
|
4
5
|
import { type TweenMeta } from "../animate/tween/spec";
|
|
5
6
|
import type { Animation } from "../animate/tween/Animation";
|
|
6
|
-
/** Animatable camera props on top of the node transform.
|
|
7
|
+
/** Animatable camera props on top of the node transform. `fov` / `near` / `far` are the SCENE camera's: on a secondary
|
|
8
|
+
* camera they throw (set them directly — they are live — or from `animate({ onUpdate })`). */
|
|
7
9
|
export type CameraTweenProps = NodeTweenProps & {
|
|
8
10
|
fov?: number | number[];
|
|
9
11
|
near?: number | number[];
|
|
10
12
|
far?: number | number[];
|
|
11
13
|
};
|
|
14
|
+
/** `new Camera(options)`: a SECONDARY camera's lens and what its view draws (the scene's own camera is `scene.camera`). */
|
|
15
|
+
export type CameraOptions = {
|
|
16
|
+
/** Vertical field of view in degrees (default 60). Live: `camera.fov`. */
|
|
17
|
+
fov?: number;
|
|
18
|
+
/** Near clip distance in metres (default 0.01). Live: `camera.near`. */
|
|
19
|
+
near?: number;
|
|
20
|
+
/** Far clip distance in metres (default 1000). Live: `camera.far`. */
|
|
21
|
+
far?: number;
|
|
22
|
+
/** The layers its view draws, a bit mask over `Node.layer` (default 0xff = everything): a renderable is drawn when its
|
|
23
|
+
* layers share a bit with these — the player's own body left out of a mirror. Fixed when the view starts. */
|
|
24
|
+
layers?: number;
|
|
25
|
+
/** Shadows in its view (default `true`): the view renders shadow maps of its own each time it draws. Fixed when the
|
|
26
|
+
* view starts. */
|
|
27
|
+
shadows?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** `camera.renderToTexture(options)`: the picture's size. */
|
|
30
|
+
export type RenderToTextureOptions = {
|
|
31
|
+
/** Texels wide, 1..4096 (default 256). */
|
|
32
|
+
width?: number;
|
|
33
|
+
/** Texels tall, 1..4096 (default 256). */
|
|
34
|
+
height?: number;
|
|
35
|
+
};
|
|
12
36
|
/** Projection every host starts a scene with (creator-gl scene.cpp / the lite core agree on these). */
|
|
13
37
|
export declare const CAMERA_DEFAULTS: {
|
|
14
38
|
fov: number;
|
|
15
39
|
near: number;
|
|
16
40
|
far: number;
|
|
17
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* A camera: a Node (position, `lookAt`, parenting — it looks down its −Z) with a lens, `fov` / `near` / `far`. Two kinds:
|
|
44
|
+
* - THE SCENE CAMERA, `scene.camera`: made by the Scene, it draws the screen. Its exposure, `projectionMatrix` and the
|
|
45
|
+
* ray helpers (`getRay`, `getViewDirection`) are the screen's, and its projection tweens (`animateTo({ fov })`).
|
|
46
|
+
* - A SECONDARY camera, `new Camera({ fov, layers, shadows })`: a plain node until `renderToTexture({ width, height })`
|
|
47
|
+
* gives it a second view of its scene, drawn into a texture every frame the scene is on show — a rear-view mirror, a
|
|
48
|
+
* monitor, a security camera. Place it like any node (`car.add(mirrorCam)`); its lens is live (`mirrorCam.fov = 50`),
|
|
49
|
+
* its view's schedule is `enabled` / `everyNth`. A cube of light for reflections is a `ReflectionProbe`.
|
|
50
|
+
*/
|
|
18
51
|
export declare class Camera extends Node {
|
|
52
|
+
/** The scene this camera draws the screen of (Scene `_attach`); -1 = a secondary camera. */
|
|
19
53
|
private _sceneId;
|
|
20
|
-
/** Tween `fov` / `near` / `far` (a zoom, a dolly) and the transform — see {@link Node.animateTo}. */
|
|
54
|
+
/** Tween `fov` / `near` / `far` (a zoom, a dolly — the scene camera's) and the transform — see {@link Node.animateTo}. */
|
|
21
55
|
animateTo(props: CameraTweenProps & TweenMeta): Animation;
|
|
22
56
|
animateFrom(props: CameraTweenProps & TweenMeta): Animation;
|
|
23
|
-
/**
|
|
57
|
+
/** The scene camera's live projection matrix (updated by the host when the viewport / fov changes). A secondary
|
|
58
|
+
* camera's stays zero: its projection is `fov` / `near` / `far` at its texture's aspect. */
|
|
24
59
|
readonly projectionMatrix: Float32Array<ArrayBuffer>;
|
|
25
60
|
private _fov;
|
|
26
61
|
private _near;
|
|
@@ -31,11 +66,54 @@ export declare class Camera extends Node {
|
|
|
31
66
|
private _exposure;
|
|
32
67
|
private _ev;
|
|
33
68
|
private _exposureSet;
|
|
69
|
+
private readonly _layers;
|
|
70
|
+
private readonly _shadows;
|
|
71
|
+
private _enabled;
|
|
72
|
+
private _everyNth;
|
|
73
|
+
/** A SECONDARY camera (`scene.camera` is the scene's own): a plain node until `renderToTexture`. `options`: its lens
|
|
74
|
+
* (live after, through `fov` / `near` / `far`) and what its view draws (`layers`, `shadows` — fixed). */
|
|
75
|
+
constructor(options?: CameraOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Draw this camera's view of its scene into a new 2D texture of `width × height` texels (default 256 × 256): the
|
|
78
|
+
* tone-mapped picture as the screen would show it (LDR) — `screen.material.map = cam.renderToTexture({ ... })`. The
|
|
79
|
+
* camera holds it (`camera.texture`).
|
|
80
|
+
*
|
|
81
|
+
* THE VIEW starts once the camera is in a scene (added to one, or under a node that is — at once if it already is)
|
|
82
|
+
* and draws every frame that scene is on show, after the frame's update passes (aspects, physics, animation: this
|
|
83
|
+
* frame's poses) and before the scene's own picture. It sees the scene's renderables, lights, environment and sky (not
|
|
84
|
+
* its overlays) from the camera's WORLD pose (scale ignored) through `fov` / `near` / `far` at the texture's aspect,
|
|
85
|
+
* with the `layers` and `shadows` the camera was made with, at the scene camera's exposure; its post-processing is the
|
|
86
|
+
* engine's default tone mapping (the scene's grading, bloom and the rest are not mirrored). Moving the camera to
|
|
87
|
+
* another scene later does not move the view.
|
|
88
|
+
*
|
|
89
|
+
* COST: every render is another pass over the scene — with `shadows`, its own shadow maps too. Keep the texture small,
|
|
90
|
+
* draw less often (`everyNth`), leave out what the view does not need (`layers`), and turn it off out of sight
|
|
91
|
+
* (`enabled = false`).
|
|
92
|
+
*
|
|
93
|
+
* Calling it again REPLACES the texture and the view: the previous view stops at once, its texture keeps its last
|
|
94
|
+
* picture while something still shows it. Throws on the scene camera, and on a host without render textures (the web
|
|
95
|
+
* hosts, for now).
|
|
96
|
+
*/
|
|
97
|
+
renderToTexture(options?: RenderToTextureOptions): RenderTexture;
|
|
98
|
+
/** The texture `renderToTexture` made — the latest, null before one. */
|
|
99
|
+
get texture(): RenderTexture | null;
|
|
100
|
+
/** Whether this secondary camera's view draws (default `true`). Off keeps the last picture in its texture and costs
|
|
101
|
+
* nothing — a mirror out of sight; back on, it renders on the next frame drawn. The scene camera always draws (reads
|
|
102
|
+
* `true`; setting it throws). */
|
|
103
|
+
get enabled(): boolean;
|
|
104
|
+
set enabled(on: boolean);
|
|
105
|
+
/** Render this secondary camera's view once every N frames DRAWN (default 1 = every frame). The count restarts with
|
|
106
|
+
* each change: the next frame drawn renders, then one in every N. The scene camera draws every frame (reads 1;
|
|
107
|
+
* setting it throws). */
|
|
108
|
+
get everyNth(): number;
|
|
109
|
+
set everyNth(n: number);
|
|
34
110
|
/** Exposure compensation in stops (default 0): +1 doubles how bright the scene renders, −2
|
|
35
111
|
* quarters it. The one exposure knob most games need — a dark interior, a flash of white, or eye
|
|
36
112
|
* adaptation when the sun swings into view (drop it, and the sun stays at the display's peak
|
|
37
113
|
* while everything else darkens). Scene light follows it; particle `emissive` is post-exposure
|
|
38
|
-
* and does not, so a fireball keeps its on-screen brightness. Cheap to animate every frame.
|
|
114
|
+
* and does not, so a fireball keeps its on-screen brightness. Cheap to animate every frame. The
|
|
115
|
+
* scene camera's: a secondary camera's view renders at its scene camera's exposure (what is set on
|
|
116
|
+
* a secondary camera is kept, unused). */
|
|
39
117
|
/** The camera's EV100 with the compensation in: log2(aperture² / shutterSpeed x 100 / iso) - compensation. Sunny 16 is
|
|
40
118
|
* ~15; a lit surface of luminance L lands on screen at L / (1.2 x 2^ev100). */
|
|
41
119
|
get ev100(): number;
|
|
@@ -43,7 +121,7 @@ export declare class Camera extends Node {
|
|
|
43
121
|
set exposureCompensation(stops: number);
|
|
44
122
|
/** The physical camera: `aperture` in f-stops, `shutterSpeed` in seconds, `iso`, plus the same
|
|
45
123
|
* `compensation` in stops — any subset, one call. `camera.setExposure({ iso: 400 })` is two stops
|
|
46
|
-
* brighter than the default f/16 · 1/125 · ISO 100. */
|
|
124
|
+
* brighter than the default f/16 · 1/125 · ISO 100. The scene camera's (as `exposureCompensation`). */
|
|
47
125
|
setExposure(exposure: {
|
|
48
126
|
aperture?: number;
|
|
49
127
|
shutterSpeed?: number;
|
|
@@ -52,15 +130,18 @@ export declare class Camera extends Node {
|
|
|
52
130
|
}): this;
|
|
53
131
|
/** Hosts that predate the call keep the fixed default (older wasm / native builds). */
|
|
54
132
|
private _applyExposure;
|
|
55
|
-
/** Vertical field of view in degrees (default 60) — a smaller angle is a longer lens.
|
|
133
|
+
/** Vertical field of view in degrees (default 60) — a smaller angle is a longer lens. Live on both kinds: a
|
|
134
|
+
* secondary camera's reaches its view at the next render (before `renderToTexture`, the view's starting value). */
|
|
56
135
|
get fov(): number;
|
|
57
136
|
set fov(degrees: number);
|
|
137
|
+
/** The horizontal field of view in degrees: the scene camera's at the screen's aspect, a secondary camera's at its
|
|
138
|
+
* texture's (square before `renderToTexture`). */
|
|
58
139
|
get horizontalFov(): number;
|
|
59
|
-
/** Near clip distance (default 0.01) — nothing closer than this draws. */
|
|
140
|
+
/** Near clip distance (default 0.01) — nothing closer than this draws. Live, as `fov`. */
|
|
60
141
|
get near(): number;
|
|
61
142
|
set near(distance: number);
|
|
62
143
|
/** Far clip distance / view range (default 1000) — geometry past it is culled. Shadows keep
|
|
63
|
-
* their own (shorter) range, so a long view distance doesn't cost shadow sharpness. */
|
|
144
|
+
* their own (shorter) range, so a long view distance doesn't cost shadow sharpness. Live, as `fov`. */
|
|
64
145
|
get far(): number;
|
|
65
146
|
set far(distance: number);
|
|
66
147
|
/** Set any of fov / near / far in one call: `camera.setProjection({ fov: 45, far: 5000 })`. */
|
|
@@ -69,8 +150,10 @@ export declare class Camera extends Node {
|
|
|
69
150
|
near?: number;
|
|
70
151
|
far?: number;
|
|
71
152
|
}): this;
|
|
72
|
-
/** Hosts that predate the call keep the fixed defaults (older wasm / native builds)
|
|
153
|
+
/** Hosts that predate the call keep the fixed defaults (older wasm / native builds); a secondary camera's view keeps
|
|
154
|
+
* the projection it started with (warned once). */
|
|
73
155
|
private _applyProjection;
|
|
156
|
+
private static _warnedViewProjection;
|
|
74
157
|
private _following;
|
|
75
158
|
/** The node the camera currently follows (`follow()`), or null. */
|
|
76
159
|
get following(): Node | null;
|
|
@@ -79,7 +162,9 @@ export declare class Camera extends Node {
|
|
|
79
162
|
* view direction), so movement aspects / animation on that node are camera moves — dolly shots,
|
|
80
163
|
* a cutscene path, a `CameraPlace` in a scene file. A node carrying a `CameraPlace` also hands
|
|
81
164
|
* over its projection (fov / near / far). `follow(null)` releases the camera where it is.
|
|
82
|
-
*
|
|
165
|
+
* Following a new node stops following the previous one, and a node leads one camera at a time.
|
|
166
|
+
* Either kind: the pose is written as the camera's own transform, so a following secondary
|
|
167
|
+
* camera is a scene root, not a child.
|
|
83
168
|
*/
|
|
84
169
|
follow(target: Node | {
|
|
85
170
|
node: Node;
|
|
@@ -87,10 +172,12 @@ export declare class Camera extends Node {
|
|
|
87
172
|
} | null): this;
|
|
88
173
|
/** The scene view's [width, height] in logical units — the units of the scene's touches
|
|
89
174
|
* (`clientX` / `clientY`) and of `getRay`, on every host; × `device.pixelRatio` for device px.
|
|
90
|
-
* [0, 0] before the scene has a viewport. */
|
|
175
|
+
* [0, 0] before the scene has a viewport. The screen's, whichever camera reads it. */
|
|
91
176
|
get displaySize(): [number, number];
|
|
92
|
-
/** World-space ray direction through a point of the scene view (logical units, as a touch's).
|
|
177
|
+
/** World-space ray direction through a point of the scene view (logical units, as a touch's). The scene camera's
|
|
178
|
+
* (a secondary camera throws). */
|
|
93
179
|
getViewDirection(screenX: number, screenY: number): Vec3;
|
|
94
|
-
/** A pick ray from the camera through a point of the scene view (logical units, as a touch's).
|
|
180
|
+
/** A pick ray from the camera through a point of the scene view (logical units, as a touch's). The scene camera's
|
|
181
|
+
* (a secondary camera throws). */
|
|
95
182
|
getRay(screenX: number, screenY: number): Ray;
|
|
96
183
|
}
|
|
@@ -18,6 +18,11 @@ export type LightmapLoadOptions = {
|
|
|
18
18
|
* `{ through, diffuse }` adds the share the fibres SCATTER - the cloth's underside glows like a matte panel and lights
|
|
19
19
|
* what is under it by the solid angle it fills, with no picture. Dense canvas: `{ through: 0.08, diffuse: 0.25 }`. */
|
|
20
20
|
transmit?: Record<string, LightmapTransmit>;
|
|
21
|
+
/** FOR THE BAKE: CUBES BY NAME — regular expressions (ECMAScript, case-sensitive) searched in every record's key
|
|
22
|
+
* (`<node key>@<ordinal>`: `"SM_pipe"` takes every pipe node, `"@1$"` the second mesh of each): a record that matches
|
|
23
|
+
* leaves the atlas like a small or thin one — an occluder lit by ambient cubes baked where it stands — whatever its size
|
|
24
|
+
* or charts. Added to the CLI's `--cube` patterns (both apply). */
|
|
25
|
+
cube?: string[];
|
|
21
26
|
};
|
|
22
27
|
/** one `transmit` entry (LightmapLoadOptions.transmit): the straight share, or both shares */
|
|
23
28
|
export type LightmapTransmit = number | {
|
|
@@ -49,6 +54,10 @@ export type LightmapFiles = {
|
|
|
49
54
|
/** THE LIGHT GRID for movers (`<stem>.lgrid`, `lecodes lightmap bake --volume`): the baked ambient light of every
|
|
50
55
|
* place a mover can be. Absent = movers keep the scene's IBL. */
|
|
51
56
|
volume?: string;
|
|
57
|
+
/** THE PACKED LIGHTMAP UV1 (`<stem>-uv1.bin`, the .bake's `uv1`): the bake packs every mesh's lightmap charts into a
|
|
58
|
+
* square of their own and its rects map that uv1 — the engine swaps it into the models' TEXCOORD_1 first. Required
|
|
59
|
+
* when the bake names one. */
|
|
60
|
+
uv1?: string;
|
|
52
61
|
};
|
|
53
62
|
/** The lightmap material's data views (`Lightmap.debug`); "direct" / "indirect" bind a `--split` bake's pages instead. */
|
|
54
63
|
export type LightmapDebugMode = "off" | "irradiance" | "albedo" | "normal" | "shadingNormal" | "share" | "skyVis" | "atlas" | "direction" | "lux" | "relief" | "direct" | "indirect" | "probe" | "probeMap" | "skyPath" | "probePath";
|
|
@@ -69,6 +78,14 @@ export type LightmapProbe = {
|
|
|
69
78
|
world: [number, number, number];
|
|
70
79
|
distance: number;
|
|
71
80
|
};
|
|
81
|
+
/** `Lightmap.add`'s options */
|
|
82
|
+
export type LightmapAddOptions = {
|
|
83
|
+
/** Bake it as AMBIENT CUBES instead of atlas texels: an occluder (its shadow and bounce stay in the atlas) whose own
|
|
84
|
+
* light is baked where it stands — the way the bake treats small and thin objects (`--min-texels`, `--thin-texels`),
|
|
85
|
+
* here by hand: a pipe run, a fence, a prop whose charts show their seams. A long one takes a slab of cubes per metre
|
|
86
|
+
* (`--object-slab`). Default false. */
|
|
87
|
+
cube?: boolean;
|
|
88
|
+
};
|
|
72
89
|
export declare class Lightmap {
|
|
73
90
|
/** True while `lecodes lightmap bake` runs the app — skip menus and build the scene straight away. */
|
|
74
91
|
static get baking(): boolean;
|
|
@@ -81,8 +98,8 @@ export declare class Lightmap {
|
|
|
81
98
|
* both receivers and occluders in the bake (a model without lightmap UVs, or with materials the lightmap shader
|
|
82
99
|
* declines — alpha cards — is an occluder alone; a terrain is ONE rect, built with `Material.terrainLightmap()`).
|
|
83
100
|
* `key` names the entry in the .bake (default: the node's name + a running number, `container#3`); pass one when
|
|
84
|
-
* names are not stable. */
|
|
85
|
-
static add(node: Node, key?: string): Node;
|
|
101
|
+
* names are not stable. `{ cube: true }` bakes it as ambient cubes instead of atlas texels (`LightmapAddOptions`). */
|
|
102
|
+
static add(node: Node, key?: string, options?: LightmapAddOptions): Node;
|
|
86
103
|
private static next;
|
|
87
104
|
private static movers;
|
|
88
105
|
private static volumeOn;
|
|
@@ -93,6 +110,10 @@ export declare class Lightmap {
|
|
|
93
110
|
* the subtree back to the scene's IBL. Safe before the level's bake has loaded. */
|
|
94
111
|
static track(node: Node, on?: boolean): void;
|
|
95
112
|
private static loadVolume;
|
|
113
|
+
/** THE PACKED UV1 the bake's rects map (the .bake's `uv1`), into the host BEFORE any rect is applied: the host swaps it
|
|
114
|
+
* into the models' TEXCOORD_1 as their rects go on. A bake without one clears the last (the models' own uv1 back).
|
|
115
|
+
* False = the bake needs it and it cannot be had - its rects would read the wrong texels. */
|
|
116
|
+
private static loadUv1;
|
|
96
117
|
/** Forget every registration (a scene rebuild). */
|
|
97
118
|
static clear(): void;
|
|
98
119
|
/** THE MOVERS' SUN SHADOWS ON THE BAKED STATICS (a bot, a barrel, the player's rifle darkening the ground under
|
|
@@ -110,8 +131,8 @@ export declare class Lightmap {
|
|
|
110
131
|
* applied (no bake yet, a host without the feature, bake mode). */
|
|
111
132
|
private static scene;
|
|
112
133
|
static load(scene: Scene, files: LightmapFiles, options?: LightmapLoadOptions): Promise<LightmapInfo | null>;
|
|
113
|
-
/** The bake's `<key
|
|
114
|
-
private static
|
|
134
|
+
/** The bake's `<key>@k` records by their node key: a model's meshes (k = the primitive's ordinal in its file). */
|
|
135
|
+
private static recordsOf;
|
|
115
136
|
/** Switch every lightmapped surface to a DATA view (or back with `"off"` / 0). Level-wide, instant —
|
|
116
137
|
* except "direct" / "indirect", which load that page set the first time (a `--split` bake listed in the scene). */
|
|
117
138
|
static debug(mode: LightmapDebugMode | number, params?: LightmapDebugParams): void;
|
package/dist/types/gl/Model.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export interface TrianglePick {
|
|
|
12
12
|
mesh: string;
|
|
13
13
|
primitive: number;
|
|
14
14
|
material: string;
|
|
15
|
-
/** the
|
|
16
|
-
|
|
15
|
+
/** the primitive's index over its file's meshes: the lightmap bake's record `<key>@<ordinal>` */
|
|
16
|
+
lightmapOrdinal: number;
|
|
17
17
|
/** triangle index within the primitive (index-buffer order), and whether the ray came from behind */
|
|
18
18
|
triangle: number;
|
|
19
19
|
backface: boolean;
|
|
@@ -83,8 +83,8 @@ export declare class Model extends Node {
|
|
|
83
83
|
total?: number;
|
|
84
84
|
}) => void;
|
|
85
85
|
/** Baked lighting (engines/bake). `true` = a STATIC: loads through the lightmap material so
|
|
86
|
-
* `Lightmap.load` can bind its atlas rect (the GLB needs TEXCOORD_1 —
|
|
87
|
-
*
|
|
86
|
+
* `Lightmap.load` can bind its atlas rect (the GLB needs TEXCOORD_1 —
|
|
87
|
+
* `lecodes assets unwrap`, which `lightmap bake` runs itself on raw GLBs) and takes nothing from the real-time lights once the bake applies. Omitted / `false` =
|
|
88
88
|
* the standard shader, lit real-time (movers). Hosts without lightmap support ignore it. */
|
|
89
89
|
lightmap?: boolean;
|
|
90
90
|
/** Vegetation: load through the FOLIAGE tier (see `Foliage`) — wind, touch bending, distance fade,
|
package/dist/types/gl/Node.d.ts
CHANGED
|
@@ -40,6 +40,19 @@ export declare class Node extends AspectHost<NodeEvents> implements CompWriter {
|
|
|
40
40
|
set name(value: string);
|
|
41
41
|
get visible(): boolean;
|
|
42
42
|
set visible(value: boolean);
|
|
43
|
+
/**
|
|
44
|
+
* The node's visibility LAYERS, a bit mask 1..255. The scene's own view draws every layer; a render
|
|
45
|
+
* view (a secondary `Camera`'s or a `ReflectionProbe`'s, their `layers` option) draws only the
|
|
46
|
+
* renderables whose layers share a bit with its mask — which is what layers are for: leaving a subtree
|
|
47
|
+
* out of a second camera (the car out of the reflection probe riding on it, the player's own body out
|
|
48
|
+
* of a mirror). A node without a layer
|
|
49
|
+
* of its own takes its nearest ancestor's, else 1, so a car's layer covers everything parented under
|
|
50
|
+
* it; `0` clears the node's own (inherit again). `visible = false` wins over any layer. Reads the
|
|
51
|
+
* effective bits. A host without layers draws everything everywhere (reads 1, a write warns once).
|
|
52
|
+
*/
|
|
53
|
+
get layer(): number;
|
|
54
|
+
set layer(mask: number);
|
|
55
|
+
private static _warnedLayer;
|
|
43
56
|
private _sync;
|
|
44
57
|
get matrix(): Mat4;
|
|
45
58
|
set matrix(m: Mat4Like);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
import { RenderTexture } from "./RenderTexture";
|
|
3
|
+
/** `new ReflectionProbe(options)`: the cube, what its view draws, and how often. */
|
|
4
|
+
export type ReflectionProbeOptions = {
|
|
5
|
+
/** The cube's edge, texels per face side (default 128): a power of two, 16..4096, when prefiltered; 1..4096 otherwise.
|
|
6
|
+
* A probe is light, not a picture — 64..128 is plenty for a car's reflections. */
|
|
7
|
+
size?: number;
|
|
8
|
+
/** The layers its view draws, a bit mask over `Node.layer` (default 0xff = everything): leave out the probe's own
|
|
9
|
+
* carrier, or the cube is the inside of the car it rides on. Fixed. */
|
|
10
|
+
layers?: number;
|
|
11
|
+
/** Shadows in its view (default `false`): with them, a full cube renders its own shadow maps six times. Fixed. */
|
|
12
|
+
shadows?: boolean;
|
|
13
|
+
/** Faces drawn per render, 1..6, round-robin (default 6 = the whole cube) — `probe.facesPerFrame`. */
|
|
14
|
+
facesPerFrame?: number;
|
|
15
|
+
/** Render once every N frames drawn (default 1 = every frame) — `probe.everyNth`. */
|
|
16
|
+
everyNth?: number;
|
|
17
|
+
/** Filter the cube for ROUGHNESS (default `true`; `size` a power of two then). Without it the cube has one sharp level:
|
|
18
|
+
* under `scene.environment` only mirror-like surfaces (roughness near 0) are right, and the diffuse ambient stays the
|
|
19
|
+
* scene's own probe's. With it the GPU filters every completed cube into five roughness levels — a brushed or painted
|
|
20
|
+
* body shows its surroundings blurred as much as its roughness says — and the roughest level becomes the diffuse
|
|
21
|
+
* ambient: what the probe sees lights matte surfaces too (a red wall tints them red).
|
|
22
|
+
*
|
|
23
|
+
* COST: one filtering per completed cube (every render at `facesPerFrame` 6, every third at 2), on the frame after:
|
|
24
|
+
* the cube's mip chain plus a pass per level whose taps are the level's texels × `samples` — for a 64 cube at the
|
|
25
|
+
* default 256 samples about 2 million cube taps — and ten small driver submissions on the CPU. `everyNth` /
|
|
26
|
+
* `facesPerFrame` space the filterings out. Fixed. */
|
|
27
|
+
prefilter?: boolean;
|
|
28
|
+
/** The filter's samples per texel, 1..2048 (default 256 — a quarter of Filament's offline default: each sample reads
|
|
29
|
+
* the mip that matches its footprint, which keeps a low count smooth; raise it if a mid-roughness surface reads
|
|
30
|
+
* blotchy). Smoothness for time; read with `prefilter` only. */
|
|
31
|
+
samples?: number;
|
|
32
|
+
/** Near clip plane in metres (default 0.01). Fixed. */
|
|
33
|
+
near?: number;
|
|
34
|
+
/** Far clip plane in metres (default 1000). Fixed. */
|
|
35
|
+
far?: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A REFLECTION PROBE: a cube of the scene's light drawn around a point, live — chrome and glass show what is actually
|
|
39
|
+
* around them, moving objects included. A Node: place it, or parent it (`car.add(probe)` — it rides along); the six faces
|
|
40
|
+
* look along the world axes from its WORLD position (its rotation and scale are ignored). It draws once it is in a scene
|
|
41
|
+
* (added to one, or under a node that is), every frame that scene is on show — after the frame's update passes, before
|
|
42
|
+
* the scene's own picture — in linear HDR light (no tone mapping) at the scene camera's exposure. It sees the scene's
|
|
43
|
+
* renderables, lights, environment and sky, not its overlays.
|
|
44
|
+
*
|
|
45
|
+
* Two ways to use it:
|
|
46
|
+
* - `scene.environment = probe`: the scene's reflections come from the cube instead of the scene's own probe
|
|
47
|
+
* (`SceneOptions.ibl`) — and, prefiltered (the default), its diffuse ambient too. A probe in no scene yet starts in
|
|
48
|
+
* that one.
|
|
49
|
+
* - `probe.texture` in a material that samples a cube itself (a custom shader's samplerCubemap): the same cube as a
|
|
50
|
+
* `RenderTexture` — when prefiltered, the filtered one, five roughness levels.
|
|
51
|
+
*
|
|
52
|
+
* COST: a full render is six passes over the scene, plus (prefiltered) a GPU filtering per completed cube (`prefilter`
|
|
53
|
+
* says what one costs). Keep `size` small (128 is a lot), spread the cube over frames (`facesPerFrame: 2` = a whole cube
|
|
54
|
+
* every 3 frames, a third of the cost each), render less often (`everyNth`), leave out what it need not see (`layers` —
|
|
55
|
+
* its carrier first), keep `shadows` off, and turn it off once a static surrounding is drawn (`enabled = false` keeps the
|
|
56
|
+
* last cube).
|
|
57
|
+
*
|
|
58
|
+
* LIFETIME: the cube and its view live as long as the probe — keep a reference (`scene.environment` holds it too).
|
|
59
|
+
* Destroying the probe's node stops the view (the cube keeps its last light); moving it to another scene later does not
|
|
60
|
+
* move the view. Throws on a host without render textures (`createRenderTexture` — the web hosts, for now).
|
|
61
|
+
*/
|
|
62
|
+
export declare class ReflectionProbe extends Node {
|
|
63
|
+
/** The cube the probe draws (`cubemap`, linear HDR light) — the filtered one, five roughness levels, when `prefilter`. */
|
|
64
|
+
readonly texture: RenderTexture;
|
|
65
|
+
/** Filtered for roughness (the `prefilter` option). */
|
|
66
|
+
readonly prefilter: boolean;
|
|
67
|
+
private readonly _layers;
|
|
68
|
+
private readonly _shadows;
|
|
69
|
+
private readonly _near;
|
|
70
|
+
private readonly _far;
|
|
71
|
+
private _enabled;
|
|
72
|
+
private _everyNth;
|
|
73
|
+
private _facesPerFrame;
|
|
74
|
+
constructor(options?: ReflectionProbeOptions);
|
|
75
|
+
/** Whether the probe draws (default `true`). Off keeps the last cube and costs nothing — a probe that has drawn its
|
|
76
|
+
* static surroundings once; back on, it renders on the next frame drawn. */
|
|
77
|
+
get enabled(): boolean;
|
|
78
|
+
set enabled(on: boolean);
|
|
79
|
+
/** Render once every N frames DRAWN (default 1 = every frame). The count restarts with each change: the next frame
|
|
80
|
+
* drawn renders, then one in every N. */
|
|
81
|
+
get everyNth(): number;
|
|
82
|
+
set everyNth(n: number);
|
|
83
|
+
/** The cube's faces drawn per render, 1..6 (default 6), round-robin from where the last render stopped: 2 spreads a
|
|
84
|
+
* whole cube over 3 renders at a third of the cost each. A prefiltered cube is filtered each time it completes. */
|
|
85
|
+
get facesPerFrame(): number;
|
|
86
|
+
set facesPerFrame(n: number);
|
|
87
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Texture } from "./Texture";
|
|
2
|
+
/**
|
|
3
|
+
* A texture a render view draws into — made by `camera.renderToTexture({ width, height })` (a 2D picture: the
|
|
4
|
+
* tone-mapped image as the screen would show it) or by a `ReflectionProbe` (`probe.texture`: a cube of linear HDR light).
|
|
5
|
+
* It IS a `Texture`: a 2D one goes wherever an image does (`material.map` — a monitor, a rear-view mirror), a cube
|
|
6
|
+
* wherever a cubemap does (`scene.environment` takes the probe itself).
|
|
7
|
+
*
|
|
8
|
+
* ROW ORDER: a 2D render texture's first texel row is the BOTTOM of the camera's picture (OpenGL's order, on every
|
|
9
|
+
* backend) — an image's first row is its top. A mesh whose v runs UP its face (`Mesh.plane`) shows it upright as is; one
|
|
10
|
+
* laid out like a glTF (v down) samples it with v flipped. A cube face is laid out as every GPU's cube lookup reads it.
|
|
11
|
+
*
|
|
12
|
+
* LIFETIME: the texture lives while something holds it — the camera or probe that made it (each keeps its texture), a
|
|
13
|
+
* material showing it — and keeps its last picture when its view stops (`enabled = false`, the camera's next
|
|
14
|
+
* `renderToTexture`, the camera gone).
|
|
15
|
+
*/
|
|
16
|
+
export declare class RenderTexture extends Texture {
|
|
17
|
+
/** A cube (a `ReflectionProbe`'s) rather than a 2D picture (a `Camera`'s). A cube's `width` and `height` are both its
|
|
18
|
+
* edge. */
|
|
19
|
+
readonly cubemap: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* RGBA8 bytes (`width × height × 4`) of a rectangle of the texture as the NEXT frame drawn leaves it — a GPU
|
|
22
|
+
* readback, for checks and tools, not a per-frame path. Rows come in the texture's own order: the first is texel row
|
|
23
|
+
* `y`, which for a 2D texture counts from the picture's BOTTOM. `face` 0..5 = +X −X +Y −Y +Z −Z of a cube (0 for a 2D
|
|
24
|
+
* picture). A camera's (LDR) texture gives its stored sRGB bytes, a probe's (HDR) its linear light clamped to 0..1 —
|
|
25
|
+
* a prefiltered probe its sharpest level. Rejects on a host without the call, or when the host refuses the read (the
|
|
26
|
+
* rectangle outside the texture, the engine gone first).
|
|
27
|
+
*/
|
|
28
|
+
readPixels(x: number, y: number, width: number, height: number, face?: number): Promise<Uint8Array>;
|
|
29
|
+
}
|
package/dist/types/gl/Scene.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Camera } from "./Camera";
|
|
|
8
8
|
import { SceneAudio } from "./audio/SceneAudio";
|
|
9
9
|
import { Material } from "./Material";
|
|
10
10
|
import { PostProcessing, type PostProcessingOptions } from "./postProcessing";
|
|
11
|
+
import { ReflectionProbe } from "./ReflectionProbe";
|
|
11
12
|
import { Node } from "./Node";
|
|
12
13
|
/** `SceneOptions.taa` / `scene.setAntialias("taa", 4, taa)`: the temporal anti-aliasing knobs. */
|
|
13
14
|
export type TaaOptions = {
|
|
@@ -187,6 +188,26 @@ export declare class Scene implements Presentable {
|
|
|
187
188
|
get environmentIntensity(): number;
|
|
188
189
|
set environmentIntensity(lux: number);
|
|
189
190
|
private static _warnedEnvIntensity;
|
|
191
|
+
/**
|
|
192
|
+
* Light the scene from a live REFLECTION PROBE (ReflectionProbe.ts) — a cube drawn around the probe's position, the
|
|
193
|
+
* probe riding the car / standing in the room: chrome and glass show what is actually around them, moving objects
|
|
194
|
+
* included. `null` gives the light back to the scene's own probe (`SceneOptions.ibl`, at `environmentIntensity`;
|
|
195
|
+
* re-installing it reloads the probe — a switch, not a per-frame call). A probe in no scene yet starts its view in this
|
|
196
|
+
* one; one already in another scene draws only while that scene is on show.
|
|
197
|
+
*
|
|
198
|
+
* Prefiltered (the default), the probe gives the reflections at every roughness — a car body, painted metal blur it as
|
|
199
|
+
* they should — and the diffuse ambient too (then `environmentIntensity` no longer changes it); it costs a GPU
|
|
200
|
+
* filtering per completed cube (`ReflectionProbeOptions.prefilter`). `prefilter: false` gives one sharp level:
|
|
201
|
+
* mirror-like surfaces (roughness near 0) are right, rougher ones read the sharp cube too, and only the reflections
|
|
202
|
+
* change — the diffuse ambient keeps the scene's own probe's shape at `environmentIntensity`.
|
|
203
|
+
*
|
|
204
|
+
* A probe that draws while it lights reads what it writes — fine on OpenGL; a Vulkan backend may want two probes in
|
|
205
|
+
* turn (a prefiltered probe never does: it lights from the filtered copy). Leave the probe's own carrier out of its view
|
|
206
|
+
* (`layers`), or the cube is the inside of the car. Warns once on a host without the call.
|
|
207
|
+
*/
|
|
208
|
+
get environment(): ReflectionProbe | null;
|
|
209
|
+
set environment(probe: ReflectionProbe | null);
|
|
210
|
+
private static _warnedEnvTexture;
|
|
190
211
|
/** The scene's stencil buffer on / off (see `SceneOptions.stencil`). */
|
|
191
212
|
setStencil(enabled: boolean): void;
|
|
192
213
|
add(...list: Node[]): this;
|
package/dist/types/inject.d.ts
CHANGED
|
@@ -148,7 +148,11 @@ export type { ScatterPlacement, ScatterOptions } from "./gl/Scatter";
|
|
|
148
148
|
export type { InstanceTransform } from "./gl/InstancedMesh";
|
|
149
149
|
export { Texture } from "./gl/Texture";
|
|
150
150
|
export type { TextureLoadOptions } from "./gl/Texture";
|
|
151
|
+
export { RenderTexture } from "./gl/RenderTexture";
|
|
151
152
|
export { Camera } from "./gl/Camera";
|
|
153
|
+
export type { CameraOptions, RenderToTextureOptions } from "./gl/Camera";
|
|
154
|
+
export { ReflectionProbe } from "./gl/ReflectionProbe";
|
|
155
|
+
export type { ReflectionProbeOptions } from "./gl/ReflectionProbe";
|
|
152
156
|
export { Ray } from "./gl/Ray";
|
|
153
157
|
export { Plane } from "./gl/Plane";
|
|
154
158
|
export { Noise } from "./gl/Noise";
|
|
@@ -130,8 +130,12 @@ export type SceneNodeDef = {
|
|
|
130
130
|
/** Baked lighting (a scene with `env.lightmap`): is this model/mesh node a lightmap STATIC — a
|
|
131
131
|
* receiver and an occluder in the bake, real-time shadow casting off once the bake applies?
|
|
132
132
|
* Default: static unless a `Physics` aspect moves the node (`dynamic` — Physics' default — or
|
|
133
|
-
* `kinematic`). Set it only to override that rule; prefab subtrees inherit the verdict.
|
|
134
|
-
|
|
133
|
+
* `kinematic`). Set it only to override that rule; prefab subtrees inherit the verdict.
|
|
134
|
+
* `'cube'` = a static whose every mesh bakes as AMBIENT CUBES instead of atlas texels — an occluder (its shadow and
|
|
135
|
+
* bounce stay in the bake) lit where it stands, the way the bake treats small and thin props on its own: a pipe run, a
|
|
136
|
+
* fence, a prop whose lightmap seams show. A prefab marked `'cube'` bakes its statics that way too. By name for a whole
|
|
137
|
+
* kit: `env.lightmap.cube`. */
|
|
138
|
+
lightmap?: boolean | "cube";
|
|
135
139
|
/** `model` nodes: vegetation — load through the FOLIAGE tier (wind, touch bending, per-copy tint; see
|
|
136
140
|
* `Foliage`). `{ fade: [start, end] }` also thins the cards out over that distance range (m) and drops the
|
|
137
141
|
* copy past `end` — for ground cover. The fade is per ASSET: every node of the same GLB shares it. */
|
|
@@ -184,10 +188,19 @@ export type SceneLightmapDef = {
|
|
|
184
188
|
* `{ through, diffuse }` splits it: `through` goes straight (the picture of the map), `diffuse` is scattered by the
|
|
185
189
|
* fibres (the underside glows, a soft fill with no picture) - dense canvas: `{ through: 0.08, diffuse: 0.25 }`. */
|
|
186
190
|
transmit?: Record<string, LightmapTransmit>;
|
|
191
|
+
/** FOR THE BAKE: CUBES BY NAME — regular expressions (ECMAScript, case-sensitive) searched in every baked mesh's key
|
|
192
|
+
* (`<node path>@<ordinal>`): `['SM_pipe', 'SM_fence']` bakes every pipe and fence node as ambient cubes instead of atlas
|
|
193
|
+
* texels, like a node's `lightmap: 'cube'`. The CLI's `--cube` adds to these. */
|
|
194
|
+
cube?: string[];
|
|
187
195
|
/** `asset('./assets/lightmap/level.lgrid')` — THE LIGHT GRID for movers: every node a Physics aspect or a
|
|
188
196
|
* CharacterController moves (and what code marks with `Lightmap.track`) takes its ambient light from the bake at the
|
|
189
197
|
* place it is at, whatever its shader. Absent = movers keep the scene's IBL. */
|
|
190
198
|
volume?: string;
|
|
199
|
+
/** `asset('./assets/lightmap/level-uv1.bin')` — THE PACKED LIGHTMAP UV1 the bake's rects map: it packs every mesh's
|
|
200
|
+
* lightmap charts into a square of their own instead of the unwrap's (once per mesh, whatever model holds it), and the
|
|
201
|
+
* engine swaps this into the models' TEXCOORD_1 before the rects go on. Required when the bake wrote one (the .bake's `uv1`): without it the statics
|
|
202
|
+
* read the wrong texels, so the bake is not applied. */
|
|
203
|
+
uv1?: string;
|
|
191
204
|
/** A DEBUG multiplier on the atlas' lux (default 1). */
|
|
192
205
|
lightScale?: number;
|
|
193
206
|
};
|
package/dist/types/ui/tree.d.ts
CHANGED
|
@@ -72,5 +72,6 @@ export declare const OWNED_KIND_ENTITY_2D = 5;
|
|
|
72
72
|
export declare const OWNED_KIND_MEDIA = 6;
|
|
73
73
|
export declare const OWNED_KIND_TWEEN = 7;
|
|
74
74
|
export declare const OWNED_KIND_CANVAS = 8;
|
|
75
|
+
export declare const OWNED_KIND_GL_RENDER_VIEW = 9;
|
|
75
76
|
import { DEAD_HANDLE } from "../core/pins";
|
|
76
77
|
export { DEAD_HANDLE };
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.4.
|
|
1
|
+
export declare const SDK_VERSION = "2.4.8";
|
|
2
2
|
/** The major of a semver string, or null when it is not one. */
|
|
3
3
|
export declare const sdkMajor: (version: string | null | undefined) => number | null;
|
|
4
4
|
/** The `// sdk: <version>` line of a compiled bundle's header (sdk/src/compile/header.ts), read from
|