Tempusxr Français
Menu
  1. Docs
  2. Build with the SDK

Open a scene file in A-Frame

A scene file runs in an A-Frame page with one attribute. It is the same JSON that loadScene and the Viewer open, drawn by the A-Frame scene of your page. You write HTML, no JavaScript.

A first example

<script src="aframe.min.js"></script>
<script src="tempusxr-aframe.min.js"></script>
<script src="tempusxr-tracker-image.min.js"></script>
<script src="tempusxr-aframe-scene.min.js"></script>

<a-scene tempusxr-scene="src: scene.json" renderer="alpha: true" vr-mode-ui="enabled: false">
  <a-camera look-controls="enabled: false" wasd-controls="enabled: false"></a-camera>
</a-scene>

Load the script of the tracker the scene needs (image, world or both), then the scene script last. The page shows a loading line, then a Start button. The tap on Start is what lets a phone play sound and video.

Try it: open the A-Frame scene page, or give it your own file with ?scene=your.json.

The attribute

PropertyWhat it does
srcThe address of the scene file. Default scene.json.
gateShow the loading line and the Start button. Default true. With false the experience starts as soon as it is loaded.
dracoPathThe folder of the Draco decoder files, for models with Draco geometry.
basisPathThe folder of the Basis transcoder files, for models with KTX2 textures.

What you can do with it

Everything the scene format says works the same as with loadScene: models and animations, images, videos, sound, text, behaviors, buttons, hotspots, virtual buttons, the 3D viewer of a world scene and its View in AR button, and walls. The scene decides, not the page.

Photos and videos work too. Add the capture scripts and the attribute tempusxr-capture:

<a-scene tempusxr-scene="src: scene.json" tempusxr-capture="video: true; microphone: true"></a-scene>

Events and the experience

On the <a-scene> element:

How it is built

The scene loader is the one of loadScene, with loadScene({ host }) giving it the A-Frame scene instead of a Three.js session of its own. The scene script uses the Three.js that A-Frame already carries, so nothing is loaded twice. The glTF, Draco and KTX2 loaders are A-Frame's own.

The same scene file therefore gives three pages: the Viewer page, a Three.js page and an A-Frame page.