lecodes-sdk 2.3.0 → 2.4.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.
@@ -142,6 +142,35 @@ export const device = {
142
142
  set statsOverlay(on: boolean) {
143
143
  _creatorDevice.setStatsOverlay?.(!!on)
144
144
  },
145
+ /** Cap the frame rate: the host runs the frame — the tick, the 3D scene — at most `fps` times a
146
+ * second. `0` removes the cap: the display's own rate (120 on a 120 Hz phone), or, with vsync
147
+ * off, as fast as the host renders. A REQUEST, not a state the app owns: a phone asks its panel
148
+ * for the rate (a 120 Hz panel at 60 shows every frame for a full period — even, cooler) and an
149
+ * OEM may refuse the switch, in which case the host renders every second refresh instead; the
150
+ * screen's own maximum always wins. The tick IS the frame here, so a cap of 30 is 30 Hz of game
151
+ * logic and input sampling too — raise it for gameplay. Host state: it stays through a project
152
+ * swap. A no-op on hosts whose loop has no pacing of its own (web, headless). */
153
+ setFrameRate(fps: number): void {
154
+ const n = +fps
155
+ _creatorDevice.setFrameRate?.(n > 0 && Number.isFinite(n) ? n : 0)
156
+ },
157
+ /** Vertical sync: `false` presents without waiting for the display's refresh — the lowest input
158
+ * latency, tearing possible, and with no cap set (`setFrameRate(0)`) the loop renders as fast as
159
+ * it can. Set a cap unless you are measuring. Desktop only: a mobile compositor never presents
160
+ * outside the refresh. Returns whether the host took the request (`false` on a host without
161
+ * the switch), so a settings menu can hide the toggle. */
162
+ setVsync(enabled: boolean): boolean {
163
+ if (!_creatorDevice.setVsync) return false
164
+ _creatorDevice.setVsync(!!enabled)
165
+ return true
166
+ },
167
+ /** The display's refresh rate in Hz: the fastest the screen offers the app — 120 on a 120 Hz
168
+ * phone whatever mode a cap has put it in (an iPhone's 60 unless the app's Info.plist lifts the
169
+ * floor), the monitor's current mode on desktop. The sensible choices of a frame-rate menu are
170
+ * its divisors. 0 where the host cannot tell (web). */
171
+ get displayRefreshRate(): number {
172
+ return _creatorDevice.displayRefreshRate?.() ?? 0
173
+ },
145
174
  /** Device-orientation sensor (gyro + accelerometer, fused) for tilt/steering and magic-window /
146
175
  * 360° panoramas. Poll `attitude` / `gravity` inside setLoop; they return the freshest fused
147
176
  * sample, so the sensor rate need not match your frame rate. Host-gated: a no-op with no sensor. */
package/src/version.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // same manifest). Its MAJOR is the bundle ↔ runtime contract: a bundle's `// sdk:` header line
5
5
  // and a host's embedded version must agree on the major for the host to run the bundle; minor
6
6
  // and patch never gate anything (features are detected, never versioned).
7
- export const SDK_VERSION = "2.3.0"
7
+ export const SDK_VERSION = "2.4.0"
8
8
 
9
9
  /** The major of a semver string, or null when it is not one. */
10
10
  export const sdkMajor = (version: string | null | undefined): number | null => {