Sceneview

From sceneview/sceneview · View interactive version

Sceneview is an AI agent skill from the GitHub repository sceneview/sceneview. Build 3D and AR with SceneView for Android (Jetpack Compose, Filament, ARCore), web and Compose Multiplatform desktop. SwiftUI, Flutter and React Native are end of life at 4.68.0; their retained references are for existing users only. Skip Unity, Unreal and raw rendering API work.

How to use this skill

Skill file

End of life: SceneView for SwiftUI (SceneViewSwift), Flutter (flutter_sceneview) and React Native (@sceneview-sdk/react-native). 4.68.0 (November 2026) is the last release. No new releases. Published versions stay installable. See DEPRECATION.md.

Android (Jetpack Compose), web, and Compose Multiplatform desktop are maintained. Android is Stable; web and desktop are Alpha. Do not recommend the retired packages for new code.

What SceneView is

SceneView is a declarative 3D and AR SDK. One mental model across every platform:

Filament renderer. Artifacts: io.github.sceneview:sceneview:4.74.0 and

io.github.sceneview:arsceneview:4.74.0.

views from the CODE0 monorepo

via Swift Package Manager (tag 4.68.0). RealityKit renderer.

(io.github.sceneview:sceneview-compose). Android and desktop use Filament.

Viewer subset only — model, orbit camera, key light, environment, tap.

No AR, no custom materials, no post-processing. The retained iOS host

requires end-of-life SceneViewSwift 4.68.0 and app-side renderer registration.

sceneview-compose is the Compose Multiplatform viewer façade with its own API; Android io.github.sceneview.* code needs io.github.sceneview:sceneview for 3D or io.github.sceneview:arsceneview for AR.

Nodes are declared as composables / SwiftUI views inside the parent SceneView's

trailing content. No imperative scene.addChild(node).

Authoritative API reference

Always treat llms.txt in the repo root as the source of truth. It carries the

full SceneView / ARSceneView signatures, every node type, every helper. URL:

<https://github.com/sceneview/sceneview/blob/main/llms.txt>

Repo-side samples/android-demo/src/main/java/io/github/sceneview/demo/demos/

contains a working demo for every node type — when in doubt, read the demo, do

NOT improvise an API.

When to use this skill

Trigger on any of:

Skip for plain ARCore-SDK, Sceneform (deprecated), Unity, Unreal, or RealityKit

projects that do NOT use the SceneViewSwift wrapper.

Open any 3D file — Android

Use one entry point for every supported mesh format. Put the file under src/main/assets/,

or pass a content://, file:// or HTTPS location to the same helper:

rememberModelInstance(modelLoader, "models/part.stl", unit = ModelUnit.Millimeters).

Import io.github.sceneview.core.model.ModelUnit. ModelLoader.supportedFormats contains

GLB, GLTF, THREE_MF, STL, OBJ, PLY_MESH (ModelFormat in the same package).

| Format | Unit used in the scene | Colours / textures | One-liner (inside a composable) |

|---|---|---|---|

| .glb | Metres, fixed by glTF | glTF materials and textures | rememberModelInstance(modelLoader, "model.glb") |

| .gltf | Metres, fixed by glTF | glTF materials and sibling textures/buffers | rememberModelInstance(modelLoader, "model.gltf") |

| .3mf | Declared unit → metres; Z-up → Y-up | Object/triangle colours; no textures | rememberModelInstance(modelLoader, "print.3mf") |

| .stl (ASCII / binary) | Millimetres by default; override with unit | Grey mesh; no textures | rememberModelInstance(modelLoader, "part.stl", unit = ModelUnit.Millimeters) |

| .obj | Millimetres by default; override with unit | Grey automatically; ObjLoader with an MTL resolver reads colours; no textures | rememberModelInstance(modelLoader, "part.obj", unit = ModelUnit.Inches) |

| .ply mesh (ASCII / binary) | Millimetres by default; override with unit | Vertex RGBA; no textures | rememberModelInstance(modelLoader, "scan.ply", unit = ModelUnit.Meters) |

ModelUnit offers Meters, Centimeters, Millimeters, Inches. It only changes unitless

STL/OBJ/PLY meshes. GLB/glTF stay in metres and 3MF retains its declared unit even when unit is

passed. Real size: omit scaleToUnits (or pass null), keep the default node scale of 1;

scaleToUnits = 1f fits the model into a one-metre box and discards its authored size.

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import io.github.sceneview.SceneView
import io.github.sceneview.core.model.ModelUnit
import io.github.sceneview.rememberEngine
import io.github.sceneview.rememberModelInstance
import io.github.sceneview.rememberModelLoader

