Skip to main content

Runtime API

The Runtime API exposes everything you could possibly want to access within the Webaverse runtime. This includes access to crypto minting, the world scene, camera, physics, and more.

You can call these directly within your app without any extra requirements on your end. This is because the Runtime API is exposed to your code at runtime.

renderer

This provides a THREE.js renderer at runtime that can be used to setAnimationLoop on.

camera

This provides a THREE.js camera at runtime.

crypto

mintToken

Parameters

NameTypeDescription
fileblobThe data of the file to be tokenized
optionsobjectYou can define the description of the token here

Returns

NameTypeDescription
tokenIdnumberThe id of the newly minted token

physics

addGeometry

Parameters

NameType
meshmesh

removeGeometry

Parameters

NameType
physicsIdnumber

getRigTransforms

Returns

[
{
position: this.localRig.inputs.leftGamepad.position,
quaternion: this.localRig.inputs.leftGamepad.quaternion,
},
{
position: this.localRig.inputs.rightGamepad.position,
quaternion: this.localRig.inputs.rightGamepad.quaternion,
},
];

app

object.add

Parameters

NameType
meshmesh

files[]

This is a map of relative file URL -> file load URL you can fetch.

No matter how you are loading the package, whether it is an XRPK or a URL or an NFT, this map should let you access all of the app's files.

Note: Files in this map are prefixed with ./


unload

This is an event that gets emitted when the app instance is deleted. You should clean up anything you app is doing here, such as removing physics, objects, timers, etc.

Note: The app.object will be automatically removed from the scene so there is no need to clean up that.


onBeforeRender()

This is a function to run alongside anything you want to run before rendering.

Note: If you do mirror rendering, it should occur between onBeforeRender and onAfterRender to ensure proper recursion.


onAfterRender()

This is a function to run alongisde anyhting you want to run after rendering.


runtime

loadFile

Parameters

NameType
filefile
optsobject

world

object

app.object is a THREE.js object where you should attach your app (using app.object.add, see below), this should be used instead of a scene.

addObject

Parameters

NameType
contentIdnumber or URL
parentIdnumber
positionTHREE.Vector3
quaternionTHREE.Quaternion
optionsobject