lecodes-cli 0.6.2 → 0.6.3
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/README.md +16 -3
- package/dist/index.js +1937 -132
- package/package.json +4 -1
- package/runtime/sdk/gl/Scene.ts +22 -0
- package/runtime/sdk/gl/touch.ts +14 -2
- package/runtime/sdk/inject.ts +1 -1
- package/runtime/sdk-types.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lecodes-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Clone, edit and push LeCodes projects from your machine.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,9 +20,11 @@
|
|
|
20
20
|
"node": ">=18"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
+
"icon": "bun scripts/make-icon.ts",
|
|
23
24
|
"vendor-runtime": "bun scripts/vendor-runtime.ts",
|
|
24
25
|
"sync-peers": "bun scripts/sync-peer-versions.ts",
|
|
25
26
|
"build": "bun scripts/vendor-runtime.ts && bun build src/index.ts --target=node --outfile dist/index.js --external @letary/chisel --external lecodes-renderer --external lecodes-design --banner=\"#!/usr/bin/env node\"",
|
|
27
|
+
"build:bin": "bun scripts/build-bin.ts",
|
|
26
28
|
"typecheck": "tsc --noEmit",
|
|
27
29
|
"dev": "bun run src/index.ts",
|
|
28
30
|
"prepublishOnly": "bun run sync-peers && bun run build"
|
|
@@ -45,6 +47,7 @@
|
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"lecodes-design": "workspace:*",
|
|
47
49
|
"lecodes-renderer": "^0.4.1",
|
|
50
|
+
"qrcode-terminal": "^0.12.0",
|
|
48
51
|
"sdk": "workspace:*"
|
|
49
52
|
}
|
|
50
53
|
}
|
package/runtime/sdk/gl/Scene.ts
CHANGED
|
@@ -195,3 +195,25 @@ export class ARScene<T extends ARMode = "default"> extends Scene {
|
|
|
195
195
|
super.close()
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
+
|
|
199
|
+
// --- VR ---
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* A 3D scene rendered in a VR headset (OpenXR — e.g. Meta Quest). The headset drives the camera:
|
|
203
|
+
* every frame both eyes are rendered from the tracked head pose, so `scene.camera` position/lookAt
|
|
204
|
+
* have no effect while the scene is open. The world origin is at floor level (stage space) —
|
|
205
|
+
* author content with the ground at y = 0 and the user standing at the origin.
|
|
206
|
+
*
|
|
207
|
+
* `open()` rejects on hosts without a VR runtime ("VR is not supported on this device").
|
|
208
|
+
*/
|
|
209
|
+
export class VRScene extends Scene {
|
|
210
|
+
override async open(): Promise<void> {
|
|
211
|
+
await new Promise<void>((res, rej) => _creator.launchVR(this._id, res, rej))
|
|
212
|
+
super.open()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
override close(): void {
|
|
216
|
+
_creator.stopVR()
|
|
217
|
+
super.close()
|
|
218
|
+
}
|
|
219
|
+
}
|
package/runtime/sdk/gl/touch.ts
CHANGED
|
@@ -5,12 +5,24 @@ import { ClickEvent, TouchStartEvent, type TrackHandler } from "../runtime/touch
|
|
|
5
5
|
import { nodeRegistry } from "./Node"
|
|
6
6
|
import { glState } from "./state"
|
|
7
7
|
|
|
8
|
+
// Hits inside a loaded model (GLB) land on sub-entities the user never created a Node for — walk up
|
|
9
|
+
// the transform hierarchy to the nearest entity someone actually holds (the model's Node).
|
|
10
|
+
const resolveHitNode = (entityId: number) => {
|
|
11
|
+
let node = nodeRegistry.get(entityId)
|
|
12
|
+
for (let id = entityId, i = 0; !node && i < 32; i++) {
|
|
13
|
+
id = _creator.getParent(id)
|
|
14
|
+
if (id === 0) break
|
|
15
|
+
node = nodeRegistry.get(id)
|
|
16
|
+
}
|
|
17
|
+
return node ?? null
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
const onTouchEnd = (pointerId: number, clientX: number, clientY: number, entityId: number): TrackHandler | null => {
|
|
9
21
|
const scene = glState.activeScene
|
|
10
22
|
if (!scene) return null
|
|
11
23
|
const ev = new ClickEvent<any>(clientX, clientY, pointerId)
|
|
12
24
|
if (entityId > 0) {
|
|
13
|
-
const node =
|
|
25
|
+
const node = resolveHitNode(entityId)
|
|
14
26
|
ev.target = node
|
|
15
27
|
if (node) node._dispatchEvent("click", ev)
|
|
16
28
|
} else {
|
|
@@ -25,7 +37,7 @@ const onTouchStart = (pointerId: number, clientX: number, clientY: number, entit
|
|
|
25
37
|
if (!scene) return null
|
|
26
38
|
const ev = new TouchStartEvent<any>(clientX, clientY, pointerId)
|
|
27
39
|
if (entityId > 0) {
|
|
28
|
-
const node =
|
|
40
|
+
const node = resolveHitNode(entityId)
|
|
29
41
|
ev.target = node
|
|
30
42
|
if (node) {
|
|
31
43
|
node._dispatchEvent("touchstart", ev)
|
package/runtime/sdk/inject.ts
CHANGED
|
@@ -79,7 +79,7 @@ export { easeIn, easeOut, easeInOut } from "./animate/easings"
|
|
|
79
79
|
export { QRScanner } from "./plugins/qr"
|
|
80
80
|
|
|
81
81
|
// ---- 3D engine (creator-gl) ----
|
|
82
|
-
export { Scene, ARScene } from "./gl/Scene"
|
|
82
|
+
export { Scene, ARScene, VRScene } from "./gl/Scene"
|
|
83
83
|
export { Node } from "./gl/Node"
|
|
84
84
|
export { Mesh } from "./gl/Mesh"
|
|
85
85
|
export { Model } from "./gl/Model"
|