ThreeJS. ThreeJSPlugin

ThreeJS Plugin - Renders a three.js scene behind the LittleJS canvas

Constructor

new ThreeJSPlugin(THREE, cameraFOVopt)

Set up the three.js rendering layer, call in gameInit

Parameters:
NameTypeAttributesDefaultDescription
THREEObject

The three.js module, supplied by the user

cameraFOVnumber<optional>
60

Vertical field of view in degrees

Example
// in gameInit, with three.js loaded by the user
new ThreeJSPlugin(THREE);
threeJS.scene.add(new THREE.AmbientLight);

Members

THREE

Properties
TypeDescription
Object

The three.js module passed into the constructor

camera

Properties
TypeDescription
Object

The three.js perspective camera

cameraAlign2D

Properties
TypeDescription
boolean

Lock the camera to the LittleJS 2D camera so the z=0 plane matches world space

cameraFar :number|undefined

Type:
  • number | undefined
Properties
TypeDescription
number | undefined

Far plane of the aligned camera before any zoom out, from camera.far on the first aligned frame; while aligned, change this rather than camera.far

cameraNear :number|undefined

Type:
  • number | undefined
Properties
TypeDescription
number | undefined

Near plane of the aligned camera before any zoom out, from camera.near on the first aligned frame; while aligned, change this rather than camera.near

renderer

Properties
TypeDescription
Object

The three.js renderer

scene

Properties
TypeDescription
Object

The three.js scene, add lights and meshes here

Methods

alignCamera2D()

Position the camera so the z=0 plane exactly matches LittleJS world space, called automatically when cameraAlign2D is set

render()

Sync the canvas layout and render the scene, called automatically each frame