Members
camera :THREE.PerspectiveCamera
Type:
(constant) colorTable :Object.<String, THREE.Color>
Type:
- Object.<String, THREE.Color>
container :HTMLDivElement
Type:
- HTMLDivElement
group :THREE.Group
Type:
help :Boolean
Type:
- Boolean
(constant) imageNames :Object.<Symbol, Array.<String>>
Type:
- Object.<Symbol, Array.<String>>
inAndOutCamera :Boolean
Type:
- Boolean
(constant) lightHelpers
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lightHelpers |
Object | container for helpers.
Properties
|
mouseX :Number
Type:
- Number
mouseXOnMouseDown :Number
Type:
- Number
(constant) oLoader :THREE.OBJLoader
Type:
(constant) path :String
Type:
- String
paused :Boolean
Type:
- Boolean
renderer :THREE.WebGLRenderer
Type:
scene :THREE.Scene
Type:
showHelpers :Boolean
Type:
- Boolean
targetRotation :Number
Type:
- Number
targetRotationOnMouseDown :Number
Type:
- Number
teaPotGroup :THREE.Group
Type:
windowHalfX :Number
Type:
- Number
windowHalfY :Number
Type:
- Number
Methods
addBaubles(group, materials)
Add 28 baubles.
Yeah, kind of hardcoded... no, I'm not proud.
But this was the most straightforward way to add trinkets to the tree that actually looked like they were on the tree.Parameters:
Name | Type | Description |
---|---|---|
group |
THREE.Group | the given group to add the baubles to. |
materials |
Object.<String, THREE.Material> | the given material object. |
addGround(group)
Add ground to scene.
The average user doesn't have a calibrated monitor and has never heard of gamma correction; therefore, many visual materials are precorrected for them. For example, by convention, all JPEG files are precorrected for a gamma of 2.2. That's not exact for any monitor, but it's in the ballpark, so the image will probably look acceptable on most monitors. This means that JPEG images (including scans and photos taken with a digital camera) are not linear, so they should not be used as texture maps by shaders that assume linear input.Parameters:
Name | Type | Description |
---|---|---|
group |
THREE.Group | the given group to add the ground to. |
- Source:
- See:
addLight(scene)
Lights galore - includes point lights, spot lights, and a directional light because why not?
We also created a camera helper for the spot light.
Lighting and color has changed a lot since version 155.
It’s important to understand that using the new lighting mode is just one prerequisite for physically correct lighting.You also have to:
- apply a real-world scale to your scene (meaning 1 world unit = 1 meter).
- not change the default decay values of 2 for all spot and point lights in your scene.
Only then you can actually consider SI units for point, spot and area lights. Ambient and hemisphere lights (which are special kind of lights and essentially simplified models of light probes), as well as directional lights, do not use SI units.

