sceneview-mcp 4.1.1 → 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/dist/samples.js CHANGED
@@ -23,7 +23,7 @@ fun ModelViewerScreen() {
23
23
  mainLightNode = rememberMainLightNode(engine) { intensity = 100_000f },
24
24
  cameraManipulator = rememberCameraManipulator()
25
25
  ) {
26
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
26
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
27
27
  ModelNode(
28
28
  modelInstance = instance,
29
29
  scaleToUnits = 1.0f,
@@ -41,12 +41,31 @@ fun ModelViewerScreen() {
41
41
  tags: ["ar", "model", "anchor", "plane-detection", "placement", "gestures"],
42
42
  dependency: "io.github.sceneview:arsceneview:" + LATEST_SCENEVIEW_RELEASE + "",
43
43
  prompt: `Create an AR screen that detects surfaces and lets the user tap to place a GLB model. Support pinch-to-scale and drag-to-rotate. Use SceneView \`io.github.sceneview:arsceneview:${LATEST_SCENEVIEW_RELEASE}\`.`,
44
- code: `@Composable
44
+ code: `import androidx.compose.foundation.layout.fillMaxSize
45
+ import androidx.compose.runtime.Composable
46
+ import androidx.compose.runtime.getValue
47
+ import androidx.compose.runtime.mutableStateOf
48
+ import androidx.compose.runtime.remember
49
+ import androidx.compose.runtime.setValue
50
+ import androidx.compose.ui.Modifier
51
+ import com.google.ar.core.Anchor
52
+ import com.google.ar.core.Config
53
+ import com.google.ar.core.Frame
54
+ import com.google.ar.core.Plane
55
+ import io.github.sceneview.ar.ARSceneView
56
+ import io.github.sceneview.ar.arcore.createAnchorOrNull
57
+ import io.github.sceneview.rememberEngine
58
+ import io.github.sceneview.rememberModelInstance
59
+ import io.github.sceneview.rememberModelLoader
60
+ import io.github.sceneview.rememberOnGestureListener
61
+
62
+ @Composable
45
63
  fun ARModelViewerScreen() {
46
64
  val engine = rememberEngine()
47
65
  val modelLoader = rememberModelLoader(engine)
48
- val modelInstance = rememberModelInstance(modelLoader, "models/damaged_helmet.glb")
66
+ val modelInstance = rememberModelInstance(modelLoader, "models/toy_car.glb")
49
67
  var anchor by remember { mutableStateOf<Anchor?>(null) }
68
+ var latestFrame by remember { mutableStateOf<Frame?>(null) }
50
69
 
51
70
  ARSceneView(
52
71
  modifier = Modifier.fillMaxSize(),
@@ -59,11 +78,20 @@ fun ARModelViewerScreen() {
59
78
  Config.DepthMode.AUTOMATIC else Config.DepthMode.DISABLED
60
79
  config.lightEstimationMode = Config.LightEstimationMode.ENVIRONMENTAL_HDR
61
80
  },
62
- onTouchEvent = { event, hitResult ->
63
- if (event.action == MotionEvent.ACTION_UP && hitResult != null)
64
- anchor = hitResult.createAnchor()
65
- true
66
- }
81
+ onSessionUpdated = { _, frame -> latestFrame = frame },
82
+ // A confirmed single tap, never a raw ACTION_UP: the end of a drag or a pinch on the
83
+ // placed model must not move it. Leaving onTouchEvent unset keeps the model's gestures.
84
+ onGestureListener = rememberOnGestureListener(
85
+ onSingleTapConfirmed = { event, node ->
86
+ if (node == null) { // empty space, not the placed model
87
+ latestFrame?.hitTest(event)
88
+ ?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }
89
+ ?.createAnchorOrNull()
90
+ // Replacing the state key disposes the old AnchorNode, which detaches its anchor.
91
+ ?.let { anchor = it }
92
+ }
93
+ }
94
+ )
67
95
  ) {
68
96
  anchor?.let { a ->
69
97
  AnchorNode(anchor = a) {
@@ -286,12 +314,14 @@ fun CameraManipulatorScreen() {
286
314
  engine = engine,
287
315
  modelLoader = modelLoader,
288
316
  cameraNode = cameraNode,
317
+ // A fixed eye, never a live value such as cameraNode.worldPosition: the manipulator
318
+ // is keyed on it, and the camera node moves on every orbit.
289
319
  cameraManipulator = rememberCameraManipulator(
290
- orbitHomePosition = cameraNode.worldPosition,
320
+ orbitHomePosition = Position(z = 4f),
291
321
  targetPosition = Position(0f)
292
322
  )
293
323
  ) {
294
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
324
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
295
325
  ModelNode(modelInstance = instance, scaleToUnits = 1.0f)
296
326
  }
297
327
  }
@@ -345,7 +375,7 @@ fun CameraAnimationScreen() {
345
375
  },
346
376
  mainLightNode = rememberMainLightNode(engine) { intensity = 100_000f }
347
377
  ) {
348
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
378
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
349
379
  ModelNode(modelInstance = instance, scaleToUnits = 1.0f)
350
380
  }
351
381
  }
@@ -691,6 +721,7 @@ fun LinePathScreen() {
691
721
  code: `@Composable
692
722
  fun TextLabelsScreen() {
693
723
  val engine = rememberEngine()
724
+ val cameraNode = rememberCameraNode(engine)
694
725
  val materialLoader = rememberMaterialLoader(engine)
695
726
  val environmentLoader = rememberEnvironmentLoader(engine)
696
727
 
@@ -704,6 +735,7 @@ fun TextLabelsScreen() {
704
735
  SceneView(
705
736
  modifier = Modifier.fillMaxSize(),
706
737
  engine = engine,
738
+ cameraNode = cameraNode,
707
739
  cameraManipulator = rememberCameraManipulator(
708
740
  orbitHomePosition = Position(x = 0f, y = 1.5f, z = 5f),
709
741
  targetPosition = Position(0f, 0.5f, 0f)
@@ -733,7 +765,9 @@ fun TextLabelsScreen() {
733
765
  backgroundColor = 0xCC000000.toInt(),
734
766
  widthMeters = 0.6f,
735
767
  heightMeters = 0.2f,
736
- position = Position(x = planet.x, y = 0.9f, z = 0f)
768
+ position = Position(x = planet.x, y = 0.9f, z = 0f),
769
+ // Without a provider a TextNode does not turn toward the camera.
770
+ cameraPositionProvider = { cameraNode.worldPosition }
737
771
  )
738
772
  }
739
773
  }
@@ -795,7 +829,7 @@ fun PostProcessingScreen() {
795
829
  modelLoader = modelLoader,
796
830
  view = view
797
831
  ) {
798
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
832
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
799
833
  ModelNode(modelInstance = instance, scaleToUnits = 1.0f)
800
834
  }
801
835
  }
@@ -806,36 +840,27 @@ fun PostProcessingScreen() {
806
840
  "video-texture": {
807
841
  id: "video-texture",
808
842
  title: "Video Texture",
809
- description: "Video playback on a 3D plane using VideoNode with MediaPlayer — supports looping, chroma-key, and auto-sizing.",
843
+ description: "Video playback on a 3D plane using VideoNode — prepared off the main thread, with play/pause, looping, chroma-key, auto-sizing and an error callback.",
810
844
  tags: ["3d", "video", "model"],
811
845
  dependency: "io.github.sceneview:sceneview:" + LATEST_SCENEVIEW_RELEASE + "",
812
846
  prompt: `Create a 3D scene with a video playing on a floating 3D plane. Include play/pause controls and chroma-key support. Use SceneView \`io.github.sceneview:sceneview:${LATEST_SCENEVIEW_RELEASE}\`.`,
813
- code: `@Composable
847
+ code: `@OptIn(ExperimentalSceneViewApi::class)
848
+ @Composable
814
849
  fun VideoTextureScreen() {
815
- val context = LocalContext.current
816
- val engine = rememberEngine()
817
850
  var isPlaying by remember { mutableStateOf(true) }
818
-
819
- val player = remember {
820
- MediaPlayer().apply {
821
- setDataSource(context, Uri.parse("android.resource://\${context.packageName}/raw/video"))
822
- isLooping = true
823
- prepare()
824
- start()
825
- }
826
- }
827
- DisposableEffect(Unit) { onDispose { player.release() } }
851
+ var error by remember { mutableStateOf<Exception?>(null) }
828
852
 
829
853
  Column {
830
- SceneView(
831
- modifier = Modifier.weight(1f).fillMaxWidth(),
832
- engine = engine
833
- ) {
854
+ SceneView(modifier = Modifier.weight(1f).fillMaxWidth()) {
855
+ // Prepared off the main thread: the node appears once the video is ready.
834
856
  VideoNode(
835
- player = player,
857
+ videoPath = "videos/promo.mp4", // under assets/, or an https:// URL
858
+ autoPlay = isPlaying, // reactive: true plays, false pauses
859
+ isLooping = true,
836
860
  // size = null auto-sizes from video aspect ratio (longer edge = 1 unit)
837
861
  position = Position(z = -2f),
838
- chromaKeyColor = null // set to android.graphics.Color.GREEN for green-screen
862
+ chromaKeyColor = null, // set to android.graphics.Color.GREEN for green-screen
863
+ onError = { cause -> error = cause } // missing file, unsupported codec, broken stream
839
864
  )
840
865
  }
841
866
  Row(
@@ -843,11 +868,12 @@ fun VideoTextureScreen() {
843
868
  horizontalArrangement = Arrangement.Center,
844
869
  verticalAlignment = Alignment.CenterVertically
845
870
  ) {
846
- Button(onClick = {
847
- if (isPlaying) player.pause() else player.start()
848
- isPlaying = !isPlaying
849
- }) {
850
- Text(if (isPlaying) "Pause" else "Play")
871
+ if (error != null) {
872
+ Text("This video cannot be played.")
873
+ } else {
874
+ Button(onClick = { isPlaying = !isPlaying }) {
875
+ Text(if (isPlaying) "Pause" else "Play")
876
+ }
851
877
  }
852
878
  }
853
879
  }
@@ -962,7 +988,7 @@ fun GestureInteractionScreen() {
962
988
  }
963
989
  )
964
990
  ) {
965
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
991
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
966
992
  ModelNode(
967
993
  modelInstance = instance,
968
994
  scaleToUnits = 1.0f,
@@ -1023,7 +1049,7 @@ fun EnvironmentLightingScreen() {
1023
1049
  PlaneNode(size = Size(10f, 10f), materialInstance = floorMat)
1024
1050
 
1025
1051
  // Model
1026
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
1052
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
1027
1053
  ModelNode(modelInstance = instance, scaleToUnits = 1.0f, position = Position(y = 0.5f))
1028
1054
  }
1029
1055
 
@@ -1154,7 +1180,7 @@ fun ComposeUI3DScreen() {
1154
1180
  viewNodeWindowManager = windowManager
1155
1181
  ) {
1156
1182
  // 3D model behind the UI
1157
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
1183
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
1158
1184
  ModelNode(modelInstance = instance, scaleToUnits = 1.0f, position = Position(z = -1f))
1159
1185
  }
1160
1186
 
@@ -1784,7 +1810,7 @@ fun BillboardSpriteScreen() {
1784
1810
  mainLightNode = rememberMainLightNode(engine) { intensity = 100_000f }
1785
1811
  ) {
1786
1812
  // A model with billboard markers above it
1787
- rememberModelInstance(modelLoader, "models/damaged_helmet.glb")?.let { instance ->
1813
+ rememberModelInstance(modelLoader, "models/toy_car.glb")?.let { instance ->
1788
1814
  ModelNode(modelInstance = instance, scaleToUnits = 1.0f)
1789
1815
  }
1790
1816
 
@@ -1969,7 +1995,28 @@ fun SpringAnimationScreen() {
1969
1995
  tags: ["ar", "cursor", "plane-detection", "placement"],
1970
1996
  dependency: "io.github.sceneview:arsceneview:" + LATEST_SCENEVIEW_RELEASE + "",
1971
1997
  prompt: `Create an AR screen with a surface cursor (reticle) in the center of the screen that follows detected surfaces, using HitResultNode. Tap to place a model at the cursor position. Use SceneView \`io.github.sceneview:arsceneview:${LATEST_SCENEVIEW_RELEASE}\`.`,
1972
- code: `@Composable
1998
+ code: `import androidx.compose.foundation.layout.fillMaxSize
1999
+ import androidx.compose.runtime.Composable
2000
+ import androidx.compose.runtime.getValue
2001
+ import androidx.compose.runtime.mutableStateOf
2002
+ import androidx.compose.runtime.remember
2003
+ import androidx.compose.runtime.setValue
2004
+ import androidx.compose.ui.Modifier
2005
+ import androidx.compose.ui.graphics.Color
2006
+ import androidx.compose.ui.platform.LocalView
2007
+ import com.google.ar.core.Anchor
2008
+ import com.google.ar.core.Config
2009
+ import com.google.ar.core.Frame
2010
+ import com.google.ar.core.Plane
2011
+ import io.github.sceneview.ar.ARSceneView
2012
+ import io.github.sceneview.ar.arcore.createAnchorOrNull
2013
+ import io.github.sceneview.rememberEngine
2014
+ import io.github.sceneview.rememberMaterialLoader
2015
+ import io.github.sceneview.rememberModelInstance
2016
+ import io.github.sceneview.rememberModelLoader
2017
+ import io.github.sceneview.rememberOnGestureListener
2018
+
2019
+ @Composable
1973
2020
  fun ARSurfaceCursorScreen() {
1974
2021
  val engine = rememberEngine()
1975
2022
  val modelLoader = rememberModelLoader(engine)
@@ -1977,6 +2024,7 @@ fun ARSurfaceCursorScreen() {
1977
2024
  val view = LocalView.current
1978
2025
  val modelInstance = rememberModelInstance(modelLoader, "models/chair.glb")
1979
2026
  var placedAnchors by remember { mutableStateOf(listOf<Anchor>()) }
2027
+ var latestFrame by remember { mutableStateOf<Frame?>(null) }
1980
2028
 
1981
2029
  ARSceneView(
1982
2030
  modifier = Modifier.fillMaxSize(),
@@ -1988,19 +2036,33 @@ fun ARSurfaceCursorScreen() {
1988
2036
  Config.DepthMode.AUTOMATIC else Config.DepthMode.DISABLED
1989
2037
  config.lightEstimationMode = Config.LightEstimationMode.ENVIRONMENTAL_HDR
1990
2038
  },
1991
- onTouchEvent = { event, hitResult ->
1992
- if (event.action == MotionEvent.ACTION_UP && hitResult != null) {
1993
- placedAnchors = placedAnchors + hitResult.createAnchor()
2039
+ onSessionUpdated = { _, frame -> latestFrame = frame },
2040
+ // A confirmed single tap, never a raw ACTION_UP: the end of a drag or a pinch on a
2041
+ // placed model must not drop another one. Leaving onTouchEvent unset keeps those gestures.
2042
+ onGestureListener = rememberOnGestureListener(
2043
+ onSingleTapConfirmed = { _, node ->
2044
+ if (node == null) { // empty space, not a placed model
2045
+ // Place at the cursor (screen centre), wherever the finger landed.
2046
+ latestFrame?.hitTest(view.width / 2f, view.height / 2f)
2047
+ ?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }
2048
+ ?.createAnchorOrNull()
2049
+ ?.let { placedAnchors = placedAnchors + it } // keep every placed model
2050
+ }
1994
2051
  }
1995
- true
1996
- }
2052
+ )
1997
2053
  ) {
1998
2054
  // Surface cursor — follows the center of the screen
1999
2055
  val cursorMat = remember(materialLoader) {
2000
2056
  materialLoader.createColorInstance(Color.White.copy(alpha = 0.6f))
2001
2057
  }
2002
2058
  HitResultNode(xPx = view.width / 2f, yPx = view.height / 2f) {
2003
- CylinderNode(radius = 0.03f, height = 0.005f, materialInstance = cursorMat)
2059
+ CylinderNode(
2060
+ radius = 0.03f,
2061
+ height = 0.005f,
2062
+ materialInstance = cursorMat,
2063
+ // Not touchable, so a tap on the reticle still counts as empty space.
2064
+ apply = { isTouchable = false }
2065
+ )
2004
2066
  }
2005
2067
 
2006
2068
  // Placed models
@@ -2050,7 +2112,7 @@ fun main() {
2050
2112
  intensity(100_000.0)
2051
2113
  direction(0.0f, -1.0f, -0.5f)
2052
2114
  }
2053
- model("models/DamagedHelmet.glb")
2115
+ model("https://sceneview.github.io/models/platforms/moto_helmet_v2.glb") // Motorcycle Helmet by sayedgamal655, CC-BY 4.0
2054
2116
  },
2055
2117
  onReady = { sceneView ->
2056
2118
  sceneView.startRendering()
@@ -2094,7 +2156,7 @@ fun main() {
2094
2156
  iblUrl = "environments/pillars_2k_ibl.ktx",
2095
2157
  skyboxUrl = "environments/pillars_2k_skybox.ktx"
2096
2158
  )
2097
- model("models/DamagedHelmet.glb")
2159
+ model("https://sceneview.github.io/models/platforms/moto_helmet_v2.glb") // Motorcycle Helmet by sayedgamal655, CC-BY 4.0
2098
2160
  },
2099
2161
  onReady = { sceneView ->
2100
2162
  sceneView.startRendering()
@@ -603,7 +603,7 @@ export const TOOL_DEFINITIONS = [
603
603
  },
604
604
  {
605
605
  name: "get_collision_guide",
606
- description: "Returns a comprehensive guide for collision detection, hit testing, and physics in SceneView — node tapping (onTouchEvent), AR surface hit testing (frame.hitTest), ray-box/ray-sphere intersection (KMP core), bounding boxes, and basic rigid body physics. Use this when a user asks about tapping 3D objects, collision detection, physics simulation, ray casting, or hit testing.",
606
+ description: "Returns a comprehensive guide for collision detection, hit testing, and physics in SceneView — node tapping (onSingleTapConfirmed), AR tap-to-place (frame.hitTest on a confirmed tap), ray-box/ray-sphere intersection (KMP core), bounding boxes, and basic rigid body physics. Use this when a user asks about tapping 3D objects, collision detection, physics simulation, ray casting, or hit testing.",
607
607
  inputSchema: {
608
608
  type: "object",
609
609
  properties: {},
@@ -680,7 +680,7 @@ export const TOOL_DEFINITIONS = [
680
680
  },
681
681
  {
682
682
  name: "generate_3d_model",
683
- description: 'Generates a brand-new 3D model (GLB) from a text prompt OR a source image using the Tripo AI API — use this when `search_models` finds no suitable existing asset and the user needs a custom one ("a low-poly cactus in a striped pot"). Returns a direct GLB download URL (expires ~5 minutes — download it immediately and self-host it) plus license/attribution metadata, ready for `rememberModelInstance(modelLoader, ...)` and AR placement. Quality tiers: "fast" (default, Tripo P1 low-poly — AR-ready, ~25-30 s) or "hd" (Tripo H3.1 quad topology with detailed geometry/textures — up to ~100 s, pricier). Requires a `TRIPO_API_KEY` environment variable (BYOK — generations are billed to the USER\'S Tripo account, roughly $0.10-0.25 per fast generation and ~$0.41 per hd generation as of July 2026; nothing is charged by SceneView). If the key is missing, the tool returns setup instructions for platform.tripo3d.ai/api-keys.',
683
+ description: 'Generates a brand-new 3D model (GLB) from a text prompt OR a source image, with TRELLIS.2 on Runware or with Tripo AI — use this when `search_models` finds no suitable existing asset and the user needs a custom one ("a low-poly cactus in a striped pot"). Returns a direct GLB download URL (expires ~5 minutes — download it immediately and self-host it) plus license/attribution metadata, ready for `rememberModelInstance(modelLoader, ...)` and AR placement. Providers (BYOK — billed to the USER\'S own account, nothing is charged by SceneView): "trellis" = Microsoft TRELLIS.2 on Runware, needs `RUNWARE_API_KEY` (my.runware.ai/keys), roughly $0.01-0.03 per model as of November 2026, ~40-90 s, text→3D renders a FLUX concept image first; "tripo" = Tripo AI, needs `TRIPO_API_KEY` (platform.tripo3d.ai/api-keys), roughly $0.10-0.25 per fast and ~$0.41 per hd generation as of July 2026. Without `provider`, Tripo is used when `TRIPO_API_KEY` is set, otherwise TRELLIS.2 when `RUNWARE_API_KEY` is set. Quality tiers: "fast" (default — Tripo P1 low-poly, or TRELLIS.2 at 1024³) or "hd" (Tripo H3.1 quad topology, or TRELLIS.2 at 1536³ — slower, pricier). If no key is set, the tool returns setup instructions for both providers.',
684
684
  inputSchema: {
685
685
  type: "object",
686
686
  properties: {
@@ -695,7 +695,12 @@ export const TOOL_DEFINITIONS = [
695
695
  quality: {
696
696
  type: "string",
697
697
  enum: ["fast", "hd"],
698
- description: '"fast" (default): Tripo P1 low-poly — cheap, AR-ready, ~25-30 s. "hd": Tripo H3.1 quad topology + detailed geometry/textures — up to ~100 s, higher credit cost.',
698
+ description: '"fast" (default): Tripo P1 low-poly (~25-30 s) or TRELLIS.2 1024³ — cheap, AR-ready. "hd": Tripo H3.1 quad topology (up to ~100 s) or TRELLIS.2 1536³ — more detail, higher cost.',
699
+ },
700
+ provider: {
701
+ type: "string",
702
+ enum: ["trellis", "tripo"],
703
+ description: '"trellis": Microsoft TRELLIS.2 on Runware (`RUNWARE_API_KEY`, a few US cents per model, image-faithful PBR mesh). "tripo": Tripo AI (`TRIPO_API_KEY`). Omit to pick whichever key is configured (Tripo first).',
699
704
  },
700
705
  },
701
706
  required: [],
@@ -23,7 +23,7 @@ import { fetchAndroidDoc, formatAndroidDocsFetch, formatAndroidDocsSearch, searc
23
23
  import { formatArtifactResponse, generateArtifact, validateArtifactInput, } from "../artifact.js";
24
24
  import { autoDetectIssue, DEBUG_CATEGORIES, getDebugGuide, } from "../debug-issue.js";
25
25
  import { COLLISION_GUIDE, MATERIAL_GUIDE, MODEL_OPTIMIZATION_GUIDE, WEB_RENDERING_GUIDE, } from "../extra-guides.js";
26
- import { formatGenerateResult, generateModel } from "../generate-model.js";
26
+ import { formatGenerateResult, generateModel, } from "../generate-model.js";
27
27
  import { formatGeneratedScene, generateScene } from "../generate-scene.js";
28
28
  import { LLMS_TXT } from "../generated/llms-txt.js";
29
29
  import { IOS_NODE_TYPE_COUNT, LATEST_SCENEVIEW_RELEASE } from "../generated/version.js";
@@ -39,34 +39,11 @@ import { formatValidationReport, validateCode } from "../validator.js";
39
39
  import { WIDGET_3D_VIEWER_URI } from "../widgets.js";
40
40
  // ─── Legal disclaimer (identical to index.ts 4.0.0) ─────────────────────
41
41
  const DISCLAIMER = "\n\n---\n*Generated code suggestion. Review before use in production. See [TERMS.md](https://github.com/sceneview/sceneview/blob/main/mcp/TERMS.md).*";
42
- // ─── Sponsor CTA (shown every N tool calls, opt-out via env var) ────────────
43
- //
44
- // One line, every `SPONSOR_CTA_INTERVAL` tool calls, pointing at the donation
45
- // page. Disabled by setting `SCENEVIEW_SPONSOR_CTA=0`. The counter is
46
- // module-scoped (per MCP process lifetime), not persisted.
47
- //
48
- // One link only: an assistant's answer is a bad place for a menu, and Open
49
- // Collective is the channel that actually receives donations. GitHub Sponsors
50
- // stays listed in the README and on the site.
51
- const SPONSOR_CTA_INTERVAL = 10;
52
- const SPONSOR_CTA = "\n\n💙 *Building SceneView is a one-dev labor of love. If it saved you time, consider [supporting it on Open Collective](https://opencollective.com/sceneview).*";
53
- let toolCallCount = 0;
54
- /** Test-only: reset the module-scoped counter between test cases. */
55
- export function __resetSponsorCounter() {
56
- toolCallCount = 0;
57
- }
58
- function shouldShowSponsorCta() {
59
- if (process.env.SCENEVIEW_SPONSOR_CTA === "0")
60
- return false;
61
- toolCallCount += 1;
62
- return toolCallCount % SPONSOR_CTA_INTERVAL === 0;
63
- }
64
42
  function withDisclaimer(content) {
65
43
  if (content.length === 0)
66
44
  return content;
67
45
  const last = content[content.length - 1];
68
- const suffix = DISCLAIMER + (shouldShowSponsorCta() ? SPONSOR_CTA : "");
69
- return [...content.slice(0, -1), { ...last, text: last.text + suffix }];
46
+ return [...content.slice(0, -1), { ...last, text: last.text + DISCLAIMER }];
70
47
  }
71
48
  // ─── llms.txt-derived state ──────────────────────────────────────────────────
72
49
  /** Raw API docs markdown — exported for the `sceneview://api` resource. */
@@ -212,8 +189,10 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
212
189
  `\`\`\`xml`,
213
190
  `<uses-permission android:name="android.permission.CAMERA" />`,
214
191
  `<uses-feature android:name="android.hardware.camera.ar" android:required="true" />`,
192
+ `<!-- On <manifest>: xmlns:tools="http://schemas.android.com/tools" -->`,
215
193
  `<application>`,
216
- ` <meta-data android:name="com.google.ar.core" android:value="required" />`,
194
+ ` <!-- arsceneview declares "optional": tools:replace overrides it (the merge fails without it) -->`,
195
+ ` <meta-data android:name="com.google.ar.core" android:value="required" tools:replace="android:value" />`,
217
196
  `</application>`,
218
197
  `\`\`\``,
219
198
  ].join("\n"),
@@ -544,7 +523,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
544
523
  ` directional()`,
545
524
  ` intensity(100_000.0)`,
546
525
  ` }`,
547
- ` model("models/DamagedHelmet.glb")`,
526
+ ` model("https://sceneview.github.io/models/platforms/moto_helmet_v2.glb") // Motorcycle Helmet by sayedgamal655, CC-BY 4.0`,
548
527
  ` autoRotate()`,
549
528
  ` },`,
550
529
  ` onReady = { sceneView ->`,
@@ -865,6 +844,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
865
844
  prompt: args?.prompt,
866
845
  imageUrl: args?.imageUrl,
867
846
  quality: args?.quality,
847
+ provider: args?.provider,
868
848
  });
869
849
  const genText = formatGenerateResult(genResult);
870
850
  return {
@@ -6,7 +6,7 @@
6
6
  * `handler.ts` directly.
7
7
  */
8
8
  export { TOOL_DEFINITIONS } from "./definitions.js";
9
- export { __resetSponsorCounter, API_DOCS, dispatchTool } from "./handler.js";
9
+ export { API_DOCS, dispatchTool } from "./handler.js";
10
10
  import { TOOL_DEFINITIONS } from "./definitions.js";
11
11
  /** Returns the full tool definition list (read-only copy). */
12
12
  export function getAllTools() {
package/dist/validator.js CHANGED
@@ -57,7 +57,7 @@ const RULES = [
57
57
  issues.push({
58
58
  severity: "warning",
59
59
  rule: "ar/node-not-anchor",
60
- message: "Manually setting `worldPosition` inside an AR scene causes drift — ARCore remaps coordinates during tracking and plain nodes don't compensate. Use `AnchorNode(anchor = hitResult.createAnchor())` instead.",
60
+ message: "Manually setting `worldPosition` inside an AR scene causes drift — ARCore remaps coordinates during tracking and plain nodes don't compensate. Use `AnchorNode(anchor = anchor)` instead, with `anchor` from `createAnchorOrNull()` on an in-polygon ARCore plane hit (`latestFrame?.hitTest(event)` in `onSingleTapConfirmed`).",
61
61
  line,
62
62
  });
63
63
  });
@@ -194,7 +194,7 @@ const RULES = [
194
194
  issues.push({
195
195
  severity: "error",
196
196
  rule: "ar/anchor-node-missing-anchor",
197
- message: "`AnchorNode()` requires an `anchor` from a hit result. Use `AnchorNode(anchor = hitResult.createAnchor())` inside `onTouchEvent` or `onSessionUpdated`.",
197
+ message: "`AnchorNode()` requires an `anchor`. Create it on a confirmed tap — `onGestureListener = rememberOnGestureListener(onSingleTapConfirmed = { event, node -> if (node == null) latestFrame?.hitTest(event)?.firstOrNull { (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true }?.createAnchorOrNull()?.let { anchor = it } })` — then declare `anchor?.let { AnchorNode(anchor = it) { … } }`.",
198
198
  line,
199
199
  });
200
200
  });
package/dist/widgets.js CHANGED
@@ -813,7 +813,12 @@ export const WIDGET_3D_VIEWER_HTML = `<!DOCTYPE html>
813
813
 
814
814
  function startWith(data, url) {
815
815
  if (viewer && typeof viewer.loadModel === "function") {
816
- viewer.loadModel(url).then(function () { reveal(data); }).catch(fail);
816
+ viewer.loadModel(url).then(function () { reveal(data); }).catch(function (err) {
817
+ // sceneview.js rejects a load that a later loadModel() replaced with an
818
+ // AbortError: the later render() owns the viewer, so this is not a failure.
819
+ if (err && err.name === "AbortError") return;
820
+ fail(err);
821
+ });
817
822
  return;
818
823
  }
819
824
  SceneView.modelViewer(canvas, url, {
@@ -834,6 +839,8 @@ export const WIDGET_3D_VIEWER_HTML = `<!DOCTYPE html>
834
839
  rendered = data;
835
840
  pending = null;
836
841
  loader.hidden = true;
842
+ // An error an earlier payload left must not sit over the model that loaded.
843
+ errorEl.hidden = true;
837
844
  canvas.style.opacity = "1";
838
845
  if (data.autoRotate === false && viewer && viewer.setAutoRotate) {
839
846
  viewer.setAutoRotate(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceneview-mcp",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "mcpName": "io.github.sceneview/mcp",
5
5
  "description": "MCP server for SceneView — cross-platform 3D & AR SDK for Android and iOS. Gives your AI coding assistant the full SceneView SDK so it writes correct, compilable code.",
6
6
  "keywords": [