When enabled the first scene will be loaded when the SceneSwitcher becomes active
the object this component is attached to. Note that this is a threejs Object3D with some additional features
the unique identifier for this component
how many scenes can be loaded in parallel
how many scenes after the currently active scene should be preloaded
how many scenes before the currently active scene should be preloaded
the url parameter that is set/used to store the currently loaded scene in, set to "" to disable
Optional
sourceholds the source identifier this object was created with/from (e.g. if it was part of a glTF file the sourceId holds the url to the glTF)
when enabled the new scene is pushed to the browser navigation history, only works with a valid query parameter set
when enabled you can switch between scenes using keyboard left, right, A and D or number keys
when enabled will automatically apply the environment scene lights
when enabled the scene name will be used as the query parameter (otherwise the scene index will be used)
Needs queryParameterName
set
when enabled you can switch between scenes using swipe (mobile only)
true if the object is enabled and active in the hierarchy
The index of the currently loaded and active scene
Get the progress of the currently loading scene. This is undefined if no scene is loading
You can also subscribe to the loading event by adding an event listener to the scene switcher.
For example like this sceneSwitcher.addEventListeneer("progress", (e) => {...})
true if this component was destroyed (this.destroy()
) or the whole object this component was part of
Forward (0,0,-1) vector in world space
Right (1,0,0) vector in world space
shorthand for this.context.scene
Up (0,1,0) vector in world space
Optional
earlyOptional
lateOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onCallback when this component joins a xr session (or becomes active in a running XR session)
Optional
onCallback when this component exists a xr session (or when it becomes inactive in a running XR session)
Optional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onCallback when a xr session updates (while it is still active in XR session)
Optional
onOptional
onXRControllerCallback when a controller is connected/added while in a XR session
OR when the component joins a running XR session that has already connected controllers
OR when the component becomes active during a running XR session that has already connected controllers
Optional
onXRControllerOptional
resolveOptional
startstarts a coroutine (javascript generator function)yield
will wait for the next frame:
yield WaitForSeconds(1)
to wait for 1 second.yield WaitForFrames(10)
to wait for 10 frames.yield new Promise(...)
to wait for a promise to resolve.generator function to start
event to register the coroutine for (default: FrameEvent.Update). Note that all coroutine FrameEvent callbacks are invoked after the matching regular component callbacks. For example FrameEvent.Update
will be called after regular component update()
methods)
the generator function (use it to stop the coroutine with stopCoroutine
)
onEnable() { this.startCoroutine(this.myCoroutine()); }
private *myCoroutine() {
while(this.activeAndEnabled) {
console.log("Hello World", this.context.time.frame);
// wait for 5 frames
for(let i = 0; i < 5; i++) yield;
}
}
Stop a coroutine that was previously started with startCoroutine
the routine to be stopped
the frame event to unregister the routine from (default: FrameEvent.Update)
Optional
supportsXROptional callback, you can implement this to only get callbacks for VR or AR sessions if necessary.
true if the mode is supported (if false the mode is not supported by this component and it will not receive XR callbacks for this mode)
Optional
updateGenerated using TypeDoc
Can be used to dynamically load and unload extra content
Available scenes are defined in the
scenes
array.events
loadscene-start
: Called when a scene starts loadingloadscene-finished
: Called when a scene finished loadingprogress
: Called when a scene is loading and the progress changes Subscribe to events like this:sceneSwitcher.addEventListener("loadscene-start", (e) => {...})