Constructor
new SimpleRotator(canvas, callback, viewDirectionVector, viewUpVector, viewDistance)
Constructor of SimpleRotator.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
HTMLCanvasElement | the HTML canvas element used for WebGL drawing. The user will rotate the scene by dragging the mouse on this canvas. This parameter is required. |
callback |
function | if present must be a function, which is called whenever the rotation changes. It is typically the function that draws the scene |
viewDirectionVector |
Array.<Number> | if present must be an array of three numbers, not all zero. The view is from the direction of this vector towards the origin (0,0,0). If not present, the value [0,0,10] is used. |
viewUpVector |
Array.<Number> | if present must be an array of three numbers. Gives a vector that will be seen as pointing upwards in the view. If not present, the value is [0,1,0]. |
viewDistance |
Number | if present must be a positive number. Gives the distance of the viewer from the origin. If not present, the length of viewDirectionVector is used. |
- Source:
Methods
getViewDistance() → {Number}
Returns the viewDistance.
- Source:
Returns:
view distance.
- Type
- Number
getViewMatrix() → {Float32Array}
Returns an array representing the viewing transformation matrix for the current view,
suitable for using with gl.uniformMatrix4fv or, for further transformation, with the glmatrix library mat4 class.
suitable for using with gl.uniformMatrix4fv or, for further transformation, with the glmatrix library mat4 class.
- Source:
Returns:
view matrix.
- Type
- Float32Array
getViewMatrixArray() → {Array.<Number>}
Returns the view transformation matrix as a regular JavaScript array,
but still represents as a 1D array of 16 elements, in column-major order.
but still represents as a 1D array of 16 elements, in column-major order.
- Source:
Returns:
view matrix.
- Type
- Array.<Number>
setView(viewDirectionVector, viewUpVector, viewDistance)
Set up the view, where the parameters are optional,
and are used in the same way,
as the corresponding parameters in the constructor.
as the corresponding parameters in the constructor.
Parameters:
Name | Type | Description |
---|---|---|
viewDirectionVector |
Array.<Number> | if present must be an array of three numbers, not all zero. The view is from the direction of this vector towards the origin (0,0,0). If not present, the value [0,0,10] is used. |
viewUpVector |
Array.<Number> | if present must be an array of three numbers. Gives a vector that will be seen as pointing upwards in the view. If not present, the value is [0,1,0]. |
viewDistance |
Number | if present must be a positive number. Gives the distance of the viewer from the origin. If not present, the length of viewDirectionVector is used. |
- Source:
setViewDistance(viewDistance)
Sets the distance of the viewer from the origin without
changing the direction of view.
If not present, the length of viewDirectionVector is used.
If not present, the length of viewDirectionVector is used.
Parameters:
Name | Type | Description |
---|---|---|
viewDistance |
Number | view distance. |
- Source:
setViewMatrix(matrix)
Sets the view matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Float32Array | view matrix. |
- Source: