@zeainc/zea-ux
Version:
1,593 lines (1,564 loc) • 90.4 kB
TypeScript
import { GLRenderer, Scene, Operator, Xfo, NumberOperatorInput, XfoOperatorOutput, NumberParameter, XfoParameter, TreeItem, SelectionSet, MultiChoiceParameter, CloneContext, BaseItem, Parameter, ColorParameter, EventEmitter, BaseTool, Rect, ScreenSpaceMaterial, ZeaPointerEvent, XRControllerEvent, VRViewport, XRController, Color, GeomItem, XRPoseEvent, ZeaKeyboardEvent, ZeaMouseEvent, CADAsset, ZeaTouchEvent, Vec3, LinesMaterial, BaseGeom, Cross, Cone, Circle, Sphere, Cuboid, Lines, Ray, ZeaWheelEvent, FlatSurfaceMaterial, GLViewport, Material, MaterialColorParam, Label, BillboardItem, ParameterOwner } from '@zeainc/zea-engine';
interface AppData {
renderer?: GLRenderer;
scene?: Scene;
sceneUnits?: string;
selectionManager?: SelectionManager;
session?: any;
sessionSync?: any;
}
/**
* An operator for aiming items at targets.
*
* @extends {Operator}
*/
declare class SelectionGroupXfoOperator extends Operator {
currGroupXfo: Xfo;
xfoModeInput: NumberOperatorInput;
xfoOutput: XfoOperatorOutput;
/**
* Creates an instance of SelectionGroupXfoOperator.
*
* @param initialXfoModeParam - Initial XFO Mode, check `INITIAL_XFO_MODES` in `KinematicGroup` documentation
* @param globalXfoParam - The GlobalXfo param found on the KinematicKinematicGroup.
*/
constructor(initialXfoModeParam: NumberParameter, globalXfoParam: XfoParameter);
/**
* Updates operator inputs(`OperatorInput`) of current `Operator` using the specified `TreeItem`.
*
* @param item - The tree item being added
*/
addItem(item: TreeItem): void;
/**
* Finds and removes the `OperatorInput` of the specified `TreeItem` from current`Operator`.
*
* @param item - The Bind Xfo calculated from the initial Transforms of the KinematicGroup Members.
*/
removeItem(item: TreeItem): void;
/**
* Move the group. When the selection group is manipulated, this method is called.
* Here we propagate the delta to each of the selection members.
*
* @param xfo - The new value being set to the Groups GlobalXfo param.
*/
backPropagateValue(xfo: Xfo): void;
/**
* Calculates a new Xfo for the group based on the members.
*/
evaluate(): void;
}
/**
* A specific type of `SelectionSet` class that contains/handles selection of one or more items from the scene.
*
* **Option parameter values**
*
* | Option | type | default | Description |
* | --- | --- | --- | --- |
* | selectionOutlineColor | `Color` | `new Color('#03e3ac'))` and opacity of `0.1` | See `Color` documentation |
* | branchSelectionOutlineColor | `Color` | `new Color('#81f1d5')` and opacity of `0.55` | See `Color` documentation |
*
* @extends {SelectionSet}
*/
declare class SelectionGroup extends SelectionSet {
initialXfoModeParam: MultiChoiceParameter;
selectionGroupXfoOp: SelectionGroupXfoOperator;
/**
* Creates an instance of SelectionGroup.
*
*
* **Parameters**
* @param options - Custom options for selection
*/
constructor(options?: Record<string, any>);
/**
* Returns enum of available xfo modes.
*
* | Name | Default |
* | --- | --- |
* | manual | <code>0</code> |
* | first | <code>1</code> |
* | average | <code>2</code> |
* | globalOri | <code>3</code> |
*/
static get INITIAL_XFO_MODES(): {
disabled: number;
manual: number;
first: number;
average: number;
globalOri: number;
};
/**
* Constructs a new selection group by copying the values from current one and returns it.
*
* @return - Cloned selection group.
*/
clone(context?: CloneContext): BaseItem;
/**
*
* @param item -
* @param index -
* @private
*/
bindItem(item: TreeItem, index: number): void;
/**
*
* @param item -
* @param index -
* @private
*/
unbindItem(item: TreeItem, index: number): void;
}
/**
* Class representing a xfo handle. Base transformations for objects in the scene
*
* **Parameters**
* * **HighlightColor(`ColorParameter`):** Specifies the highlight color of the handle.
*
* @extends TreeItem
*/
declare class XfoHandle extends TreeItem {
param: Parameter<unknown>;
highlightColorParam: ColorParameter;
/**
* Create an axial rotation scene widget.
*
* @param size - The size value.
* @param thickness - The thickness value.
*/
constructor(size?: number, thickness?: number);
/**
* Displays handles depending on the specified mode(Move, Rotate, Scale).
* If nothing is specified, it hides all of them.
* @deprecated
* @param visible - The mode of the Xfo parameter
*/
showHandles(visible: boolean): void;
/**
* Sets global xfo target parameter.
*
* @param param - The parameter that will be modified during manipulation
*/
setTargetParam(param: XfoParameter): void;
/**
* Sets selectionGroup so this handle can modify the items.
*
* @param selectionGroup - The SelectionGroup.
*/
setSelectionGroup(selectionGroup: SelectionGroup): void;
}
/**
* `UndoRedoManager` is a mixture of the [Factory Design Pattern](https://en.wikipedia.org/wiki/Factory_method_pattern) and the actual changes stacks manager.
* This is the heart of the Undo/Redo System, letting you navigate through the changes history you've saved.
*
* **Events**
* * **changeAdded:** Triggered when a change is added.
* * **changeUpdated:** Triggered when the last change added updates its state.
* * **changeUndone:** Triggered when the `undo` method is called, after removing the last change from the stack.
* * **changeRedone:** Triggered when the `redo` method is called, after restoring the last change removed from the undo stack.
* */
declare class UndoRedoManager extends EventEmitter {
__undoStack: Change[];
__redoStack: Change[];
__currChange: Change | null;
/**
* It doesn't have any parameters, but under the hood it uses [EventsEmitter]() to notify subscribers when something happens.
* The implementation is really simple, just initialize it like any other class.
*/
constructor();
/**
* As the name indicates, it empties undo/redo stacks permanently, losing all stored actions.
* Right now, before flushing the stacks it calls the `destroy` method on all changes, ensure to at least declare it.
*/
flush(): void;
/**
* Receives an instance of a class that extends or has the same structure as `Change` class.
* When this action happens, the last added change update notifications will get disconnected.
* Which implies that any future updates to changes that are not the last one, would need a new call to the `addChange` method.
* Also, resets the redo stack(Calls destroy method when doing it).
*
* @param change - The change param.
*/
addChange(change: Change): void;
/**
* Returns the last change added to the undo stack, but in case it is empty a `null` is returned.
*
* @return {Change|null} The return value.
*/
getCurrentChange(): Change | null;
/**
* @param updateData
*/
private currChangeUpdated;
/**
* Rollback the latest action, passing it to the redo stack in case you wanna recover it later on.
* Emits the `changeRedone` event, passing the change
* @param pushOnRedoStack - The pushOnRedoStack param.
*/
undo(pushOnRedoStack?: boolean): void;
/**
* Method to cancel the current change added to the UndoRedoManager.
* Reverts the change and discards it.
*/
cancel(): void;
/**
* Rollbacks the `undo` action by moving the change from the `redo` stack to the `undo` stack.
* Emits the `changeRedone` event, passing the change in the event, if you want to subscribe to it.
*/
redo(): void;
/**
* Basically returns a new instance of the derived `Change` class. This is why we need the `name` attribute.
*
* @param className - The className param.
* @return - The return value.
*/
constructChange(className: string): Change;
/**
* Checks if a class of an instantiated object is registered in the UndoRedo Factory.
*
* @param inst - The instance of the Change class.
* @return {boolean} - Returns 'true' if the class has been registered.
*/
static isChangeClassRegistered(inst: Change): boolean;
/**
* Very simple method that returns the name of the instantiated class, checking first in the registry and returning if found,
* if not then checks the `name` attribute declared in constructor.
*
* @param inst - The instance of the Change class.
* @return {string} - The return value.
*/
static getChangeClassName(inst: Change): string;
/**
* Registers the class in the UndoRedoManager Factory.
* Why do we need to specify the name of the class?
* Because when the code is transpiled, the defined class names change, so it won't be known as we declared it anymore.
*
* @param name - The name param.
* @param cls - The cls param.
*/
static registerChange(name: string, cls: any): void;
static getInstance(): UndoRedoManager;
}
/**
* Kind of an abstract class, that represents the mandatory structure of a change classes that are used in the [`UndoRedoManager`]().
*
* @note If you don't extend this class, ensure to implement all methods specified in here.
* @extends {EventEmitter}
*/
declare class Change extends EventEmitter {
name: string;
secondaryChanges: Change[];
suppressPrimaryChange: boolean;
closed: boolean;
/**
* Every class that extends from `Change` must contain a global `name` attribute.
* It is used by the `UndoRedoManager` factory to re-construct the class of the specific implementation of the `Change` class.
*
* @param name - The name value.
*/
constructor(name?: string);
addSecondaryChange(secondaryChange: Change): number;
setPrimaryChange(primaryChange: Change): void;
/**
* Called by the `UndoRedoManager` in the `undo` method, and contains the code you wanna run when the undo action is triggered,
* of course it depends on what you're doing.
*
* @note This method needs to be implemented, otherwise it will throw an Error.
*/
undo(): void;
/**
* Called by the `UndoRedoManager` in the `redo` method, and is the same as the `undo` method, contains the specific code you wanna run.
*
* @note This method needs to be implemented, otherwise it will throw an Error.
*/
redo(): void;
/**
* Use this method to update the state of your `Change` class.
*
* @note This method needs to be implemented, otherwise it will throw an Error.
*
* @param updateData - The updateData param.
*/
update(updateData: Record<any, any>): void;
/**
* Serializes the `Change` instance as a JSON object, allowing persistence/replication
*
* @note This method needs to be implemented, otherwise it will return an empty object.
*
* @param context - The appData param.
*/
toJSON(context: Record<any, any>): Record<any, any>;
/**
* The counterpart of the `toJSON` method, restoring `Change` instance's state with the specified JSON object.
* Each `Change` class must implement the logic for reconstructing itself.
* Very often used to restore from persisted/replicated JSON.
*
* @note This method needs to be implemented, otherwise it will do nothing.
*
* @param j - The j param.
* @param context - The context param.
*/
fromJSON(j: Record<any, any>, context: Record<any, any>): void;
/**
* Method destined to clean up things that would need to be cleaned manually.
* It is executed when flushing the undo/redo stacks or adding a new change to the undo stack,
* so it is require in any class that represents a change.
*
*/
destroy(): void;
}
/**
* Represents a `Change` class for storing `Parameter` values.
*
* **Events**
* * **updated:** Triggered when the `ParameterValueChange` value is updated.
*
* @extends Change
*/
declare class ParameterValueChange extends Change {
param: Parameter<unknown>;
nextValue: any;
prevValue: any;
supressed: boolean;
/**
* Creates an instance of ParameterValueChange.
*
* @param param - The Parameter object that is modified by this change.
* @param newValue - The newValue value.
*/
constructor(param?: Parameter<unknown>, newValue?: any);
/**
* Rollbacks the value of the parameter to the previous one, passing it to the redo stack in case you wanna recover it later on.
*/
undo(): void;
/**
* Rollbacks the `undo` action by moving the change from the `redo` stack to the `undo` stack
* and updating the parameter with the new value.
*/
redo(): void;
/**
* Updates the state of the current parameter change value.
*
* @param updateData - The updateData param.
*/
update(updateData: Record<string, any>): void;
/**
* Serializes `Parameter` instance value as a JSON object, allowing persistence/replication.
*
* @param context - The context param.
* @return {object} The return value.
*/
toJSON(context: Record<any, any>): Record<any, any>;
/**
* Restores `Parameter` instance's state with the specified JSON object.
*
* @param j - The j param.
* @param context - The context param.
*/
fromJSON(j: Record<any, any>, context: Record<any, any>): Record<any, any>;
}
/**
* Represents a `Change` class for storing `Selection` values.
*
* @extends Change
*/
declare class SelectionChange extends Change {
__selectionManager: SelectionManager;
__prevSelection: Set<TreeItem>;
__newSelection: Set<TreeItem>;
/**
* Creates an instance of SelectionChange.
*
* @param selectionManager - The selectionManager value.
* @param prevSelection - The prevSelection value.
* @param newSelection - The newSelection value.
*/
constructor(selectionManager: SelectionManager, prevSelection: Set<TreeItem>, newSelection: Set<TreeItem>);
/**
* Sets the state of selections to the previous list of items selected.
*/
undo(): void;
/**
* Restores the state of the selections to the latest the list of items selected.
*/
redo(): void;
/**
* Serializes selection values as a JSON object, allowing persistence/replication.
*
* @param context - The appData param.
* @return {object} The return value.
*/
toJSON(context: Record<any, any>): Record<any, any>;
/**
* Restores selection state from a JSON object.
*
* @param j - The j param.
* @param context - The context param.
*/
fromJSON(j: Record<any, any>, context: Record<any, any>): void;
}
/**
* Class representing a change of visibility state for selected items.
*
* @extends Change
*/
declare class SelectionVisibilityChange extends Change {
selection: Set<TreeItem>;
state: boolean;
/**
* Create a toggle selection visibility.
*
* @param selection - The selection value.
* @param state - The state value.
*/
constructor(selection: Set<TreeItem>, state: boolean);
/**
* Restores previous visibility status of the selected items
*/
undo(): void;
/**
* Recreates previous visibility status of the selected items
*/
redo(): void;
/**
* Changes items visibility.
*
* @param state - The state param.
* @private
*/
_changeItemsVisibility(state: boolean): void;
}
/**
* Class representing an `Add TreeItem` Change. Meaning that this should be called when you add a new `TreeItem` to the scene.
*
* @extends Change
*/
declare class TreeItemAddChange extends Change {
treeItem: TreeItem;
owner: TreeItem;
prevSelection: Set<TreeItem>;
selectionManager: SelectionManager;
treeItemIndex: number;
/**
* Creates an instance of TreeItemAddChange.
*
* @param treeItem -
* @param owner -
* @param selectionManager -
*/
constructor(treeItem: TreeItem, owner: TreeItem, selectionManager: SelectionManager);
/**
* Removes the newly added TreeItem from its owner.
*/
undo(): void;
/**
* Restores undone `TreeItem`.
*/
redo(): void;
/**
* Serializes `TreeItem` like instanced class into a JSON object.
*
* @param context - The context treeItem
* @return {object} - JSON object
*/
toJSON(context: Record<any, any>): Record<string, any>;
/**
* Reconstructs `TreeItem` like parameter from JSON object.
*
* @param j -The j treeItem
* @param context - The context treeItem
*/
fromJSON(j: Record<any, any>, context: Record<any, any>): void;
/**
* Removes reference of the `TreeItem` from current change.
*/
destroy(): void;
}
/**
* Class representing a `Move TreeItem` Change(Moving a TreeItem from one parent to another).
*
* @extends Change
*/
declare class TreeItemMoveChange extends Change {
treeItem: TreeItem;
oldOwner: TreeItem;
oldOwnerIndex: number;
newOwner: TreeItem;
/**
* Creates an instance of TreeItemMoveChange.
*
* @param treeItem - The item to move.
* @param newOwner - The new owner item.
* @memberof TreeItemMoveChange
*/
constructor(treeItem: TreeItem, newOwner: TreeItem);
/**
* Inserts back the moved TreeItem in the old owner item(Rollbacks the move action).
*/
undo(): void;
/**
* Executes the move action inserting the TreeItem back to the new owner item.
*/
redo(): void;
/**
* Returns a JSON object with the specifications of the change(Typically used for replication).
*
* @param context - The context value
* @return {object} - JSON object of the change
*/
toJSON(context: Record<string, any>): Record<string, any>;
/**
* Restores the Change state from the specified JSON object.
*
* @param j - The serialized object with the change data.
* @param context - The context value
*/
fromJSON(j: Record<string, any>, context: Record<string, any>): void;
}
/**
* Class representing a TreeItems removal Change,
* taking into account that it would remove all the specified items ti their children
*
* @extends Change
*/
declare class TreeItemsRemoveChange extends Change {
private items;
private itemOwners;
private itemPaths;
private itemIndices;
/**
* Creates an instance of TreeItemsRemoveChange.
*
* @param items - List of TreeItems
* @param appData - The appData value
*/
constructor(items: Array<TreeItem>, appData: AppData);
/**
* Restores all items removed in the change, reattaching them to their old owners.
*/
undo(): void;
/**
* Executes initial change to remove items from their owners.
*/
redo(): void;
/**
* Serializes current change data as a JSON object, so this action can be stored/replicated somewhere else.
*
* @param appData - The appData value
* @return {object} - JSON Object representation of current change
* @memberof TreeItemsRemoveChange
*/
toJSON(context?: Record<any, any>): Record<string, any>;
/**
* Restores Change action from a JSON object.
*
* @param j - The JSON object with Change data.
* @param appData - The appData value
* @memberof TreeItemsRemoveChange
*/
fromJSON(j: Record<string, any>, context: Record<any, any>): void;
}
/**
* Represents a `Change` class for storing `Parameter` values.
*
* **Events**
* * **updated:** Triggered when the `SelectionXfoChange` value is updated.
*
* @extends Change
*/
declare class SelectionXfoChange extends Change {
supressed: boolean;
treeItems: TreeItem[];
baseXfo: Xfo;
localXfos: Xfo[];
prevValues: Xfo[];
newValues: Xfo[];
/**
* Creates an instance of SelectionXfoChange.
*
* @param param - The Parameter object that is modified by this change.
* @param newValue - The newValue value.
*/
constructor(treeItems: TreeItem[], baseXfo: Xfo);
setDeltaXfo(delta: Xfo): void;
setDone(): void;
/**
* Rollbacks the value of the parameter to the previous one, passing it to the redo stack in case you wanna recover it later on.
*/
undo(): void;
/**
* Rollbacks the `undo` action by moving the change from the `redo` stack to the `undo` stack
* and updating the parameter with the new value.
*/
redo(): void;
/**
* Updates the state of the current parameter change value.
*
* @param updateData - The updateData param.
*/
update(updateData: Record<string, any>): void;
/**
* Serializes `Parameter` instance value as a JSON object, allowing persistence/replication.
*
* @param context - The context param.
* @return {object} The return value.
*/
toJSON(context: Record<any, any>): Record<any, any>;
/**
* Restores `Parameter` instance's state with the specified JSON object.
*
* @param j - The j param.
* @param context - The context param.
*/
fromJSON(j: Record<any, any>, context: Record<any, any>): void;
}
/**
* Class representing a selection manager
*
* **Events**
* **leadSelectionChanged:** Triggered when selecting one item.
* **selectionChanged:** Triggered when the selected objects change.
*
* @extends {EventEmitter}
*/
declare class SelectionManager extends EventEmitter {
appData: AppData;
leadSelection: TreeItem;
selectionGroup: SelectionGroup;
xfoHandle: XfoHandle;
xfoHandleVisible: boolean;
renderer: GLRenderer;
pickFilter: (treeItem: TreeItem) => TreeItem;
pickCB: (treeItem: TreeItem) => void;
/**
* Creates an instance of SelectionManager.
*
* @param appData - The options object.
* @param [options={}] - The appData value.
* enableXfoHandles - enables display Xfo Gizmo handles when items are selected.
* selectionOutlineColor - enables highlight color to use to outline selected items.
* branchSelectionOutlineColor - enables highlight color to use to outline selected items.
*/
constructor(appData: AppData, options?: any);
/**
* Adds specified the renderer to the `SelectionManager` and attaches the `SelectionGroup`.
*
* @param renderer - The renderer param.
*/
setRenderer(renderer: GLRenderer): void;
/**
* Sets initial Xfo mode of the selection group.
*
* @see `KinematicGroup` class documentation
*
* @param mode - The Xfo mode
*/
setXfoMode(mode: number): void;
/**
* Displays handles depending on the specified mode(Move, Rotate, Scale).
* If nothing is specified, it hides all of them.
* @deprecated
* @param enabled - The mode of the Xfo parameter
*/
showHandles(enabled: boolean): void;
/**
* Determines if the Xfo Manipulation handle should be displayed or not.
*/
updateHandleVisibility(): void;
/**
* Returns an array with the selected items.
*
* @return - The return value.
*/
getSelection(): Set<TreeItem>;
/**
* Sets a new selection of items in the `SelectionManager`
*
* @param newSelection - The newSelection param
* @param [createUndo=true] - The createUndo param
*/
setSelection(newSelection: Set<TreeItem>, createUndo?: boolean, parentChange?: Change): void;
/**
* @param treeItem - The treeItem value
*/
private setLeadSelection;
/**
* The toggleItemSelection method.
*
* @param treeItem - The treeItem param.
* @param replaceSelection - The replaceSelection param.
*/
toggleItemSelection(treeItem: TreeItem, replaceSelection?: boolean, createUndo?: boolean, parentChange?: Change): void;
/**
* Clears selection state by removing previous selected items and the Xfo handlers.
*
* @param createUndo - The createUndo param.
* @return {boolean} - The return value.
*/
clearSelection(createUndo?: boolean, parentChange?: Change): void;
/**
* Selects the specified items replacing previous selection or concatenating new items to it.
*
* @param treeItems - The treeItems param.
* @param replaceSelection - The replaceSelection param.
*/
selectItems(treeItems: Set<TreeItem>, replaceSelection?: boolean, createUndo?: boolean, parentChange?: Change): void;
/**
* Deselects the specified items from the selection group.
*
* @param treeItems - The treeItems param.
*/
deselectItems(treeItems: Set<TreeItem>, createUndo?: boolean, parentChange?: Change): void;
/**
* The startPickingMode method.
*
* @param label - The label param.
* @param fn - The fn param.
* @param filterFn - The filterFn param.
* @param count - The count param.
*/
startPickingMode(fn: (treeItem: TreeItem) => void, filterFn: (treeItem: TreeItem) => TreeItem | null): void;
/**
* The pickingModeActive method.
*
* @return {boolean} The return value.
*/
pickingModeActive(): boolean;
/**
* The endPickingMode method.
*/
endPickingMode(): void;
/**
* The pick method.
* @param item - The item param.
*/
pick(item: TreeItem | Array<TreeItem>): void;
}
/**
* Class representing a selection tool.
*
* @extends BaseTool
*/
declare class SelectionTool extends BaseTool {
private appData;
private dragging;
private selectionManager;
private selectionRectXfo;
private rectItem;
private pointerDownPos;
selectionRect: Rect;
selectionRectMat: ScreenSpaceMaterial;
selectionFilterFn: (treeItem: TreeItem) => TreeItem | null;
/**
* Creates an instance of SelectionTool.
*
* @param appData - The appData value
*/
constructor(appData: AppData);
/**
* Activates selection tool.
*/
activateTool(): void;
/**
* Deactivates the selection tool.
*/
deactivateTool(): void;
/**
* Activates selection tool.
*/
setSelectionManager(selectionManager: SelectionManager): void;
setSelectionFilter(fn: (treeItem: TreeItem) => TreeItem | null): void;
/**
*
*
* @param viewport - The viewport value
* @param delta - The delta value
*/
private resizeRect;
/**
*
*
* @param event - The event param.
* @private
*/
onPointerDoublePress(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is pressed while the pointer is over the tool.
*
* @param event - The event param.
* @return {boolean} The return value.
*/
onPointerDown(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device is moved while the cursor's hotspot is inside it.
*
* @param event - The event param.
* @return {boolean} The return value.
*/
onPointerMove(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is released while the pointer is over the tool.
*
* @param event - The event param.
* @return {boolean} The return value.
*/
onPointerUp(event: ZeaPointerEvent): void;
/**
* Event fired when a VR controller button is pressed over a tool.
*
* @param event - The event param.
* @return {boolean} The return value.
*/
onXRControllerButtonDown(event: XRControllerEvent): void;
}
declare class PointerTool extends BaseTool {
protected appData: AppData;
protected vrViewport: VRViewport;
protected prevCursor: string;
pointerController: XRController;
pointerThickness: number;
pointerColor: Color;
private geom;
private material;
protected defaultRaycastDist: number;
raycastDist: number;
protected bindControllerId: number;
protected pointerGeomItems: GeomItem[];
constructor(appData: AppData);
/**
* Enables tools usage. This method is called by either the Viewport when a tool is removed, or the ToolManage if it is installed.
*/
activateTool(): void;
/**
* The deactivateTool method.
*/
deactivateTool(): void;
protected displayPointers(): void;
/**
* The deactivateTool method.
*/
removePointers(): void;
protected setPointerLength(length: number, controller: XRController): void;
protected checkPointerIntersection(controller: XRController): void;
/**
* Event fired when a pointing device is moved
*
* @param event - The event param.
*/
onPointerMove(event: ZeaPointerEvent): void;
}
interface UIIntersection {
clientX: number;
clientY: number;
}
/**
* Class representing a VR UI tool.
*
* @extends BaseTool
*/
declare class VRUITool extends PointerTool {
private vrUIDOMElement;
private controllerUI;
private uiOpen;
private uiOpenedByMouse;
private triggerHeld;
private visibilityStates;
private uiController;
private element;
private listenerIds;
openUIKeyboardHotkey: string;
openUiAngleTolerance: number;
/**
* Create a VR UI tool.
* @param appData - The appData value.
* @param vrUIDOMElement - The dom element we will use as the VR UI
*/
constructor(appData: AppData, vrUIDOMElement: HTMLElement);
/**
* The getName method.
*
* @return {string} The return value.
*/
getName(): string;
/**
* The activateTool method.
*/
activateTool(): void;
/**
* The deactivateTool method.
*/
deactivateTool(): void;
/**
* The openUI method.
* @param uiController - The uiController param.
* @param : VRController - The pointerController param.
* @param headXfo - The headXfo param.
*/
openUI(uiController: XRController, pointerController: XRController): void;
private childAdded;
private restoreVisibility;
/**
* The closeUI method.
*/
closeUI(): void;
private calcUIIntersection;
private getDOMElementFromPoint;
/**
* The sendEventToUI method.
* @param eventName - The eventName param.
* @param args - The args param.
* @return The return value.
*/
sendEventToUI(controller: XRController, element: Element, eventName: string, hit: UIIntersection, args?: Record<string, any>): void;
/**
* The onXRControllerButtonDown method.
* @param event - The event param.
*/
onPointerDown(event: XRControllerEvent): void;
/**
* Event fired when a pointing device button is clicked.
*
* @param event - The event param.
*/
onPointerClick(event: ZeaPointerEvent): void;
onPointerDoubleClick(event: ZeaPointerEvent): void;
/**
* The onVRControllerButtonUp method.
* @param event - The event param.
*/
onPointerUp(event: ZeaPointerEvent): void;
/**
* The onXRPoseChanged method.
* @param event - The event param.
*/
onPointerMove(event: XRPoseEvent): void;
/**
* Event fired when the user presses down a key on the keyboard.
*
* @param event - The event param.
*/
onKeyDown(event: ZeaKeyboardEvent): void;
/**
* Event fired when the user releases a key on the keyboard.
*
* @param event - The event param.
*/
onKeyUp(event: ZeaKeyboardEvent): void;
}
/**
* Class representing a VR hold objects tool.
* @extends BaseTool
*/
declare class VRHoldObjectsTool extends PointerTool {
treeWalkSteps: number;
smoothFactor: number;
private pressedButtonCount;
private vrControllers;
private heldObjectCount;
private heldTreeItems;
private highlighteTreeItemIds;
private heldTreeItemItemIds;
private heldTreeItemItemRefs;
private heldTreeItemItemOffsets;
private change;
private prevUpdateGrabXfos;
/**
* Create a VR hold objects tool.
* @param appData - The appData value.
*/
constructor(appData: AppData);
/**
* The computeGrabXfo method.
* @param refs - The refs param.
* @return {Xfo} The return value.
*/
computeGrabXfo(refs: number[]): Xfo;
/**
* The initAction method.
*/
initAction(): void;
/**
* Event fired when a pointing device button is pressed
*
* @param event - The event param.
*/
onPointerDown(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is released while the pointer is over the tool.
*
* @param event - The event param.
*/
onPointerUp(event: ZeaPointerEvent): void;
onPointerClick(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device is moved
*
* @param event - The event param.
*/
onPointerMove(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is double clicked on the tool.
*
* @param event - The event param.
*/
onPointerDoublePress(event: ZeaMouseEvent): void;
}
declare class HandHeldTool extends BaseTool {
appData: AppData;
cadAsset: CADAsset;
toolController: XRController;
constructor(assetUrl: string, offsetXfo: Xfo, appData: AppData);
/**
* Enables tools usage. This method is called by either the Viewport when a tool is removed, or the ToolManage if it is installed.
*/
activateTool(): void;
/**
* Disables tool usage. This method is called by either the Viewport when a tool is removed, or the ToolManage if it is installed.
*/
deactivateTool(): void;
/**
* Event fired when either the mouse button is pressed, or a touch start event occurs.
*
* @param event - The event param.
*/
onPointerDown(event: ZeaPointerEvent): void;
/**
* Event fired when either the mouse cursor is moved, or a touch point moves.
*
* @param event - The event param.
*/
onPointerMove(event: ZeaPointerEvent): void;
/**
* Event fired when either the mouse button is released, or a touch end event occurs.
*
* @param event - The event param.
*/
onPointerUp(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is clicked.
*
* @param event - The event param.
*/
onPointerClick(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is double clicked.
*
* @param event - The event param.
*/
onPointerDoubleClick(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is held for a long time..
*
* @param event - The event param.
*/
onPointerLongPress(event: ZeaPointerEvent): void;
/**
* Event fired when a mouse pointer enters the viewport
*
* @param event - The event param.
*/
onPointerEnter(event: ZeaPointerEvent): void;
/**
* Event fired when a mouse pointer leaves the viewport
*
* @param event - The event param.
*/
onPointerLeave(event: ZeaPointerEvent): void;
/**
* Event fired when the user rotates the pointing device wheel.
*
* @param event - The event param.
*/
onWheel(event: ZeaPointerEvent): void;
/**
* Event fired when the user presses down a key on the keyboard.
*
* @param event - The event param.
*/
onKeyDown(event: ZeaKeyboardEvent): void;
/**
* Event fired when the user releases a key on the keyboard.
*
* @param event - The event param.
*/
onKeyUp(event: ZeaKeyboardEvent): void;
/**
* Event fired when one or more touch points have been disrupted in an implementation-specific manner.
*
* @param event - The event param.
*/
onTouchCancel(event: ZeaTouchEvent): void;
}
/**
* @extends BaseTool
*/
declare class ToolManager extends BaseTool {
toolStack: BaseTool[];
tools: Record<string, BaseTool>;
constructor();
registerTool(toolName: string, tool: BaseTool): void;
insertTool(tool: string | BaseTool, index: number): void;
removeTool(tool: string | BaseTool): void;
pushTool(tool: string | BaseTool): void;
popTool(): void;
/**
* Returns the tool currently at the top of the stack.
* @return - the currently active tool.
*/
activeTool(): BaseTool | undefined;
/**
* Returns the name of the tool currently at the top of the stack.
* @return - the name of the tool.
*/
activeToolName(): string;
/**
* Event fired when a pointing device button is pressed while the pointer is over the tool.
*
* @param event - The event param.
*/
onPointerDown(event: ZeaMouseEvent): void;
/**
* Event fired when a pointing device is moved while the cursor's hotspot is inside it.
*
* @param event - The event param.
*/
onPointerMove(event: ZeaMouseEvent): void;
/**
* Event fired when a pointing device button is released while the pointer is over the tool.
*
* @param event - The event param.
*/
onPointerUp(event: ZeaMouseEvent): void;
/**
* Event fired when a pointing device button is released and released in the same location.
*
* @param event - The event param.
*/
onPointerClick(event: ZeaMouseEvent): void;
/**
* Event fired when a pointing device button is double clicked on the tool.
*
* @param event - The event param.
*/
onPointerDoubleClick(event: ZeaMouseEvent): void;
/**
* Event fired when the user rotates the pointing device wheel.
*
* @param event - The event param.
*/
onWheel(event: ZeaMouseEvent): void;
/**
* Event fired when the user presses down a key on the keyboard.
*
* @param event - The event param.
*/
onKeyDown(event: ZeaKeyboardEvent): void;
/**
* Event fired when the user releases a key on the keyboard.
*
* @param event - The event param.
*/
onKeyUp(event: ZeaKeyboardEvent): void;
}
declare class DropUserTool extends PointerTool {
private toolManager;
private dropAvatar;
private floorPlane;
faceUserTowardsSceneCenter: boolean;
sceneCenter: Vec3;
constructor(appData: AppData, toolManager: ToolManager);
/**
* Enables tools usage. This method is called by either the Viewport when a tool is removed, or the ToolManage if it is installed.
*/
activateTool(): void;
/**
* The deactivateTool method.
*/
deactivateTool(): void;
/**
* Event fired when a pointing device is moved
*
* @param event - The event param.
*/
onPointerMove(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is clicked.
*
* @param event - The event param.
*/
onPointerDown(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is double clicked.
*
* @param event - The event param.
*/
onPointerDoubleClick(event: ZeaPointerEvent): void;
}
/**
* Class representing a primary create tool.
*
* @extends BaseTool
*/
declare class BaseCreateTool extends BaseTool {
appData: AppData;
/**
* Creates an instance of BaseCreateTool.
*
* @param appData - The appData value.
*/
constructor(appData: AppData);
}
/**
* Base class for creating geometry tools.
*
* @extends BaseCreateTool
*/
declare class CreateGeomTool extends BaseCreateTool {
stage: number;
removeToolOnRightClick: boolean;
parentItem: TreeItem;
colorParam: ColorParameter;
vrControllerToolTipMat: LinesMaterial;
vrControllerToolTip: BaseGeom | Cross;
prevCursor: string;
constructionPlane: Xfo;
private activeController;
/**
* Create a create geom tool.
*
* @param appData - The appData value.
*/
constructor(appData: AppData, parentItem: TreeItem);
/**
* Adds a geometry icon to the VR Controller
* @param controller - The controller object.
*/
addIconToVRController(controller: XRController): void;
controllerAddedHandler(event: {
controller: any;
}): void;
/**
* The activateTool method.
*/
activateTool(): void;
/**
* The deactivateTool method.
*/
deactivateTool(): void;
private setupConstructionPlane;
/**
* Transforms the screen position in the viewport to an Xfo object.
*
* @param event - The event param
* @return {Xfo} The return value.
*/
screenPosToXfo(event: ZeaMouseEvent | ZeaTouchEvent, snapToSurfaceUnderPointer?: boolean): Xfo;
/**
* Starts the creation of the geometry.
*
* @param xfo - The xfo param.
*/
protected createStart(xfo: Xfo, event: ZeaPointerEvent): void;
/**
* The createPoint method.
*
* @param pt - The pt param.
*/
protected createPoint(pt: Vec3, event?: ZeaPointerEvent): void;
/**
* The createMove method.
*
* @param pt - The pt param.
*/
protected createMove(pt: Vec3, event: ZeaPointerEvent): void;
/**
* The createRelease method.
*
* @param pt - The pt param.
*/
protected createRelease(pt: Vec3, event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is pressed over the viewport while the tool is activated.
*
* @param event - The event param.
*/
onPointerDown(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device is moved while the cursor's hotspot is inside the viewport, while tool is activated.
*
* @param event - The event param.
*/
onPointerMove(event: ZeaPointerEvent): void;
/**
* Event fired when a pointing device button is released while the pointer is over the viewport, while the tool is activated.
*
* @param event - The event param.
*/
onPointerUp(event: ZeaPointerEvent): void;
/**
* Event fired when the user rotates the pointing device wheel, while the tool is activated.
*
* @param event - The event param.
*/
onWheel(event: ZeaPointerEvent): void;
/**
* Event fired when the user presses a key on the keyboard, while the tool is activated.
*
* @param event - The event param.
*/
onKeyPressed(event: ZeaKeyboardEvent): void;
/**
* Event fired when the user presses down a key on the keyboard, while the tool is activated.
*
* @param event - The event param.
*/
onKeyDown(event: ZeaKeyboardEvent): void;
/**
* Event fired when the user releases a key on the keyboard.
*
* @param event - The event param.
*/
onKeyUp(event: ZeaKeyboardEvent): void;
/**
* Event fired when one or more touch points have been disrupted in an implementation-specific manner inside the viewport, when the tool is activated.
*
* @param event - The event param.
*/
onTouchCancel(event: ZeaPointerEvent): void;
/**
* Event fired when a VR controller button is pressed inside the viewport, when the tool is activated.
*
* @param event - The event param.
*/
onXRControllerButtonDown(event: XRControllerEvent): void;
/**
* The onXRPoseChanged method.
*
* @param event - The event param.
*/
onXRPoseChanged(event: XRPoseEvent): void;
/**
* Event fired when a VR controller button is released inside the viewport, when the tool is activated.
*
* @param event - The event param.
*/
onVRControllerButtonUp(event: XRControllerEvent): void;
}
/**
* Class representing a create geom change.
*
* @extends Change
*/
declare class CreateGeomChange extends Change {
parentItem: TreeItem;
geomItem: GeomItem;
childIndex: number;
xfo: Xfo;
color: Color;
/**
* Create a create circle change.
* @param name - The name value.
*/
constructor(name: string, parentItem: TreeItem, xfo: Xfo, color?: Color);
protected createGeomItem(): void;
/**
* Removes recently created geometry from its parent.
*/
undo(): void;
/**
* Restores recently created geometry and adds it to the specified parent tree item.
*/
redo(): void;
/**
* Serializes the change as a JSON object.
*
* @param context - The context value
* @return - The serialized change
*/
toJSON(context?: Record<any, any>): Record<any, any>;
/**
* Restores geometry from using the specified JSON
*
* @param j - The j param.
* @param context - The appData param.
*/
fromJSON(j: Record<any, any>, context: Record<any, any>): void;
}
/**
* Tool for creating a line tool.
*
* **Events**
* * **actionFinished:** Triggered when the creation of the geometry is completed.
*
* @extends CreateGeomTool
*/
declare class CreateLineTool extends CreateGeomTool {
lineThickness: NumberParameter;
change: CreateGeomChange;
length: number;
xfo: Xfo;
/**
* Create a create line tool.
* @param appData - The appData value.
*/
constructor(appData: AppData, parentItem: TreeItem);
/**
* Starts line geometry creation.
*
* @param xfo - The xfo param.
*/
createStart(xfo: Xfo, event: ZeaPointerEvent): void;
/**
* Updates line structural data.
*
* @param pt - The pt param.
*/
createMove(pt: Vec3, event: ZeaPointerEvent): void;
/**
* Finishes Line geometry creation.
*
* @param pt - The pt param.
*/
createRelease(pt: Vec3, event: ZeaPointerEvent): void;
/**
* The onXRControllerButtonDown method.
*
* @param event - The event param.
*/
onXRControllerButtonDown(event: XRControllerEvent): void;
}
declare class CreateMultiLineTool extends CreateGeomTool {
change: CreateGeomChange;
length: number;
inverseXfo: Xfo;
vertices: Vec3[];
distanceToSnap: number;
pointerVertex: Vec3;
tailVertex: Vec3;
lastClickTime: number;
lastClickPt: Vec3;
doubleClickTime: number;
doubleClickMaxDistance: number;
/**
* Create a create line tool.
* @param appData - The appData value.
*/
constructor(appData: AppData, parentItem: TreeItem);
/**
* Starts line geometry creation.
*
* @param xfo - The xfo param.
*/
createStart(xfo: Xfo, event: ZeaPointerEvent): void;
/**
* Updates line structural data.
*
* @param pt - The pt param.
* @param event - The event param.
*/
createMove(pt: Vec3, event: ZeaPointerEvent): void;
snapToClosestAxis(vertex: Vec3): Vec3;
/**
* Add vertex or finish Line geometry creation.
*
* @param pt - The pt param.
*/
createRelease(pt: Vec3, event: ZeaPointerEvent): void;
protected shouldClosePolygon(event: ZeaPointerEvent): boolean;
onKeyUp(event: ZeaKeyboardEvent): void;
resetTool(): void;
/**
* The onXRControllerButtonDown method.
*
* @param event - The event param.
*/
onXRControllerButtonDown(event: XRControllerEvent): void;
}
/**
* Class representing a create cone change.
*
* **Events**
* * **updated:** Triggered when the change is updated
*
* @extends CreateGeomChange
*/
declare class CreateConeChange extends CreateGeomChange {
cone: Cone;
/**
* Create a create cone change.
*
* @param parentItem - The parentItem value.
* @param xfo - The xfo value.
*/
constructor(parentItem: TreeItem, xfo: Xfo, color: Color);
protected createGeomItem(): void;
/**
* Updates cone with the specified data.
*
* @param updateData - The updateData param.
*/
update(updateData: Record<any, any>): void;
}
/**
* Tool for creating a Cone geometry.
*
* **Events**
* * **actionFinished:** Triggered when the creation of the geometry is completed.
*
* @extends CreateGeomTool
*/
declare class CreateConeTool extends CreateGeomTool {
xfo: Xfo;
invXfo: Xfo;
change: CreateConeChange;
radius: number;
height: number;
/**
* Create a create cone tool.
* @param appData - The appData value.
*/
constructor(appData: AppData, parentItem: TreeItem);
/**
* Starts the creation of the geometry.
*
* @param xfo - The xfo param.
*/
createStart(xfo: Xfo, event: ZeaPointerEvent): void;
/**
* Updates Cone geometry structural properties.
*
* @param pt - The pt param.
*/
createMove(pt: Vec3, event: ZeaPointerEvent): void;
/**
* Finishes the creation of the Cone.
*
* @param pt - The pt param.
*/
createRelease(pt: Vec3, event: ZeaPointerEvent): void;
}
/**
* Class representing a create circle change.
*
* **Events**
* * **updated:** Triggered when the change is updated
*
* @extends CreateGeomChange
*/
declare class CreateCircleChange extends CreateGeomChange {
circle: Circle;
/**
* Creates an instance of CreateCircleChange.
*
* @param parentItem - The parentItem value.
* @param xfo - The xfo value.
*/
constructor(parentItem: TreeItem, xfo: Xfo, color: Color);
protected createGeomItem(): void;
/**
* Updates circle with the specified data.
*
* @param updateData - The updateData param.
*/
update(updateData: Record<any, any>): void;
/**
* Serializes change as a JS