the object this component is attached to. Note that this is a threejs Object3D with some additional features
the unique identifier for this component
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)
true if the object is enabled and active in the hierarchy
The camera's aspect ratio (width divided by height) if it is a perspective camera
The blurriness of the background texture (when using a skybox)
The background color of the camera when ClearFlags are set to SolidColor
The intensity of the background texture (when using a skybox)
the rotation of the background texture (when using a skybox)
The camera's clear flags - determines if the background is a skybox or a solid color or transparent
Set only a specific layer active to be rendered by the camera.
This is equivalent to calling layers.set(val)
The mask
value of the three camera object layers
If you want to just see objects on one layer (e.g. layer 2) then you can use cullingLayer = 2
on this camera component instead
true if this component was destroyed (this.destroy()
) or the whole object this component was part of
The intensity of the environment map
The camera's far clipping plane
The camera's field of view in degrees if it is a perspective camera
the layer of the gameObject this component is attached to
the name of the gameObject this component is attached to
The camera's near clipping plane
shorthand for this.context.scene
the scene of the context
Is the gameObject marked as static
the tag of the gameObject this component is attached to
The texture that the camera should render to It can be used to render to a Texture instead of the screen.
Creates a PerspectiveCamera if it does not exist yet and set the camera's properties. This is internally also called when accessing the cam property.
Optional
earlyOptional
forceUpdate: booleanthis camera's projection screen matrix.
Optional
lateOptional
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
updateStatic
backgroundUsed to determine if the background should be transparent when in pass through AR
true when in XR on a pass through device where the background shouldbe invisible
Generated using TypeDoc
Needle Engine component base class. Component's are the main building blocks of the Needle Engine.
Derive from Behaviour to implement your own using the provided lifecycle methods.
Components can be added to threejs objects using
{@link addComponent}
or{@link GameObject.addComponent}
The most common lifecycle methods are
awake
,start
,onEnable
,onDisable
update
andonDestroy
.XR specific callbacks include
onEnterXR
,onLeaveXR
,onUpdateXR
,onControllerAdded
andonControllerRemoved
.To receive pointer events implement
onPointerDown
,onPointerUp
,onPointerEnter
,onPointerExit
andonPointerMove
.Example