lecodes-sdk 1.0.0 → 1.2.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 +18 -4
- package/dist/inject.js +260 -361
- package/dist/types/animate/tween/Animation.d.ts +69 -0
- package/dist/types/animate/tween/Timeline.d.ts +55 -0
- package/dist/types/animate/tween/animateValue.d.ts +27 -0
- package/dist/types/animate/tween/easing.d.ts +29 -0
- package/dist/types/animate/tween/spec.d.ts +178 -0
- package/dist/types/g2/Node2D.d.ts +16 -0
- package/dist/types/g2/Sprite.d.ts +11 -1
- package/dist/types/gl/Camera.d.ts +15 -1
- package/dist/types/gl/Foliage.d.ts +47 -0
- package/dist/types/gl/Geometry.d.ts +24 -0
- package/dist/types/gl/Light.d.ts +28 -7
- package/dist/types/gl/Lightmap.d.ts +90 -60
- package/dist/types/gl/Material.d.ts +28 -20
- package/dist/types/gl/Model.d.ts +7 -5
- package/dist/types/gl/Node.d.ts +18 -0
- package/dist/types/gl/Particles.d.ts +55 -1
- package/dist/types/gl/Scene.d.ts +20 -0
- package/dist/types/gl/animation/AnimationClip.d.ts +19 -0
- package/dist/types/gl/animation/Animator.d.ts +27 -0
- package/dist/types/gl/animation/DynamicBone.d.ts +19 -8
- package/dist/types/gl/animation/IK.d.ts +86 -30
- package/dist/types/gl/animation/Locomotion.d.ts +52 -3
- package/dist/types/gl/animation/Warp.d.ts +2 -1
- package/dist/types/gl/animation/core.d.ts +35 -4
- package/dist/types/gl/physics/Ragdoll.d.ts +87 -12
- package/dist/types/gl/terrain/Terrain.d.ts +12 -2
- package/dist/types/inject.d.ts +8 -2
- package/dist/types/runtime/input.d.ts +7 -0
- package/dist/types/scene/defineScene.d.ts +44 -32
- package/dist/types/ui/UIButton.d.ts +3 -1
- package/dist/types/ui/UIInput.d.ts +5 -1
- package/dist/types/ui/UINode.d.ts +24 -24
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/prompts/README.md +142 -142
- package/prompts/core-design.md +27 -4
- package/prompts/core.md +35 -6
- package/prompts/dist/2d-game.md +197 -408
- package/prompts/dist/3d-app.md +166 -491
- package/prompts/dist/ar-app.md +163 -373
- package/prompts/dist/design.md +87 -83
- package/prompts/dist/ui-app.md +136 -325
- package/prompts/select.ts +19 -4
- package/src/animate/tween/Animation.ts +378 -0
- package/src/animate/tween/Timeline.ts +175 -0
- package/src/animate/tween/animateValue.ts +100 -0
- package/src/animate/tween/easing.ts +172 -0
- package/src/animate/tween/spec.ts +479 -0
- package/src/audio/audio.ts +161 -161
- package/src/bridges.d.ts +235 -65
- package/src/compile/__tests__/assetMacro.test.ts +26 -0
- package/src/compile/__tests__/detectEntry.test.ts +19 -0
- package/src/compile/__tests__/serverSplit.test.ts +27 -0
- package/src/compile/bundler.ts +34 -4
- package/src/compile/compileProject.ts +31 -1
- package/src/compile/detectEntry.ts +8 -3
- package/src/compile/index.ts +2 -0
- package/src/compile/serverSplit.ts +9 -3
- package/src/g2/Node2D.ts +38 -0
- package/src/g2/Sprite.ts +20 -1
- package/src/gl/Camera.ts +34 -1
- package/src/gl/CameraPlace.ts +52 -52
- package/src/gl/Foliage.ts +102 -0
- package/src/gl/Geometry.ts +393 -348
- package/src/gl/Light.ts +49 -16
- package/src/gl/Lightmap.ts +439 -275
- package/src/gl/Material.ts +59 -47
- package/src/gl/Mesh.ts +120 -120
- package/src/gl/Model.ts +23 -12
- package/src/gl/Node.ts +39 -0
- package/src/gl/Particles.ts +80 -2
- package/src/gl/Scene.ts +34 -1
- package/src/gl/animation/AnimationClip.ts +52 -0
- package/src/gl/animation/Animator.ts +42 -2
- package/src/gl/animation/DynamicBone.ts +35 -12
- package/src/gl/animation/IK.ts +173 -152
- package/src/gl/animation/Locomotion.ts +72 -8
- package/src/gl/animation/Playback.ts +5 -4
- package/src/gl/animation/Warp.ts +5 -2
- package/src/gl/animation/core.ts +65 -4
- package/src/gl/physics/Ragdoll.ts +451 -272
- package/src/gl/scenarios.ts +291 -291
- package/src/gl/terrain/Terrain.ts +33 -2
- package/src/inject.ts +236 -226
- package/src/runtime/input.ts +11 -0
- package/src/scene/defineScene.ts +72 -62
- package/src/scene/gizmos.ts +148 -148
- package/src/ui/UIButton.ts +2 -2
- package/src/ui/UIInput.ts +3 -3
- package/src/ui/UINode.ts +61 -36
- package/dist/types/animate/animate.d.ts +0 -20
- package/src/animate/animate.ts +0 -238
package/src/gl/animation/core.ts
CHANGED
|
@@ -25,15 +25,24 @@ export type PlayOptions = {
|
|
|
25
25
|
fade?: number
|
|
26
26
|
/** Transition seconds for the way in only (overrides `fade`). */
|
|
27
27
|
fadeIn?: number
|
|
28
|
-
/** One-shots: the transition BACK to the loop
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
/** One-shots: the transition BACK to the loop after the end (overrides `fade`; `0` = cut at the end).
|
|
29
|
+
* The clip plays to its last frame; the loop then takes over and the difference between the two poses
|
|
30
|
+
* (and their velocities) decays over this time, so no part of the clip is cut — to play less of it,
|
|
31
|
+
* give it an `end`. On a layer with no loop the clip HOLDS its last frame (a rock that broke stays
|
|
32
|
+
* broken) — `anim.stop({ fade })` is the way back to rest. */
|
|
32
33
|
fadeOut?: number
|
|
33
34
|
/** Playback rate for this clip (default 1). */
|
|
34
35
|
speed?: number
|
|
35
36
|
/** Rewind even if the clip is already playing (default: rewind only if it isn't). */
|
|
36
37
|
restart?: boolean
|
|
38
|
+
/** Play a WINDOW of the clip, seconds of the clip: enter at `start` (default 0; only when the play
|
|
39
|
+
* rewinds — see `restart`) and treat `end` (default the clip's end) as the end — the hand-over fires
|
|
40
|
+
* there, the last frame held there, events beyond it never fire. Only the swing of a longer take, the
|
|
41
|
+
* wind-up without the recovery. A window that lives in the clip table belongs in
|
|
42
|
+
* `AnimationClip.from(clip, { from, to })` instead. Not combined with `phase`. Hosts without the
|
|
43
|
+
* window play the whole clip. */
|
|
44
|
+
start?: number
|
|
45
|
+
end?: number
|
|
37
46
|
/** Enter the clip at a point in the GAIT CYCLE instead of at its start: `'match'` = the phase the
|
|
38
47
|
* layer shows right now (the walk's left foot is down → the turn clip starts where its left foot
|
|
39
48
|
* is down too, so nothing slides), or a number 0–1. Clips without a gait cycle ignore it. */
|
|
@@ -293,6 +302,12 @@ export class Core {
|
|
|
293
302
|
ensure(): boolean {
|
|
294
303
|
if (this.id) return true
|
|
295
304
|
if (this.embedded().length === 0 && this.table.size === 0) { console.warn(`Animator: no clips on ${this.node.name || "the node"} — nothing to play`); return false }
|
|
305
|
+
return this.ensureRig()
|
|
306
|
+
}
|
|
307
|
+
/** The native animator for the RIG alone — an IK chain or a socket on a model that has no clips
|
|
308
|
+
* still needs the joint tree described to the engine. False = no transform hierarchy (warned). */
|
|
309
|
+
ensureRig(): boolean {
|
|
310
|
+
if (this.id) return true
|
|
296
311
|
ensureEvents()
|
|
297
312
|
this.id = _creator.animatorCreate(this.node.id)
|
|
298
313
|
if (!this.id) { console.warn("Animator: node has no transform hierarchy"); return false }
|
|
@@ -303,6 +318,7 @@ export class Core {
|
|
|
303
318
|
if (this._feetParams && _creator.animatorSetFeetParams) _creator.animatorSetFeetParams(this.id, this._feetParams)
|
|
304
319
|
if (this.speed !== 1) _creator.animatorSetGlobal(this.id, this.speed, false)
|
|
305
320
|
for (const L of this.layers) if (L.index > 0) this.pushLayer(L)
|
|
321
|
+
for (const s of this._sockets.values()) this.pushSocket(s)
|
|
306
322
|
return true
|
|
307
323
|
}
|
|
308
324
|
destroy(): void {
|
|
@@ -378,6 +394,11 @@ export class Core {
|
|
|
378
394
|
s.playback = rec
|
|
379
395
|
_creator.animatorPlay(this.id, s.slot, false, o.speed ?? 1, fadeIn, fadeOut, o.restart ?? false)
|
|
380
396
|
if (o.turn !== undefined) _creator.animatorSlotSetTurn?.(this.id, s.slot, o.turn * Math.PI / 180, true)
|
|
397
|
+
if (o.start !== undefined || o.end !== undefined) {
|
|
398
|
+
const st = Math.max(0, o.start ?? 0), en = o.end === undefined ? -1 : Math.min(o.end, clip.duration)
|
|
399
|
+
if (en >= 0 && en <= st) console.warn(`Animator: '${name}' window ${st}–${o.end} is empty (${clip.duration.toFixed(2)}s clip)`)
|
|
400
|
+
_creator.animatorSlotSetWindow?.(this.id, s.slot, st, en)
|
|
401
|
+
}
|
|
381
402
|
if (phase !== undefined) _creator.animatorSeekPhase(this.id, s.slot, phase)
|
|
382
403
|
return new Playback(rec, this)
|
|
383
404
|
}
|
|
@@ -671,6 +692,11 @@ export class Core {
|
|
|
671
692
|
this._warp = params
|
|
672
693
|
if (this.id) _creator.animatorSetWarpParams(this.id, params)
|
|
673
694
|
}
|
|
695
|
+
/** The body's world velocity this frame (m/s) — the game side of the stride / orientation fit. Nothing
|
|
696
|
+
* to feed before the animator exists; hosts without the warp stage have no method. */
|
|
697
|
+
setMotion(vx: number, vy: number, vz: number): void {
|
|
698
|
+
if (this.id && _creator.animatorSetMotion) _creator.animatorSetMotion(this.id, vx, vy, vz)
|
|
699
|
+
}
|
|
674
700
|
/** The feet stage (lock / ground IK), as the engine's fixed-order parameter array. */
|
|
675
701
|
private _feetParams?: Float32Array
|
|
676
702
|
setFeetParams(params: Float32Array): void {
|
|
@@ -682,6 +708,41 @@ export class Core {
|
|
|
682
708
|
footState(side: 0 | 1, out: Float32Array): boolean {
|
|
683
709
|
return this.id !== 0 && _creator.animatorFootState !== undefined && _creator.animatorFootState(this.id, side, out)
|
|
684
710
|
}
|
|
711
|
+
// ---- IK chains + sockets (creator-anim anchors.cpp; the aspects in IK.ts) ----
|
|
712
|
+
// Hosts without the chains (an engine predating them) get a warning once and inert chains.
|
|
713
|
+
private static _warnedIk = false
|
|
714
|
+
private hasIk(): boolean {
|
|
715
|
+
if (_creator.animatorIkCreate) return true
|
|
716
|
+
if (!Core._warnedIk) { Core._warnedIk = true; console.warn("IK: this host has no IK chains (engine predates them) — chains and sockets are inert") }
|
|
717
|
+
return false
|
|
718
|
+
}
|
|
719
|
+
/** A chain ending in `endEntity` (kind 0 two-bone: the bone, its parent, its grandparent; 1 look-at). 0 = none. */
|
|
720
|
+
ikCreate(kind: 0 | 1, endEntity: number): number {
|
|
721
|
+
if (!this.ensureRig() || !this.hasIk()) return 0
|
|
722
|
+
return _creator.animatorIkCreate!(this.id, kind, endEntity)
|
|
723
|
+
}
|
|
724
|
+
ikDestroy(ik: number): void { if (this.id && _creator.animatorIkDestroy) _creator.animatorIkDestroy(this.id, ik) }
|
|
725
|
+
ikSet(ik: number, params: Float32Array): void { if (this.id && _creator.animatorIkSet) _creator.animatorIkSet(this.id, ik, params) }
|
|
726
|
+
ikNodes(ik: number, target: number, pole: number, rotation: number): void { if (this.id && _creator.animatorIkNodes) _creator.animatorIkNodes(this.id, ik, target, pole, rotation) }
|
|
727
|
+
ikAnchor(ik: number, socket: string): void { if (this.id && _creator.animatorIkAnchor) _creator.animatorIkAnchor(this.id, ik, socket) }
|
|
728
|
+
ikState(ik: number, out: Float32Array): boolean { return this.id !== 0 && _creator.animatorIkState !== undefined && _creator.animatorIkState(this.id, ik, out) }
|
|
729
|
+
/** Sockets by "set/name", replayed when the animator is (re)created. */
|
|
730
|
+
private readonly _sockets = new Map<string, { set: string, name: string, joint: number, node: number, trs: Float32Array | null }>()
|
|
731
|
+
/** Define a socket on joint `joint` (a bone's entity): a NODE socket (read by the engine every frame) or a
|
|
732
|
+
* fixed TRS in the joint's space. set "" = the live set, any other name = a donor's. */
|
|
733
|
+
setSocket(set: string, name: string, joint: number, node: number, trs: Float32Array | null): void {
|
|
734
|
+
const rec = { set, name, joint, node, trs }
|
|
735
|
+
this._sockets.set(`${set}/${name}`, rec)
|
|
736
|
+
if (this.ensureRig()) this.pushSocket(rec)
|
|
737
|
+
}
|
|
738
|
+
removeSocket(set: string, name: string): void {
|
|
739
|
+
this._sockets.delete(`${set}/${name}`)
|
|
740
|
+
if (this.id && _creator.animatorSetSocket) _creator.animatorSetSocket(this.id, set, name, 0, 0, null)
|
|
741
|
+
}
|
|
742
|
+
private pushSocket(s: { set: string, name: string, joint: number, node: number, trs: Float32Array | null }): void {
|
|
743
|
+
if (this.hasIk() && _creator.animatorSetSocket) _creator.animatorSetSocket(this.id, s.set, s.name, s.joint, s.node, s.trs)
|
|
744
|
+
}
|
|
745
|
+
|
|
685
746
|
private readonly _steps = new Set<StepHandler>()
|
|
686
747
|
onStepHandler(cb: StepHandler): void { this._steps.add(cb) }
|
|
687
748
|
offStepHandler(cb: StepHandler): void { this._steps.delete(cb) }
|