lens-inspector 0.1.0 → 0.1.2

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # lens-inspector
2
2
 
3
- A browser-based scene graph inspector for Lens Studio. It shows you the full hierarchy of your scene while your effect runs, including objects that scripts create at runtime, so you can see what's actually happening instead of reconstructing state from log statements.
3
+ When you create objects from a Script at runtime (`instantiatePrefab`, `createSceneObject`), they aren't visible in the Scene Hierarchy. This means you can't know what components are attached, or where things ended up spatially, so you end up doing lots of print-debugging.
4
+
5
+ Lens Inspector fixes this by streaming the full live scene graph to a browser panel over WebSocket while the lens runs in editor. This captures all the objects that are invisible to the Scene Hierarchy such as: runtime-spawned prefabs, dynamically created SceneObjects, all their components (physics, scripts, audio, VFX, interactions, tracking), with transforms updating in real time.
4
6
 
5
7
  ![Live scene with node selected](media/02-selected.png)
6
8
 
@@ -8,6 +10,12 @@ A browser-based scene graph inspector for Lens Studio. It shows you the full hie
8
10
 
9
11
  You need [Node.js](https://nodejs.org/) installed (any recent version works).
10
12
 
13
+ ```bash
14
+ npx lens-inspector
15
+ ```
16
+
17
+ Or clone the repo if you want to modify things:
18
+
11
19
  ```bash
12
20
  git clone https://github.com/a-sumo/lens-inspector.git
13
21
  cd lens-inspector
@@ -21,7 +29,7 @@ The server starts and opens the viewer in your browser automatically. You'll see
21
29
 
22
30
  From there:
23
31
 
24
- 1. Copy `SceneInspector.ts` into your Lens Studio project's `Assets/` folder
32
+ 1. Download `SceneInspector.ts` from the running server at [localhost:8200/SceneInspector.ts](http://localhost:8200/SceneInspector.ts) and drop it into your Lens Studio project's `Assets/` folder
25
33
  2. Attach the SceneInspector component to any SceneObject in your scene
26
34
  3. In Lens Studio, go to **Project Settings > General** and enable **Experimental APIs** (required for `ws://localhost` connections)
27
35
  4. Hit Play in Lens Studio
@@ -32,19 +40,33 @@ Once Lens Studio connects, the welcome screen disappears and your scene tree app
32
40
 
33
41
  If you want to see it working right away, open the included `LSProject/` folder in Lens Studio. It has SceneInspector and a RuntimeSpawner script already set up. Hit Play, and blocks will start appearing in both Lens Studio and the browser viewer.
34
42
 
35
- https://github.com/a-sumo/lens-inspector/raw/main/media/demo.mp4
43
+ ![Demo](media/demo.gif)
36
44
 
37
45
  ## Two modes
38
46
 
39
- **Runtime**: A component inside your effect walks the full scene graph using the SceneObject API, serializes the hierarchy into JSON, and sends it over WebSocket to the browser. This captures everything, both the objects you placed in the editor and anything created by scripts at runtime.
47
+ **Runtime**: A Script component inside your lens walks the full scene graph using the SceneObject API, serializes the hierarchy into JSON, and sends it over WebSocket to the browser. This captures everything: both the objects you placed in the Scene Hierarchy and anything created by Scripts at runtime.
40
48
 
41
49
  ![Runtime-spawned objects appearing live](media/04-runtime.png)
42
50
 
43
- **Design-time**: When your effect isn't running, the viewer can fetch the static scene structure through Lens Studio's MCP server. This is useful for inspecting your hierarchy without entering preview mode.
51
+ **Design-time**: When your lens isn't running, the viewer can fetch the static scene structure through Lens Studio's MCP server. This is useful for inspecting your Scene Hierarchy without entering preview mode.
52
+
53
+ To use design-time mode:
54
+
55
+ 1. In Lens Studio, go to **AI Assistant > MCP > Configure Server** and set a port
56
+ 2. Click **Copy MCP Config** to get the server URL and token
57
+ 3. In the inspector viewer, paste the token into the MCP field in the top bar and click **Design-Time**
58
+
59
+ If your MCP server runs on a non-default port, pass it when starting the inspector:
60
+
61
+ ```bash
62
+ npx lens-inspector --mcp http://localhost:8733/mcp
63
+ ```
64
+
65
+ The MCP config from Lens Studio also works with AI coding assistants like Claude. Paste it into your assistant's MCP server config to let it read and modify your scene programmatically.
44
66
 
45
67
  ## The viewer
46
68
 
47
- The browser shows three synchronized panels. A collapsible tree that matches the scene hierarchy, where you can search and click to select nodes. A 2D spatial canvas with switchable projection planes (TOP/FRONT/SIDE) that plots object positions with pan and zoom, so you can see how things are laid out relative to each other. And a properties panel that shows transform data, component details, text content, and colors for whatever node you've selected.
69
+ The browser shows three synchronized panels. A collapsible tree that matches the Scene Hierarchy, where you can search and click to select nodes. A 2D spatial canvas with switchable projection planes (TOP/FRONT/SIDE) that plots object positions with pan and zoom, so you can see how things are laid out relative to each other. And an inspector panel that shows transform data, component details, text content, and colors for whatever node you've selected.
48
70
 
49
71
  ![Front view showing spatial layout](media/03-front.png)
50
72
 
@@ -59,7 +81,7 @@ node server.js # terminal 1
59
81
  node example.js # terminal 2
60
82
  ```
61
83
 
62
- The browser opens automatically. The example streams a scene with blocks, columns, and new objects spawning over time, so you can see how the tree, canvas, and properties panel respond to live changes.
84
+ The browser opens automatically. The example streams a scene with blocks, columns, and new SceneObjects spawning over time, so you can see how the tree, canvas, and inspector panel respond to live changes.
63
85
 
64
86
  ## Configuration
65
87
 
package/index.html CHANGED
@@ -219,7 +219,7 @@ body { background: var(--bg); color: var(--text); font-family: var(--font); heig
219
219
  <div class="step">
220
220
  <span class="step-num">2</span>
221
221
  <span class="step-text">
222
- In your Lens Studio project, add <code>SceneInspector.ts</code> to Assets and attach it to any object.
222
+ Download <a href="/SceneInspector.ts" style="color: var(--accent);">SceneInspector.ts</a>, add it to your Lens Studio project's Assets, and attach it to any object.
223
223
  Then go to <strong>Project Settings &gt; General</strong> and enable <strong>Experimental APIs</strong>.
224
224
  </span>
225
225
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lens-inspector",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Browser-based scene graph inspector for Lens Studio. See every object in your scene, live.",
5
5
  "type": "module",
6
6
  "bin": {
package/server.js CHANGED
@@ -81,6 +81,14 @@ const http = createServer(async (req, res) => {
81
81
  return;
82
82
  }
83
83
 
84
+ // Serve SceneInspector.ts for download
85
+ if (req.method === "GET" && req.url === "/SceneInspector.ts") {
86
+ const ts = readFileSync(join(__dirname, "SceneInspector.ts"));
87
+ res.writeHead(200, { "Content-Type": "text/plain", "Content-Disposition": "attachment; filename=SceneInspector.ts" });
88
+ res.end(ts);
89
+ return;
90
+ }
91
+
84
92
  // Health
85
93
  if (req.method === "GET" && req.url === "/health") {
86
94
  res.writeHead(200, { "Content-Type": "application/json" });