Creates a new TransformGizmo object.
The application instance.
The camera component.
The render layer.
const gizmo = new pc.TransformGizmo(app, camera, layer);
Protected
_appInternal reference to the app containing the gizmo.
Protected
_cameraInternal reference to camera component to view the gizmo.
Private
_colorInternal color alpha value.
Protected
_coordInternal version of coordinate space. Defaults to GIZMO_WORLD.
Protected
_deviceInternal reference to the graphics device of the app.
Protected
_draggingInternal state for if the gizmo is being dragged.
Protected
_guideInternal version of the guide line color.
Private
_hoverInternal currently hovered axis.
Private
_hoverInternal state of if currently hovered shape is a plane.
Private
_hoverInternal currently hovered shape.
Protected
_layerInternal reference to layer to render the gizmo..
Protected
_meshInternal color for meshs.
Protected
_rootInternal gizmo starting rotation in world space.
Protected
_scaleInternal version of the gizmo scale. Defaults to 1.
Protected
_selectedInternal currently selected axis.
Protected
_selectedInternal state of if currently selected shape is a plane.
Protected
_selectionInternal selection starting angle in world space.
Protected
_selectionInternal selection starting coordinates in world space.
Private
_shapeInternal mapping of mesh instances to axis shapes.
Protected
_shapesInternal object containing the axis shapes to render.
Private
_snapInternal state for if snapping is enabled. Defaults to false.
The intersection data object.
The graph nodes attached to the gizmo.
The root gizmo entity.
Snapping increment. Defaults to 1.
The color alpha for all axes.
The gizmo size. Defaults to 1.
State for if snapping is enabled. Defaults to false.
X axis color.
Y axis color.
Z axis color.
Attach an array of graph nodes to the gizmo.
Optional
nodes: GraphNode[] = []The graph nodes. Defaults to [].
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.attach([boxA, boxB]);
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
obj.fire('test', 'This is the message');
Test if there are any handlers bound to an event name.
The name of the event to test.
True if the object has handlers bound to the specified event name.
obj.on('test', function () { }); // bind an event to 'test'
obj.hasEvent('test'); // returns true
obj.hasEvent('hello'); // returns false
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
obj.on('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
const evt = obj.on('test', function (a, b) {
console.log(a + b);
});
// some time later
evt.off();
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
obj.once('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
obj.fire('test', 1, 2); // not going to get handled
Static
EVENT_Fired when graph nodes are attached.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('nodes:attach', () => {
console.log('Graph nodes attached');
});
Static
EVENT_Fired when graph nodes are detached.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('nodes:detach', () => {
console.log('Graph nodes detached');
});
Static
EVENT_Fired when the pointer is down on the gizmo.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('pointer:down', (x, y, meshInstance) => {
console.log(`Pointer was down on ${meshInstance.node.name} at ${x}, ${y}`);
});
Static
EVENT_Fired when the pointer is moving over the gizmo.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('pointer:move', (x, y, meshInstance) => {
console.log(`Pointer was moving on ${meshInstance.node.name} at ${x}, ${y}`);
});
Static
EVENT_Fired when the pointer is up off the gizmo.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('pointer:up', (x, y, meshInstance) => {
console.log(`Pointer was up on ${meshInstance.node.name} at ${x}, ${y}`);
})
Static
EVENT_Fired when the gizmo's position is updated.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('position:update', (position) => {
console.log(`The gizmo's position was updated to ${position}`);
})
Static
EVENT_Fired when when the gizmo render has updated.
const gizmo = new pc.TransformGizmo(app, camera, layer);
gizmo.on('render:update', () => {
console.log('Gizmo render has been updated');
});
Static
EVENT_Fired when the gizmo's rotation is updated.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('rotation:update', (rotation) => {
console.log(`The gizmo's rotation was updated to ${rotation}`);
});
Static
EVENT_Fired when the gizmo's scale is updated.
const gizmo = new pc.Gizmo(app, camera, layer);
gizmo.on('scale:update', (scale) => {
console.log(`The gizmo's scale was updated to ${scale}`);
});
Static
EVENT_Fired when when the transformation has ended.
const gizmo = new pc.TransformGizmo(app, camera, layer);
gizmo.on('transform:end', () => {
console.log('Transformation ended');
});
Static
EVENT_Fired during the transformation.
const gizmo = new pc.TransformGizmo(app, camera, layer);
gizmo.on('transform:move', (pointDelta, angleDelta) => {
console.log('Transformation moved by ${pointDelta} (angle: ${angleDelta})');
});
Static
EVENT_Fired when when the transformation has started.
const gizmo = new pc.TransformGizmo(app, camera, layer);
gizmo.on('transform:start', () => {
console.log('Transformation started');
});
The base class for all transform gizmos.