API

Interface IBoundingBoxGizmo

Interface for bounding box gizmo

interface IBoundingBoxGizmo {
    _rootMesh: Mesh;
    additionalTransformNode?: TransformNode;
    anchorPoint: GizmoAnchorPoint;
    attachedMesh: Nullable<AbstractMesh>;
    attachedNode: Nullable<Node>;
    axisFactor: Vector3;
    coloredMaterial: StandardMaterial;
    coordinatesMode: GizmoCoordinatesMode;
    customRotationQuaternion: Nullable<Quaternion>;
    fixedDragMeshBoundsSize: boolean;
    fixedDragMeshScreenSize: boolean;
    fixedDragMeshScreenSizeDistanceFactor: number;
    gizmoLayer: UtilityLayerRenderer;
    hoverMaterial: StandardMaterial;
    ignoreChildren: boolean;
    includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
    isDragging: boolean;
    isHovered: boolean;
    onDragStartObservable: Observable<
        { dragAxis: Vector3; dragOperation: DragOperation },
    >;
    onHoverEndObservable: Observable<void>;
    onHoverStartObservable: Observable<void>;
    onRotationSphereDragEndObservable: Observable<
        { dragAxis: Vector3; dragOperation: DragOperation },
    >;
    onRotationSphereDragObservable: Observable<
        { dragAxis: Vector3; dragOperation: DragOperation },
    >;
    onScaleBoxDragEndObservable: Observable<
        { dragAxis: Vector3; dragOperation: DragOperation },
    >;
    onScaleBoxDragObservable: Observable<
        { dragAxis: Vector3; dragOperation: DragOperation },
    >;
    rotationSnapDistance: number;
    rotationSphereSize: number;
    scaleBoxSize: number;
    scaleDragSpeed: number;
    scalePivot: Nullable<Vector3>;
    scaleRatio: number;
    scalingSnapDistance: number;
    updateGizmoPositionToMatchAttachedMesh: boolean;
    updateGizmoRotationToMatchAttachedMesh: boolean;
    updateScale: boolean;
    dispose(): void;
    enableDragBehavior(): void;
    getScaleBoxes(): AbstractMesh[];
    releaseDrag(): void;
    setColor(color: Color3): void;
    setCustomMesh(mesh: Mesh): void;
    setEnabledRotationAxis(axis: string): void;
    setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
    updateBoundingBox(): void;
}

Hierarchy (View Summary)

Implemented by

Index
_rootMesh: Mesh

The root mesh of the gizmo

additionalTransformNode?: TransformNode

Additional transform applied to the gizmo. It's useful when the gizmo is attached to a bone: if the bone is part of a skeleton attached to a mesh, you should define the mesh as additionalTransformNode if you want the gizmo to be displayed at the bone's correct location. Otherwise, as the gizmo is relative to the skeleton root, the mesh transformation will not be taken into account.

anchorPoint: GizmoAnchorPoint

Defines where the gizmo will be positioned if updateGizmoPositionToMatchAttachedMesh is enabled. (Default: GizmoAnchorPoint.Origin)

attachedMesh: Nullable<AbstractMesh>

Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)

  • When set, interactions will be enabled
attachedNode: Nullable<Node>

Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)

  • When set, interactions will be enabled
axisFactor: Vector3

Scale factor vector used for masking some axis

coloredMaterial: StandardMaterial

Default material used to render when gizmo is not disabled or hovered

coordinatesMode: GizmoCoordinatesMode

Set the coordinate mode to use. By default it's local.

customRotationQuaternion: Nullable<Quaternion>

Orientation that the gizmo will be displayed with. When set null, default value will be used (Quaternion(0, 0, 0, 1))

fixedDragMeshBoundsSize: boolean

If set, the rotation anchors and scale boxes will increase in size based on the size of the bounding box Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true

fixedDragMeshScreenSize: boolean

If set, the rotation anchors and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true

fixedDragMeshScreenSizeDistanceFactor: number

The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true

The utility layer the gizmo will be added to

hoverMaterial: StandardMaterial

Material used to render when gizmo is hovered with mouse

ignoreChildren: boolean

If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes.

includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>

Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored.

isDragging: boolean

True when a rotation anchor or scale box or a attached mesh is dragged

isHovered: boolean

True when the mouse pointer is hovered a gizmo mesh

onDragStartObservable: Observable<
    { dragAxis: Vector3; dragOperation: DragOperation },
>

Fired when a rotation anchor or scale box is dragged

onHoverEndObservable: Observable<void>

Fired when the gizmo mesh hovering ends

onHoverStartObservable: Observable<void>

Fired when the gizmo mesh hovering starts

onRotationSphereDragEndObservable: Observable<
    { dragAxis: Vector3; dragOperation: DragOperation },
>

Fired when a rotation anchor drag is ended

onRotationSphereDragObservable: Observable<
    { dragAxis: Vector3; dragOperation: DragOperation },
>

Fired when a rotation anchor is dragged

onScaleBoxDragEndObservable: Observable<
    { dragAxis: Vector3; dragOperation: DragOperation },
>

Fired when a scale box drag is ended

onScaleBoxDragObservable: Observable<
    { dragAxis: Vector3; dragOperation: DragOperation },
>

Fired when a scale box is dragged

rotationSnapDistance: number

Drag distance in babylon units that the gizmo will snap rotation to when dragged

rotationSphereSize: number

The size of the rotation anchors attached to the bounding box

scaleBoxSize: number

The size of the scale boxes attached to the bounding box

scaleDragSpeed: number

Scale factor scalar affecting all axes' drag speed

scalePivot: Nullable<Vector3>

Relative bounding box pivot used when scaling the attached node.

scaleRatio: number

Ratio for the scale of the gizmo

scalingSnapDistance: number

Drag distance in babylon units that the gizmo will snap scaling to when dragged

updateGizmoPositionToMatchAttachedMesh: boolean

If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)

updateGizmoRotationToMatchAttachedMesh: boolean

If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)

updateScale: boolean

When set, the gizmo will always appear the same size no matter where the camera is (default: true)

  • Enables rotation on the specified axis and disables rotation on the others

    Parameters

    • axis: string

      The list of axis that should be enabled (eg. "xy" or "xyz")

    Returns void

  • Enables/disables scaling

    Parameters

    • enable: boolean

      if scaling should be enabled

    • OptionalhomogeneousScaling: boolean

      defines if scaling should only be homogeneous

    Returns void