Skip to content
simCecca edited this page May 18, 2022 · 1 revision

In this section I would like to write a little documentation about this package

The constructor

const compass = new Compass(camera, renderer);

where

  • camera: THREE.PerspectiveCamera
  • renderer: THREE.WebGLRenderer

Public Methods

compass.getBounds()

returns the boundaries of the Three.js canvas space, so the space as an object

return value: { minWidth: number; maxWidth: number; minHeight: number; maxHeight: number; }


compass.getABSBounds()

return the absolute bounds of the canvas space, so the one that depends on z, fov and the aspect

return value: { width: number; height: number; }


compass.fromCanvasPercentageToWorldCoordinates(percentX: number, percentY: number)

translate from the coordinates expressed in percentages to world coordinates

return value: { wx: number; wy: number; }


compass.getWorldToCanvasPercentCoordinates(wx: number, wy: number)

take world x coordinate and world y coordinate and transform them in to percentage coordinates in the space of the canvas so in numbers between -1 and 1

return value: { percentX: number from -1 to 1; percentY: number from -1 to 1; }


compass.getWorldToCanvasABSPercentCoordinates(wx: number, wy: number)

take world x coordinate and world y coordinate and transform them in to percentage coordinates in the space of the canvas but the absolute one, so in numbers between 0 and 1

return value: { percentX: number from 0 to 1; percentY: number from 0 to 1 }


compass.getWorldToCanvasCoordinates(wx: number, wy: number)

get world coordinates and return the translated ones from the space of the canvas

return value: { x: number; y: number}


compass.getWorldToCanvasABSCoordinates(wx: number, wy: number)

get world coordinates and return the translated ones from the space of the canvas, but the absolute one.

return value: { x: number; y: number }


compass.setAllEvents()

set the zoom and the pan of the application, after this method you can use zoom and pan


compass.removeAllEvents()

remove zoom and pan handler


compass.setZoomHandler()

enable the zoom handler in the application, after this method you can use the zoom


compass.removeZoomEvent()

remove the zoom handler


compass.setDragCanvas()

enable the pan handler in the application, after this method you can use the pan


compass.removeDragCanvas()

remove the pan handler

Clone this wiki locally