sceneview-mcp 4.1.2 → 4.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/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,7 +236,7 @@ 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
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 32.
242
242
 
@@ -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) |
@@ -367,19 +367,28 @@ Call it like `search_models({ query: "red sports car", category: "cars-vehicles"
367
367
 
368
368
  ## `generate_3d_model` — create brand-new 3D assets from the AI
369
369
 
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) via the [Tripo AI](https://www.tripo3d.ai) API, then returns a direct GLB download URL plus license/attribution metadata — ready for `rememberModelInstance(modelLoader, ...)` and AR placement.
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), then returns a direct GLB download URL plus license/attribution metadata — ready for `rememberModelInstance(modelLoader, ...)` and AR placement.
371
371
 
372
- Two quality tiers:
372
+ Two providers, both bring-your-own-key:
373
+
374
+ | `provider` | Key | Model | Approx. cost per model |
375
+ |---|---|---|---|
376
+ | `"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) |
377
+ | `"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) |
378
+
379
+ 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).
380
+
381
+ Tripo's two quality tiers:
373
382
 
374
383
  | `quality` | Tripo model | Topology | Latency | Approx. cost (July 2026) |
375
384
  |---|---|---|---|---|
376
385
  | `"fast"` (default) | P1 (`P1-20260311`) | low-poly, AR-ready | ~25–30 s | ~$0.10–0.25 of your credits |
377
386
  | `"hd"` | H3.1 (`v3.1-20260211`) | quad mesh, detailed geometry + textures | up to ~100 s | ~$0.41 of your credits |
378
387
 
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:
388
+ **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
389
 
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:
390
+ 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)
391
+ 2. Set `RUNWARE_API_KEY` or `TRIPO_API_KEY` in your MCP client config:
383
392
 
384
393
  ```json
385
394
  {
@@ -387,15 +396,15 @@ Two quality tiers:
387
396
  "sceneview": {
388
397
  "command": "npx",
389
398
  "args": ["-y", "sceneview-mcp"],
390
- "env": { "TRIPO_API_KEY": "YOUR_KEY_HERE" }
399
+ "env": { "RUNWARE_API_KEY": "YOUR_KEY_HERE" }
391
400
  }
392
401
  }
393
402
  }
394
403
  ```
395
404
 
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`.
405
+ 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
406
 
398
- **⚠️ The GLB download URL expires ~5 minutes after generation** — 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.
407
+ **⚠️ 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
408
 
400
409
  ## `analyze_project` — local project scan
401
410
 
