2.8.0 • Published 2 years ago

pex-cam v2.8.0

Weekly downloads
39
License
MIT
Repository
github
Last release
2 years ago

pex-cam

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Cameras models and controllers for 3D rendering in PEX.

npm.io

Installation

npm install pex-cam

Usage

import {
  perspective as createPerspectiveCamera,
  orbiter as createOrbiter,
} from "pex-cam";

const perspectiveCamera = createPerspectiveCamera({
  position: [2, 2, 2],
  target: [0, -0.5, 0],
  aspect: window.innerWidth / window.innerHeight,
});

const perspectiveOrbiter = createOrbiter({
  camera: perspectiveCamera,
});

console.log(perspectiveCamera.projectionMatrix);

API

Modules

Classes

Typedefs

index

Re-export classes and factory functions

index.perspective ⇒ PerspectiveCamera

Factory function for perspective camera

Kind: static constant of index

ParamType
optsCameraOptions | PerspectiveCameraOptions

index.orthographic ⇒ OrthographicCamera

Factory function for orthographic camera

Kind: static constant of index

ParamType
optsCameraOptions | OrthographicCameraOptions

index.orbiter ⇒ OrbiterControls

Factory function for orbiter controls

Kind: static constant of index

ParamType
optsOrbiterControlsOptions

Camera

An interface for cameras to extend

Kind: global class

camera.set(opts)

Update the camera

Kind: instance method of Camera

ParamType
optsCameraOptions

OrbiterControls

Camera controls to orbit around a target

Kind: global class

new OrbiterControls(opts)

Create an instance of OrbiterControls

ParamType
optsOrbiterControlsOptions

orbiterControls.set(opts)

Update the control

Kind: instance method of OrbiterControls

ParamType
optsOrbiterOptions

orbiterControls.dispose()

Remove all event listeners

Kind: instance method of OrbiterControls

OrthographicCamera ⇐ Camera

A class to create an orthographic camera

Kind: global class Extends: Camera

new OrthographicCamera(opts)

Create an instance of PerspectiveCamera

ParamType
optsCameraOptions | OrthographicCameraOptions

orthographicCamera.set(opts)

Update the camera

Kind: instance method of OrthographicCamera Overrides: set

ParamType
optsCameraOptions | OrthographicCameraOptions

PerspectiveCamera ⇐ Camera

A class to create a perspective camera

Kind: global class Extends: Camera

new PerspectiveCamera(opts)

Create an instance of PerspectiveCamera

ParamType
optsCameraOptions | PerspectiveCameraOptions

perspectiveCamera.set(opts)

Update the camera

Kind: instance method of PerspectiveCamera Overrides: set

ParamType
optsCameraOptions | PerspectiveCameraOptions

perspectiveCamera.getViewRay(x, y, windowWidth, windowHeight) ⇒ ray

Create a picking ray in view (camera) coordinates

Kind: instance method of PerspectiveCamera

ParamTypeDescription
xnumbermouse x
ynumbermouse y
windowWidthnumber
windowHeightnumber

perspectiveCamera.getWorldRay(x, y, windowWidth, windowHeight) ⇒ ray

Create a picking ray in world coordinates

Kind: instance method of PerspectiveCamera

ParamType
xnumber
ynumber
windowWidthnumber
windowHeightnumber

Radians : number

Kind: global typedef

Degrees : number

Kind: global typedef

CameraView : Object

Kind: global typedef Properties

NameType
offsetmodule:pex-math~vec2
sizemodule:pex-math~vec2
totalSizemodule:pex-math~vec2

CameraOptions : Object

Kind: global typedef Properties

NameTypeDefault
projectionMatrixmodule:pex-math~mat4mat4.create()
invViewMatrixmodule:pex-math~mat4mat4.create()
viewMatrixmodule:pex-math~mat4mat4.create()
positionmodule:pex-math~vec30, 0, 3
targetmodule:pex-math~vec30, 0, 0
upmodule:pex-math~vec30, 1, 0
aspectnumber1
nearnumber0.1
farnumber100
viewCameraView

PerspectiveCameraOptions : Object

Kind: global typedef Properties

NameTypeDefault
fovRadiansMath.PI / 3

OrthographicCameraOptions : Object

Kind: global typedef Properties

NameTypeDefault
leftnumber-1
rightnumber1
bottomnumber-1
topnumber1
zoomnumber1

OrbiterControlsOptions : Object

Kind: global typedef Properties

NameTypeDefault
cameraCamera
elementHTMLElementdocument
easingnumber0.1
zoombooleantrue
panbooleantrue
dragbooleantrue
minDistancenumber0.1
maxDistancenumber10
minLatDegrees-89.5
maxLatDegrees89.5
minLonnumber-Infinity
maxLonnumberInfinity
panSlowdownnumber4
zoomSlowdownnumber400
dragSlowdownnumber4
autoUpdatebooleantrue

License

MIT. See license file.

3.0.0-alpha.1

2 years ago

3.0.0-alpha.0

2 years ago

2.8.0

4 years ago

2.7.1

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.2

6 years ago

2.3.1

6 years ago

2.3.0

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.0-beta.2

8 years ago

1.0.0-beta.1

8 years ago