Skip to content

Latest commit

 

History

History
809 lines (494 loc) · 17.9 KB

p5.easycam.docs.md

File metadata and controls

809 lines (494 loc) · 17.9 KB

Table of Contents

Dw

INFO

EasyCam Library Info

LIBRARY

name

VERSION

version

AUTHOR

author

SOURCE

source

EasyCam

EasyCam

  new Dw.EasyCam(p5.RendererGL, {
    distance : z                 // scalar
    center   : [x, y, z]         // vector
    rotation : [q0, q1, q2, q3]  // quaternion
    viewport : [x, y, w, h]      // array
  }

Parameters

  • renderer p5.RendererGL p5 WEBGL renderer
  • args Object {distance, center, rotation, viewport} // * @memberof Dw

setCanvas

sets the WEBGL renderer the camera is working on

Parameters

  • renderer RendererGL ... p5 WEBGL renderer

getCanvas

Returns RendererGL the currently used renderer

attachMouseListeners

attaches input-listeners (mouse, touch, key) to the used renderer

Parameters

  • renderer

removeMouseListeners

detaches all attached input-listeners

dispose

Disposes/releases the camera.

getAutoUpdate

Returns boolean the current autoUpdate state

setAutoUpdate

If true, the EasyCam will update automatically in a pre-draw step. This updates the camera state and updates the renderers modelview/camera matrix.

If false, the update() needs to be called manually.

Parameters

  • status
  • the boolean new autoUpdate state

update

Updates the camera state (interpolated / damped animations) and updates the renderers' modelview/camera matrix.

if "auto_update" is true, this is called automatically in a pre-draw call.

apply

Applies the current camera state to the renderers' modelview/camera matrix. If no argument is given, then the cameras currently set renderer is used.

Parameters

  • renderer

setViewport

Parameters

  • viewport
  • the Array<int> new viewport-def, as [x,y,w,h]

getViewport

Returns Array<int> the current viewport-def, as [x,y,w,h]

mouseWheelZoom

implemented zoom-cb for mouswheel handler.

mouseDragZoom

implemented zoom-cb for mousedrag/touch handler.

mouseDragPan

implemented pan-cb for mousedrag/touch handler.

mouseDragRotate

implemented rotate-cb for mousedrag/touch handler.

getZoomMult

(private) returns the used zoom -multiplier for damped actions.

getPanMult

(private) returns the used pan-multiplier for damped actions.

getRotationMult

(private) returns the used rotate-multiplier for damped actions.

zoom

Applies a change to the current zoom.

Parameters

  • dz

panX

Applies a change to the current pan-xValue.

Parameters

  • dx

panY

Applies a change to the current pan-yValue.

Parameters

  • dy

pan

Applies a change to the current pan-value.

Parameters

  • dx
  • dy

rotateX

Applies a change to the current xRotation.

Parameters

  • rx

rotateY

Applies a change to the current yRotation.

Parameters

  • ry

rotateZ

Applies a change to the current zRotation.

Parameters

  • rz

rotate

Applies a change to the current rotation, using the given axis/angle.

Parameters

  • axis
  • angle

setInterpolatedDistance

Sets the new camera-distance, interpolated (t) between given A and B.

Parameters

  • valA
  • valB
  • t

setInterpolatedCenter

Sets the new camera-center, interpolated (t) between given A and B.

Parameters

  • valA
  • valB
  • t

setInterpolatedRotation

Sets the new camera-rotation, interpolated (t) between given A and B.

Parameters

  • valA
  • valB
  • t

setDistanceMin

Sets the minimum camera distance.

Parameters

  • distance_min

setDistanceMax

Sets the maximum camera distance.

Parameters

  • distance_max

setDistance

Sets the new camera distance.

Parameters

  • distance
  • duration
  • new double distance.
  • animation long time in millis.

getDistance

Returns double the current camera distance.

setCenter

Sets the new camera center.

Parameters

  • center
  • duration
  • new Array<double> center.
  • animation long time in millis.

getCenter

Returns Array<double> the current camera center.

setRotation

Sets the new camera rotation (quaternion).

Parameters

  • rotation
  • duration
  • new Array<double> rotation as quat[q0,q1,q2,q3].
  • animation long time in millis.

getRotation

Returns Array<double> the current camera rotation as quat[q0,q1,q2,q3].

getPosition

Parameters

  • dst

Returns Array<double> the current camera position, aka. the eye position.

getUpVector

Parameters

  • dst

Returns Array<double> the current camera up vector.

getState

Returns Object a copy of the camera state {distance,center,rotation}

setState

Parameters

  • other
  • duration
  • a Object new camera state {distance,center,rotation}.
  • animation long time in millis.

pushResetState

sets the current state as reset-state.

reset

resets the camera, by applying the reset-state.

Parameters

  • duration

setRotationScale

sets the rotation scale/speed.

Parameters

  • scale_rotation

setPanScale

sets the pan scale/speed.

Parameters

  • scale_pan

setZoomScale

sets the zoom scale/speed.

Parameters

  • scale_zoom

setWheelScale

sets the wheel scale/speed.

Parameters

  • wheelScale

getRotationScale

Returns any the rotation scale/speed.

getPanScale

Returns any the pan scale/speed.

getZoomScale

Returns any the zoom scale/speed.

getWheelScale

Returns any the wheel scale/speed.

setDamping

sets the default damping scale/speed.

Parameters

  • damping

setDefaultInterpolationTime

sets the default interpolation time in millis.

Parameters

  • duration

setRotationConstraint

sets the rotation constraint for each axis separately.

Parameters

beginHUD

begin screen-aligned 2D-drawing.

beginHUD()
  disabled depth test
  ortho
  ... your code is executed here ...
endHUD()

Parameters

  • renderer
  • w
  • h

endHUD

end screen-aligned 2D-drawing.

Parameters

  • renderer

INFO

damped-callback

Damped callback, that accepts the resulting damped/smooth value.

Type: Function

Parameters

  • value double the damped/smoothed value

DampedAction

DampedAction, for smoothly changing a value to zero.

Parameters

addForce

adds a value to the current value beeing damped.

Parameters

  • force double the value beeing added.

update

updates the damping and calls damped-callback.

stop

stops the damping.

interpolation-callback

Interpolation callback, that implements any form of interpolation between two values A and B and the interpolationparameter t.

  linear: A * (1-t) + B * t
  smooth, etc...

Type: Function

Parameters

  • A Object First Value
  • B Object Second Value
  • t double interpolation parameter [0, 1]

Interpolation

Interpolation, for smoothly changing a value by interpolating it over time.

Parameters

start

starts the interpolation. If the given interpolation-duration is 0, then interpolation-callback is called immediately.

Parameters

  • valA
  • valB
  • duration
  • actions

update

updates the interpolation and calls interpolation-callback.

stop

stops the interpolation.

Rotation

Rotation as Quaternion [q0, q1, q2, q3]

Note: Only functions that were required for the EasyCam to work are implemented.

identity

Returns Array<Number> an identity rotation [1,0,0,0]

applyToVec3

Applies the rotation to a vector and returns dst or a new vector.

Parameters

Returns Array<Number> dst- resulting vector

applyToRotation

Applies the rotation to another rotation and returns dst or a new rotation.

Parameters

Returns Array<Number> dst - resulting rotation

slerp

Interpolates a rotation.

Parameters

Returns Array<Number> dst - resulting rotation

create

Creates/Initiates a new Rotation

   1) Axis,Angle:
      {
        axis : [x, y, z],
        angle: double
      }
     
   2) Another Rotation:
      {
        rotation : [q0, q1, q2, q3],
        normalize: boolean
      }
     
   3) 3 euler angles, XYZ-order:
      {
        angles_xyz : [rX, rY, rZ]
      }
  

Parameters

  • def Object Definition, for creating the new Rotation
  • dst Array<Number> resulting rotation

Returns Array<Number> dst - resulting rotation

Scalar

Scalar as a simple number.

Note: Only functions that were required for the EasyCam to work are implemented.

mix

Linear interpolation between A and B using t[0,1]

Parameters

  • a
  • b
  • t

smoothstep

modifying t as a function of smoothstep(0,1,t);

Parameters

  • x

smootherstep

modifying t as a function of smootherstep(0,1,t);

Parameters

  • t

Vec3

Vec3 as a 3D vector (Array)

add

addition:

 dst = a + b 

Parameters

  • a
  • b
  • dst

mult

componentwise multiplication:

 dst = a * b 

Parameters

  • a
  • b
  • dst

magSq

squared length

Parameters

  • a

mag

length

Parameters

  • a

dot

dot-product

Parameters

  • a
  • b

cross

cross-product

Parameters

  • a
  • b
  • dst

angle

angle

Parameters

  • v1
  • v2

mix

linear interpolation:

 dst = a _ (1 - t) + b _ t 

Parameters

  • a
  • b
  • t
  • dst