lecodes-cli 0.17.2 → 0.18.1

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 (62) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +2376 -755
  3. package/package.json +4 -4
  4. package/runtime/scene-harness.json +1 -1
  5. package/runtime/sdk/compile/aspectMacro.ts +52 -8
  6. package/runtime/sdk/compile/assetMacro.ts +116 -15
  7. package/runtime/sdk/compile/bundler.ts +39 -4
  8. package/runtime/sdk/compile/compileProject.ts +16 -1
  9. package/runtime/sdk/compile/header.ts +6 -1
  10. package/runtime/sdk/compile/index.ts +31 -0
  11. package/runtime/sdk/compile/liteMaterial.ts +247 -0
  12. package/runtime/sdk/compile/sceneEditor.ts +11 -1
  13. package/runtime/sdk/compile/shaderSchema.ts +202 -0
  14. package/runtime/sdk/compile/shaderTargets.ts +81 -0
  15. package/runtime/sdk/core/Aspect.ts +363 -95
  16. package/runtime/sdk/core/compWrite.ts +42 -0
  17. package/runtime/sdk/core/fields.ts +1 -1
  18. package/runtime/sdk/core/time.ts +81 -0
  19. package/runtime/sdk/g2/Camera2D.ts +8 -1
  20. package/runtime/sdk/g2/CharacterController2D.ts +253 -53
  21. package/runtime/sdk/g2/Node2D.ts +80 -10
  22. package/runtime/sdk/g2/OneWay2D.ts +66 -0
  23. package/runtime/sdk/g2/Physics2D.ts +240 -30
  24. package/runtime/sdk/g2/Scene2D.ts +33 -1
  25. package/runtime/sdk/g2/Shape2D.ts +218 -22
  26. package/runtime/sdk/g2/Trigger2D.ts +42 -12
  27. package/runtime/sdk/g2/groups2d.ts +106 -0
  28. package/runtime/sdk/g2/loop.ts +15 -4
  29. package/runtime/sdk/gl/Camera.ts +41 -0
  30. package/runtime/sdk/gl/CameraPlace.ts +52 -0
  31. package/runtime/sdk/gl/CharacterController.ts +184 -55
  32. package/runtime/sdk/gl/Gearbox.ts +212 -0
  33. package/runtime/sdk/gl/Geometry.ts +70 -9
  34. package/runtime/sdk/gl/IK.ts +193 -174
  35. package/runtime/sdk/gl/Light.ts +64 -2
  36. package/runtime/sdk/gl/Lightmap.ts +179 -0
  37. package/runtime/sdk/gl/Material.ts +36 -0
  38. package/runtime/sdk/gl/Mesh.ts +6 -23
  39. package/runtime/sdk/gl/Model.ts +23 -8
  40. package/runtime/sdk/gl/Node.ts +350 -285
  41. package/runtime/sdk/gl/Physics.ts +222 -126
  42. package/runtime/sdk/gl/Scene.ts +175 -8
  43. package/runtime/sdk/gl/Shape.ts +255 -12
  44. package/runtime/sdk/gl/Trigger.ts +1 -6
  45. package/runtime/sdk/gl/Vehicle.ts +473 -0
  46. package/runtime/sdk/gl/Wheel.ts +240 -0
  47. package/runtime/sdk/gl/{AnimationClip.ts → animation/AnimationClip.ts} +37 -7
  48. package/runtime/sdk/gl/animation/Animator.ts +87 -0
  49. package/runtime/sdk/gl/animation/Layer.ts +29 -0
  50. package/runtime/sdk/gl/animation/Loop.ts +25 -0
  51. package/runtime/sdk/gl/animation/Playback.ts +43 -0
  52. package/runtime/sdk/gl/animation/core.ts +294 -0
  53. package/runtime/sdk/gl/scenarios.ts +291 -349
  54. package/runtime/sdk/inject.ts +186 -162
  55. package/runtime/sdk/runtime/app.ts +13 -0
  56. package/runtime/sdk/runtime/input.ts +169 -6
  57. package/runtime/sdk/scene/defineScene.ts +1227 -1016
  58. package/runtime/sdk/scene/gizmos.ts +148 -0
  59. package/runtime/sdk/scene/material.ts +188 -0
  60. package/runtime/sdk-types.json +1 -1
  61. package/runtime/sdk/gl/Animator.ts +0 -642
  62. package/runtime/sdk/gl/ModelAnimation.ts +0 -95
