sceneview-mcp 4.1.2 → 4.3.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/README.md +24 -14
- package/dist/advanced-guides.js +62 -20
- package/dist/analyze-project.js +41 -13
- package/dist/android-docs.js +1 -2
- package/dist/artifact.js +24 -1
- package/dist/debug-issue.js +22 -13
- package/dist/discover.js +17 -3
- package/dist/extra-guides.js +47 -17
- package/dist/generate-model-runware.js +221 -0
- package/dist/generate-model.js +66 -13
- package/dist/generate-scene.js +26 -5
- package/dist/generated/llms-txt.js +1 -1
- package/dist/generated/symbols.js +1452 -40
- package/dist/generated/version.js +5 -5
- package/dist/guides.js +38 -18
- package/dist/http.js +1 -1
- package/dist/issues.js +1 -1
- package/dist/migrate-code.js +7 -7
- package/dist/migration.js +6 -6
- package/dist/platform-setup.js +37 -15
- package/dist/preview.js +2 -1
- package/dist/samples.js +112 -50
- package/dist/server.js +2 -2
- package/dist/spatial-answer-link.js +55 -0
- package/dist/tools/definitions.js +71 -3
- package/dist/tools/handler.js +64 -17
- package/dist/validator.js +2 -2
- package/dist/widgets.js +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -215,7 +215,7 @@ open-world rather than read-only.
|
|
|
215
215
|
|
|
216
216
|
**Prefer it local?** `npx -y sceneview-mcp` runs the exact same server over stdio. The local
|
|
217
217
|
route is the one that reads your project from disk (`analyze_project`) and the one that accepts
|
|
218
|
-
your own `SKETCHFAB_API_KEY` / `TRIPO_API_KEY`; the hosted connector, being shared and anonymous,
|
|
218
|
+
your own `SKETCHFAB_API_KEY` / `TRIPO_API_KEY` / `RUNWARE_API_KEY`; the hosted connector, being shared and anonymous,
|
|
219
219
|
cannot.
|
|
220
220
|
|
|
221
221
|
### Remote server (Streamable HTTP)
|
|
@@ -236,9 +236,9 @@ npx sceneview-mcp --http
|
|
|
236
236
|
| `GET /.well-known/openai-apps-challenge` | OpenAI domain verification — returns `OPENAI_APPS_CHALLENGE_TOKEN` as `text/plain`, `404` when unset |
|
|
237
237
|
| anything else | `404` |
|
|
238
238
|
|
|
239
|
-
Configuration: `PORT` (default `3333`), `HOST` (default `127.0.0.1` — set `HOST=0.0.0.0` to expose it, and put HTTPS in front), `OPENAI_APPS_CHALLENGE_TOKEN` (the value OpenAI gives you when you submit the domain). CORS allows any origin. The usual `SKETCHFAB_API_KEY` / `TRIPO_API_KEY` / `SCENEVIEW_TELEMETRY=0` knobs apply.
|
|
239
|
+
Configuration: `PORT` (default `3333`), `HOST` (default `127.0.0.1` — set `HOST=0.0.0.0` to expose it, and put HTTPS in front), `OPENAI_APPS_CHALLENGE_TOKEN` (the value OpenAI gives you when you submit the domain). CORS allows any origin. The usual `SKETCHFAB_API_KEY` / `TRIPO_API_KEY` / `RUNWARE_API_KEY` / `SCENEVIEW_TELEMETRY=0` knobs apply.
|
|
240
240
|
|
|
241
|
-
**Everything is free, but not everything is remote.** Three generation tools (`render_3d_preview`, `create_3d_artifact`, `generate_scene`) need your own third-party credentials, which a shared anonymous endpoint cannot hold, so the remote surface omits them and refuses those names at call time with a clear `isError` message pointing at the local `npx sceneview-mcp` path. stdio lists and runs all
|
|
241
|
+
**Everything is free, but not everything is remote.** Three generation tools (`render_3d_preview`, `create_3d_artifact`, `generate_scene`) need your own third-party credentials, which a shared anonymous endpoint cannot hold, so the remote surface omits them and refuses those names at call time with a clear `isError` message pointing at the local `npx sceneview-mcp` path. stdio lists and runs all 33.
|
|
242
242
|
|
|
243
243
|
**Inline 3D viewer.** `view_3d_model` returns `structuredContent` plus `_meta.ui.resourceUri = ui://widget/3d-viewer.html`; the widget (SceneView.js + Filament.js, served by `resources/read` with the `text/html;profile=mcp-app` mime type and its `_meta.ui.csp`) renders the model inline in ChatGPT and any MCP Apps host.
|
|
244
244
|
|
|
@@ -318,7 +318,7 @@ Six tools carry most of what assistants actually do with SceneView. If you read
|
|
|
318
318
|
| Tool | What it does |
|
|
319
319
|
|---|---|
|
|
320
320
|
| `search_models` | Searches Sketchfab for free 3D models (BYOK — set `SKETCHFAB_API_KEY`) |
|
|
321
|
-
| `generate_3d_model` | Generates a brand-new GLB from a text prompt or image via Tripo AI (BYOK — set `TRIPO_API_KEY`) |
|
|
321
|
+
| `generate_3d_model` | Generates a brand-new GLB from a text prompt or image via TRELLIS.2 on Runware or Tripo AI (BYOK — set `RUNWARE_API_KEY` or `TRIPO_API_KEY`) |
|
|
322
322
|
| `analyze_project` | Scans a local SceneView project on disk — detects platform, extracts version, flags outdated deps and known anti-patterns |
|
|
323
323
|
| `search_android_docs` | Searches Google's stock Android docs knowledge base (needs the `android` CLI on PATH) |
|
|
324
324
|
| `fetch_android_doc` | Fetches a full Android docs entry by its `kb://...` URI (needs the `android` CLI on PATH) |
|
|
@@ -327,6 +327,7 @@ Six tools carry most of what assistants actually do with SceneView. If you read
|
|
|
327
327
|
|
|
328
328
|
| Tool | What it does |
|
|
329
329
|
|---|---|
|
|
330
|
+
| `show_in_space` | Builds one link to show a box at real scale in the SceneView Android app, or its size on the web page with an app offer. Supply width, height and depth in cm, a label, optional floor/table placement and user/estimated dimension source. No fit detection or accuracy claim. Available locally and remotely. |
|
|
330
331
|
| `view_3d_model` | Renders a public GLB / glTF URL in an interactive SceneView.js + Filament.js viewer inline in ChatGPT and any MCP Apps host (orbit, auto-rotate). For an https model it adds an "Open in AR on your phone" action (an `ar.sceneview.dev/open` link to the 3D AR Model Viewer app, with a QR code on desktop). Returns `structuredContent` + `_meta.ui.resourceUri` |
|
|
331
332
|
|
|
332
333
|
### 5 resources
|
|
@@ -367,19 +368,28 @@ Call it like `search_models({ query: "red sports car", category: "cars-vehicles"
|
|
|
367
368
|
|
|
368
369
|
## `generate_3d_model` — create brand-new 3D assets from the AI
|
|
369
370
|
|
|
370
|
-
When no existing model fits, `generate_3d_model` closes the other half of the asset loop: it generates a fresh GLB from a **text prompt** (text→3D) or a **source image** (image→3D)
|
|
371
|
+
When no existing model fits, `generate_3d_model` closes the other half of the asset loop: it generates a fresh GLB from a **text prompt** (text→3D) or a **source image** (image→3D), then returns a direct GLB download URL plus license/attribution metadata — ready for `rememberModelInstance(modelLoader, ...)` and AR placement.
|
|
371
372
|
|
|
372
|
-
Two
|
|
373
|
+
Two providers, both bring-your-own-key:
|
|
374
|
+
|
|
375
|
+
| `provider` | Key | Model | Approx. cost per model |
|
|
376
|
+
|---|---|---|---|
|
|
377
|
+
| `"trellis"` | `RUNWARE_API_KEY` ([my.runware.ai/keys](https://my.runware.ai/keys)) | Microsoft [TRELLIS.2](https://github.com/microsoft/TRELLIS.2) (MIT weights) on [Runware](https://runware.ai) — `fast` = 1024³, `hd` = 1536³ | ~$0.01–0.03, billed by compute time (November 2026) |
|
|
378
|
+
| `"tripo"` | `TRIPO_API_KEY` ([platform.tripo3d.ai/api-keys](https://platform.tripo3d.ai/api-keys)) | [Tripo AI](https://www.tripo3d.ai) P1 / H3.1 | ~$0.10–0.41 (July 2026) |
|
|
379
|
+
|
|
380
|
+
Without `provider`, the tool uses Tripo when `TRIPO_API_KEY` is set, otherwise TRELLIS.2 when `RUNWARE_API_KEY` is set. TRELLIS.2 is image→3D only, so a text prompt first renders a single-object concept image with FLUX.1 [schnell] on the same Runware key (the result links it, and reports the total cost).
|
|
381
|
+
|
|
382
|
+
Tripo's two quality tiers:
|
|
373
383
|
|
|
374
384
|
| `quality` | Tripo model | Topology | Latency | Approx. cost (July 2026) |
|
|
375
385
|
|---|---|---|---|---|
|
|
376
386
|
| `"fast"` (default) | P1 (`P1-20260311`) | low-poly, AR-ready | ~25–30 s | ~$0.10–0.25 of your credits |
|
|
377
387
|
| `"hd"` | H3.1 (`v3.1-20260211`) | quad mesh, detailed geometry + textures | up to ~100 s | ~$0.41 of your credits |
|
|
378
388
|
|
|
379
|
-
**Bring your own key (BYOK).** Exactly like `search_models`: SceneView never proxies the request or holds your key — generations are billed to **your** Tripo account. To set it up:
|
|
389
|
+
**Bring your own key (BYOK).** Exactly like `search_models`: SceneView never proxies the request or holds your key — generations are billed to **your** Runware or Tripo account. To set it up:
|
|
380
390
|
|
|
381
|
-
1. Create an API key at [platform.tripo3d.ai/api-keys](https://platform.tripo3d.ai/api-keys) (new accounts get free trial credits)
|
|
382
|
-
2. Set `TRIPO_API_KEY` in your MCP client config:
|
|
391
|
+
1. Create an API key at [my.runware.ai/keys](https://my.runware.ai/keys) (TRELLIS.2) or [platform.tripo3d.ai/api-keys](https://platform.tripo3d.ai/api-keys) (Tripo, new accounts get free trial credits)
|
|
392
|
+
2. Set `RUNWARE_API_KEY` or `TRIPO_API_KEY` in your MCP client config:
|
|
383
393
|
|
|
384
394
|
```json
|
|
385
395
|
{
|
|
@@ -387,15 +397,15 @@ Two quality tiers:
|
|
|
387
397
|
"sceneview": {
|
|
388
398
|
"command": "npx",
|
|
389
399
|
"args": ["-y", "sceneview-mcp"],
|
|
390
|
-
"env": { "
|
|
400
|
+
"env": { "RUNWARE_API_KEY": "YOUR_KEY_HERE" }
|
|
391
401
|
}
|
|
392
402
|
}
|
|
393
403
|
}
|
|
394
404
|
```
|
|
395
405
|
|
|
396
|
-
Call it like `generate_3d_model({ prompt: "a low-poly cactus in a striped pot" })` or `generate_3d_model({ imageUrl: "https://example.com/chair.jpg", quality: "hd" })`. Provide exactly one of `prompt` / `imageUrl`.
|
|
406
|
+
Call it like `generate_3d_model({ prompt: "a low-poly cactus in a striped pot" })` or `generate_3d_model({ imageUrl: "https://example.com/chair.jpg", quality: "hd", provider: "trellis" })`. Provide exactly one of `prompt` / `imageUrl`.
|
|
397
407
|
|
|
398
|
-
**⚠️ The GLB download URL
|
|
408
|
+
**⚠️ The GLB download URL is temporary (Tripo: ~5 minutes)** — download the file immediately and self-host it (e.g. copy it into your app's `assets/models/`). The tool result repeats this warning. Missing key, task failures, rate limits, and poll timeouts (2 min fast / 4 min hd cap) all return clear, actionable messages instead of hanging or crashing.
|
|
399
409
|
|
|
400
410
|
## `analyze_project` — local project scan
|
|
401
411
|
|
|
@@ -490,7 +500,7 @@ Install Node.js from [nodejs.org](https://nodejs.org/) (LTS recommended). npm an
|
|
|
490
500
|
|
|
491
501
|
### Firewall or proxy issues
|
|
492
502
|
|
|
493
|
-
The only network calls are to the GitHub API (for known issues), Sketchfab (when `SKETCHFAB_API_KEY` is set), Tripo AI (when `TRIPO_API_KEY` is set and `generate_3d_model` is called), and the anonymous telemetry endpoint (off with `SCENEVIEW_TELEMETRY=0`). Everything else works offline.
|
|
503
|
+
The only network calls are to the GitHub API (for known issues), Sketchfab (when `SKETCHFAB_API_KEY` is set), Tripo AI or Runware (when `TRIPO_API_KEY` / `RUNWARE_API_KEY` is set and `generate_3d_model` is called), and the anonymous telemetry endpoint (off with `SCENEVIEW_TELEMETRY=0`). Everything else works offline.
|
|
494
504
|
|
|
495
505
|
```json
|
|
496
506
|
{
|
|
@@ -510,7 +520,7 @@ The only network calls are to the GitHub API (for known issues), Sketchfab (when
|
|
|
510
520
|
|
|
511
521
|
## Sponsor
|
|
512
522
|
|
|
513
|
-
If sceneview-mcp saves you time,
|
|
523
|
+
If sceneview-mcp saves you time, you can [sponsor SceneView on Open Collective](https://opencollective.com/sceneview), or through [GitHub Sponsors](https://github.com/sponsors/sceneview). Every tool is free with or without a contribution, and a sponsorship changes nothing in what the server returns. [How sponsorship works](https://sceneview.github.io/sponsors.html).
|
|
514
524
|
|
|
515
525
|
---
|
|
516
526
|
|
package/dist/advanced-guides.js
CHANGED
|
@@ -224,23 +224,39 @@ fun SmoothFollowDemo() {
|
|
|
224
224
|
## 5. AR Animation — Animated Model on Anchor
|
|
225
225
|
|
|
226
226
|
\`\`\`kotlin
|
|
227
|
+
import com.google.ar.core.Anchor
|
|
228
|
+
import com.google.ar.core.Frame
|
|
229
|
+
import com.google.ar.core.Plane
|
|
230
|
+
import io.github.sceneview.ar.arcore.createAnchorOrNull
|
|
231
|
+
import io.github.sceneview.rememberOnGestureListener
|
|
232
|
+
// …plus androidx.compose.runtime.* and the io.github.sceneview entry points (ARSceneView, rememberEngine, …)
|
|
233
|
+
|
|
227
234
|
@Composable
|
|
228
235
|
fun ARAnimatedModel() {
|
|
229
236
|
val engine = rememberEngine()
|
|
230
237
|
val modelLoader = rememberModelLoader(engine)
|
|
231
238
|
val modelInstance = rememberModelInstance(modelLoader, "models/dancing_character.glb")
|
|
232
239
|
var anchor by remember { mutableStateOf<Anchor?>(null) }
|
|
240
|
+
var latestFrame by remember { mutableStateOf<Frame?>(null) }
|
|
233
241
|
|
|
234
242
|
ARSceneView(
|
|
235
243
|
engine = engine,
|
|
236
244
|
modelLoader = modelLoader,
|
|
237
245
|
planeRenderer = true,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
246
|
+
onSessionUpdated = { _, frame -> latestFrame = frame },
|
|
247
|
+
// A confirmed single tap, never a raw ACTION_UP: the end of a drag or a pinch on the
|
|
248
|
+
// placed model must not move it. Leaving onTouchEvent unset keeps the model's gestures.
|
|
249
|
+
onGestureListener = rememberOnGestureListener(
|
|
250
|
+
onSingleTapConfirmed = { event, node ->
|
|
251
|
+
if (node == null) { // empty space, not the placed model
|
|
252
|
+
latestFrame?.hitTest(event)
|
|
253
|
+
?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }
|
|
254
|
+
?.createAnchorOrNull()
|
|
255
|
+
// Replacing the state key disposes the old AnchorNode, which detaches its anchor.
|
|
256
|
+
?.let { anchor = it }
|
|
257
|
+
}
|
|
241
258
|
}
|
|
242
|
-
|
|
243
|
-
}
|
|
259
|
+
)
|
|
244
260
|
) {
|
|
245
261
|
anchor?.let { a ->
|
|
246
262
|
AnchorNode(anchor = a) {
|
|
@@ -352,24 +368,39 @@ fun CustomGestureScreen() {
|
|
|
352
368
|
The most common AR gesture — tap a detected plane to place a model.
|
|
353
369
|
|
|
354
370
|
\`\`\`kotlin
|
|
371
|
+
import com.google.ar.core.Anchor
|
|
372
|
+
import com.google.ar.core.Frame
|
|
373
|
+
import com.google.ar.core.Plane
|
|
374
|
+
import io.github.sceneview.ar.arcore.createAnchorOrNull
|
|
375
|
+
import io.github.sceneview.rememberOnGestureListener
|
|
376
|
+
// …plus androidx.compose.runtime.* and the io.github.sceneview entry points (ARSceneView, rememberEngine, …)
|
|
377
|
+
|
|
355
378
|
@Composable
|
|
356
379
|
fun TapToPlaceAR() {
|
|
357
380
|
val engine = rememberEngine()
|
|
358
381
|
val modelLoader = rememberModelLoader(engine)
|
|
359
382
|
val modelInstance = rememberModelInstance(modelLoader, "models/furniture.glb")
|
|
360
383
|
var anchor by remember { mutableStateOf<Anchor?>(null) }
|
|
384
|
+
var latestFrame by remember { mutableStateOf<Frame?>(null) }
|
|
361
385
|
|
|
362
386
|
ARSceneView(
|
|
363
387
|
engine = engine,
|
|
364
388
|
modelLoader = modelLoader,
|
|
365
389
|
planeRenderer = true,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
390
|
+
onSessionUpdated = { _, frame -> latestFrame = frame },
|
|
391
|
+
// A confirmed single tap, never a raw ACTION_UP: the end of a drag or a pinch on the
|
|
392
|
+
// placed model must not move it. Leaving onTouchEvent unset keeps the model's gestures.
|
|
393
|
+
onGestureListener = rememberOnGestureListener(
|
|
394
|
+
onSingleTapConfirmed = { event, node ->
|
|
395
|
+
if (node == null) { // empty space, not the placed model
|
|
396
|
+
latestFrame?.hitTest(event)
|
|
397
|
+
?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }
|
|
398
|
+
?.createAnchorOrNull()
|
|
399
|
+
// Replacing the state key disposes the old AnchorNode, which detaches its anchor.
|
|
400
|
+
?.let { anchor = it }
|
|
401
|
+
}
|
|
370
402
|
}
|
|
371
|
-
|
|
372
|
-
}
|
|
403
|
+
)
|
|
373
404
|
) {
|
|
374
405
|
anchor?.let { a ->
|
|
375
406
|
AnchorNode(anchor = a) {
|
|
@@ -478,7 +509,8 @@ fun MultiModelSelectionScreen() {
|
|
|
478
509
|
scaleToUnits = 0.5f,
|
|
479
510
|
position = Position(-1f, 0f, 0f),
|
|
480
511
|
isEditable = true,
|
|
481
|
-
|
|
512
|
+
// Per-node tap: Node.onSingleTapConfirmed is (MotionEvent) -> Boolean
|
|
513
|
+
apply = { onSingleTapConfirmed = { selectedModel = "chair"; true } }
|
|
482
514
|
)
|
|
483
515
|
}
|
|
484
516
|
table?.let { instance ->
|
|
@@ -487,7 +519,7 @@ fun MultiModelSelectionScreen() {
|
|
|
487
519
|
scaleToUnits = 0.5f,
|
|
488
520
|
position = Position(1f, 0f, 0f),
|
|
489
521
|
isEditable = true,
|
|
490
|
-
|
|
522
|
+
apply = { onSingleTapConfirmed = { selectedModel = "table"; true } }
|
|
491
523
|
)
|
|
492
524
|
}
|
|
493
525
|
}
|
|
@@ -529,10 +561,10 @@ fun SurfaceCursorAR() {
|
|
|
529
561
|
|
|
530
562
|
1. **\`isEditable = true\`** — one-liner for pinch/drag/tap on any ModelNode.
|
|
531
563
|
2. **\`onTouchEvent\`** — full MotionEvent access for custom gesture logic.
|
|
532
|
-
3. **AR tap-to-place** —
|
|
564
|
+
3. **AR tap-to-place** — in \`onGestureListener = rememberOnGestureListener(onSingleTapConfirmed = { event, node -> if (node == null) … })\`, hit-test the latest ARCore \`Frame\` (from \`onSessionUpdated\`) and call \`createAnchorOrNull()\` on the in-polygon plane hit. Never place on a raw \`ACTION_UP\` in \`onTouchEvent\`: it also fires at the end of every drag and pinch, and returning \`true\` there swallows the editable model's gestures. Swapping the \`anchor\` state disposes the old \`AnchorNode\`, which detaches its anchor.
|
|
533
565
|
4. **Custom rotation/scale** — track touch deltas or use \`ScaleGestureDetector\`.
|
|
534
566
|
5. **HitResultNode** — AR surface cursor that follows the center of the screen.
|
|
535
|
-
6. **Multi-model** —
|
|
567
|
+
6. **Multi-model** — set \`onSingleTapConfirmed\` per ModelNode (in \`apply\`) for selection, or use \`rememberOnGestureListener(onSingleTapConfirmed = { e, node -> })\` on the scene.
|
|
536
568
|
`;
|
|
537
569
|
// ─── Performance Tips ────────────────────────────────────────────────────────
|
|
538
570
|
export const PERFORMANCE_TIPS = `# SceneView Performance Optimization Guide
|
|
@@ -735,7 +767,11 @@ LightNode(
|
|
|
735
767
|
)
|
|
736
768
|
|
|
737
769
|
// Use small HDR environments
|
|
738
|
-
val
|
|
770
|
+
val environmentLoader = rememberEnvironmentLoader(engine)
|
|
771
|
+
val environment = rememberEnvironment(environmentLoader) {
|
|
772
|
+
environmentLoader.createHDREnvironment("environments/sky_2k.hdr")
|
|
773
|
+
?: createEnvironment(environmentLoader)
|
|
774
|
+
}
|
|
739
775
|
// NOT: sky_4k.hdr or sky_8k.hdr (wastes GPU memory on mobile)
|
|
740
776
|
\`\`\`
|
|
741
777
|
|
|
@@ -747,11 +783,17 @@ val environment = rememberEnvironment(engine, "environments/sky_2k.hdr")
|
|
|
747
783
|
## 6. Post-Processing
|
|
748
784
|
|
|
749
785
|
\`\`\`kotlin
|
|
750
|
-
//
|
|
786
|
+
// Lighter preset: shadows, SSAO and bloom off, dynamic resolution on
|
|
751
787
|
SceneView(
|
|
752
788
|
engine = engine,
|
|
753
|
-
|
|
754
|
-
) {
|
|
789
|
+
renderQuality = RenderQuality.Performance
|
|
790
|
+
) { /* ... */ }
|
|
791
|
+
|
|
792
|
+
// Or disable post-processing entirely on the Filament View (no bloom, SSAO, tone mapping, FXAA)
|
|
793
|
+
val view = rememberView(engine) {
|
|
794
|
+
createView(engine).apply { isPostProcessingEnabled = false }
|
|
795
|
+
}
|
|
796
|
+
SceneView(engine = engine, view = view) {
|
|
755
797
|
// Simpler rendering, better FPS
|
|
756
798
|
}
|
|
757
799
|
\`\`\`
|
|
@@ -802,5 +844,5 @@ For detailed GPU profiling:
|
|
|
802
844
|
4. **Frustum culling** — break scenes into multiple nodes for automatic culling.
|
|
803
845
|
5. **Instancing** — reuse the same \`modelInstance\` for repeated objects.
|
|
804
846
|
6. **Profile** — use Systrace or AGI to find real bottlenecks, don't guess.
|
|
805
|
-
7. **Post-processing** — disable what you don't need (\`
|
|
847
|
+
7. **Post-processing** — disable what you don't need (\`renderQuality = RenderQuality.Performance\`, or \`view.isPostProcessingEnabled = false\`).
|
|
806
848
|
`;
|
package/dist/analyze-project.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* analyze-project — local filesystem scan of a SceneView project.
|
|
3
3
|
*
|
|
4
4
|
* Because the SceneView MCP server runs on the user's machine, we can read
|
|
5
|
-
* their project files directly: detect
|
|
5
|
+
* their project files directly: detect Android, Apple, Web, Flutter or React Native,
|
|
6
6
|
* extract the SceneView dependency version, compare against the latest known
|
|
7
7
|
* release, and scan source files for well-known anti-patterns (threading
|
|
8
8
|
* violations, LightNode trailing-lambda bug, deprecated 2.x APIs, …).
|
|
@@ -31,6 +31,7 @@ import { LATEST_SCENEVIEW_RELEASE } from "./generated/version.js";
|
|
|
31
31
|
* LLM that "4.0.0" was current even when the real SDK was at 4.0.9.
|
|
32
32
|
*/
|
|
33
33
|
export const LATEST_SCENEVIEW_VERSION = LATEST_SCENEVIEW_RELEASE;
|
|
34
|
+
const LAST_RETIRED_PLATFORM_VERSION = "4.68.0";
|
|
34
35
|
/** Hard cap on the number of source files inspected per call. */
|
|
35
36
|
export const MAX_FILES_SCANNED = 30;
|
|
36
37
|
/** Hard cap on total bytes read across all source files per call (500 KB). */
|
|
@@ -221,13 +222,13 @@ function extractSwiftVersion(contents) {
|
|
|
221
222
|
return branchOrVersion[1];
|
|
222
223
|
return null;
|
|
223
224
|
}
|
|
224
|
-
/** Extract
|
|
225
|
-
function extractNpmVersion(contents) {
|
|
225
|
+
/** Extract a supported dependency version from a `package.json`. */
|
|
226
|
+
function extractNpmVersion(contents, packageNames = ["sceneview-web", "@sceneview/sceneview-web"]) {
|
|
226
227
|
try {
|
|
227
228
|
const pkg = JSON.parse(contents);
|
|
228
229
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
229
230
|
for (const [name, spec] of Object.entries(deps)) {
|
|
230
|
-
if (name
|
|
231
|
+
if (packageNames.includes(name)) {
|
|
231
232
|
// Strip leading ^ / ~ / >= etc.
|
|
232
233
|
const cleaned = spec.replace(/^[^\d]*/, "");
|
|
233
234
|
const match = cleaned.match(/\d+\.\d+\.\d+(?:-[\w.]+)?/);
|
|
@@ -242,6 +243,27 @@ function extractNpmVersion(contents) {
|
|
|
242
243
|
return null;
|
|
243
244
|
}
|
|
244
245
|
async function detectProject(rootDir) {
|
|
246
|
+
// Detect bridges before their native host projects so their package release
|
|
247
|
+
// remains independent of the maintained Android SDK.
|
|
248
|
+
const pubspec = await tryRead(rootDir, "pubspec.yaml");
|
|
249
|
+
const flutterDependency = pubspec?.contents.match(/^([ \t]+)flutter_sceneview:[ \t]*([^\n]*)(?:\n((?:\1[ \t]+[^\n]*(?:\n|$))*))?/m);
|
|
250
|
+
if (pubspec && flutterDependency) {
|
|
251
|
+
const inline = flutterDependency[2].match(/^["']?[\^~>= \t]*(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
|
|
252
|
+
const nested = flutterDependency[3]?.match(/\b(?:ref|version):[ \t]*["']?v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
|
|
253
|
+
return {
|
|
254
|
+
projectType: "flutter",
|
|
255
|
+
sceneViewVersion: inline?.[1] ?? nested?.[1] ?? null,
|
|
256
|
+
sourceFile: pubspec.path,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const packageJson = await tryRead(rootDir, "package.json");
|
|
260
|
+
if (packageJson && /"@sceneview-sdk\/react-native"\s*:/.test(packageJson.contents)) {
|
|
261
|
+
return {
|
|
262
|
+
projectType: "react-native",
|
|
263
|
+
sceneViewVersion: extractNpmVersion(packageJson.contents, ["@sceneview-sdk/react-native"]),
|
|
264
|
+
sourceFile: packageJson.path,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
245
267
|
// Android: build.gradle or build.gradle.kts anywhere reachable from root.
|
|
246
268
|
// We first check the root for speed, then one level down for typical module layouts.
|
|
247
269
|
const androidCandidates = [
|
|
@@ -273,7 +295,6 @@ async function detectProject(rootDir) {
|
|
|
273
295
|
};
|
|
274
296
|
}
|
|
275
297
|
// Web: package.json referencing sceneview-web.
|
|
276
|
-
const packageJson = await tryRead(rootDir, "package.json");
|
|
277
298
|
if (packageJson && /"(?:@sceneview\/)?sceneview-web"/.test(packageJson.contents)) {
|
|
278
299
|
return {
|
|
279
300
|
projectType: "web",
|
|
@@ -285,11 +306,11 @@ async function detectProject(rootDir) {
|
|
|
285
306
|
}
|
|
286
307
|
// ─── Semver comparison (simple X.Y.Z) ────────────────────────────────────────
|
|
287
308
|
/**
|
|
288
|
-
* Returns `true` when `version` is strictly older than
|
|
309
|
+
* Returns `true` when `version` is strictly older than the platform's last release.
|
|
289
310
|
* Falls back to `false` (don't flag) if either side fails to parse cleanly —
|
|
290
311
|
* we'd rather underreport than harass a user with a pre-release build.
|
|
291
312
|
*/
|
|
292
|
-
function isVersionOutdated(version) {
|
|
313
|
+
function isVersionOutdated(version, latestVersion) {
|
|
293
314
|
if (!version)
|
|
294
315
|
return false;
|
|
295
316
|
const parse = (v) => {
|
|
@@ -299,7 +320,7 @@ function isVersionOutdated(version) {
|
|
|
299
320
|
return [parseInt(m[1], 10), parseInt(m[2], 10), parseInt(m[3], 10)];
|
|
300
321
|
};
|
|
301
322
|
const a = parse(version);
|
|
302
|
-
const b = parse(
|
|
323
|
+
const b = parse(latestVersion);
|
|
303
324
|
if (!a || !b)
|
|
304
325
|
return false;
|
|
305
326
|
for (let i = 0; i < 3; i++) {
|
|
@@ -358,13 +379,16 @@ export async function analyzeProject(input = {}) {
|
|
|
358
379
|
const detection = await detectProject(scannedPath);
|
|
359
380
|
result.projectType = detection.projectType;
|
|
360
381
|
result.sceneViewVersion = detection.sceneViewVersion;
|
|
361
|
-
|
|
382
|
+
const retired = ["ios", "flutter", "react-native"].includes(detection.projectType);
|
|
383
|
+
result.latestVersion = retired ? LAST_RETIRED_PLATFORM_VERSION : LATEST_SCENEVIEW_VERSION;
|
|
384
|
+
result.isOutdated = isVersionOutdated(detection.sceneViewVersion, result.latestVersion);
|
|
362
385
|
if (detection.projectType === "unknown") {
|
|
363
386
|
result.warnings.push({
|
|
364
387
|
file: scannedPath,
|
|
365
388
|
type: "scan/no-sceneview-dependency",
|
|
366
389
|
message: "No SceneView dependency was detected. Looked for `io.github.sceneview:sceneview` in " +
|
|
367
|
-
"Gradle files, `SceneViewSwift` in `Package.swift`,
|
|
390
|
+
"Gradle files, `SceneViewSwift` in `Package.swift`, `flutter_sceneview` in `pubspec.yaml`, " +
|
|
391
|
+
"and `sceneview-web` or `@sceneview-sdk/react-native` in `package.json`.",
|
|
368
392
|
});
|
|
369
393
|
}
|
|
370
394
|
else if (!detection.sceneViewVersion) {
|
|
@@ -379,9 +403,13 @@ export async function analyzeProject(input = {}) {
|
|
|
379
403
|
if (result.isOutdated && detection.sceneViewVersion) {
|
|
380
404
|
result.suggestions.push({
|
|
381
405
|
type: "suggestion/upgrade-sceneview",
|
|
382
|
-
message:
|
|
383
|
-
|
|
384
|
-
|
|
406
|
+
message: retired
|
|
407
|
+
? `You are on SceneView ${detection.sceneViewVersion}. The last release for this ` +
|
|
408
|
+
`platform is ${result.latestVersion} (end of life; no new releases). ` +
|
|
409
|
+
"Published versions remain available for existing projects."
|
|
410
|
+
: `You are on SceneView ${detection.sceneViewVersion}. The latest known release is ` +
|
|
411
|
+
`${result.latestVersion}. Consider upgrading — run \`get_migration_guide\` for ` +
|
|
412
|
+
"the 2.x → 3.x migration notes, or `migrate_code` for automatic Kotlin rewrites.",
|
|
385
413
|
});
|
|
386
414
|
}
|
|
387
415
|
// Step 2: anti-pattern scan (only if we have a known project type).
|
package/dist/android-docs.js
CHANGED
|
@@ -92,8 +92,7 @@ function cliMissingError() {
|
|
|
92
92
|
"`android docs` is an optional runtime dependency — `sceneview-mcp` works fine without it,",
|
|
93
93
|
"but `search_android_docs` / `fetch_android_doc` cannot run until the CLI is on PATH.",
|
|
94
94
|
"",
|
|
95
|
-
`Install it from ${INSTALL_URL}
|
|
96
|
-
"from a SceneView checkout), then retry.",
|
|
95
|
+
`Install it from ${INSTALL_URL}, then retry.`,
|
|
97
96
|
].join("\n"),
|
|
98
97
|
};
|
|
99
98
|
}
|
package/dist/artifact.js
CHANGED
|
@@ -16,7 +16,14 @@ import { FILAMENT_WEB_NPM_VERSION } from "./generated/version.js";
|
|
|
16
16
|
// The npm `filament` pin from gradle/libs.versions.toml (`filamentWeb`),
|
|
17
17
|
// snapshotted at build time — never a hand-copied version (#3173).
|
|
18
18
|
const FILAMENT_CDN = `https://cdn.jsdelivr.net/npm/filament@${FILAMENT_WEB_NPM_VERSION}/filament.js`;
|
|
19
|
-
|
|
19
|
+
// Motorcycle Helmet by sayedgamal655, CC-BY 4.0, served from the SceneView website.
|
|
20
|
+
// Its licence needs the credit line below on any page that shows it (#4951).
|
|
21
|
+
const DEFAULT_MODEL = "https://sceneview.github.io/models/platforms/moto_helmet_v2.glb";
|
|
22
|
+
const DEFAULT_MODEL_CREDIT = `<div style="position:absolute;bottom:26px;right:12px;font-size:11px;color:#888;font-family:system-ui,sans-serif;z-index:10"><a href="https://sketchfab.com/3d-models/moto-helmet-6c75ac1b13a047bd86742f37ce25adac" target="_blank" rel="noopener" style="color:inherit">Motorcycle Helmet</a> by sayedgamal655, <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener" style="color:inherit">CC BY 4.0</a></div>`;
|
|
23
|
+
/** The credit line a page needs when it shows the default model, or nothing. */
|
|
24
|
+
function modelCredit(model) {
|
|
25
|
+
return model === DEFAULT_MODEL ? DEFAULT_MODEL_CREDIT : "";
|
|
26
|
+
}
|
|
20
27
|
const DEFAULT_COLORS = [
|
|
21
28
|
"#4285F4",
|
|
22
29
|
"#EA4335",
|
|
@@ -170,6 +177,19 @@ Filament.init(['${modelUrl}'], function() {
|
|
|
170
177
|
asset.loadResources();
|
|
171
178
|
scene.addEntity(asset.getRoot());
|
|
172
179
|
scene.addEntities(asset.getRenderableEntities());
|
|
180
|
+
|
|
181
|
+
// Centre the model on the orbit target and scale its longest side to 2 units,
|
|
182
|
+
// so a model authored in metres, centimetres or anything else fills the frame.
|
|
183
|
+
var box = asset.getBoundingBox();
|
|
184
|
+
var size = Math.max(box.max[0] - box.min[0], box.max[1] - box.min[1], box.max[2] - box.min[2]);
|
|
185
|
+
if (size > 0 && isFinite(size)) {
|
|
186
|
+
var k = 2 / size;
|
|
187
|
+
var tcm = engine.getTransformManager();
|
|
188
|
+
var rootInst = tcm.getInstance(asset.getRoot());
|
|
189
|
+
tcm.setTransform(rootInst, [k, 0, 0, 0, 0, k, 0, 0, 0, 0, k, 0,
|
|
190
|
+
-k * (box.min[0] + box.max[0]) / 2, -k * (box.min[1] + box.max[1]) / 2, -k * (box.min[2] + box.max[2]) / 2, 1]);
|
|
191
|
+
rootInst.delete();
|
|
192
|
+
}
|
|
173
193
|
}
|
|
174
194
|
|
|
175
195
|
// Orbit controls
|
|
@@ -238,6 +258,7 @@ canvas:active{cursor:grabbing}
|
|
|
238
258
|
<div id="status">Loading Filament.js WASM...</div>
|
|
239
259
|
<canvas id="viewer"></canvas>
|
|
240
260
|
${BRANDING}
|
|
261
|
+
${modelCredit(model)}
|
|
241
262
|
${filamentRendererScript({ modelUrl: model, bgColor: hexToBgColor(bg), autoRotate })}`;
|
|
242
263
|
return {
|
|
243
264
|
html: htmlShell(title, body),
|
|
@@ -321,6 +342,7 @@ canvas:active{cursor:grabbing}
|
|
|
321
342
|
<canvas id="viewer"></canvas>
|
|
322
343
|
<div class="controls-hint">Drag to orbit • Scroll to zoom • Two-finger to pan</div>
|
|
323
344
|
${BRANDING}
|
|
345
|
+
${modelCredit(model)}
|
|
324
346
|
${filamentRendererScript({ modelUrl: model, bgColor: hexToBgColor(bg), autoRotate, sunIntensity: 120000, fillIntensity: 35000, orbitRadius: 4.0, orbitHeight: 1.0 })}`;
|
|
325
347
|
return {
|
|
326
348
|
html: htmlShell(title, body),
|
|
@@ -379,6 +401,7 @@ canvas:active{cursor:grabbing}
|
|
|
379
401
|
${hotspotHtml}
|
|
380
402
|
<div class="rotate-hint">360° interactive view</div>
|
|
381
403
|
${BRANDING}
|
|
404
|
+
${modelCredit(model)}
|
|
382
405
|
${filamentRendererScript({ modelUrl: model, bgColor: hexToBgColor(bg), autoRotate })}`;
|
|
383
406
|
return {
|
|
384
407
|
html: htmlShell(title, body),
|
package/dist/debug-issue.js
CHANGED
|
@@ -121,7 +121,8 @@ fun DebugModelViewer() {
|
|
|
121
121
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
122
122
|
<uses-feature android:name="android.hardware.camera.ar" android:required="true" />
|
|
123
123
|
<application>
|
|
124
|
-
|
|
124
|
+
<!-- arsceneview declares "optional": overriding it needs xmlns:tools="http://schemas.android.com/tools" on <manifest> -->
|
|
125
|
+
<meta-data android:name="com.google.ar.core" android:value="required" tools:replace="android:value" />
|
|
125
126
|
</application>
|
|
126
127
|
\`\`\`
|
|
127
128
|
|
|
@@ -145,9 +146,9 @@ fun DebugModelViewer() {
|
|
|
145
146
|
- Ensure good lighting — ARCore struggles in dim conditions.
|
|
146
147
|
|
|
147
148
|
5. **Objects not appearing on tap?**
|
|
148
|
-
- Is \`onTouchEvent\`
|
|
149
|
-
- Is \`
|
|
150
|
-
- Are you creating an anchor? \`
|
|
149
|
+
- Is the tap wired up? Use \`onGestureListener = rememberOnGestureListener(onSingleTapConfirmed = { event, node -> if (node == null) … })\` on \`ARSceneView\`, not a raw \`ACTION_UP\` in \`onTouchEvent\` (that also fires when a drag or a pinch ends, and returning \`true\` swallows the model's gestures).
|
|
150
|
+
- Is \`latestFrame\` set? Keep it from \`onSessionUpdated = { _, frame -> latestFrame = frame }\`.
|
|
151
|
+
- Are you creating an anchor? Hit-test that ARCore \`Frame\` (\`latestFrame?.hitTest(event)\`), keep the first in-polygon \`com.google.ar.core.Plane\` hit and call \`createAnchorOrNull()\` on it (\`import io.github.sceneview.ar.arcore.createAnchorOrNull\`). The scene-level \`hitResult\` of \`onTouchEvent\` is a scene-node hit with no \`createAnchor()\`.
|
|
151
152
|
- Is the model loaded? Check \`rememberModelInstance\` is not null.
|
|
152
153
|
|
|
153
154
|
6. **Anchor drift / objects moving?**
|
|
@@ -199,7 +200,7 @@ fun DebugModelViewer() {
|
|
|
199
200
|
### NullPointerException
|
|
200
201
|
|
|
201
202
|
- \`rememberModelInstance\` returns null while loading — always null-check.
|
|
202
|
-
- \`
|
|
203
|
+
- \`latestFrame?.hitTest(event)\` returns an empty list when no surface is hit — chain \`?.firstOrNull { … }?.createAnchorOrNull()\` instead of indexing \`[0]\`.
|
|
203
204
|
|
|
204
205
|
### Out of Memory
|
|
205
206
|
|
|
@@ -273,7 +274,7 @@ fun DebugModelViewer() {
|
|
|
273
274
|
| Too many draw calls | Merge meshes in 3D editor (1 material = 1 draw call) |
|
|
274
275
|
| Per-frame allocations | Reuse objects in \`onFrame\`, avoid creating Position/Rotation each frame |
|
|
275
276
|
| Multiple engines | Use single \`rememberEngine()\`, never create multiple |
|
|
276
|
-
| Post-processing enabled |
|
|
277
|
+
| Post-processing enabled | Lighten or disable if not needed: \`SceneView(renderQuality = RenderQuality.Performance)\`, or \`view.isPostProcessingEnabled = false\` |
|
|
277
278
|
| Shadow-casting lights | Each shadow light = extra depth pass. Limit to 1-2. |
|
|
278
279
|
|
|
279
280
|
#### High Memory (>500MB)
|
|
@@ -407,7 +408,7 @@ SceneView(
|
|
|
407
408
|
onFrame = { Log.d("SV", "Frame rendered") } // If not logged, SceneView isn't rendering
|
|
408
409
|
) {
|
|
409
410
|
// Minimal visible content
|
|
410
|
-
CubeNode(
|
|
411
|
+
CubeNode(size = Size(1.0f))
|
|
411
412
|
LightNode(type = LightManager.Type.DIRECTIONAL, apply = { intensity(100_000f) })
|
|
412
413
|
}
|
|
413
414
|
\`\`\``,
|
|
@@ -473,10 +474,11 @@ SceneView(
|
|
|
473
474
|
|
|
474
475
|
### Tap-to-Place Not Working in AR
|
|
475
476
|
|
|
476
|
-
1.
|
|
477
|
+
1. Place from \`onGestureListener = rememberOnGestureListener(onSingleTapConfirmed = { event, node -> if (node == null) … })\`, never from a raw \`ACTION_UP\` in \`onTouchEvent\`: that also fires at the end of every drag and pinch, and returning \`true\` there blocks the gesture detector.
|
|
477
478
|
2. Ensure plane detection is enabled: \`planeFindingMode = HORIZONTAL_AND_VERTICAL\`.
|
|
478
479
|
3. Plane renderer helps user see where planes are: \`planeRenderer = true\`.
|
|
479
|
-
4. Create anchor from hit: \`
|
|
480
|
+
4. Create the anchor from an in-polygon ARCore plane hit: \`latestFrame?.hitTest(event)?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }?.createAnchorOrNull()\` (\`latestFrame\` from \`onSessionUpdated\`; \`Plane\` is \`com.google.ar.core.Plane\`).
|
|
481
|
+
5. A reticle or other decoration under the finger makes \`node\` non-null: set \`isTouchable = false\` on it.
|
|
480
482
|
|
|
481
483
|
### Camera Orbit Not Working
|
|
482
484
|
|
|
@@ -634,13 +636,20 @@ SceneView(
|
|
|
634
636
|
|
|
635
637
|
For smooth node transforms (not skeletal animation):
|
|
636
638
|
\`\`\`kotlin
|
|
637
|
-
//
|
|
639
|
+
// ModelNode has no smoothing parameter: keep a reference to the node and ask it to
|
|
640
|
+
// interpolate. Don't also pass \`position\` — the composable assigns it directly.
|
|
641
|
+
var shipNode by remember { mutableStateOf<io.github.sceneview.node.Node?>(null) }
|
|
642
|
+
val createdShipNode = remember {
|
|
643
|
+
java.util.concurrent.atomic.AtomicReference<io.github.sceneview.node.Node?>(null)
|
|
644
|
+
}
|
|
638
645
|
ModelNode(
|
|
639
646
|
modelInstance = instance,
|
|
640
|
-
|
|
641
|
-
position = targetPosition,
|
|
642
|
-
smoothSpeed = 5.0f
|
|
647
|
+
apply = { createdShipNode.set(this) }
|
|
643
648
|
)
|
|
649
|
+
SideEffect { shipNode = createdShipNode.get() }
|
|
650
|
+
LaunchedEffect(shipNode, targetPosition) {
|
|
651
|
+
shipNode?.transform(position = targetPosition, smooth = true, smoothSpeed = 5.0f)
|
|
652
|
+
}
|
|
644
653
|
\`\`\`
|
|
645
654
|
|
|
646
655
|
### Common Animation Issues
|
package/dist/discover.js
CHANGED
|
@@ -76,9 +76,23 @@ export const DISCOVER_TTL_MS = 3_600_000;
|
|
|
76
76
|
* Natural-language guidance, mirrored from the package description. Kept short
|
|
77
77
|
* on purpose: per the spec it should not duplicate tool descriptions.
|
|
78
78
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
/**
|
|
80
|
+
* What an agent should know before its first tool call. Sent in two places from
|
|
81
|
+
* this one string: the `initialize` result (`server.ts`, which most hosts put in
|
|
82
|
+
* the model's context at connect time) and `server/discover` below. Before this
|
|
83
|
+
* was wired into `initialize`, hosts that read server instructions got nothing.
|
|
84
|
+
* Keep it short: hosts place it in every conversation.
|
|
85
|
+
*/
|
|
86
|
+
export const SERVER_INSTRUCTIONS = [
|
|
87
|
+
"SceneView MCP: the SceneView 3D & AR SDK (Android Jetpack Compose + Filament + ARCore, and the web) as tools and resources, so you write SceneView code that compiles on the first try.",
|
|
88
|
+
"Before writing SceneView code:",
|
|
89
|
+
"1. Read the `sceneview://api` resource. Use the 4.x names it lists; never emit a 2.x or Sceneform name from memory (`migrate_code` rewrites old code).",
|
|
90
|
+
"2. Start from `get_sample` or `get_setup` rather than from scratch.",
|
|
91
|
+
"3. Run `validate_code` on any Kotlin you show, and fix what it reports before answering.",
|
|
92
|
+
"Rules that break apps when missed: load models with `rememberModelInstance(modelLoader, path)` inside composables. Filament calls (`modelLoader.createModel*`, `materialLoader.*`) must run on the main thread, never from a background coroutine.",
|
|
93
|
+
"For a runtime error or a blank scene, call `debug_issue` or `get_troubleshooting`, and read `sceneview://known-issues`.",
|
|
94
|
+
].join("\n");
|
|
95
|
+
const DISCOVER_INSTRUCTIONS = SERVER_INSTRUCTIONS;
|
|
82
96
|
/**
|
|
83
97
|
* Builds the `DiscoverResult`.
|
|
84
98
|
*
|