XRServer
Server for AR and VR features.
XRServer.swift:20class XRServer
The AR/VR server is the heart of our Advanced and Virtual Reality solution and handles all the processing.
This object emits the following signals:
Superclasses
class Object
Base class for all other classes in the engine.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
enum RotationMode
class Signal1
Signal support.
class Signal2
Signal support.
class Signal3
Signal support.
class Signal4
Signal support.
class Signal5
Signal support.
enum TrackerType
Type members
static var primaryInterface: XRInterface?
The primary
XRInterface
currently bound to theXRServer
.static var worldOrigin: Transform3D
The current origin of our tracking space in the virtual world. This is used by the renderer to properly position the camera with new tracking data.
static var worldScale: Double
Allows you to adjust the scale to your game’s units. Most AR/VR platforms assume a scale of 1 game world unit = 1 real world meter.
static func addInterface(XRInterface?
) Registers an
XRInterface
object.static func addTracker(XRPositionalTracker?
) Registers a new
XRPositionalTracker
that tracks a spatial location in real space.static func centerOnHmd(rotationMode: XRServer.RotationMode, keepHeight: Bool
) This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
static func findInterface(name: String
) -> XRInterface? Finds an interface by its
name
. For example, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it.static func getHmdTransform(
) -> Transform3D Returns the primary interface’s transformation.
static func getInterface(idx: Int32
) -> XRInterface? Returns the interface registered at the given
idx
index in the list of interfaces.static func getInterfaceCount(
) -> Int32 Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns
true
.static func getInterfaces(
) -> VariantCollection<GDictionary> Returns a list of available interfaces the ID and name of each interface.
static func getReferenceFrame(
) -> Transform3D Returns the reference frame transform. Mostly used internally and exposed for GDExtension build interfaces.
static func getTracker(trackerName: StringName
) -> XRPositionalTracker? Returns the positional tracker with the given
trackerName
.static func getTrackers(trackerTypes: Int32
) -> GDictionary Returns a dictionary of trackers for
trackerTypes
.static func removeInterface(XRInterface?
) Removes this
interface
.static func removeTracker(XRPositionalTracker?
) Removes this positional
tracker
.class var godotClassName: StringName
Instance members
var interfaceAdded: Signal1
Emitted when a new interface has been added.
var interfaceRemoved: Signal2
Emitted when an interface is removed.
var trackerAdded: Signal3
Emitted when a new tracker has been added. If you don’t use a fixed number of controllers or if you’re using
XRAnchor3D
s for an AR solution, it is important to react to this signal to add the appropriateXRController3D
orXRAnchor3D
nodes related to this new tracker.var trackerRemoved: Signal5
Emitted when a tracker is removed. You should remove any
XRController3D
orXRAnchor3D
points if applicable. This is not mandatory, the nodes simply become inactive and will be made active again when a new tracker becomes available (i.e. a new controller is switched on that takes the place of the previous one).var trackerUpdated: Signal4
Emitted when an existing tracker has been updated. This can happen if the user switches controllers.