lecodes-sdk 2.4.7 → 2.4.9

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.
@@ -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;
@@ -130,6 +130,7 @@ export type { DynamicBoneCurve, DynamicBoneFloor, DynamicBoneColliders } from ".
130
130
  export type { IKTwoBone, IKLookAt } from "./gl/animation/IK";
131
131
  export { Light } from "./gl/Light";
132
132
  export { Lightmap } from "./gl/Lightmap";
133
+ export type { LightmapDef, LightmapFiles, LightmapOptions, LightmapTransmit } from "./gl/Lightmap";
133
134
  export { Foliage } from "./gl/Foliage";
134
135
  export type { FoliageOptions, FoliageWind } from "./gl/Foliage";
135
136
  export { Terrain } from "./gl/terrain/Terrain";
@@ -148,7 +149,11 @@ export type { ScatterPlacement, ScatterOptions } from "./gl/Scatter";
148
149
  export type { InstanceTransform } from "./gl/InstancedMesh";
149
150
  export { Texture } from "./gl/Texture";
150
151
  export type { TextureLoadOptions } from "./gl/Texture";
152
+ export { RenderTexture } from "./gl/RenderTexture";
151
153
  export { Camera } from "./gl/Camera";
154
+ export type { CameraOptions, RenderToTextureOptions } from "./gl/Camera";
155
+ export { ReflectionProbe } from "./gl/ReflectionProbe";
156
+ export type { ReflectionProbeOptions } from "./gl/ReflectionProbe";
152
157
  export { Ray } from "./gl/Ray";
153
158
  export { Plane } from "./gl/Plane";
154
159
  export { Noise } from "./gl/Noise";
@@ -4,10 +4,10 @@ import { Scene, type SceneOptions } from "../gl/Scene";
4
4
  import { Node } from "../gl/Node";
5
5
  import { Mesh } from "../gl/Mesh";
6
6
  import { Model } from "../gl/Model";
7
- import { type LightmapTransmit } from "../gl/Lightmap";
7
+ import { type LightmapDef } from "../gl/Lightmap";
8
8
  import { type FoliageOptions } from "../gl/Foliage";
9
9
  import { type TerrainLayer, type TerrainRegion, type TerrainOptions } from "../gl/terrain/Terrain";
10
- import { Light, type SunOptions } from "../gl/Light";
10
+ import { Light, type PointOptions, type SpotOptions, type SunOptions } from "../gl/Light";
11
11
  import { type MaterialDef } from "./material";
12
12
  import type { CapsuleOptions, CylinderOptions, PlaneOptions, SphereOptions } from "../gl/Geometry";
13
13
  import { GizmoBuffer } from "./gizmos";
@@ -23,9 +23,16 @@ export type MeshDef = {
23
23
  } & CapsuleOptions) | ({
24
24
  kind: "plane";
25
25
  } & PlaneOptions);
26
- export type LightDef = {
26
+ /** The `light: {}` source block, by `kind` — `Light.sun` / `Light.point` / `Light.spot` with the node's transform: a
27
+ * point light's `bakeArea` panel lies in the node's local XZ plane and emits along its local -Y, so `eulerAngles`
28
+ * tilts it; a spot shines along the node's -Z (`direction` aims it, as a sun's does). */
29
+ export type LightDef = ({
27
30
  kind: "sun";
28
- } & SunOptions;
31
+ } & SunOptions) | ({
32
+ kind: "point";
33
+ } & PointOptions) | ({
34
+ kind: "spot";
35
+ } & SpotOptions);
29
36
  /** A stamp: the terrain conforms to another node of this file (a road) at load — see Terrain.conform. */
