import { Camera, Intersection, Object3D, Vector3, WebGLRenderer } from 'three'; import { Hitbox } from './Hitbox.js'; export type MiscUpdateEvents = MiscEvents & UpdateEvents; export type Events = InteractionEvents & MiscUpdateEvents; /** * Represents events related to updates. These events do not propagate to parents. */ export interface UpdateEvents { /** Event triggered when the position of the object changes. */ positionchange: never; /** Event triggered when the scale of the object changes. */ scalechange: never; /** Event triggered when the rotation of the object changes. */ rotationchange: never; /** Event triggered when the enabledState of the object changes (either its own or the parent's `enabled` property). */ enabledchange: PropertyChangeEvent; /** Event triggered when the visibilityState of the object changes (either its own or the parent's `visible` property). */ visiblechange: PropertyChangeEvent; } /** * Represents miscellaneous events. These events do not propagate to parents. */ export interface MiscEvents { /** Event triggered on first render and every time an object is rendered with a different viewport size from the previous one. */ viewportresize: ViewportResizeEvent; /** Event triggered every frame, before 'animate'. Usually used to prepare object animations. */ beforeanimate: AnimateEvent; /** Event triggered every frame. Used to animate objects. */ animate: AnimateEvent; /** Event triggered every frame, after 'animate'. Usually used if you want to operate after the animation is computed. */ afteranimate: AnimateEvent; } /** * Represents interaction events. These events propagate to parents. * @typeparam T - The primary target type. * @typeparam R - The related target type. * @typeparam RD - The related target type on drag events. */ export interface InteractionEvents { /** Event triggered when a pointer enters the target. */ pointerover: PointerEventExt; /** Event triggered when a pointer enters the target (no propagation). */ pointerenter: PointerEventExt; /** Event triggered when a pointer leaves the target. */ pointerout: PointerEventExt; /** Event triggered when a pointer leaves the target (no propagation). */ pointerleave: PointerEventExt; /** Event triggered when a pointer moves over the target. */ pointermove: PointerEventExt; /** Event triggered when a pointer button is pressed. */ pointerdown: PointerEventExt; /** Event triggered when a pointer button is released. */ pointerup: PointerEventExt; /** Event triggered if pointer is on target. Triggers every frame and only works if the scene has 'continuousRaycasting' equal to true. */ pointerintersection: PointerIntersectionEvent; /** Event triggered when a click event occurs. */ click: PointerEventExt; /** Event triggered when a double click event occurs. */ dblclick: PointerEventExt; /** Event triggered when scrolling the mouse wheel. */ wheel: WheelEventExt; /** Event triggered when target gains focus (no propagation). */ focusin: FocusEventExt; /** Event triggered when target loses focus (no propagation). */ focusout: FocusEventExt; /** Event triggered when target gains focus. */ focus: FocusEventExt; /** Event triggered when target loses focus. */ blur: FocusEventExt; /** Event triggered on the focused object when a key is pressed. */ keydown: KeyboardEventExt; /** Event triggered on the focused object when a key is released. */ keyup: KeyboardEventExt; /** Event triggered when the target is dragged. */ drag: DragEventExt; /** Event triggered when dragging starts. */ dragstart: DragEventExt; /** Event triggered when dragging ends. */ dragend: DragEventExt; /** Event triggered when dragging is canceled (Can be canceled pressing 'ESC'). This is triggered on target and dropTarget. */ dragcancel: DragEventExt; /** Event triggered when a draggable object enters a drop target. */ dragenter: DragEventExt; /** * Event triggered when a draggable object moves over the drop target. * Triggers every frame if the scene has 'continuousRaycastingDropTarget' equal to true. */ dragover: DragEventExt; /** Event triggered when a draggable object leaves a drop target. */ dragleave: DragEventExt; /** Event triggered when a draggable object is dropped onto a drop target. */ drop: DragEventExt; } /** * Represents an extended intersection between a ray and 3D objects in a scene. */ export interface IntersectionExt extends Intersection { object: Object3D; /** The hitbox hit by the raycaster. */ hitbox: Hitbox; } /** * Represents a custom extended event. */ export declare class EventExt { /** A boolean value indicating whether or not the event bubbles up through the DOM. */ get bubbles(): boolean; /** A boolean value indicating whether the event is cancelable. */ readonly cancelable: boolean; /** A reference to the currently registered target for the event. This is the object to which the event is currently slated to be sent. It's possible this has been changed along the way through retargeting. */ currentTarget: T; /** Indicates whether or not the call to event.preventDefault() canceled the event. */ get defaultPrevented(): boolean; /** A reference to the object to which the event was originally dispatched. */ get target(): T; /** The time at which the event was created (in milliseconds). By specification, this value is time since epoch—but in reality, browsers' definitions vary. In addition, work is underway to change this to be a DOMHighResTimeStamp instead. */ readonly timeStamp: number; /** The case-insensitive name identifying the type of the event. */ get type(): keyof Events; /** * @param cancelable A boolean value indicating whether the event is cancelable. */ constructor(cancelable?: boolean); /** Cancels the event. */ preventDefault(): void; /** For this particular event, prevent all other listeners from being called. This includes listeners attached to the same element as well as those attached to elements that will be traversed later (during the capture phase, for instance). */ stopImmediatePropagation(): void; /** Stops the propagation of events further along in the Object3D hierarchy. */ stopPropagation(): void; } /** * Represents a custom extended mouse event. * @template T - The type of the primary target for the event (default is `Object3D`). * @template R - The type of the related target for the event (default is `Object3D`). */ export declare class MouseEventExt extends EventExt { /** Original dom event. */ readonly domEvent: MouseEvent; /** Returns true if the alt key was down when the mouse event was fired. */ get altKey(): boolean; /** The button number that was pressed (if applicable) when the mouse event was fired. */ get button(): number; /** The buttons being pressed (if any) when the mouse event was fired. */ get buttons(): number; /** The X coordinate of the mouse pointer in local (DOM content) coordinates. */ get clientX(): number; /** The Y coordinate of the mouse pointer in local (DOM content) coordinates. */ get clientY(): number; /** Returns true if the control key was down when the mouse event was fired. */ get ctrlKey(): boolean; /** Returns true if the meta key was down when the mouse event was fired. */ get metaKey(): boolean; /** The X coordinate of the pointer relative to the position of the last event. */ get movementX(): number; /** The Y coordinate of the pointer relative to the position of the last event. */ get movementY(): number; /** The X coordinate of the mouse pointer relative to the position of the padding edge of the target node. */ get offsetX(): number; /** The Y coordinate of the mouse pointer relative to the position of the padding edge of the target node. */ get offsetY(): number; /** The X coordinate of the mouse pointer relative to the whole document. */ get pageX(): number; /** The Y coordinate of the mouse pointer relative to the whole document. */ get pageY(): number; /** The secondary target for the event, if there is one. */ readonly relatedTarget: R; /** The X coordinate of the mouse pointer in global (screen) coordinates. */ get screenX(): number; /** The Y coordinate of the mouse pointer in global (screen) coordinates. */ get screenY(): number; /** Returns true if the shift key was down when the mouse event was fired. */ get shiftKey(): boolean; /** Returns the intersection information between the mouse event and 3D objects in the scene. */ readonly intersection: IntersectionExt; /** * @param event Original dom event. * @param intersection The intersection information between the mouse event and 3D objects in the scene. * @param relatedTarget The secondary target for the event. * @param cancelable A boolean value indicating whether the event is cancelable. */ constructor(event: MouseEvent, intersection: IntersectionExt, relatedTarget?: R, cancelable?: boolean); /** Returns the current state of the specified modifier key. See KeyboardEvent.getModifierState() for details. */ getModifierState(keyArg: string): boolean; } /** * Represents a custom extended pointer event. * @template T - The type of the primary target for the event (default is `Object3D`). * @template R - The type of the related target for the event (default is `Object3D`). */ export declare class PointerEventExt extends MouseEventExt { readonly domEvent: PointerEvent; /** A unique identifier for the pointer causing the event. */ get pointerId(): number; /** The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. */ get width(): number; /** The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. */ get height(): number; /** The normalized pressure of the pointer input in the range 0 to 1, where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. */ get pressure(): number; /** The normalized tangential pressure of the pointer input (also known as barrel pressure or cylinder stress) in the range -1 to 1, where 0 is the neutral position of the control. */ get tangentialPressure(): number; /** The plane angle (in degrees, in the range of -90 to 90) between the Y–Z plane and the plane containing both the pointer (e.g. pen stylus) axis and the Y axis. */ get tiltX(): number; /** The plane angle (in degrees, in the range of -90 to 90) between the X–Z plane and the plane containing both the pointer (e.g. pen stylus) axis and the X axis. */ get tiltY(): number; /** The clockwise rotation of the pointer (e.g. pen stylus) around its major axis in degrees, with a value in the range 0 to 359. */ get twist(): number; /** Indicates the device type that caused the event (mouse, pen, touch, etc.). */ get pointerType(): string; /** Indicates if the pointer represents the primary pointer of this pointer type. */ get isPrimary(): boolean; } /** * Represents a custom extended drag event. * @template T - The type of the primary target for the event (default is `Object3D`). * @template R - The type of the related target for the event (default is `Object3D`). */ export declare class DragEventExt extends PointerEventExt { /** The data that is transferred during a drag and drop interaction. */ readonly dataTransfer: { [x: string]: any; }; /** Returns the new position of the dragged object.' */ readonly position: Vector3; /** * @param event Original dom event. * @param cancelable A boolean value indicating whether the event is cancelable. * @param dataTransfer The data that is transferred during a drag and drop interaction. * @param position The new position of the dragged object. * @param relatedTarget The secondary target for the event. * @param intersection The intersection information between the mouse event and 3D objects in the scene. */ constructor(event?: PointerEvent, cancelable?: boolean, dataTransfer?: { [x: string]: any; }, position?: Vector3, relatedTarget?: R, intersection?: IntersectionExt); } /** * Represents a custom extended wheel event. * @template T - The type of the primary target for the event (default is `Object3D`). * @template R - The type of the related target for the event (default is `Object3D`). */ export declare class WheelEventExt extends MouseEventExt { readonly domEvent: WheelEvent; get deltaMode(): number; /** Returns a double representing the horizontal scroll amount. */ get deltaX(): number; /** Returns a double representing the vertical scroll amount. */ get deltaY(): number; /** Returns a double representing the scroll amount for the z-axis. */ get deltaZ(): number; } /** * Represents a pointer intersection event. * @template T - The type of the primary target for the event (default is `Object3D`). */ export declare class PointerIntersectionEvent extends EventExt { /** Returns the intersection information between the mouse event and 3D objects in the scene. */ readonly intersection: IntersectionExt; /** * @param intersection The intersection information between the mouse event and 3D objects in the scene. */ constructor(intersection: IntersectionExt); } /** * Represents a custom extended keyboard event. * @template T - The type of the primary target for the event (default is `Object3D`). */ export declare class KeyboardEventExt extends EventExt { /** Original dom event. */ readonly domEvent: KeyboardEvent; /** Returns a boolean value that is true if the Alt (Option or ⌥ on macOS) key was active when the key event was generated. */ get altKey(): boolean; /** Returns a string with the code value of the physical key represented by the event. */ get code(): string; /** Returns a boolean value that is true if the Ctrl key was active when the key event was generated. */ get ctrlKey(): boolean; /** Returns a string representing the key value of the key represented by the event. */ get key(): string; /** Returns a number representing the location of the key on the keyboard or other input device. Visit https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/location for more info. */ get location(): number; /** Returns a boolean value that is true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the key event was generated. */ get metaKey(): boolean; /** Returns a boolean value that is true if the key is being held down such that it is automatically repeating. */ get repeat(): boolean; /** Returns a boolean value that is true if the Shift key was active when the key event was generated. */ get shiftKey(): boolean; /** * @param event Original dom event. * @param cancelable A boolean value indicating whether the event is cancelable. */ constructor(event: KeyboardEvent, cancelable: boolean); /** Returns a boolean value indicating if a modifier key such as Alt, Shift, Ctrl, or Meta, was pressed when the event was created. */ getModifierState(keyArg: string): boolean; } /** * Represents a custom extended focus event. * @template T - The type of the primary target for the event (default is `Object3D`). * @template R - The type of the related target for the event (default is `Object3D`). */ export declare class FocusEventExt extends EventExt { /** The secondary target for the event. */ relatedTarget: R; /** * @param relatedTarget The secondary target for the event. */ constructor(relatedTarget: R); } /** * Represents an event related to resizing of a renderer. */ export interface ViewportResizeEvent { /** Returns new render width. */ width: number; /** Returns the render height. */ height: number; /** Returns renderer. */ renderer: WebGLRenderer; /** Returns rendering camera. */ camera: Camera; } /** * Represents an event related to animation. */ export interface AnimateEvent { /** The difference in time between the current animation frame and the previous one (in milliseconds). */ delta: DOMHighResTimeStamp; /** The total amount of time that has passed since the animation started (in milliseconds). */ total: DOMHighResTimeStamp; } /** * Represents a property change event. * @template V - The type of the new value associated with the property change. */ export interface PropertyChangeEvent { /** A reference to the object to which the event was originally dispatched. */ target: Object3D; /** The new value associated with the property change. */ value: V; } //# sourceMappingURL=Events.d.ts.map