@Composable
fun RealSizeStlViewer() {
    val engine = rememberEngine()
    val modelLoader = rememberModelLoader(engine)
    val instance = rememberModelInstance(modelLoader, "models/part.stl", unit = ModelUnit.Millimeters)
    SceneView(modifier = Modifier.fillMaxSize(), engine = engine, modelLoader = modelLoader) {
        instance?.let { ModelNode(modelInstance = it, scaleToUnits = null) }
    }
}

For AR at real size, use the same instance in PlacementScene's named onPlaced callback:

AnchorNode(anchor = anchor) { ModelNode(modelInstance = instance, scaleToUnits = null) }.

Unsupported on Android: STEP, FBX and USDZ (and unknown inputs) are refused before Filament

parses them, with io.github.sceneview.core.model.UnsupportedModelFormat(extension): thrown by

createModel* and awaitModelInstance, so

rememberModelLoadState(modelLoader, location, unit = ModelUnit.Millimeters) shows it as

ModelLoadState.Failed.error. rememberModelInstance, the suspend loadModel /

loadModelInstance / loadInstancedModel and the *Async callbacks log it and return null

(or an empty instance list), as for a file a converter cannot parse.

ModelFormat.sniff(fileName: String?, head: ByteArray) also recognises PLY_SPLAT and SPZ,

but they require SplatNode / SplatParser, not mesh loading: they are excluded from

supportedFormats and refused by ModelConverter / ModelLoader with the same typed error.

For raw bytes in shared Kotlin code, use ModelConverter.toGlb(bytes, format, unit) from

io.github.sceneview.core.model, after ModelFormat.sniff(fileName, bytes). Recognisable bytes

win over a wrong extension; the extension is the fallback. Supply the complete file for 3MF's

ZIP-directory check and binary STL's length/count check. A bare .ply extension defaults to

mesh; its header distinguishes Gaussian splats. GLB is returned without copying. JSON glTF is

wrapped in a GLB JSON chunk; its resource URIs are retained and must still be resolved.

The shared API runs on Kotlin platforms; Apple Swift and the web JavaScript APIs retain their

own entry points and format support (see their sections below).

Compose Multiplatform: `SceneViewer` (viewer subset, unreleased)

sceneview-compose is the only way to write one 3D composable in commonMain. It is

not a portable replacement for SceneView { } — it covers the model-viewer case and

stops there, on purpose.

Choose it only when the ask is genuinely shared-source. If the app is Android-only,

or needs AR, custom materials or post-processing, use the platform-native API instead;

this façade will not grow to cover them.

// commonMain — compiles on Android, iOS and Desktop
SceneViewer(
    model = ModelSource.Asset("models/toy_car.glb"),
    modifier = Modifier.fillMaxSize(),
    camera = rememberCameraState(distance = 4f),
    lighting = Lighting(intensity = 100_000f, castShadows = true),
    environment = EnvironmentSource.Default,
    onTap = { hit -> if (hit != null) println("hit at ${hit.position}") },
    onError = { error -> println("load failed: ${error.message}") },
)

Rules an agent must not get wrong:

or Url(url). Url accepts http/https only and throws IllegalArgumentException

on anything else, in commonMain, on every platform.

Only Asset resolves sibling .bin/texture files. A .gltf with external resources

passed as Bytes loads incomplete and silently.

indistinguishable from a load still in progress. Pass onError — without it the only

trace is the platform log under the SceneViewer tag. It fires both for an exception

(missing asset, HTTP error) and for a malformed model Filament refuses to parse, where

SceneViewerError.cause is null.

must register SceneViewerBridge.factory once at launch — a KMP module cannot depend

on a Swift Package. Desktop draws a visible placeholder; it is not wired yet. On an

unwired platform this never throws and never shows an empty viewport.

Android reads slightly differently on iOS. That is a property of the façade.

The minimal correct Android example

Verified against samples/android-demo/.../ModelViewerDemo.kt:

@Composable
fun ModelViewerDemo() {
    val engine = rememberEngine()
    val modelLoader = rememberModelLoader(engine)
    val environmentLoader = rememberEnvironmentLoader(engine)
    val modelInstance = rememberModelInstance(modelLoader, "models/helmet.glb")

    SceneView(
        modifier = Modifier.fillMaxSize(),
        engine = engine,
        modelLoader = modelLoader,
        environmentLoader = environmentLoader,
    ) {
        modelInstance?.let { instance ->
            ModelNode(
                modelInstance = instance,
                scaleToUnits = 0.3f,
            )
        }
    }
}

AR tap-to-place is the same shape with ARSceneView. Verified against

samples/android-demo/.../ARPlacementDemo.kt:

@Composable
fun ARPlacementDemo() {
    val engine = rememberEngine()
    val modelLoader = rememberModelLoader(engine)
    val placedAnchors = remember { mutableStateListOf<Anchor>() }
    var latestFrame by remember { mutableStateOf<Frame?>(null) }

    ARSceneView(
        modifier = Modifier.fillMaxSize(),
        engine = engine,
        modelLoader = modelLoader,
        planeRenderer = true,
        sessionConfiguration = { _, config ->
            config.planeFindingMode = Config.PlaneFindingMode.HORIZONTAL_AND_VERTICAL
            config.lightEstimationMode = Config.LightEstimationMode.ENVIRONMENTAL_HDR
        },
        onSessionUpdated = { _, frame -> latestFrame = frame },
        onGestureListener = rememberOnGestureListener(
            onSingleTapConfirmed = { event, node ->
                if (node != null) return@rememberOnGestureListener
                val frame = latestFrame ?: return@rememberOnGestureListener
                val hit = frame.hitTest(event).firstOrNull {
                    it.trackable is Plane && (it.trackable as Plane).isPoseInPolygon(it.hitPose)
                }
                hit?.createAnchor()?.let { placedAnchors.add(it) }
            }
        ),
    ) {
        placedAnchors.forEach { anchor ->
            key(anchor) {
                AnchorNode(anchor = anchor) {
                    rememberModelInstance(modelLoader, "models/helmet.glb")?.let { instance ->
                        ModelNode(modelInstance = instance, scaleToUnits = 0.3f, isEditable = true)
                    }
                }
            }
        }
    }
}

Note: ARSceneView takes a sessionConfiguration: (Session, Config) -> Unit

lambda — there is NO rememberARSession() helper, do NOT invent one.

AnchorNode takes a com.google.ar.core.Anchor instance; create one via

hit.createAnchor() after a hit-test on the latest Frame.

Critical rules (verified — do not break)

  1. rememberModelInstance returns nullable. First recomposition returns

null while loading. Always guard with ?.let { … } or ?:. Never !!.

  1. Filament JNI is main-thread-only. The remember* helpers handle this.

For imperative code use modelLoader.loadModelInstanceAsync (see

llms.txt § Threading rules).

  1. LightNode accepts both top-level params and apply = { … } for builder

extras. The canonical form for intensity/color/direction is top-level

(verified against LightingDemo.kt):

```kotlin

LightNode(

type = LightManager.Type.POINT,

intensity = 30_000f,

direction = Direction(-x, -y, -z),

position = Position(x, y, z),

color = colorOf(r = 1.0f, g = 0.95f, b = 0.8f),

apply = { falloff(6f) }, // only Filament-builder extras go here

)

```

type is com.google.android.filament.LightManager.Type (DIRECTIONAL,

POINT, FOCUSED_SPOT, SPOT, SUN).

  1. AR anchors come from ARCore. Build an AnchorNode with a real

com.google.ar.core.Anchor from hit.createAnchor(). There are NO

AnchorNode.image() / .face() / .plane() factory functions on Android

in v4.2 — use AugmentedImageNode for tracked images and

AugmentedFaceNode for face meshes (both in arsceneview package).

  1. SceneView vs ARSceneView ship in different artifacts. Don't mix.

3D-only → io.github.sceneview:sceneview. AR → io.github.sceneview:arsceneview

(it transitively includes sceneview).

  1. .3mf needs no special handling — do not write any. A 3MF (what ChatGPT and

every slicer emit for a printable model) goes through the same

rememberModelInstance / loadModel* call as a GLB: ModelLoader detects it by

