RCP 3 Script Graphs in 27.0 appear to be JavaScript-backed and hot-reloadable. SceneKit historically exposed its scene graph to JavaScript via JavaScriptCore, so Apple has bridged a 3D framework to JS before. Questions about the runtime surface:
-
Is there a public runtime API to evaluate JavaScript against a RealityKit scene, or to drive Script Graph behavior programmatically at runtime — or is the JS layer private SPI used only by RCP-authored, baked graphs?
-
If there's a runtime JS layer, what object model is exposed — which entity/component types are bridged, and is that surface documented or intended to become public?
-
What's the hot-reload mechanism, and is it reachable outside RCP's Preview on Device?
-
Can a script graph be constructed or parameterized at runtime from a string, or is authoring strictly RCP-side with baked output loaded as an asset?
We ship JavaScript scripting via JavaScriptCore ourselves, so a public RealityKit-to-JS binding would be a natural way to extend it — trying to understand what's public vs. private and the intended direction.
Hi @arthurfromberlin! You can check the new RealityKitScripting Swift Package we just released.
It will allow you to evaluate your JS against RealityKit. This is a public Swift Package and you can load your script at runtime from a string.
Something similar to:
import RealityKit
struct ContentView: View {
let script = """
const RealityKit = require("RealityKit");
const Math3D = require("Math3D");
this.update = function(deltaTime) {
const rotation = new Math3D.Quaternion(deltaTime * Math.PI, new Math3D.Vector3(0, 1, 0));
this.entity.orientation.multiply(rotation);
};
this.didAdd = function() {
console.log(`Script attached to: "${this.entity.name}"`);
};
"""
var body: some View {
RealityView { content in
let entity = ModelEntity(mesh: .generateBox(size: 0.2), materials: [SimpleMaterial(color: .blue, isMetallic: false)])
entity.name = "Box"
entity.components.set(ScriptingComponent(source: script))
content.add(entity)
}
.scriptingSystem()
}
}