@@ -490,7 +499,7 @@ Install Node.js from [nodejs.org](https://nodejs.org/) (LTS recommended). npm an
490
499
 
491
500
  ### Firewall or proxy issues
492
501
 
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.
502
+ 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
503
 
495
504
  ```json
496
505
  {
@@ -510,7 +519,7 @@ The only network calls are to the GitHub API (for known issues), Sketchfab (when
510
519
 
511
520
  ## Sponsor
512
521
 
513
- If sceneview-mcp saves you time, consider [donating on Open Collective](https://opencollective.com/sceneview), or [GitHub Sponsors](https://github.com/sponsors/sceneview) if you prefer. SceneView is free and open source, funded by the people and companies who use it; every tool is free with or without a donation.
522
+ 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
523
 
515
524
  ---
516
525
 
@@ -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
- onTouchEvent = { event, hitResult ->
239
- if (event.action == MotionEvent.ACTION_UP && hitResult != null) {
240
- anchor = hitResult.createAnchor()
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
- true
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
- onTouchEvent = { event, hitResult ->
367
- if (event.action == MotionEvent.ACTION_UP && hitResult != null) {
368
- // Create an anchor at the tap location on the AR plane
369
- anchor = hitResult.createAnchor()
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
- true
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
- onTap = { selectedModel = "chair" }
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
- onTap = { selectedModel = "table" }
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** — use \`hitResult.createAnchor()\` in \`onTouchEvent\` with \`ACTION_UP\`.
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** — use \`onTap\` callback per ModelNode for selection.
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 environment = rememberEnvironment(engine, "environments/sky_2k.hdr")
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
- // Disable post-processing for simpler scenes (saves ~2ms per frame)
786
+ // Lighter preset: shadows, SSAO and bloom off, dynamic resolution on
751
787
  SceneView(
752
788
  engine = engine,
753
- postProcessing = false // skips bloom, SSAO, tone mapping
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 (\`postProcessing = false\`).
847
+ 7. **Post-processing** — disable what you don't need (\`renderQuality = RenderQuality.Performance\`, or \`view.isPostProcessingEnabled = false\`).
806
848
  `;
@@ -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} (or run \`bash .claude/scripts/android-env-check.sh --fix\``,
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
- const DEFAULT_MODEL = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/DamagedHelmet/glTF-Binary/DamagedHelmet.glb";
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 &bull; Scroll to zoom &bull; 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&deg; 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),
@@ -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
- <meta-data android:name="com.google.ar.core" android:value="required" />
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\` wired up?
149
- - Is \`hitResult\` null? Log it: \`Log.d("AR", "hitResult: $hitResult")\`
150
- - Are you creating an anchor? \`hitResult.createAnchor()\` must be called.
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
- - \`hitResult\` can be null in \`onTouchEvent\` if no surface is hit.
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 | Disable if not needed: \`SceneView(postProcessing = false)\` |
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(engine = engine, size = 1.0f)
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. Check \`hitResult\` is not null — log it.
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: \`hitResult.createAnchor()\`.
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
- // Use SmoothTransform from sceneview-core
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
- // Position changes are smoothly interpolated
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
@@ -145,7 +145,12 @@ export const COLLISION_GUIDE = `# SceneView Collision & Physics Guide
145
145
 
146
146
  ## Hit Testing (Tap on 3D Objects)
147
147
 
