lecodes-sdk 2.2.13 → 2.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.
Files changed (48) hide show
  1. package/dist/global.d.ts +11 -0
  2. package/dist/types/gl/Scene.d.ts +0 -11
  3. package/dist/types/gl/postProcessing.d.ts +31 -2
  4. package/dist/types/inject.d.ts +3 -2
  5. package/dist/types/plugin.d.ts +3 -0
  6. package/dist/types/plugins/gen/push/sdk/push.d.ts +10 -3
  7. package/dist/types/plugins/gen/push/sdk/push.gen.d.ts +11 -3
  8. package/dist/types/runtime/device.d.ts +7 -19
  9. package/dist/types/runtime/pushSeam.d.ts +23 -0
  10. package/dist/types/runtime/rpc.d.ts +15 -1
  11. package/dist/types/server/auth/models.d.ts +13 -1
  12. package/dist/types/server/auth/types.d.ts +2 -0
  13. package/dist/types/server/inject.d.ts +1 -0
  14. package/dist/types/server/pushChannel.d.ts +79 -0
  15. package/dist/types/ui/UINode.d.ts +1 -1
  16. package/dist/types/version.d.ts +1 -1
  17. package/dist/types.json +1 -1
  18. package/package.json +1 -1
  19. package/src/animate/tween/Timeline.ts +175 -175
  20. package/src/bridges/gl.d.ts +5 -13
  21. package/src/compile/serverSplit.ts +29 -19
  22. package/src/compile/serverTypes.ts +1 -1
  23. package/src/gl/CameraPlace.ts +52 -52
  24. package/src/gl/Light.ts +257 -257
  25. package/src/gl/Mesh.ts +120 -120
  26. package/src/gl/Scene.ts +0 -13
  27. package/src/gl/animation/DynamicBone.ts +486 -486
  28. package/src/gl/postProcessing.ts +52 -9
  29. package/src/gl/scenarios.ts +291 -291
  30. package/src/inject.ts +3 -2
  31. package/src/plugin.ts +3 -0
  32. package/src/plugins/gen/push/contract.d.ts +24 -2
  33. package/src/plugins/gen/push/sdk/push.gen.ts +17 -5
  34. package/src/plugins/gen/push/sdk/push.ts +159 -55
  35. package/src/runtime/device.ts +8 -37
  36. package/src/runtime/pushSeam.ts +22 -0
  37. package/src/runtime/rpc.ts +35 -1
  38. package/src/server/auth/host.ts +40 -9
  39. package/src/server/auth/models.ts +5 -1
  40. package/src/server/auth/types.ts +2 -0
  41. package/src/server/host.ts +6 -0
  42. package/src/server/inject.ts +3 -2
  43. package/src/server/push/host.ts +143 -0
  44. package/src/server/pushChannel.ts +121 -0
  45. package/src/server/runtime.ts +20 -8
  46. package/src/ui/UIInput.ts +2 -2
  47. package/src/ui/UINode.ts +1 -1
  48. package/src/version.ts +1 -1
@@ -12,12 +12,13 @@
12
12
  // Two bands inside, because the engine treats them differently:
13
13
  //
14
14
  // - The GRADING band — tone mapping, exposure, white balance, contrast / saturation / vibrance,
15
- // shadows / midtones / highlights, slope / offset / power, curves, the .cube LUT — is baked by the
16
- // engine into the ONE 3D lookup table the frame always samples. Free per frame; a CHANGE re-bakes
17
- // a 32³ table on the CPU. So writes here are COALESCED: a field write marks the band dirty and the
18
- // whole band goes to the engine once, in a microtask (the end of the current handler), and the
19
- // values are quantised to 1/1000 so a tween that barely moves does not re-bake. Not a thing to
20
- // animate every frame; a blend between two looks over a second is fine (a few dozen bakes).
15
+ // shadows / midtones / highlights, slope / offset / power, curves, the .cube LUT, the HDR look —
16
+ // is baked by the engine into the ONE 3D lookup table the frame always samples. Free per frame;
17
+ // a CHANGE re-bakes a 32³ table on the CPU. So writes here are COALESCED: a field write marks the
18
+ // band dirty and the whole band goes to the engine once, in a microtask (the end of the current
19
+ // handler), and the values are quantised to 1/1000 (the HDR look to 0.05) so a tween that barely
20
+ // moves does not re-bake. Not a thing to animate every frame; a blend between two looks over a
21
+ // second is fine (a few dozen bakes).
21
22
  // - The LIVE band — bloom, vignette, ambient occlusion, screen-space reflections, depth of field —
