Optional
args: ContextArgsAn alias for the context
access animation mixer used by components in the scene
AssetDataBase is deprecated
access networking methods (use it to send or listen to messages or join a networking backend)
The <needle-engine>
web component
Optional
hashused to append to loaded assets
When the renderer or camera are managed by an external process (e.g. when running in r3f context).
When this is false you are responsible to call update(timestamp, xframe.
It is also currently assumed that rendering is handled performed by an external process
set to true to pause the update loop. You can receive an event for it in your components. Note that script updates will not be called when paused
The main camera component of the scene - this camera is used for rendering
Optional
maxClamps the renderer max resolution. If undefined the max resolution is not clamped. Default is undefined
The name of the context
access physics related methods (e.g. raycasting). To access the phyiscs engine use context.physics.engine
Readonly
post_called every frame after rendering (after all component events)
Readonly
post_callbacks called once after the context has been created
Readonly
pre_called every frame before rendering (after all component events)
Readonly
pre_called every frame at the beginning of the frame (after component start events and before earlyUpdate)
Readonly
pre_called every frame befroe update (this list is emptied every frame)
When enabled the application will run while not visible on the page
Optional
targetSet to the target framerate you want your application to run in (you can use ?stats to check the fps) Set to undefined if you want to run at the maximum framerate
Optional
value?: numberaccess timings (current frame number, deltaTime, timeScale, ...)
shorthand for NeedleXRSession.active
Automatically set by NeedleXRSession when a XR session is active
the active XR session or null if no session is active
Current event of the update cycle
The height of the <needle-engine>
element on the website
The width of the <needle-engine>
element on the website
the X position of the Needle Engine element on the website
the Y position of the Needlee Engine element on the website
If a XR session is active and in pass through mode (immersive-ar on e.g. Quest)
returns true if the dom element is visible on screen
The main camera of the scene - this camera is used for rendering
Set the main camera of the scene. If set to null the camera of the mainCameraComponent will be used - this camera is used for rendering
Use sceneLighting
use to scale the resolution up or down of the renderer. default is 1
The needle engine version
the current WebXR camera while the WebXRManager is active (shorthand for context.renderer.xr.getCamera()
)
the latest XRFrame (if a XRSession is currently active)
access the raw XRSession
object (shorthand for context.renderer.xr.getSession()
). For more control use NeedleXRSession.active
Static
CurrentStatic
DefaultWhen a new context is created this is the framerate that will be used by default
When a new context is created this is the framerate that will be used by default
Static
DefaultThe default parameters that will be used when creating a new WebGLRenderer.
Modify in global context to change the default parameters for all new contexts.
import { Context } from "@needle-tools/engine";
Context.DefaultWebGLRendererParameters.antialias = false;
use this to subscribe to onAfterRender events on threejs objects
use this to subscribe to onBeforeRender events on threejs objects
Optional
opts: ContextCreateArgsOptional
opts: ContextCreateArgsuse create. This method will be removed in a future version
Optional
cam: CameraOptional
camera: CameraOptional
width: numberOptional
height: numberCall to manually perform physics steps.
By default the context uses the physicsSteps
property to perform steps during the update loop
If you just want to increase the accuracy of physics you can instead set the physicsSteps
property to a higher value
Generated using TypeDoc
The context is the main object that holds all the data and state of the Needle Engine.
It can be used to access the scene, renderer, camera, input, physics, networking, and more.
Example