its ZIP magic and converts it to GLB in memory (#3482). Never branch on the file

extension or the MIME type to decide — Android reports neither reliably, and a

shared .3mf routinely arrives as application/octet-stream with no name at all.

If you genuinely need to identify a buffer, ThreeMfLoader.isThreeMf(bytes) in

sceneview-core reads the bytes, on every platform. See

references/recipes.md § Recipe: open a .3mf print. The conversion also scales

the file's declared unit to metres and rotates the printer's Z-up to Y-up, so a

60 mm print is life-size and upright in AR — never add a scale factor of your own

to "fix" it.

  1. Use the same model entry point for GLB/glTF, 3MF, STL, OBJ and PLY meshes on Android.

The "Open any 3D file" section above lists units and limits. STEP/FBX/USDZ are refused with

UnsupportedModelFormat; Gaussian PLY/SPZ need SplatNode. Apple and web keep their own

format support; do not infer their capabilities from Android's supportedFormats.

  1. Don't recompose-thrash the loaders. rememberEngine / rememberModelLoader

/ rememberMaterialLoader / rememberEnvironmentLoader belong at the top of

the screen-level composable, NOT inside scroll lists or item composables.

Performance / hot paths

A SceneView renders on demand by default (4.38.0+). isRendering is gone;

frameRatePolicy = FrameRatePolicy.OnDemand() is the default, Continuous() is the

old every-vsync behaviour, and maxFps caps either mode. The library tracks what

changes the picture, so never generate a hand-rolled dirty flag — but a write made

straight into Filament (a MaterialInstance parameter, a light through LightManager,

a Skybox / IndirectLight, bone or morph writes) is invisible to it and needs

node.requestRender() or rememberRenderInvalidator() after it. A recomposition is

not a change, and ARSceneView takes no policy. Details:

CODE0 § Rendering cadence.

**Never call a decomposing or allocating getter inside onFrame (or any 30–60 Hz

loop).** Set the whole node.transform = … once instead of writing position /

quaternion / scale one at a time (one-at-a-time writes recompose the matrix and

drift — issue #2187); use

Mat4.copyColumnsInto(scratch) not Mat4.toColumnsFloatArray() for per-frame uniform

uploads; prefer the TRS-tuple slerp(startPosition, startQuaternion, startScale, …)

when you already hold the components. Reading node.worldPosition /

worldQuaternion per frame is fine now — those are cached. Always load via

rememberModelInstance / rememberNode (cached + main-thread). Full table:

CODE0 § Hot Paths & Allocation-Free APIs

(audit umbrella #2263).

Toolchain pairing

This skill is most useful paired with the android-cli skill:

Measured three times in this repo (#2796, #2854, #2990) — most recently on

CLI 1.0.15498356, where it printed App loaded: and

Debuggable: true, then rejected an activity the platform resolves fine, and

installed nothing — leaving an older build on the device while a QA run

measured it. Install with adb install -r APK and launch with

adb shell am start -n PKG/.MainActivity, then confirm the device's

lastUpdateTime actually moved (adb shell dumpsys package PKG). An install

step that reports success is not evidence the binary on the device is yours.

--screenshot=ui.png --string="tap #N"` — visual UI testing of a 3D scene.

reports as a single AndroidView, so for in-3D tap targets you still need

pointerInput / hit testing).

Haptic feedback

io.github.sceneview.haptic.SceneViewHaptic wraps Android's Vibrator

behind seven semantic presets plus low-level escape hatches. Get an

instance with rememberHapticFeedback() inside a @Composable; it is a

silent no-op (one Log.d, never throws) when the device has no vibrator or

the consumer app omits the permission.

import io.github.sceneview.haptic.rememberHapticFeedback

@Composable
fun PlaceAnchorButton(onPlace: () -> Unit) {
    val haptic = rememberHapticFeedback()
    Button(onClick = { haptic.medium(); onPlace() }) { Text("Place") }
}

selection(). Escape hatches: continuous(intensity, durationMs) and

pattern(events). cancel() stops an in-progress vibration —

rememberHapticFeedback() calls it automatically on dispose.

<uses-permission android:name="android.permission.VIBRATE" /> to its

manifest — the sceneview library does not auto-merge it.

(sceneview.haptic.*). See llms.txt § Haptic Feedback.

Resources

helper, with their actual signatures pulled from llms.txt.

samples/android-demo/ for each of the 13 canonical patterns. Read the demo

file, copy from it. Do not improvise.

CODE0

for the full rename map.

Workflow guidance

When the user asks for a SceneView feature:

  1. Confirm the platform. Android / iOS / Web / Flutter / RN — don't assume.
  2. Pick the right entrypoint. SceneView { } for 3D-only,

ARSceneView { } for AR. Mention the matching Gradle artifact.

  1. Read the matching demo in samples/android-demo/.../demos/ before

writing code. If you can't find one, fall back to llms.txt. Never

invent an API.

  1. Use the remember* helpers at the top of the composable. Never call

raw constructors for Engine / ModelLoader.

  1. Handle the null from rememberModelInstance with ?.let { … }.
  2. For AR, arsceneview already declares Manifest.permission.CAMERA

and the com.google.ar.core <meta-data> as optional. An AR Optional

app declares

<uses-feature android:name="android.hardware.camera.ar" android:required="false" />

and

<uses-feature android:name="android.hardware.camera" android:required="false" />.

An AR Required app overrides the <meta-data> with

tools:replace="android:value" (see llms.txt § Setup); without it the

manifest merger fails.

  1. Never write the SceneView 2.x API from memory — 2.x code may still compile,

with deprecation warnings, but always write the 4.x form: Scene(childNodes = …)

is SceneView { … }, ARScene(childNodes = …) is ARSceneView { … }, and

rememberNodes / childNodes = listOf(…) become ModelNode(…) declared inside

the block. If the user pastes 2.x / 3.x code,

point them at

CODE0

and the local CODE0.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.