@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
143 lines (142 loc) • 5.75 kB
TypeScript
import type { Observer } from "../Misc/observable.js";
import { Observable } from "../Misc/observable.js";
import type { Nullable } from "../types.js";
import type { PointerInfo } from "../Events/pointerEvents.js";
import { Vector3 } from "../Maths/math.vector.js";
import type { AbstractMesh } from "../Meshes/abstractMesh.js";
import type { Node } from "../node.js";
import { Mesh } from "../Meshes/mesh.js";
import { StandardMaterial } from "../Materials/standardMaterial.js";
import { PointerDragBehavior } from "../Behaviors/Meshes/pointerDragBehavior.js";
import type { IGizmo } from "./gizmo.js";
import { Gizmo } from "./gizmo.js";
import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer.js";
import type { ScaleGizmo } from "./scaleGizmo.js";
import { Color3 } from "../Maths/math.color.js";
/**
* Interface for axis scale gizmo
*/
export interface IAxisScaleGizmo extends IGizmo {
/** Drag behavior responsible for the gizmos dragging interactions */
dragBehavior: PointerDragBehavior;
/** Drag distance in babylon units that the gizmo will snap to when dragged */
snapDistance: number;
/** Incremental snap scaling. When true, with a snapDistance of 0.1, scaling will be 1.1,1.2,1.3 instead of, when false: 1.1,1.21,1.33,... */
incrementalSnap: boolean;
/**
* Event that fires each time the gizmo snaps to a new location.
* * snapDistance is the change in distance
*/
onSnapObservable: Observable<{
snapDistance: number;
}>;
/** If the scaling operation should be done on all axis */
uniformScaling: boolean;
/** Custom sensitivity value for the drag strength */
sensitivity: number;
/** The magnitude of the drag strength (scaling factor) */
dragScale: number;
/** If the gizmo is enabled */
isEnabled: boolean;
/** Default material used to render when gizmo is not disabled or hovered */
coloredMaterial: StandardMaterial;
/** Material used to render when gizmo is hovered with mouse*/
hoverMaterial: StandardMaterial;
/** Material used to render when gizmo is disabled. typically grey.*/
disableMaterial: StandardMaterial;
}
/**
* Single axis scale gizmo
*/
export declare class AxisScaleGizmo extends Gizmo implements IAxisScaleGizmo {
/**
* Drag behavior responsible for the gizmos dragging interactions
*/
dragBehavior: PointerDragBehavior;
protected _pointerObserver: Nullable<Observer<PointerInfo>>;
/**
* Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
*/
snapDistance: number;
/**
* Event that fires each time the gizmo snaps to a new location.
* * snapDistance is the change in distance
*/
onSnapObservable: Observable<{
snapDistance: number;
}>;
/**
* If the scaling operation should be done on all axis (default: false)
*/
uniformScaling: boolean;
/**
* Custom sensitivity value for the drag strength
*/
sensitivity: number;
/**
* The magnitude of the drag strength (scaling factor)
*/
dragScale: number;
/**
* The minimal absolute scale per component. can be positive or negative but never smaller.
*/
static MinimumAbsoluteScale: number;
/**
* Incremental snap scaling (default is false). When true, with a snapDistance of 0.1, scaling will be 1.1,1.2,1.3 instead of, when false: 1.1,1.21,1.33,...
*/
incrementalSnap: boolean;
protected _isEnabled: boolean;
protected _parent: Nullable<ScaleGizmo>;
protected _gizmoMesh: Mesh;
protected _coloredMaterial: StandardMaterial;
protected _hoverMaterial: StandardMaterial;
protected _disableMaterial: StandardMaterial;
protected _dragging: boolean;
private _tmpVector;
private _incrementalStartupValue;
/** Default material used to render when gizmo is not disabled or hovered */
get coloredMaterial(): StandardMaterial;
/** Material used to render when gizmo is hovered with mouse*/
get hoverMaterial(): StandardMaterial;
/** Material used to render when gizmo is disabled. typically grey.*/
get disableMaterial(): StandardMaterial;
/**
* Creates an AxisScaleGizmo
* @param dragAxis The axis which the gizmo will be able to scale on
* @param color The color of the gizmo
* @param gizmoLayer The utility layer the gizmo will be added to
* @param parent
* @param thickness display gizmo axis thickness
* @param hoverColor The color of the gizmo when hovering over and dragging
* @param disableColor The Color of the gizmo when its disabled
*/
constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number, hoverColor?: Color3, disableColor?: Color3);
/**
* @internal
* Create Geometry for Gizmo
* @param parentMesh
* @param thickness
* @param isCollider
* @returns the gizmo mesh
*/
protected _createGizmoMesh(parentMesh: AbstractMesh, thickness: number, isCollider?: boolean): {
arrowMesh: Mesh;
arrowTail: Mesh;
};
protected _attachedNodeChanged(value: Nullable<Node>): void;
/**
* If the gizmo is enabled
*/
set isEnabled(value: boolean);
get isEnabled(): boolean;
/**
* Disposes of the gizmo
*/
dispose(): void;
/**
* Disposes and replaces the current meshes in the gizmo with the specified mesh
* @param mesh The mesh to replace the default mesh of the gizmo
* @param useGizmoMaterial If the gizmo's default material should be used (default: false)
*/
setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
}