Engine API Reference - v2.24.0-beta.28
    Preparing search index...

    Class ConeGizmo

    Draws a cone along its y-axis, with handles that drag its base radius and its height. A height edit keeps the center in place.

    const gizmo = new ConeGizmo(cameraComponent, layer);
    gizmo.on('handle:move', () => {
    collision.radius = gizmo.radius;
    collision.height = gizmo.height;
    });

    Relevant Engine API examples:

    Hierarchy (View Summary)

    Index
    _app: AppBase

    The app.

    The camera viewing the gizmo.

    _coordSpace: GizmoSpace = 'world'

    The coordinate space.

    The graphics device.

    _drag: GizmoHandle = ...

    The dragged handle, as it was at the start of the drag.

    _dragging: boolean = false

    Whether a handle is being dragged.

    _handles: EventHandle[] = []

    The app event handles.

    _layer: Layer

    The render layer.

    _mouseButtons: [boolean, boolean, boolean] = ...

    The mouse buttons that interact.

    _renderer: OverlayRenderer

    The overlay renderer.

    _scale: number = 1

    The gizmo scale.

    _theme: HandleGizmoTheme = ...

    Internal theme.

    handles: boolean = true

    Whether to show handles that edit the shapes. Defaults to true.

    height: number = 1

    The height of the cone. Defaults to 1.

    icon: boolean = true

    Whether to show an icon at each node. Defaults to true.

    intersectShapes: Shape[] = []

    The shapes the gizmo picks.

    nodes: GraphNode[] = []

    The graph nodes attached to the gizmo.

    position: Vec3 = ...

    The world position of the center of the shape.

    preventDefault: boolean = true

    Whether to call preventDefault on pointer events.

    radius: number = 0.5

    The radius of the base of the cone. Defaults to 0.5.

    readout: boolean = true

    Whether to show the value of a hovered or dragged handle. Defaults to true.

    root: Entity

    The root gizmo entity.

    rotation: Quat = ...

    The world rotation of the shape.

    snap: boolean = false

    Whether dragging snaps to the increments. Defaults to false.

    snapAngleIncrement: number = 5

    The increment angles snap to, in degrees. Defaults to 5.

    • get _requiresNodes(): boolean
      Protected

      Shape gizmos show without attached nodes.

      Returns boolean

    • get lineThickness(): number

      Gets the line thickness in CSS pixels.

      Returns number

    • set lineThickness(value: number): void

      Sets the line thickness in CSS pixels; dashed lines space their dashes to match. Defaults to 2.

      Parameters

      • value: number

      Returns void

    • get mouseButtons(): [boolean, boolean, boolean]

      The mouse buttons that interact with the gizmo, by button index: 0 left, 1 middle, 2 right.

      Returns [boolean, boolean, boolean]

    • 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 snapIncrement(): number

      Gets the increment lengths and ScaleGizmo factors snap to.

      Returns number

    • set snapIncrement(value: number): void

      Sets the increment lengths and ScaleGizmo factors snap to. Defaults to 1.

      Parameters

      • value: number

      Returns void

    • Protected

      Gets whether the handle editing a value is hovered or dragged.

      Parameters

      • node: GraphNode | null

        The node the handle edits, or null for a shape gizmo.

      • name: string

        The value the handle edits.

      • index: number

        The index of the handle among those editing the value.

      Returns boolean

      Whether the handle is active.

    • Protected

      Places the face and corner handles of the box last passed to HandleGizmo#_boxCorners, once large enough on screen.

      Parameters

      • center: Vec3

        The center of the box.

      • halfExtents: Vec3

        The half extents.

      • options: BoxHandleOptions

        The handles to show.

      • Optionalpad: number = 0

        The padding on each side, left out of the readout extents.

      Returns void

    • Protected

      Gets whether a shape is large enough on screen to show its handles.

      Parameters

      • center: Vec3

        The center of the shape.

      • radius: number

        The radius of the shape.

      Returns boolean

      Whether to show the details.

    • Protected

      Places a handle that drags along a line or in a plane, with a dashed guide from the origin while hovered or dragged.

      Parameters

      • position: Vec3

        The world position.

      • color: Color

        The color of the handle when hovered or dragged, and of its guide.

      • node: GraphNode | null

        The node the handle edits, or null for a shape gizmo.

      • name: string

        The value the handle edits.

      • index: number

        The index of the handle among those editing the value.

      • origin: Vec3

        A point the edit is measured from, on the line or plane.

      • dir: Vec3

        The unit direction of the line, or the normal of the plane.

      • OptionalinPlane: boolean = false

        Whether the handle moves in a plane.

      • Optionalguide: boolean = !inPlane

        Whether to show the dashed line. Defaults to true for a line.

      Returns boolean

      Whether the handle is hovered or dragged.

    • Protected

      Gets the normal of the plane through a line that best faces the camera, for dragging along the line.

      Parameters

      • dir: Vec3

        The unit direction of the line.

      • facing: Vec3

        The unit direction towards the camera.

      • out: Vec3

        Receives the unit normal.

      Returns boolean

      False when the line points at the camera.

    • Protected

      Shows the value of a hovered or dragged handle below it.

      Parameters

      • position: Vec3

        The handle position.

      • label: string

        The value label.

      • color: Color

        The label color.

      • value: number

        The value.

      • Optionalunit: string = ''

        The unit after the value.

      Returns void

    • Protected

      Formats a value with two decimals after a colored label.

      Parameters

      • label: string

        The label.

      • color: Color

        The label color.

      • value: number

        The value.

      • Optionalunit: string = ''

        The unit after the value.

      Returns string

      The markup.

    • Protected

      Resizes a box to a dragged HandleGizmo#_boxHandles handle, keeping the opposite face or corner in place, or the center for a centered box.

      Parameters

      • handle: GizmoHandle

        The dragged handle.

      • point: Vec3

        Where the handle is dragged to.

      • rotation: Quat

        The rotation of the box.

      • startPosition: Vec3

        The center at the start of the resize.

      • startHalfExtents: Vec3

        The half extents at the start of the resize.

      • options: BoxHandleOptions

        How the handles resize the box.

      • pad: number

        The padding on each side, left out of the snapped extents.

      • position: Vec3

        Receives the center.

      • halfExtents: Vec3

        Receives the half extents.

      Returns void

    • Protected

      Rounds a value to a multiple of an increment while snapping.

      Parameters

      • value: number

        The value.

      • increment: number

        The increment.

      Returns number

      The value, snapped while DragGizmo#snap is on.

    • Protected

      Places handles at the ends of a sphere's axes, which drag its radius.

      Parameters

      • center: Vec3

        The center of the sphere.

      • rotation: Quat

        The rotation of the axes.

      • radius: number

        The radius of the sphere.

      • node: GraphNode | null

        The node the handles edit, or null for a shape gizmo.

      • name: string

        The value the handles edit.

      Returns void

    • Protected

      Places the outline of a sphere, over faint great circles once large enough on screen, or solid rings when the camera is inside it.

      Parameters

      • center: Vec3

        The center of the sphere.

      • rotation: Quat

        The rotation of the great circles.

      • radius: number

        The radius of the sphere.

      Returns void

    • Protected

      Places three great circles of a sphere.

      Parameters

      • center: Vec3

        The center of the sphere.

      • rotation: Quat

        The rotation of the sphere.

      • radius: number

        The radius of the sphere.

      • Optionalweight: number = 1

        The thickness as a factor of the line thickness.

      • Optionalalpha: number = 1

        The alpha factor.

      Returns void

    • Detaches all graph nodes from the gizmo.

      Returns void

      const gizmo = new 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.

      Use this form to remove all listeners matching a name (and optionally callback/scope). To remove a single known subscription, prefer retaining the EventHandle returned by EventHandler#on / EventHandler#once and calling its EventHandle#off: it removes exactly that subscription and is faster (no scan of the callback list).

      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

      An event handle. For later removal, prefer retaining this handle and calling its EventHandle#off over EventHandler#off with a name/callback: it removes exactly this subscription and is faster (no scan of the callback list).

      obj.on('test', (a, b) => {
      console.log(a + b);
      });
      obj.fire('test', 1, 2); // prints 3 to the console
      // preferred removal: retain the handle and call off() on it
      const evt = obj.on('test', (a, b) => {
      console.log(a + b);
      });
      // some time later
      evt.off();
    • Attach an event handler to an event. The handler is removed before it is called, so it runs at most once, even if it fires the same event again or throws.

      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

      An event handle. For removal before it fires, prefer retaining this handle and calling its EventHandle#off over EventHandler#off with a name/callback: it removes exactly this subscription and is faster (no scan of the callback list).

      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
    • Sets the theme or partial theme for the gizmo.

      Parameters

      Returns void

      gizmo.setTheme({ occluded: new Color(1, 1, 1, 0.5) });
      
      // accents told apart without red and green
      gizmo.setTheme({
      primary: new Color(0.9, 0.6, 0),
      secondary: new Color(0.35, 0.7, 0.9),
      tertiary: new Color(0.8, 0.6, 0.7)
      });
    • Updates the gizmo position, rotation, and scale.

      Returns void

      const gizmo = new Gizmo(camera, layer);
      gizmo.attach([boxA, boxB]);
      gizmo.update();
    • Creates a new gizmo layer and adds it to the scene.

      Parameters

      • app: AppBase

        The app.

      • OptionallayerName: string = 'Gizmo'

        The layer name. Defaults to 'Gizmo'.

      • OptionallayerIndex: number = app.scene.layers.layerList.length

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

      • Optionaldepth: boolean = false

        Whether the layer keeps the scene depth and sorts transparent mesh instances manually, as overlay gizmos need so occluded parts draw faint. Otherwise it clears depth and draws on top, as transform gizmos need. Defaults to false.

      Returns Layer

      The new layer.

      const layer = Gizmo.createLayer(app, 'Overlays', undefined, true);
      
    EVENT_HANDLEEND: string = 'handle:end'

    Fired when a handle stops being dragged.

    const gizmo = new pc.LightGizmo(camera, layer);
    gizmo.on('handle:end', (node, name) => {
    console.log(`Finished editing ${name} of ${node.name}`);
    });
    EVENT_HANDLEMOVE: string = 'handle:move'

    Fired when a dragged handle edits its value.

    const gizmo = new pc.LightGizmo(camera, layer);
    gizmo.on('handle:move', (node, name) => {
    console.log(`Edited ${name} of ${node.name}`);
    });
    EVENT_HANDLESTART: string = 'handle:start'

    Fired when a handle starts being dragged.

    const gizmo = new pc.LightGizmo(camera, layer);
    gizmo.on('handle:start', (node, name) => {
    console.log(`Started editing ${name} of ${node.name}`);
    });
    EVENT_ICONSELECT: string = 'icon:select'

    Fired when the icon of a node is clicked.

    const gizmo = new pc.LightGizmo(camera, layer);
    gizmo.on('icon:select', (node) => {
    console.log(`Clicked the icon of ${node.name}`);
    });
    EVENT_NODESATTACH: string = 'nodes:attach'

    Fired when graph nodes are attached.

    const gizmo = new 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 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 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 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 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 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 the gizmo render has updated.

    const gizmo = new 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 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 Gizmo(camera, layer);
    gizmo.on('scale:update', (scale) => {
    console.log(`The gizmo's scale was updated to ${scale}`);
    });