@@ -1,95 +0,0 @@
1
- // GLB skeletal animation as an aspect. Auto-attached by Model (a glb always has its clips), so you
2
- // reach it directly: model.anim.play('Run'). Clips come baked in the glb; play by name or index.
3
- // This is the BASE player (one clip at a time, Filament's Animator underneath). For crossfades,
4
- // blend spaces, layers and clips from other files attach the Animator aspect — it takes the skeleton
5
- // over while attached and this player is suspended (docs/animation-plan.md).
6
-
7
- import { Aspect } from "../core/Aspect"
8
- import { nodeRegistry } from "./Node"
9
- import { AnimationClip } from "./AnimationClip"
10
- import type { Model } from "./Model"
11
-
12
- let animatorRegistered = false
13
- const ensureAnimator = (): void => {
14
- if (animatorRegistered) return
15
- animatorRegistered = true
16
- _creator.setOnAnimationComplete((entityId, clipIndex) => nodeRegistry.get(entityId)?._onAnimationComplete(clipIndex) ?? true)
17
- }
18
-
19
- export class ModelAnimation extends Aspect<"anim", Model> {
20
- static readonly aspect = "anim"
21
-
22
- private _playing = false
23
- private _clip = 0
24
- private _speed = 1
25
- private _loop = false
26
- private _suspended = false
27
- private _clips?: AnimationClip[]
28
-
29
- onAttach(): void {
30
- this.node._animComplete = (clipIndex) => {
31
- if (clipIndex !== this._clip) return true
32
- if (!this._loop) { this._playing = false; this.node._emitAnim("completed", clipIndex) }
33
- else this.node._emitAnim("loopReached", clipIndex)
34
- return this._playing
35
- }
36
- }
37
-
38
- /** The clips baked into the glb, as AnimationClip objects (usable in an Animator's clip table —
39
- * e.g. share one model's baked clip with another model of the same rig). */
40
- get clips(): AnimationClip[] {
41
- if (this._clips) return this._clips
42
- const setId = typeof _creator.getGlbClipSet === "function" ? _creator.getGlbClipSet(this.node.id) : 0
43
- if (setId) this._clips = AnimationClip._ofSet(setId)
44
- else {
45
- // no embedded set (older / lite hosts, or a GLB without animations): name + duration only
46
- this._clips = ((_creator.getGlbAnimations(this.node.id) ?? []) as { name: string, duration: number }[])
47
- .map((c) => ({ name: c.name, duration: c.duration, trackCount: 0 }) as unknown as AnimationClip)
48
- }
49
- return this._clips
50
- }
51
-
52
- /** @internal — an Animator owns the skeleton while attached; this player goes quiet. */
53
- _suspend(on: boolean): void {
54
- this._suspended = on
55
- if (on && this._playing) { this._playing = false }
56
- }
57
- private _blocked(): boolean {
58
- if (!this._suspended) return false
59
- console.warn("model.anim is suspended while an Animator is attached — use model.animator")
60
- return true
61
- }
62
-
63
- get playing(): boolean { return this._playing }
64
- set playing(value: boolean) {
65
- if (this._blocked()) return
66
- this._playing = value
67
- _creator.setAnimation(this.node.id, value, this._clip, this._speed)
68
- }
69
-
70
- /** Play a clip by name or index. Chainable. */
71
- play(clip?: string | number, options: { loop?: boolean } = {}): this {
72
- if (this._blocked()) return this
73
- if (typeof clip === "number") this._clip = clip
74
- else if (typeof clip === "string") {
75
- const i = this.clips.findIndex((c) => c.name === clip)
76
- if (i >= 0) this._clip = i
77
- }
78
- if (options.loop !== undefined) this._loop = options.loop
79
- this.playing = true
80
- ensureAnimator()
81
- return this
82
- }
83
- stop(): this { this.playing = false; return this }
84
-
85
- get loop(): boolean { return this._loop }
86
- set loop(v: boolean) { this._loop = v }
87
- get speed(): number { return this._speed }
88
- set speed(v: number) {
89
- this._speed = v
90
- if (this._suspended) return
91
- _creator.setAnimation(this.node.id, this._playing, this._clip, v)
92
- }
93
- get time(): number { return _creator.getAnimationTime(this.node.id) }
94
- set time(v: number) { if (!this._blocked()) _creator.setAnimationTime(this.node.id, this._clip, v) }
95
- }