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/dist/samples.js
CHANGED
|
@@ -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:
|
|
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
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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,8 +314,10 @@ 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 =
|
|
320
|
+
orbitHomePosition = Position(z = 4f),
|
|
291
321
|
targetPosition = Position(0f)
|
|
292
322
|
)
|
|
293
323
|
) {
|
|
@@ -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
|
}
|
|
@@ -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
|
|
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: `@
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
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
|
}
|
|
@@ -1268,7 +1294,7 @@ fun NodeHierarchyScreen() {
|
|
|
1268
1294
|
title: "iOS 3D Model Viewer",
|
|
1269
1295
|
description: "SwiftUI 3D scene with a USDZ model, IBL environment, orbit camera, and animation playback.",
|
|
1270
1296
|
tags: ["3d", "model", "environment", "camera", "animation", "ios", "swift"],
|
|
1271
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1297
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1272
1298
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1273
1299
|
prompt: "Create a SwiftUI screen that loads a USDZ model and displays it with IBL lighting, orbit camera, and animation playback. Use SceneViewSwift.",
|
|
1274
1300
|
language: "swift",
|
|
@@ -1307,7 +1333,7 @@ struct ModelViewerScreen: View {
|
|
|
1307
1333
|
title: "iOS AR Tap-to-Place Model Viewer",
|
|
1308
1334
|
description: "AR scene with plane detection. Tap a surface to place a 3D model using ARKit + RealityKit.",
|
|
1309
1335
|
tags: ["ar", "model", "anchor", "plane-detection", "placement", "ios", "swift"],
|
|
1310
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1336
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1311
1337
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1312
1338
|
prompt: "Create an iOS AR screen that detects surfaces and lets the user tap to place a USDZ model. Use SceneViewSwift.",
|
|
1313
1339
|
language: "swift",
|
|
@@ -1347,7 +1373,7 @@ struct ARModelViewerScreen: View {
|
|
|
1347
1373
|
title: "iOS AR Augmented Image",
|
|
1348
1374
|
description: "Detects reference images in the camera feed and overlays 3D content above them using ARKit.",
|
|
1349
1375
|
tags: ["ar", "model", "image-tracking", "ios", "swift"],
|
|
1350
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1376
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1351
1377
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1352
1378
|
prompt: "Create an iOS AR screen that detects a printed reference image and places a 3D model above it. Use SceneViewSwift.",
|
|
1353
1379
|
language: "swift",
|
|
@@ -1385,7 +1411,7 @@ struct AugmentedImageScreen: View {
|
|
|
1385
1411
|
title: "iOS Procedural Geometry",
|
|
1386
1412
|
description: "Procedural geometry shapes — cube, sphere, cylinder, cone, and plane — with PBR materials.",
|
|
1387
1413
|
tags: ["3d", "geometry", "ios", "swift"],
|
|
1388
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1414
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1389
1415
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1390
1416
|
prompt: "Create a SwiftUI scene showing procedural geometry shapes (cube, sphere, cylinder, cone, plane) with different materials. Use SceneViewSwift.",
|
|
1391
1417
|
language: "swift",
|
|
@@ -1439,7 +1465,7 @@ struct GeometryShapesScreen: View {
|
|
|
1439
1465
|
title: "iOS Lighting",
|
|
1440
1466
|
description: "Directional, point, and spot lights with configurable intensity, color, and shadows.",
|
|
1441
1467
|
tags: ["3d", "lighting", "environment", "ios", "swift"],
|
|
1442
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1468
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1443
1469
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1444
1470
|
prompt: "Create a SwiftUI 3D scene with directional, point, and spot lights illuminating geometry. Use SceneViewSwift.",
|
|
1445
1471
|
language: "swift",
|
|
@@ -1503,7 +1529,7 @@ struct LightingScreen: View {
|
|
|
1503
1529
|
title: "iOS Physics Demo",
|
|
1504
1530
|
description: "Interactive physics simulation with bouncing spheres, gravity, and configurable restitution.",
|
|
1505
1531
|
tags: ["3d", "physics", "geometry", "ios", "swift"],
|
|
1506
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1532
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1507
1533
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1508
1534
|
prompt: "Create a SwiftUI 3D scene where tapping spawns coloured spheres that fall under gravity and bounce off a floor. Use SceneViewSwift.",
|
|
1509
1535
|
language: "swift",
|
|
@@ -1567,7 +1593,7 @@ struct PhysicsDemoScreen: View {
|
|
|
1567
1593
|
title: "iOS 3D Text Labels",
|
|
1568
1594
|
description: "Camera-facing 3D text labels using TextNode and BillboardNode for always-facing-camera behavior.",
|
|
1569
1595
|
tags: ["3d", "text", "geometry", "ios", "swift"],
|
|
1570
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1596
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1571
1597
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1572
1598
|
prompt: "Create a SwiftUI 3D scene with floating text labels that always face the camera, showing planet names. Use SceneViewSwift.",
|
|
1573
1599
|
language: "swift",
|
|
@@ -1615,7 +1641,7 @@ struct TextLabelsScreen: View {
|
|
|
1615
1641
|
title: "iOS Video on 3D Surface",
|
|
1616
1642
|
description: "Video playback on a 3D plane using VideoNode with play/pause controls.",
|
|
1617
1643
|
tags: ["3d", "video", "ios", "swift"],
|
|
1618
|
-
dependency: `https://github.com/sceneview/sceneview —
|
|
1644
|
+
dependency: `https://github.com/sceneview/sceneview — exact: "4.68.0"`,
|
|
1619
1645
|
spmDependency: "https://github.com/sceneview/sceneview",
|
|
1620
1646
|
prompt: "Create a SwiftUI 3D scene with a video playing on a floating 3D plane. Include play/pause controls. Use SceneViewSwift.",
|
|
1621
1647
|
language: "swift",
|
|
@@ -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:
|
|
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
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
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
|
-
|
|
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(
|
|
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/
|
|
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/
|
|
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()
|
package/dist/server.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
21
21
|
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
22
|
-
import { buildDiscoverResult, DiscoverRequestSchema, SERVER_CAPABILITIES, SERVER_INFO, } from "./discover.js";
|
|
22
|
+
import { buildDiscoverResult, DiscoverRequestSchema, SERVER_CAPABILITIES, SERVER_INFO, SERVER_INSTRUCTIONS, } from "./discover.js";
|
|
23
23
|
import { DEMO_WITH_SETTINGS_EXAMPLE, SKETCHFAB_STREAMING_EXAMPLE } from "./examples.js";
|
|
24
24
|
import { LATEST_SCENEVIEW_RELEASE } from "./generated/version.js";
|
|
25
25
|
import { fetchKnownIssues } from "./issues.js";
|
|
@@ -57,7 +57,7 @@ export function createSceneViewServer(options = {}) {
|
|
|
57
57
|
// `SERVER_INFO` / `SERVER_CAPABILITIES` live in `./discover.ts` so the
|
|
58
58
|
// handshake and `server/discover` answer the identity/capability question the
|
|
59
59
|
// same way, from one source.
|
|
60
|
-
const server = new Server({ ...SERVER_INFO }, { capabilities: { ...SERVER_CAPABILITIES } });
|
|
60
|
+
const server = new Server({ ...SERVER_INFO }, { capabilities: { ...SERVER_CAPABILITIES }, instructions: SERVER_INSTRUCTIONS });
|
|
61
61
|
// ─── server/discover (MCP 2026-07-28) ──────────────────────────────────────
|
|
62
62
|
//
|
|
63
63
|
// Handshake-free discovery: answered before `initialize`, with no session and
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function validateSpec(spec) {
|
|
2
|
+
if (spec.v !== 1)
|
|
3
|
+
throw new Error("Spatial answer v must be 1.");
|
|
4
|
+
if (spec.object?.kind !== "box" ||
|
|
5
|
+
!Array.isArray(spec.object.sizeM) ||
|
|
6
|
+
spec.object.sizeM.length !== 3 ||
|
|
7
|
+
spec.object.sizeM.some((s) => typeof s !== "number" || !Number.isFinite(s) || s <= 0.01 || s > 10)) {
|
|
8
|
+
throw new Error("Each box size must be a finite number greater than 0.01 and at most 10 metres (greater than 1 and at most 1000 cm).");
|
|
9
|
+
}
|
|
10
|
+
if (typeof spec.label !== "string" || Array.from(spec.label).length > 60) {
|
|
11
|
+
throw new Error("label must be a string of at most 60 characters.");
|
|
12
|
+
}
|
|
13
|
+
if (spec.placement !== "floor" && spec.placement !== "table") {
|
|
14
|
+
throw new Error('placement must be "floor" or "table".');
|
|
15
|
+
}
|
|
16
|
+
if (!["user", "estimated", "measured"].includes(spec.dimensionSource)) {
|
|
17
|
+
throw new Error('dimensionSource must be "user", "estimated" or "measured".');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Convert centimetres supplied by the assistant into the shared app spec. */
|
|
21
|
+
export function buildSpatialAnswerSpec(input) {
|
|
22
|
+
const sizes = [input.widthCm, input.heightCm, input.depthCm];
|
|
23
|
+
if (sizes.some((s) => typeof s !== "number" || !Number.isFinite(s) || s <= 1 || s > 1000)) {
|
|
24
|
+
throw new Error("widthCm, heightCm and depthCm must each be a finite number greater than 1 and at most 1000 cm.");
|
|
25
|
+
}
|
|
26
|
+
const dimensionSource = input.dimensionSource === undefined ? "user" : input.dimensionSource;
|
|
27
|
+
if (dimensionSource !== "user" && dimensionSource !== "estimated") {
|
|
28
|
+
throw new Error('dimensionSource must be "user" or "estimated".');
|
|
29
|
+
}
|
|
30
|
+
const spec = {
|
|
31
|
+
v: 1,
|
|
32
|
+
object: {
|
|
33
|
+
kind: "box",
|
|
34
|
+
sizeM: sizes.map((s) => s / 100),
|
|
35
|
+
},
|
|
36
|
+
dimensionSource,
|
|
37
|
+
placement: (input.placement === undefined
|
|
38
|
+
? "floor"
|
|
39
|
+
: input.placement),
|
|
40
|
+
label: input.label,
|
|
41
|
+
};
|
|
42
|
+
validateSpec(spec);
|
|
43
|
+
return spec;
|
|
44
|
+
}
|
|
45
|
+
/** UTF-8 JSON, base64url without padding; enforce the app's payload limit. */
|
|
46
|
+
export function encodeSpatialAnswer(spec) {
|
|
47
|
+
validateSpec(spec);
|
|
48
|
+
const encoded = Buffer.from(JSON.stringify(spec), "utf8").toString("base64url");
|
|
49
|
+
if (encoded.length > 2048)
|
|
50
|
+
throw new Error("Encoded spatial answer payload must be at most 2048 characters.");
|
|
51
|
+
return encoded;
|
|
52
|
+
}
|
|
53
|
+
export function spatialAnswerUrl(spec) {
|
|
54
|
+
return `https://sceneview.github.io/open?demo=spatial-answer&answer=${encodeSpatialAnswer(spec)}`;
|
|
55
|
+
}
|
|
@@ -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 (
|
|
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
|
|
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
|
|
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: [],
|
|
@@ -767,6 +772,69 @@ export const TOOL_DEFINITIONS = [
|
|
|
767
772
|
title: "Fetch an Android doc",
|
|
768
773
|
},
|
|
769
774
|
},
|
|
775
|
+
{
|
|
776
|
+
name: "show_in_space",
|
|
777
|
+
description: "Use when the user wants to see an object of given size in their room at real scale: furniture, a box, a parcel or a TV. Returns one link opening the Spatial answer in the SceneView Android app; without the app, the web page shows the size and offers the app. Represents the object's bounding box using the sizes the user said (dimensionSource: user) or the assistant estimated (estimated). No fit detection and no accuracy claim. Dimensions are width, height, depth in centimetres.",
|
|
778
|
+
inputSchema: {
|
|
779
|
+
type: "object",
|
|
780
|
+
properties: {
|
|
781
|
+
widthCm: {
|
|
782
|
+
type: "number",
|
|
783
|
+
exclusiveMinimum: 1,
|
|
784
|
+
maximum: 1000,
|
|
785
|
+
description: "Width in centimetres, left to right as you face the object (a desk's length).",
|
|
786
|
+
},
|
|
787
|
+
heightCm: {
|
|
788
|
+
type: "number",
|
|
789
|
+
exclusiveMinimum: 1,
|
|
790
|
+
maximum: 1000,
|
|
791
|
+
description: "Height in centimetres, from the floor or table up.",
|
|
792
|
+
},
|
|
793
|
+
depthCm: {
|
|
794
|
+
type: "number",
|
|
795
|
+
exclusiveMinimum: 1,
|
|
796
|
+
maximum: 1000,
|
|
797
|
+
description: "Depth in centimetres, front to back.",
|
|
798
|
+
},
|
|
799
|
+
label: {
|
|
800
|
+
type: "string",
|
|
801
|
+
maxLength: 60,
|
|
802
|
+
description: 'Short name shown with the box, e.g. "Desk" or "55-inch TV".',
|
|
803
|
+
},
|
|
804
|
+
placement: {
|
|
805
|
+
type: "string",
|
|
806
|
+
enum: ["floor", "table"],
|
|
807
|
+
default: "floor",
|
|
808
|
+
description: "Where the object stands: on the floor (furniture) or on a table (a parcel, a speaker).",
|
|
809
|
+
},
|
|
810
|
+
dimensionSource: {
|
|
811
|
+
type: "string",
|
|
812
|
+
enum: ["user", "estimated"],
|
|
813
|
+
default: "user",
|
|
814
|
+
description: '"user" when the user gave the sizes, "estimated" when you estimated them (say so in your answer).',
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
required: ["widthCm", "heightCm", "depthCm", "label"],
|
|
818
|
+
additionalProperties: false,
|
|
819
|
+
},
|
|
820
|
+
outputSchema: {
|
|
821
|
+
type: "object",
|
|
822
|
+
properties: {
|
|
823
|
+
url: { type: "string" },
|
|
824
|
+
label: { type: "string" },
|
|
825
|
+
sizeCm: { type: "array", items: { type: "number" }, minItems: 3, maxItems: 3 },
|
|
826
|
+
placement: { type: "string", enum: ["floor", "table"] },
|
|
827
|
+
},
|
|
828
|
+
required: ["url", "label", "sizeCm", "placement"],
|
|
829
|
+
additionalProperties: false,
|
|
830
|
+
},
|
|
831
|
+
annotations: {
|
|
832
|
+
readOnlyHint: true,
|
|
833
|
+
openWorldHint: false,
|
|
834
|
+
destructiveHint: false,
|
|
835
|
+
title: "Show in space",
|
|
836
|
+
},
|
|
837
|
+
},
|
|
770
838
|
{
|
|
771
839
|
name: "view_3d_model",
|
|
772
840
|
description: "Render an interactive 3D model viewer inline in the conversation. Pass a public GLB / GLTF / 3MF URL and the assistant will display it in a SceneView-branded widget with orbit controls, auto-rotate, and AR mode (where supported). Use this when the user asks to PREVIEW a 3D model, asks 'what does X look like in 3D?', after `search_models` to render the chosen result, or to show a `.3mf` you just produced for 3D printing — the widget converts 3MF to glTF in the browser, so a printable model is previewable without any download.",
|