Class: Stage3D

Stage3D

new Stage3D(autoRenderopt)

All 3D elements to be rendered are to be added to a Stage3D instance. Note that the Stage3D does NOT replace the createjs.Stage. It goes inside of it like a normal CreateJS display object. Even though it inherits from DisplayObject3D it should be treated like a 2D object on the CreateJS stage as far as its own positioning/rotating goes. Any z, rotX, rotY, and rotZ properties are not intended to function; only x and y should be used. If you want a container for 3D elements that you can move and rotated in 3D space then see Group3D.

Also note that a Stage3D needs to be updated each frame. If autoRender is used (as is default) it will just constantly update. This is not as taxing as it would seem since it uses a diry/clean rendering system. For slightly better performance you can update manually as needed using the render method.

See createjs.Container to understand the properties, methods, and events it inherits from createjs.Container.
Parameters:
Name Type Attributes Default Description
autoRender Boolean <optional>
true Shortcut to the set autoRender property.
Source:

Extends

Members

alphaDepthOfField :AlphaDepthOfField

Depth of field is an effect by which objects appear blurrier the further they are from the focus of a camera. The AlphaDepthOfField class can mimic this effect in DepthJS except with alpha instead of blur. To do so set this property to an AlphaDepthOfField instance. Use null for none.
Type:
Default Value:
  • null
Source:

autoRender :Number

Turn on/off automatic rendering. When true this will update the stage on every frame. Because of the engine's dirty/clean rendering system this is not very taxing. However, if you wish to update it yourself see the render method. This is also set by constructor argument from instantiation.
Type:
  • Number
Default Value:
  • true
Source:

depthOfField :DepthOfField

Depth of field is an effect by which objects appear blurrier the further they are from the focus of a camera. The DepthOfField class can mimic this effect in DepthJS. To do so set this property to a DepthOfField instance. Use null for none. Blurriness in CreateJS is not the best nor easy on the system. Consider using the alphaDepthOfField property instead.
Type:
Default Value:
  • null
Source:

distortion :Number

distortion affects how the location of objects are distorted (lesser for further away, more for closer) as they move on the z-axis. Experiment to get the effect that works for your use.
Type:
  • Number
Default Value:
  • 6
Source:

(readonly) isStage3D :Boolean

isStage3D is a read-only property to easily determine if an object is a Stage3D instance.
Type:
  • Boolean
Default Value:
  • true
Source:

(readonly) stage3D :Stage3D

In Stage3D instances the DisplayObject3D property stage3D always should read as the Stage3D instance itself.
Type:
Overrides:
Default Value:
  • this
Source:

x :Number

The instance's x coordinate in normal CreateJS 2D space.
Type:
  • Number
Overrides:
Default Value:
  • 0
Source:

y :Number

The instance's y coordinate in normal CreateJS 2D space.
Type:
  • Number
Overrides:
Default Value:
  • 0
Source:

zoom :Number

zoom affects how objects are scaled as they move on the z-axis. Experiment to get the effect that works for your use.
Type:
  • Number
Default Value:
  • 5000
Source:

Methods

addChild() → {DisplayObject3D}

addChild allows objects to be added to this Stage3D instance. addChild may take a singular value to add or may be given many such as instance.addChild(one, two, three, four);
Parameters:
Type Description
DisplayObject3D Any object that inherits from DisplayObject3D may be added.
Source:
Returns:
Returns the DisplayObject3D that was added, or the last that was added if multiple were added at once.
Type
DisplayObject3D

removeChild() → {Boolean}

removeChild allows objects that were added via addChild to be removed. removeChild may take a singular value to remove or may be given many such as instance.removeChild(one, two, three, four);
Parameters:
Type Description
DisplayObject3D Any object that inherits from DisplayObject3D and has been added may be removed.
Source:
Returns:
Returns a Boolean value for if the object was removed (false if it was not in the display list to be removed), or the result for the last that was removed if multiple were removed at once.
Type
Boolean

update()

Stage3D's update method updates the locations/rotations of everything in the display list if their locations/rotation values are dirty (i.e. are not the same as the last render/update). This method only needs to be used if not using autoRender.
Source: