scene(perspective, update_perspective, perspective_origin_x, perspective_origin_y) scene.messages = [params] = []


This controller must be set on the scene-containing DOM node, most often this being the <body> tag. Its parameters perspective, perspective_origin_x and perspective_origin_y are applied as CSS style properties and define the perspective effect of the rendered scene.

Since the 3D view-point (defined by perspective_origin_x and perspective_origin_y) is static and is not moved by the browser when its viewport (i.e. view-point) changes, the scene() controller monitors the browser's viewport and modifies these two CSS properties, matching the 3D view-point with the center of the viewport for a true 3D experience.

For scene consistency, when a new behave3d element is created, all DOM nodes in the parent chain between it and the scene node have their CSS properties style.transform-style set to preserve-3d. This makes sure all the elements share a common 3D space.

Note that a default scene() controller will be automatically created and assigned to document.body on the first call to Behave3d.updatePool() if a definition of a scene() controller is not found during the DOM scanning.


Parameters of scale():

Distance between the 3D view-point (the camera) and the page layout plane (z = 0) in pixels. The bigger the value, the less pronounced the 'perspective' effect. Very big values give an effect close to an orthogonal projection (no perspective), which can be set with a value of "none" By default, the camera is situated at a distance equal to the width of the current viewport, and the exact value is calculated every time the viewport changes. This means that when zooming in, with the viewport getting progressively smaller, the camera will get closer to the layout plane. Default value: 100%v
Set this to false if you don't want the controller to update the values of parameters perspective_origin_x and perspective_origin_y upon viewport change. Default value: true
perspective_origin_x, perspective_origin_y
Coordinates of the view-point measured as parts (positions) within the scene element's box. Set initial values (or permanent ones if parameter update_perspective is false) of the view-point coordinates. Default values: 0.5, 0.5

Accepted Messages

Messages accepted by scale():

Apply new values of any of the scene parameters. Message params: {perspective, update_perspective, perspective_origin_x, perspective_origin_y}

Generated Events

Controller scale() doesn't fire any events.

Interaction with DOM

Changes Log

  1. Controller introduced in v.0.80

See Also