Returns the active client pixel ratio as updated on the last render.
Sets the client pixel ratio, will be updated on the next render.
Gets parentElement.clientHeight. Differs from canvas.width if window.devicePixelRatio set
Gets parentElement.clientWidth. Differs from canvas.width if window.devicePixelRatio set
The root dom element for the control. Either a canvas or a div containing a canvas
Enable or disable logging Cogs heapsize every 5 seconds.
Gets Cogs Resources
Gets Cogs Runtime
Gets Cogs Scene
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Optional
options: boolean | AddEventListenerOptionsDispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Gets the XR control module. 'any' for now until IControlXR have been finalized.
Called to shut down Cogs.js, free memory including WEB Assembly. This instance cannot be used after release() called.
Releases the XR control module to disable XR
Removes the event listener in target's event listener list with the same type, callback, and options.
Optional
options: boolean | EventListenerOptionsRequest full screen. Currently not tested in any example. API can only be initiated by a user gesture.
True if lock
True if resize.
Resize control. This is for the contents. This typically need to match the canvas size which is set separately.
Control width pixels
Control height pixels
Enable continuous rendering after startup by passing true. Cogs will redraw the display when needed. Use carefully as enabling will consume a lot of resources. Use triggerUpdate() for manual display redraw.
True if enabled
Sets XR control from the external CogsXR package. 'any' for now until IControlXR have been finalized.
Optional
force: booleanStatic
createFactory method for creating a new Cogs control. See
Parameters for control initialization.
Created control
control = await Cogs.Control.create({
parent: parentElement,
onInitialized: function () {
runtime = control.runtime;
runtime.Cube.create();
const cameraController = runtime.OrbitingCameraController.create();
runtime.scene.camera.components.add(cameraController);
},
print: function (text) {
console.log(text);
}
});
parent.appendChild(control.domElement);
A Cogs control tells which canvas we're drawing to. Multiple controls requires separate instances of Cogs New instances are created using
See
Call
class Control is an