How do we set 3D perspective in the new Famous Engine

157 views Asked by At

Famo.us has now released the new Famous Engine (v0.5.0). It has a whole new architecture in how to build 3D transforms.

The prior (v0.3.5) API created a context and on that context you would setPerspective.

var mainContext = Engine.createContext();
mainContext.setPerspective(1000);

What is the new way of setting perspective for the Famous Engine?

1

There are 1 answers

0
talves On

I found the answer. The new engine has introduced a Camera

Camera is a component that is responsible for sending information to the renderer about where the camera is in the scene. This allows the user to set the type of projection, the focal depth, and other properties to adjust the way the scenes are rendered.

// Dependencies
var FamousEngine = famous.core.FamousEngine;
var Camera = famous.components.Camera;

// Boilerplate code to make your life easier
FamousEngine.init();

// Initialize with a scene;
var scene = FamousEngine.createScene();

// To set perspective
var camera = new Camera(scene);
camera.setDepth(1000);