22
23
  // is a set of view options: written to the engine at once, free to animate (a focus pull every
23
24
  // frame is what depthOfField is for).
@@ -134,6 +135,26 @@ export type ColorCurves = {
134
135
  highlightScale?: Rgb
135
136
  }
136
137
 
138
+ /** The look on an HDR display — a screen with headroom above SDR white (Apple's XDR panels, an
139
+ * external display in HDR mode), where the operator is stretched past SDR white toward the peak.
140
+ * Ignored on SDR: stored, read back, nothing changes on screen (`device.hdr.available` says which
141
+ * display this is). Part of the grading band — a change is a bake — and quantised to 0.05 steps. */
142
+ export type HdrLook = {
143
+ /** How much of the picture reaches for the display's headroom, 0..1 (default 0.35). 0 touches only
144
+ * what SDR clipped — the SDR grade kept exactly, but a mostly-mid-tone frame then looks flat next
145
+ * to its one bright spot; 1 lifts nearly everything above black toward the peak. A sunlit
146
+ * exterior takes 1, a dim interior wants less. */
147
+ strength?: number
148
+ /** Where white lands, as a multiple of SDR white, 1..8 (default 1) — the "HDR brightness" of a
149
+ * console game's calibration screen, where 1.5–2 is the norm. It scales the WHOLE picture: at 1
150
+ * a white wall is as bright as the UI's white (faithful, and dim next to what "HDR on" is
151
+ * expected to look like), at 2 twice that, and highlights still climb above it (the engine keeps
152
+ * `headroom / paperWhite` for them, clamped at the peak). `strength` decides how much of the
153
+ * picture reaches for the peak; this decides where the picture starts — a game that wants to read
154
+ * as "HDR on" rather than "SDR with a brighter sun" wants this over `strength`. */
155
+ paperWhite?: number
156
+ }
157
+
137
158
  export type PostProcessingOptions = {
138
159
  /** The operator that folds the scene's HDR light into the display's range (default 'aces').
139
160
  * `'aces'` (filament's ACES legacy) desaturates bright colours towards white — HDR fire reads
@@ -167,6 +188,11 @@ export type PostProcessingOptions = {
167
188
  * the operator, in display-referred sRGB — a `.cube` file: `asset('./look.cube')`, or a bare
168
189
  * staged filename. `null` removes it. */
169
190
  lut?: string | null
191
+ /** The look on an HDR display: `strength` 0..1 (how much of the picture reaches for the peak:
192
+ * 0 only what SDR clipped … 1 nearly everything; default 0.35), `paperWhite` 1..8 (where white
193
+ * lands × SDR white — the console "HDR brightness", 1.5–2 the norm; default 1). Ignored on SDR.
194
+ * An overlay takes its parent's, like the rest of the grading. */
195
+ hdr?: HdrLook
170
196
  /** `true` = defaults (intensity 0.2), an object = its knobs, `false` = off. */
171
197
  bloom?: boolean | BloomOptions
172
198
  /** `true` = defaults (a soft black edge), an object = its knobs, `false` = off. */
@@ -180,12 +206,13 @@ export type PostProcessingOptions = {
180
206
  }
181
207
 
182
208
  /** The float layout of `_creator.setColorGrading` — creator.h's ColorGradingParam. Indices never
183
- * move; a new field goes at the end and COUNT grows. */
209
+ * move; a new field goes at the end and COUNT grows (the engine takes an older bundle's shorter
210
+ * array, down to the 39 before HDR_*, with the tail at its defaults). */
184
211
  export const CG = {
185
212
  TONE_MAPPING: 0, EXPOSURE: 1, TEMPERATURE: 2, TINT: 3, CONTRAST: 4, VIBRANCE: 5, SATURATION: 6,
186
213
  SHADOWS: 7, MIDTONES: 10, HIGHLIGHTS: 13, RANGES: 16, SLOPE: 20, OFFSET: 23, POWER: 26,
187
- SHADOW_GAMMA: 29, MID_POINT: 32, HIGHLIGHT_SCALE: 35, LUT: 38,
188
- COUNT: 39,
214
+ SHADOW_GAMMA: 29, MID_POINT: 32, HIGHLIGHT_SCALE: 35, LUT: 38, HDR_STRENGTH: 39, HDR_PAPER_WHITE: 40,
215
+ COUNT: 41,
189
216
  } as const
190
217
 
191
218
  const TONE_MAPPING_MODE: Record<ToneMappingOperator, number> = { aces: 0, neutral: 1, linear: 2, filmic: 3 }
@@ -196,6 +223,10 @@ const ONE: Rgb = [ 1, 1, 1 ]
196
223
  const ZERO: Rgb = [ 0, 0, 0 ]
197
224
  const rgb = (v: Rgb | undefined, d: Rgb): Rgb => v ? [ v[0], v[1], v[2] ] : d
198
225
  const pair = (v: readonly [number, number] | undefined, d: readonly [number, number]): readonly [number, number] => v ? [ v[0], v[1] ] : d
226
+ /** The HDR look on the wire: clamped to its range and quantised to 0.05 — a slider must not re-bake a
227
+ * 32³ LUT per pixel of travel (the quantum is the SDK's; the engine only clamps). */
228
+ const hdrStep = (v: number, min: number, max: number, d: number): number =>
229
+ Number.isFinite(v) ? Math.round(Math.min(max, Math.max(min, v)) * 20) / 20 : d
199
230
 
200
231
  /** The grading band, normalised: every field present. */
201
232
  type Grading = {
@@ -218,12 +249,15 @@ type Grading = {
218
249
  midPoint: Rgb
219
250
  highlightScale: Rgb
220
251
  lut: string | null
252
+ hdrStrength: number
253
+ hdrPaperWhite: number
221
254
  }
222
255
 
223
256
  const defaultGrading = (): Grading => ({
224
257
  toneMapping: "aces", exposure: 0, temperature: 0, tint: 0, contrast: 1, saturation: 1, vibrance: 1,
225
258
  shadows: ONE, midtones: ONE, highlights: ONE, rangeShadows: [ 0, 0.333 ], rangeHighlights: [ 0.55, 1 ],
226
259
  slope: ONE, offset: ZERO, power: ONE, shadowGamma: ONE, midPoint: ONE, highlightScale: ONE, lut: null,
260
+ hdrStrength: 0.35, hdrPaperWhite: 1,
227
261
  })
228
262
 
229
263
  const BLOOM_DEFAULTS: Required<BloomOptions> = { intensity: 0.2, threshold: true, highlight: 1000, levels: 6, quality: "medium", lensFlare: false, dirt: null, dirtStrength: 0.2 }
@@ -279,6 +313,7 @@ export class PostProcessing {
279
313
  if (options.power !== undefined) this.power = options.power
280
314
  if (options.curves !== undefined) this.curves = options.curves
281
315
  if (options.lut !== undefined) this.lut = options.lut
316
+ if (options.hdr !== undefined) this.hdr = options.hdr
282
317
  this.flush()
283
318
  if (options.bloom !== undefined) this.bloom = options.bloom
284
319
  if (options.vignette !== undefined) this.vignette = options.vignette
@@ -348,6 +383,12 @@ export class PostProcessing {
348
383
  }
349
384
  get lut(): string | null { return this._g.lut }
350
385
  set lut(v: string | null) { this._g.lut = v; this._lutDirty = v !== this._sentLut; this._touch() }
386
+ get hdr(): Required<HdrLook> { return { strength: this._g.hdrStrength, paperWhite: this._g.hdrPaperWhite } }
387
+ set hdr(v: HdrLook) {
388
+ if (v.strength !== undefined) this._g.hdrStrength = v.strength
389
+ if (v.paperWhite !== undefined) this._g.hdrPaperWhite = v.paperWhite
390
+ this._touch()
391
+ }
351
392
 
352
393
  // ---- the live band: view options, written at once ----
353
394
 
@@ -445,6 +486,8 @@ export class PostProcessing {
445
486
  put3(CG.MID_POINT, g.midPoint)
446
487
  put3(CG.HIGHLIGHT_SCALE, g.highlightScale)
447
488
  p[CG.LUT] = g.lut !== null ? 1 : 0
489
+ p[CG.HDR_STRENGTH] = hdrStep(g.hdrStrength, 0, 1, 0.35)
490
+ p[CG.HDR_PAPER_WHITE] = hdrStep(g.hdrPaperWhite, 1, 8, 1)
448
491
  return p
449
492
  }
450
493
  }