These updates enable a “linear workflow” by default, for better image quality.
To set “renderer.useLegacyLights = false;” in init,
I had to increase the light intensities,
and set decay to zero (my lights are too far away from the scene borders):
- ambient light 0.2 → 2
- point light 2 → 4
- spot light 1 → 2
- ambient light 2 → Math.PI * 2
- pointLight.decay = 0;
- spotLight.decay = 0;
Parameters:
Name | Type | Description |
---|---|---|
scene |
THREE.Scene | the given scene. |
addObject(group, objectFile, x, y, z, size, rotate, color)
Loads an object to the scene.
Used to add the teapot and the bunnies. Frigging bunnies all around, everyone loves bunnies. Teapot is our new Christmas tree star.Parameters:
Name | Type | Description |
---|---|---|
group |
THREE.Group | the given group to add the object to. |
objectFile |
String | the object file to be read. |
x |
Number | position x |
y |
Number | position y |
z |
Number | position z |
size |
Number | the object's size. |
rotate |
Number | rotation amount. |
color |
THREE.Color | the objects's color. |
addPresent(group, size, x, y, z, images, imgpath)
I developed a certain dislike for skyboxes or at least for the clunky ones. As such, the PRESENTS are going to be skyboxes.
Why not, am I right? No specification were given saying that the skyboxes had to be used as the 'environment'.Parameters:
Name | Type | Description |
---|---|---|
group |
THREE.Group | the given group to add the presents to. |
size |
Number | the size of the box -- will correspond to width, length, and height. |
x |
Number | position x |
y |
Number | position y |
z |
Number | position z |
images |
Array.<String> | image array to use. |
imgpath |
String | path to the image array. |
- Source:
- See:
addSnowflakes(group)
Christmas needs frigging snowflakes.
Except Christmas in Brazil, then it is just palm trees... Based on a tutorial found on huzzahParameters:
Name | Type | Description |
---|---|---|
group |
THREE.Group | the given group to add the snowflakes to. |
cameraControl(c, ch)
Parameters:
Name | Type | Description |
---|---|---|
c |
THREE.Camera | the given camera. |
ch |
String | a given character. |
displayHelpers()
getChar(event)
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent | keyboard event. |
- Source:
- See:
handleKeyPress(event)
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent | keydown event. |
init()
Add listeners for "mousedown", "touchstart", and "touchmove".
The listeners are added to the canvas element (renderer.domElement), so to prevent "the pull to refresh" on a swipe-down.makeCamera(scene)
Parameters:
Name | Type | Description |
---|---|---|
scene |
THREE.Scene | given scene. |
makeGreeting()
makeTree(group, materials)
Parameters:
Name | Type | Description |
---|---|---|
group |
THREE.Object3D | the given group to add the tree to. |
materials |
Object.<String, THREE.Material> | the given material object. |
- Source:
- See:
onWindowResize()
Resizes the scene according to the screen size.
Many thanks.prepareMaterials(group)
Parameters:
Name | Type | Description |
---|---|---|
group |
THREE.Group | the given group. |
render() → {animate}
- Source:
- See:
Returns:
- Type
- animate
setAnimationLoop(loop)
A built in function that can be used instead of requestAnimationFrame.
The renderer.setAnimationLoop parameter is a callback, which will be called every available frame.If null is passed it will stop any already ongoing animation.
Parameters:
Name | Type | Description |
---|---|---|
loop |
function | callback. |
Type Definitions
animate()
Events
keydown
Key handler.
Fired when a key is pressed.
Calls handleKeyPress when pressing assigned keys:- Space - pause
- h - help
- l - light helpers
- w, s, a, d - forward, backward, left, right
- I, K, J, L - orbit down, up, left, right
- +, - - field of view (zoom)
- ↑, ↓- up, down
- n - move camera close/farther away wile rotating, or not
- Source:
- See:
load
Load the applicarion.
Fired when the whole page has loaded, including all dependent resources such as stylesheets, scripts, iframes, and images, except those that are loaded lazily. Initialize and start animation.Parameters:
Name | Type | Description |
---|---|---|
event |
Event | a generic Event. |
- Source:
- See:
onDocumentMouseDown
Add listeners for "mousemove", "mouseup", and "mouseout".
Parameters:
Name | Type | Description |
---|---|---|
event |
MouseEvent | mouse event. |
- Source:
- See:
onDocumentMouseMove
Parameters:
Name | Type | Description |
---|---|---|
event |
MouseEvent | mouse event. |
- Source:
- See:
onDocumentMouseOut
Removes the listeners for "mousemove", "mouseup", and "mouseout".
Parameters:
Name | Type | Description |
---|---|---|
event |
MouseEvent | mouse event. |
- Source:
- See:
onDocumentMouseUp
Remove listeners for "mousemove", "mouseup", and "mouseout".
Parameters:
Name | Type | Description |
---|---|---|
event |
MouseEvent | mouse event. |
- Source:
- See:
onDocumentTouchMove
Parameters:
Name | Type | Description |
---|---|---|
event |
TouchEvent | touch event. |
- Source:
- See:
onDocumentTouchStart
Parameters:
Name | Type | Description |
---|---|---|
event |
TouchEvent | touch event. |
- Source:
- See:
resize
Appends an event listener for events whose type attribute value is resize.
Fires when the document view (window) has been resized.The callback argument sets the callback that will be invoked when the event is dispatched.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | the document view is resized. |
function |
callback | function to run when the event occurs. |
useCapture |
Boolean | handler is executed in the bubbling or capturing phase. |
- Source:
- See: