lecodes-sdk 0.20.0 → 1.0.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.
- package/dist/global.d.ts +48 -5
- package/dist/inject.js +361 -260
- package/dist/types/audio/Bus.d.ts +45 -0
- package/dist/types/audio/Sound.d.ts +28 -0
- package/dist/types/audio/Voice.d.ts +27 -0
- package/dist/types/audio/audio.d.ts +83 -0
- package/dist/types/audio/support.d.ts +1 -0
- package/dist/types/canvas/Canvas.d.ts +2 -0
- package/dist/types/gl/DecalSet.d.ts +148 -0
- package/dist/types/gl/Geometry.d.ts +17 -0
- package/dist/types/gl/Light.d.ts +7 -0
- package/dist/types/gl/Lightmap.d.ts +9 -0
- package/dist/types/gl/Material.d.ts +90 -2
- package/dist/types/gl/Mesh.d.ts +18 -1
- package/dist/types/gl/Model.d.ts +34 -0
- package/dist/types/gl/Particles.d.ts +13 -0
- package/dist/types/gl/Scene.d.ts +23 -0
- package/dist/types/gl/Texture.d.ts +29 -1
- package/dist/types/gl/animation/AnimationClip.d.ts +25 -12
- package/dist/types/gl/animation/DynamicBone.d.ts +173 -0
- package/dist/types/gl/{IK.d.ts → animation/IK.d.ts} +4 -4
- package/dist/types/gl/{Locomotion.d.ts → animation/Locomotion.d.ts} +6 -6
- package/dist/types/gl/animation/core.d.ts +15 -10
- package/dist/types/gl/audio/AudioSource.d.ts +60 -0
- package/dist/types/gl/audio/AudioZone.d.ts +32 -0
- package/dist/types/gl/audio/SceneAudio.d.ts +11 -0
- package/dist/types/gl/{NavAgent.d.ts → nav/NavAgent.d.ts} +4 -4
- package/dist/types/gl/{NavMesh.d.ts → nav/NavMesh.d.ts} +4 -4
- package/dist/types/gl/{CharacterController.d.ts → physics/CharacterController.d.ts} +5 -5
- package/dist/types/gl/{Physics.d.ts → physics/Physics.d.ts} +6 -5
- package/dist/types/gl/{Ragdoll.d.ts → physics/Ragdoll.d.ts} +4 -4
- package/dist/types/gl/{Shape.d.ts → physics/Shape.d.ts} +3 -3
- package/dist/types/gl/{Trigger.d.ts → physics/Trigger.d.ts} +2 -2
- package/dist/types/gl/state.d.ts +0 -1
- package/dist/types/gl/{Terrain.d.ts → terrain/Terrain.d.ts} +6 -6
- package/dist/types/gl/{terrainMesh.d.ts → terrain/terrainMesh.d.ts} +1 -1
- package/dist/types/gl/vehicle/Vehicle.d.ts +300 -0
- package/dist/types/gl/vehicle/Wheel.d.ts +147 -0
- package/dist/types/inject.d.ts +33 -21
- package/dist/types/runtime/files.d.ts +24 -1
- package/dist/types/runtime/input.d.ts +11 -0
- package/dist/types/scene/defineScene.d.ts +10 -3
- package/dist/types/ui/UIImage.d.ts +15 -5
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/prompts/README.md +142 -142
- package/prompts/dist/2d-game.md +408 -197
- package/prompts/dist/3d-app.md +491 -166
- package/prompts/dist/ar-app.md +373 -163
- package/prompts/dist/design.md +83 -87
- package/prompts/dist/ui-app.md +325 -136
- package/src/audio/Bus.ts +102 -0
- package/src/audio/Sound.ts +96 -0
- package/src/audio/Voice.ts +102 -0
- package/src/audio/audio.ts +161 -0
- package/src/audio/support.ts +6 -0
- package/src/bridges.d.ts +279 -32
- package/src/canvas/Canvas.ts +21 -0
- package/src/compile/__tests__/compile.test.ts +11 -0
- package/src/compile/compileProject.ts +30 -15
- package/src/compile/header.ts +6 -3
- package/src/compile/index.ts +4 -0
- package/src/compile/sceneEditor.ts +42 -1
- package/src/core/Aspect.ts +33 -8
- package/src/g2/Scene2D.ts +7 -0
- package/src/gl/CameraPlace.ts +52 -52
- package/src/gl/DecalSet.ts +360 -0
- package/src/gl/Geometry.ts +348 -279
- package/src/gl/Light.ts +16 -0
- package/src/gl/Lightmap.ts +35 -7
- package/src/gl/Material.ts +173 -4
- package/src/gl/Mesh.ts +120 -83
- package/src/gl/Model.ts +33 -1
- package/src/gl/Node.ts +1 -1
- package/src/gl/Particles.ts +21 -3
- package/src/gl/Scene.ts +41 -7
- package/src/gl/Texture.ts +43 -3
- package/src/gl/animation/AnimationClip.ts +43 -20
- package/src/gl/animation/Animator.ts +4 -3
- package/src/gl/animation/DynamicBone.ts +459 -0
- package/src/gl/{IK.ts → animation/IK.ts} +4 -4
- package/src/gl/{Locomotion.ts → animation/Locomotion.ts} +7 -7
- package/src/gl/animation/core.ts +20 -15
- package/src/gl/audio/AudioSource.ts +113 -0
- package/src/gl/audio/AudioZone.ts +75 -0
- package/src/gl/audio/SceneAudio.ts +26 -0
- package/src/gl/{NavAgent.ts → nav/NavAgent.ts} +5 -5
- package/src/gl/{NavMesh.ts → nav/NavMesh.ts} +8 -8
- package/src/gl/{CharacterController.ts → physics/CharacterController.ts} +5 -5
- package/src/gl/{Physics.ts → physics/Physics.ts} +12 -5
- package/src/gl/{Ragdoll.ts → physics/Ragdoll.ts} +272 -270
- package/src/gl/{Shape.ts → physics/Shape.ts} +3 -3
- package/src/gl/{Trigger.ts → physics/Trigger.ts} +2 -2
- package/src/gl/{physicsEvents.ts → physics/physicsEvents.ts} +1 -1
- package/src/gl/scenarios.ts +291 -291
- package/src/gl/state.ts +1 -1
- package/src/gl/{Terrain.ts → terrain/Terrain.ts} +10 -10
- package/src/gl/{terrainMesh.ts → terrain/terrainMesh.ts} +1 -1
- package/src/gl/vehicle/Vehicle.ts +666 -0
- package/src/gl/vehicle/Wheel.ts +290 -0
- package/src/inject.ts +226 -212
- package/src/runtime/files.ts +32 -2
- package/src/runtime/input.ts +6 -1
- package/src/scene/defineScene.ts +26 -10
- package/src/scene/gizmos.ts +148 -148
- package/src/scene/level.ts +2 -2
- package/src/ui/UIImage.ts +21 -7
- package/dist/types/gl/Gearbox.d.ts +0 -86
- package/dist/types/gl/Vehicle.d.ts +0 -191
- package/dist/types/gl/Wheel.d.ts +0 -95
- package/src/gl/Gearbox.ts +0 -212
- package/src/gl/Vehicle.ts +0 -473
- package/src/gl/Wheel.ts +0 -240
- /package/dist/types/gl/{physicsEvents.d.ts → physics/physicsEvents.d.ts} +0 -0
|
@@ -11,6 +11,19 @@ export declare function openFilePicker(options: OpenFilePickerOptions & {
|
|
|
11
11
|
/** Anything writable as-is: text, raw bytes, or a buffer the host already holds
|
|
12
12
|
* (a picked `File`, a `FetchResponse`, a `Canvas.toFile()` snapshot). */
|
|
13
13
|
export type FileData = string | Uint8Array | ArrayBuffer | File | FetchResponse;
|
|
14
|
+
/** One directory entry, as `files.ls` / `files.stat` report it. */
|
|
15
|
+
export type FileEntry = {
|
|
16
|
+
/** The last path segment. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Relative to the listed directory, `/`-separated — equal to `name` unless the listing was
|
|
19
|
+
* recursive. Join it onto the directory you listed to read the file. */
|
|
20
|
+
path: string;
|
|
21
|
+
kind: "file" | "dir";
|
|
22
|
+
/** Bytes; 0 for a directory. */
|
|
23
|
+
size: number;
|
|
24
|
+
/** Last modification, ms since the epoch (a `Date` value). */
|
|
25
|
+
modified: number;
|
|
26
|
+
};
|
|
14
27
|
export declare const files: {
|
|
15
28
|
/** Is there a filesystem here (desktop)? False on web/mobile, where every other call rejects. */
|
|
16
29
|
readonly supported: boolean;
|
|
@@ -24,10 +37,20 @@ export declare const files: {
|
|
|
24
37
|
readBytes(path: string): Promise<Uint8Array | null>;
|
|
25
38
|
/** Delete a file, or a directory (empty, or any directory with `{ recursive: true }`). Deleting
|
|
26
39
|
* something already gone is success — what's promised is that the path is free afterwards. */
|
|
27
|
-
|
|
40
|
+
rm(path: string, options?: {
|
|
28
41
|
recursive?: boolean;
|
|
29
42
|
}): Promise<void>;
|
|
30
43
|
/** Create a directory and any missing parents. An existing directory is fine. */
|
|
31
44
|
mkdir(path: string): Promise<void>;
|
|
45
|
+
/** The entries of a directory, sorted by path — null when there is no such directory (an empty
|
|
46
|
+
* one is `[]`, so `(await files.ls("saves")) ?? []` covers both). `{ recursive: true }` walks
|
|
47
|
+
* the subfolders too; each entry's `path` is then relative to the directory listed. A path that
|
|
48
|
+
* is a file, not a directory, rejects. Filter in JS — `entries.filter(e => e.name.endsWith(".json"))`. */
|
|
49
|
+
ls(path: string, options?: {
|
|
50
|
+
recursive?: boolean;
|
|
51
|
+
}): Promise<FileEntry[] | null>;
|
|
52
|
+
/** What is at `path`: a file or a directory entry (`path` equal to `name`), or null when nothing
|
|
53
|
+
* is there — `(await files.stat(p)) !== null` is the exists check. */
|
|
54
|
+
stat(path: string): Promise<FileEntry | null>;
|
|
32
55
|
};
|
|
33
56
|
export {};
|
|
@@ -8,6 +8,7 @@ export declare const InputChannel: {
|
|
|
8
8
|
readonly WheelY: 5;
|
|
9
9
|
readonly PointerLocked: 6;
|
|
10
10
|
readonly GamepadCount: 7;
|
|
11
|
+
readonly PointerOnUI: 8;
|
|
11
12
|
readonly GamepadBase: 16;
|
|
12
13
|
readonly GamepadStride: 16;
|
|
13
14
|
readonly PadConnected: 0;
|
|
@@ -64,6 +65,11 @@ export declare const mouse: {
|
|
|
64
65
|
* gesture (call it in a 'keydown' handler for MouseLeft); hosts drop it on focus loss and
|
|
65
66
|
* re-acquire on focus. Escape does NOT unlock by itself on native hosts — call `unlock()`. */
|
|
66
67
|
readonly locked: boolean;
|
|
68
|
+
/** The primary button went down on a UI element (a button, a scrollable, an input, a modal
|
|
69
|
+
* backdrop) and is still held. Stays true wherever the cursor drifts until the release, so
|
|
70
|
+
* `if (!Input.mouse.onUI) look(Input.mouse.delta)` never turns a HUD drag into camera look.
|
|
71
|
+
* Always false while `locked`. A press that fell through to the scene reads false. */
|
|
72
|
+
readonly onUI: boolean;
|
|
67
73
|
lock(): boolean;
|
|
68
74
|
unlock(): void;
|
|
69
75
|
};
|
|
@@ -108,6 +114,11 @@ export declare const Input: {
|
|
|
108
114
|
* gesture (call it in a 'keydown' handler for MouseLeft); hosts drop it on focus loss and
|
|
109
115
|
* re-acquire on focus. Escape does NOT unlock by itself on native hosts — call `unlock()`. */
|
|
110
116
|
readonly locked: boolean;
|
|
117
|
+
/** The primary button went down on a UI element (a button, a scrollable, an input, a modal
|
|
118
|
+
* backdrop) and is still held. Stays true wherever the cursor drifts until the release, so
|
|
119
|
+
* `if (!Input.mouse.onUI) look(Input.mouse.delta)` never turns a HUD drag into camera look.
|
|
120
|
+
* Always false while `locked`. A press that fell through to the scene reads false. */
|
|
121
|
+
readonly onUI: boolean;
|
|
111
122
|
lock(): boolean;
|
|
112
123
|
unlock(): void;
|
|
113
124
|
};
|
|
@@ -5,10 +5,10 @@ import { Scene, type SceneOptions } from "../gl/Scene";
|
|
|
5
5
|
import { Node } from "../gl/Node";
|
|
6
6
|
import { Mesh } from "../gl/Mesh";
|
|
7
7
|
import { Model } from "../gl/Model";
|
|
8
|
-
import { type TerrainLayer, type TerrainRegion, type TerrainOptions } from "../gl/Terrain";
|
|
8
|
+
import { type TerrainLayer, type TerrainRegion, type TerrainOptions } from "../gl/terrain/Terrain";
|
|
9
9
|
import { Light, type SunOptions } from "../gl/Light";
|
|
10
10
|
import { type MaterialDef } from "./material";
|
|
11
|
-
import type { CylinderOptions, PlaneOptions, SphereOptions } from "../gl/Geometry";
|
|
11
|
+
import type { CapsuleOptions, CylinderOptions, PlaneOptions, SphereOptions } from "../gl/Geometry";
|
|
12
12
|
export type MeshDef = {
|
|
13
13
|
kind: "box";
|
|
14
14
|
size?: Vec3Like | number;
|
|
@@ -17,6 +17,8 @@ export type MeshDef = {
|
|
|
17
17
|
} & SphereOptions) | ({
|
|
18
18
|
kind: "cylinder";
|
|
19
19
|
} & CylinderOptions) | ({
|
|
20
|
+
kind: "capsule";
|
|
21
|
+
} & CapsuleOptions) | ({
|
|
20
22
|
kind: "plane";
|
|
21
23
|
} & PlaneOptions);
|
|
22
24
|
export type LightDef = {
|
|
@@ -173,6 +175,10 @@ export type SceneLightmapDef = {
|
|
|
173
175
|
* ambient cube (2026-08-31) movers shade like the statics and the default is right; it stays as a
|
|
174
176
|
* trim. See `LightmapLoadOptions.volumeBoost`. */
|
|
175
177
|
volumeBoost?: number;
|
|
178
|
+
/** Occluder-only statics (props without lightmap UVs): `"baked"` (default) = their shadow is in the
|
|
179
|
+
* atlas, they stop casting in real time and the shadow pass draws only the movers; `"realtime"` =
|
|
180
|
+
* they keep casting (their shadow on other non-receiver props). See `LightmapLoadOptions.occluderShadows`. */
|
|
181
|
+
occluderShadows?: "baked" | "realtime";
|
|
176
182
|
};
|
|
177
183
|
/** `env.navmesh` — the level's navigation mesh (see navmesh.md): the file `lecodes navmesh bake`
|
|
178
184
|
* writes, the agent size it is built for, and the named areas. Absent = no navigation. */
|
|
@@ -256,7 +262,8 @@ export type ModelPartRow = {
|
|
|
256
262
|
* not parts, skipped. Filtering BEFORE segment math keeps `name[i]` indices stable no matter
|
|
257
263
|
* what defs are parented in. */
|
|
258
264
|
export declare const modelPartRows: (root: Node) => ModelPartRow[];
|
|
259
|
-
/** The static verdict for one node def (the editor's "Baked lighting" switch shows the same rule).
|
|
265
|
+
/** The static verdict for one node def (the editor's "Baked lighting" switch shows the same rule).
|
|
266
|
+
* Children of a mover are movers too — buildNodes carries that down, this is the node's own verdict. */
|
|
260
267
|
export declare const isLightmapStatic: (def: SceneNodeDef) => boolean;
|
|
261
268
|
/** Edit mode: play the preview pose on a model node (`editor: { clip, time }`) — idempotent, the
|
|
262
269
|
* harness re-applies it on inspector edits. No clip = back to the rest pose. */
|
|
@@ -2,6 +2,7 @@ import type { FetchResponse } from "../runtime/fetch";
|
|
|
2
2
|
import type { SvgSourceValue as SvgSource } from "../runtime/misc";
|
|
3
3
|
import type { File } from "../runtime/fetch";
|
|
4
4
|
import { Canvas } from "../canvas/Canvas";
|
|
5
|
+
import type { Scene2D } from "../g2/Scene2D";
|
|
5
6
|
import { type Color, type ElementStyle, type UIElementBase } from "./UINode";
|
|
6
7
|
export type UIImageStyle = ElementStyle & {
|
|
7
8
|
borderRadius?: number;
|
|
@@ -13,12 +14,21 @@ export type UIImageStyle = ElementStyle & {
|
|
|
13
14
|
export type CanvasImageSource = {
|
|
14
15
|
canvasSurface: number;
|
|
15
16
|
};
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export type
|
|
17
|
+
/** A live 2D scene as an image source: the host draws the scene into the node's box every frame
|
|
18
|
+
* (the scene's camera, projected into the box). No intrinsic size — give the node a width and
|
|
19
|
+
* height. */
|
|
20
|
+
export type Scene2DImageSource = {
|
|
21
|
+
scene2d: number;
|
|
22
|
+
};
|
|
23
|
+
/** Accepted image sources. A Canvas is baked to a surface marker on assign; a Scene2D becomes a
|
|
24
|
+
* live-scene marker. */
|
|
25
|
+
export type ImageSource = string | FetchResponse | File | SvgSource | Canvas | Scene2D;
|
|
26
|
+
/** The stored/resolved image source (a Canvas is resolved to a surface marker, a Scene2D to a
|
|
27
|
+
* live-scene marker). */
|
|
28
|
+
export type ResolvedImageSource = string | FetchResponse | File | SvgSource | CanvasImageSource | Scene2DImageSource;
|
|
20
29
|
/** An image element. Sources: URL / `asset(...)`, fetch response / File, an SVG source
|
|
21
|
-
* (`assetIcon`),
|
|
30
|
+
* (`assetIcon`), a live Canvas (`canvas.update()` refreshes the node in place), or a live Scene2D
|
|
31
|
+
* (drawn into the box every frame — a minimap). */
|
|
22
32
|
export interface UIImage extends UIElementBase<UIImageStyle> {
|
|
23
33
|
readonly type: "image";
|
|
24
34
|
/** The image source — writable to swap the picture in place. */
|