30
37
  export type TerrainStampDef = {
31
38
  /** Path of the node (a Mesh, a Model, or a node holding them) the ground hugs. */
@@ -134,7 +141,7 @@ export type SceneNodeDef = {
134
141
  * `'cube'` = a static whose every mesh bakes as AMBIENT CUBES instead of atlas texels — an occluder (its shadow and
135
142
  * 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
143
  * 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`. */
144
+ * kit: the `cube` option of `env.lightmap`'s `bake()`. */
138
145
  lightmap?: boolean | "cube";
139
146
  /** `model` nodes: vegetation — load through the FOLIAGE tier (wind, touch bending, per-copy tint; see
140
147
  * `Foliage`). `{ fade: [start, end] }` also thins the cards out over that distance range (m) and drops the
@@ -156,54 +163,6 @@ export type SceneCameraDef = CameraProjectionDef & {
156
163
  /** Point the camera looks at. */
157
164
  target?: Vec3Like;
158
165
  };
159
- /** `env.lightmap` — the level's baked lighting (engines/bake): the files `lecodes lightmap bake`
160
- * writes. Absent = real-time only. */
161
- export type SceneLightmapDef = {
162
- /** `asset('./assets/lightmap/level.bake')` */
163
- data: string;
164
- /** `asset('./assets/lightmap/level-light.ktx2')` — or, for a bake that took more than one atlas PAGE
165
- * (`lecodes lightmap bake --pages`), every page in order: `[asset('x-light.ktx2'), asset('x-light_1.ktx2')]`. */
166
- light: string | string[];
167
- /** `asset('./assets/lightmap/level-aux.ktx2')` (pages like `light`) — sun / sky visibility + light direction. */
168
- aux: string | string[];
169
- /** DEBUG: the page sets a `lecodes lightmap bake --split` wrote (`<stem>-direct[_n].ktx2`, `<stem>-indirect[_n].ktx2`),
170
- * pages like `light` — the `Lightmap.debug("direct" | "indirect")` views bind them in place of `light`. */
171
- direct?: string | string[];
172
- indirect?: string | string[];
173
- /** `asset('./assets/lightmap/level-probes.ktx2')` — the bake's reflection probes (one prefiltered cubemap of the level's
174
- * radiance per probe; every static reflects the nearest). Absent = statics reflect the sky's SH alone. */
175
- probes?: string;
176
- /** FOR THE BAKE: the radiance in cd / m² of emission 1.0 on this level (emissive factor x strength x map) - every lit
177
- * region of an emissive surface bakes as a rectangle lamp. An imported pack's emission is a LOOK (the school's panels
178
- * say 10); this is where the level says what they give: a 1.3 m ceiling panel of ~8000 lm is ~1600 nits. Default: what
179
- * the camera makes of 1.0 (`1.2 x 2^EV100`). 0 = emissive surfaces light nothing. `--emissive-nits` overrides. */
180
- emissiveNits?: number;
181
- /** `false` = the emissive surfaces light nothing in the bake - the level is lit by its lamps (`Light.point` with a
182
- * `bakeArea` next to every panel, the Unity packs' way) and the panels are decoration; `emissiveNits` then only says how
183
- * bright their glow is DRAWN (scene-referred: nits through the camera's exposure). Default true. */
184
- emissiveBake?: boolean;
185
- /** FOR THE BAKE: materials that let light THROUGH them, by glTF material name (`"name*"` = every name with that start) →
186
- * the share of a shadow ray that passes, tinted by the material's base colour x map: `{ mat_awning: 0.3 }` puts the
187
- * awning's warm, patterned light on the sand. The surface stays opaque - baked, drawn as before, a shadow caster.
188
- * `{ through, diffuse }` splits it: `through` goes straight (the picture of the map), `diffuse` is scattered by the
189
- * fibres (the underside glows, a soft fill with no picture) - dense canvas: `{ through: 0.08, diffuse: 0.25 }`. */
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[];
195
- /** `asset('./assets/lightmap/level.lgrid')` — THE LIGHT GRID for movers: every node a Physics aspect or a
196
- * CharacterController moves (and what code marks with `Lightmap.track`) takes its ambient light from the bake at the
197
- * place it is at, whatever its shader. Absent = movers keep the scene's IBL. */
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;
204
- /** A DEBUG multiplier on the atlas' lux (default 1). */
205
- lightScale?: number;
206
- };
207
166
  /** `env.navmesh` — the level's navigation mesh (see navmesh.md): the file `lecodes navmesh bake`
208
167
  * writes, the agent size it is built for, and the named areas. Absent = no navigation. */
209
168
  export type SceneNavmeshDef = {
@@ -220,8 +179,10 @@ export type SceneNavmeshDef = {
220
179
  areas?: Record<string, number>;
221
180
  };
222
181
  export type SceneDef = {
182
+ /** `lightmap` = the level's baked lighting (engines/bake): `bake('./assets/lightmap/level.bake', { …options })`, the
183
+ * macro that reads the bake's manifest at compile time (`LightmapDef`). Absent = real-time only. */
223
184
  env?: SceneOptions & {
224
- lightmap?: SceneLightmapDef;
185
+ lightmap?: LightmapDef;
225
186
  navmesh?: SceneNavmeshDef;
226
187
  foliage?: FoliageOptions;
227
188
  };
@@ -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 };
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "2.4.7";
1
+ export declare const SDK_VERSION = "2.4.9";
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