Engine API Reference - v2.6.1
    Preparing search index...

    Class ScaleGizmo

    Scaling gizmo.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _app: AppBase

    Internal reference to the app containing the gizmo.

    Internal reference to camera component to view the gizmo.

    _coordSpace: string = GIZMOSPACE_LOCAL

    Internal version of coordinate space. Defaults to GIZMOSPACE_WORLD.

    Internal reference to the graphics device of the app.

    _dragging: boolean = false

    Internal state for if the gizmo is being dragged.

    _guideColors: Record<string, Color> = ...

    Internal version of the guide line color.

    _layer: Layer

    Internal reference to layer to render the gizmo..

    _meshColors: {
        axis: Record<string, Color>;
        disabled: Color;
        hover: Record<string, Color>;
    } = ...

    Internal color for meshes.

    _rootStartPos: Vec3 = ...

    Internal gizmo starting rotation in world space.

    _rootStartRot: Quat = ...

    Internal gizmo starting rotation in world space.

    _scale: number = 1

    Internal version of the gizmo scale. Defaults to 1.

    _selectedAxis: string = ''

    Internal currently selected axis.

    _selectedIsPlane: boolean = false

    Internal state of if currently selected shape is a plane.

    _selectionStartPoint: Vec3 = ...

    Internal selection starting coordinates in world space.

    _shading: boolean = false

    Internal state of if shading is enabled. Defaults to true.

    _shapes: {
        x: BoxLineShape;
        xy: PlaneShape;
        xyz: BoxShape;
        xz: PlaneShape;
        y: BoxLineShape;
        yz: PlaneShape;
        z: BoxLineShape;
    } = ...

    Internal object containing the gizmo shapes to render.

    _useUniformScaling: boolean = false

    Internal state if transform should use uniform scaling.

    flipShapes: boolean = true

    Flips the planes to face the camera.

    intersectShapes: Shape[] = []

    The intersection shapes for the gizmo.

    lowerBoundScale: Vec3 = ...

    The lower bound for scaling.

    nodes: GraphNode[] = []

    The graph nodes attached to the gizmo.

    root: Entity

    The root gizmo entity.

    snapIncrement: number = 1

    Accessors

    • get colorAlpha(): number

      Gets the color alpha for all axes.

      Returns number

    • set colorAlpha(value: number): void

      Sets the color alpha for all axes.

      Parameters

      • value: number

      Returns void

    • get shading(): boolean

      Gets whether shading are enabled. Defaults to true.

      Returns boolean

    • set shading(value: boolean): void

      Sets whether shading are enabled. Defaults to true.

      Parameters

      • value: boolean

      Returns void

    • get size(): number

      Gets the gizmo size.

      Returns number

    • set size(value: number): void

      Sets the gizmo size. Defaults to 1.

      Parameters

      • value: number

      Returns void

    • get snap(): boolean

      Gets whether snapping is enabled. Defaults to false.

      Returns boolean

    • set snap(value: boolean): void

      Sets whether snapping is enabled. Defaults to false.

      Parameters

      • value: boolean

      Returns void

    Methods

    • Detaches all graph nodes from the gizmo.

      Returns void

      const gizmo = new pc.Gizmo(camera, layer);
      gizmo.attach([boxA, boxB]);
      gizmo.detach();
    • Fire an event, all additional arguments are passed on to the event listener.

      Parameters

      • name: string

        Name of event to fire.

      • Optionalarg1: any

        First argument that is passed to the event handler.

      • Optionalarg2: any

        Second argument that is passed to the event handler.

      • Optionalarg3: any

        Third argument that is passed to the event handler.

      • Optionalarg4: any

        Fourth argument that is passed to the event handler.

      • Optionalarg5: any

        Fifth argument that is passed to the event handler.

      • Optionalarg6: any

        Sixth argument that is passed to the event handler.

      • Optionalarg7: any

        Seventh argument that is passed to the event handler.

      • Optionalarg8: any

        Eighth argument that is passed to the event handler.

      Returns EventHandler

      Self for chaining.

      obj.fire('test', 'This is the message');
      
    • Test if there are any handlers bound to an event name.

      Parameters

      • name: string

        The name of the event to test.

      Returns boolean

      True if the object has handlers bound to the specified event name.

      obj.on('test', () => {}); // 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.

      Parameters

      • Optionalname: string

        Name of the event to unbind.

      • Optionalcallback: HandleEventCallback

        Function to be unbound.

      • Optionalscope: any

        Scope that was used as the this when the event is fired.

      Returns EventHandler

      Self for chaining.

      const handler = () => {};
      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.

      Parameters

      • name: string

        Name of the event to bind the callback to.

      • callback: HandleEventCallback

        Function that is called when event is fired. Note the callback is limited to 8 arguments.

      • Optionalscope: any = ...

        Object to use as 'this' when the event is fired, defaults to current this.

      Returns EventHandle

      Can be used for removing event in the future.

      obj.on('test', (a, b) => {
      console.log(a + b);
      });
      obj.fire('test', 1, 2); // prints 3 to the console
      const evt = obj.on('test', (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.

      Parameters

      • name: string

        Name of the event to bind the callback to.

      • callback: HandleEventCallback

        Function that is called when event is fired. Note the callback is limited to 8 arguments.

      • Optionalscope: any = ...

        Object to use as 'this' when the event is fired, defaults to current this.

      Returns EventHandle

      • can be used for removing event in the future.
      obj.once('test', (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
    • Creates a new gizmo layer and adds it to the scene.

      Parameters

      • app: AppBase

        The app.

      • OptionallayerName: string = LAYER_NAME

        The layer name. Defaults to 'Gizmo'.

      • OptionallayerIndex: number

        The layer index. Defaults to the end of the layer list.

      Returns Layer

      The new layer.

    Events

    EVENT_NODESATTACH: string = 'nodes:attach'

    Fired when graph nodes are attached.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('nodes:attach', () => {
    console.log('Graph nodes attached');
    });
    EVENT_NODESDETACH: string = 'nodes:detach'

    Fired when graph nodes are detached.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('nodes:detach', () => {
    console.log('Graph nodes detached');
    });
    EVENT_POINTERDOWN: string = 'pointer:down'

    Fired when the pointer is down on the gizmo.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('pointer:down', (x, y, meshInstance) => {
    console.log(`Pointer was down on ${meshInstance.node.name} at ${x}, ${y}`);
    });
    EVENT_POINTERMOVE: string = 'pointer:move'

    Fired when the pointer is moving over the gizmo.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('pointer:move', (x, y, meshInstance) => {
    console.log(`Pointer was moving on ${meshInstance.node.name} at ${x}, ${y}`);
    });
    EVENT_POINTERUP: string = 'pointer:up'

    Fired when the pointer is up off the gizmo.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('pointer:up', (x, y, meshInstance) => {
    console.log(`Pointer was up on ${meshInstance.node.name} at ${x}, ${y}`);
    })
    EVENT_POSITIONUPDATE: string = 'position:update'

    Fired when the gizmo's position is updated.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('position:update', (position) => {
    console.log(`The gizmo's position was updated to ${position}`);
    })
    EVENT_RENDERUPDATE: string = 'render:update'

    Fired when when the gizmo render has updated.

    const gizmo = new pc.TransformGizmo(camera, layer);
    gizmo.on('render:update', () => {
    console.log('Gizmo render has been updated');
    });
    EVENT_ROTATIONUPDATE: string = 'rotation:update'

    Fired when the gizmo's rotation is updated.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('rotation:update', (rotation) => {
    console.log(`The gizmo's rotation was updated to ${rotation}`);
    });
    EVENT_SCALEUPDATE: string = 'scale:update'

    Fired when the gizmo's scale is updated.

    const gizmo = new pc.Gizmo(camera, layer);
    gizmo.on('scale:update', (scale) => {
    console.log(`The gizmo's scale was updated to ${scale}`);
    });
    EVENT_TRANSFORMEND: string = 'transform:end'

    Fired when when the transformation has ended.

    const gizmo = new pc.TransformGizmo(camera, layer);
    gizmo.on('transform:end', () => {
    console.log('Transformation ended');
    });
    EVENT_TRANSFORMMOVE: string = 'transform:move'

    Fired during the transformation.

    const gizmo = new pc.TransformGizmo(camera, layer);
    gizmo.on('transform:move', (pointDelta, angleDelta) => {
    console.log('Transformation moved by ${pointDelta} (angle: ${angleDelta})');
    });
    EVENT_TRANSFORMSTART: string = 'transform:start'

    Fired when when the transformation has started.

    const gizmo = new pc.TransformGizmo(camera, layer);
    gizmo.on('transform:start', () => {
    console.log('Transformation started');
    });