LookAt Manager
LookAtManager is a class that manages the orientation of joints or bones in a Three.js scene, typically used for eyes and neck of a character, following the mouse movement within a defined hotzone.
Constructor
LookAtManager(screenViewPercentage, canvasID, camera)
screenViewPercentage: Percentage of the screen width to consider for the hotzone.canvasID: The ID of the canvas element.camera: The Three.js camera.
Properties
Properties for ScreenshotManager are not meant to be edited directly they are modified with methods.
-
.bonesInfo: ArrayAn array containing information about the bones being managed.
-
.curMousePos: Vector2Current mouse position.
-
.hotzoneSection: ObjectObject defining the hotzone section on the screen.
-
.enabled: BooleanFlag indicating whether the look-at feature is enabled.
-
.userActivated: BooleanFlag indicating whether the user has activated the look-at feature.
-
.lookInterest: NumberThe level of interest in looking at the target.
-
.hasInterest: BooleanFlag indicating whether there is an interest in looking at the target.
-
.interestSpeed: NumberSpeed of the interest adjustment.
-
.onCanvas: BooleanFlag indicating whether the mouse is on the canvas.
-
.camera: CameraThe Three.js camera.
-
.maxLookPercent: ObjectMaximum percentage limits for different bones' look.
-
.windowEventListeners: ArrayArray to store references to window event listeners.
Methods
setActive(active)
Sets the activation state of the look-at feature.
active: Boolean value to set the activation state.
setCamera(camera)
Sets the camera for the look-at manager.
camera: The new Three.js camera.
addVRM(vrm)
Adds a VRM (Virtual Reality Model) to the look-at manager.
vrm: The VRM instance to be added.
removeVRM(vrm)
Removes a VRM from the look-at manager.
vrm: The VRM instance to be removed.
lerp(a, b, t)
Performs linear interpolation between two values.
a: Initial value.b: Target value.t: Interpolation factor.
update()
Updates the look-at manager based on mouse movement and other settings. It adjusts the orientation of bones within the hotzone.
getHotzoneSection()
Calculates and returns the hotzone section based on the screen width percentage.