Gizmo

Gizmo

Abstract class for Gizmo. The workflow of gizmo adjustment is:

  1. gizmo.show(entity) //when entity is in focus
    • gizmo.addRenderable()
    • this._entityTransformComponent = entity.transformComponent
  2. gizmo.activate() //when start dragging gizmo
    • gizmo._setPlane()
    • gizmo._setLine()
  3. gizmo.process() //if gizmo is activated, call process() for each frame
    • delta(T/R/S)--> this._entityTransformComponent.transform
    • gizmo.updateTransform()
    • gizmo._postProcess()
  4. gizmo.deactivate() //when stop dragging gizmo
  5. gizmo.hide() //when entity is not in focus

Constructor

new Gizmo()

Members

onChange :Array.<function()>

Callbacks function in _postProcess()

renderables :Array.<Entity>

Renderable gizmo mesh entities

Methods

(static) buildMaterialForAxis(axis, opacity) → {Material}

build gizmo axis material

Parameters:
Name Type Description
axis string
opacity number

(static) getHandle(id) → {Object}

Get the handle based on id

Parameters:
Name Type Description
id number

(static) registerHandle(handle) → {number}

register gizmo handle

Parameters:
Name Type Description
handle Object

activate(properties)

Activate this gizmo when the dragging motion starts

Parameters:
Name Type Description
properties Object
Properties
Name Type Description
data Object

active handle information

id string

active handle id

color Array.<number>

active handle color

addRenderable(renderable, world)

Add the renderable gizmo mesh entities to this.renderables

Parameters:
Name Type Description
renderable Object

render info for a gizmo mesh component

world Entity

the world to create entity.

compileRenderables()

Build mesh and materials for the gizmo

copyTransform(transform)

Copy the transform from the target entity to the gizmo mesh entity

Parameters:
Name Type Description
transform Transform

world transform of target entity

deactivate()

Deactivate the gizmo when the dragging motion stops

getGizmoLocalToWorldPosition(local, world)

get world position of points in gizmo local space

Parameters:
Name Type Description
local Vector3
world Vector3

getRenderable(id) → {Entity|false}

Get gizmo mesh entity based on id

Parameters:
Name Type Description
id number

reset()

reset the gizmo mesh entity

setSnap(snap)

Turns snapping on or off

Parameters:
Name Type Description
snap boolean

show(entity)

Show the gizmo mesh entity

Parameters:
Name Type Description
entity Entity

target entity

updateTransforms()

Updates the transforms of the renderables of this gizmo mesh entity.
Scale adjustment is also performed.