148
- SceneView supports hit testing via \`onTouchEvent\` on nodes. The \`hitResult\` gives you the exact 3D point where the user tapped.
148
+ Every node is touchable by default (\`isTouchable = true\`); set \`isTouchable = false\` on decorations that must let taps through. A tap reaches your code in two ways:
149
+
150
+ - **Per node** — assign \`onSingleTapConfirmed: (MotionEvent) -> Boolean\` in the node's \`apply = { }\` block. For the exact 3D point, \`onTouch = { motionEvent, hitResult -> … false }\` sees every raw event on that node with \`hitResult.getWorldPosition()\`; return \`false\`, because \`true\` hides the event from the gesture detector.
151
+ - **Scene level** — \`onGestureListener = rememberOnGestureListener(onSingleTapConfirmed = { event, node -> … })\` on \`SceneView\` / \`ARSceneView\`: \`node\` is the touchable node under the finger, or \`null\` for empty space.
152
+
153
+ \`Node.onTouchEvent(e, hitResult)\` is an open function you override in a \`Node\` subclass, not a property you assign. The scene-level \`onTouchEvent\` parameter sees every raw \`MotionEvent\` first, and returning \`true\` from it hides the event from nodes and from the gesture detector — use the gesture listener for taps.
149
154
 
150
155
  ### Basic Node Tapping
151
156
 
@@ -157,22 +162,21 @@ fun TappableModelScreen() {
157
162
  val modelInstance = rememberModelInstance(modelLoader, "models/button.glb")
158
163
  var tapped by remember { mutableStateOf(false) }
159
164
 
160
- SceneView(engine = engine) {
165
+ SceneView(engine = engine, modelLoader = modelLoader) {
161
166
  modelInstance?.let { instance ->
162
167
  ModelNode(
163
168
  modelInstance = instance,
164
169
  scaleToUnits = 0.5f,
165
- centerOrigin = Position(y = -0.5f)
166
- ) {
167
- // Make node respond to touch
168
- isTouchable = true
169
- onTouchEvent = { hitResult, motionEvent ->
170
- if (motionEvent.action == MotionEvent.ACTION_DOWN) {
170
+ centerOrigin = Position(y = -0.5f),
171
+ // Node properties go in \`apply\`; the trailing { } lambda is for child nodes.
172
+ apply = {
173
+ isTouchable = true // already the default, shown for clarity
174
+ onSingleTapConfirmed = { _ ->
171
175
  tapped = true
176
+ true // handled
172
177
  }
173
- true
174
178
  }
175
- }
179
+ )
176
180
  }
177
181
  }
178
182
  }
@@ -180,25 +184,51 @@ fun TappableModelScreen() {
180
184
 
181
185
  ## AR Hit Testing (Tap to Place)
182
186
 
183
- In AR, hit testing detects real-world surfaces:
187
+ In AR, hit testing detects real-world surfaces: keep the latest ARCore \`Frame\` and hit-test it on a confirmed tap on empty space. Never place on a raw \`ACTION_UP\` in \`onTouchEvent\` — it also fires when a drag or a pinch ends.
184
188
 
185
189
  \`\`\`kotlin
190
+ import com.google.ar.core.Anchor
191
+ import com.google.ar.core.Config
192
+ import com.google.ar.core.Frame
193
+ import com.google.ar.core.Plane
194
+ import io.github.sceneview.ar.arcore.createAnchorOrNull
195
+ import io.github.sceneview.rememberOnGestureListener
196
+ // …plus androidx.compose.runtime.* and the io.github.sceneview entry points (ARSceneView, rememberEngine, …)
197
+
186
198
  @Composable
187
199
  fun ARTapToPlaceScreen() {
188
200
  val engine = rememberEngine()
189
201
  val modelLoader = rememberModelLoader(engine)
190
202
  val modelInstance = rememberModelInstance(modelLoader, "models/chair.glb")
203
+ var anchor by remember { mutableStateOf<Anchor?>(null) }
204
+ var latestFrame by remember { mutableStateOf<Frame?>(null) }
191
205
 
192
206
  ARSceneView(
193
207
  engine = engine,
194
- sessionConfiguration = { session, config ->
208
+ modelLoader = modelLoader,
209
+ planeRenderer = true,
210
+ sessionConfiguration = { _, config ->
195
211
  config.planeFindingMode = Config.PlaneFindingMode.HORIZONTAL_AND_VERTICAL
196
212
  },
197
- onSessionUpdated = { session, frame ->
198
- // frame.hitTest() gives real-world surface intersections
199
- }
213
+ onSessionUpdated = { _, frame -> latestFrame = frame },
214
+ onGestureListener = rememberOnGestureListener(
215
+ onSingleTapConfirmed = { event, node ->
216
+ if (node == null) { // empty space, not the placed model
217
+ // frame.hitTest() gives real-world surface intersections, nearest first
218
+ latestFrame?.hitTest(event)
219
+ ?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }
220
+ ?.createAnchorOrNull()
221
+ // Replacing the state key disposes the old AnchorNode, which detaches its anchor.
222
+ ?.let { anchor = it }
223
+ }
224
+ }
225
+ )
200
226
  ) {
201
- // Place model at anchor when user taps
227
+ anchor?.let { a ->
228
+ AnchorNode(anchor = a) {
229
+ modelInstance?.let { ModelNode(modelInstance = it, scaleToUnits = 0.5f, isEditable = true) }
230
+ }
231
+ }
202
232
  }
203
233
  }
204
234
  \`\`\`
@@ -279,7 +309,7 @@ ModelNode(modelInstance = instance) {
279
309
 
280
310
  ## Tips
281
311
 
282
- 1. **Use \`isTouchable = true\`** — nodes are not touchable by default
312
+ 1. **Taps go through \`onSingleTapConfirmed\`** — nodes are touchable by default; set \`isTouchable = false\` on decorations such as a reticle
283
313
  2. **AR hit test with \`frame.hitTest()\`** — returns surfaces sorted by distance
284
314
  3. **BoundingBox for broad-phase** — check box overlap before expensive ray tests
285
315
  4. **Physics is optional** — import \`sceneview-core\` separately from \`sceneview\`