pex-gl / pex-rfc

Requests for comments related to the pex library
2 stars 0 forks source link

Managing transformation hierarchies #3

Open vorg opened 9 years ago

vorg commented 9 years ago

Currently there is no built-in solution in pex.

Scene graph

Like THREE.js

// Create a new Three.js scene
scene = new THREE.Scene();

// Add  a camera so we can view the scene
camera = new THREE.PerspectiveCamera( 45, canvas.width / canvas.height, 1, 4000 );
camera.position.z = 10;
scene.add(camera);

// Create a group to hold all the objects
cubeGroup = new THREE.Object3D;

// Add a directional light to show off the objects
var light = new THREE.DirectionalLight( 0xffffff, 1.5);
// Position the light out from the scene, pointing at the origin
light.position.set(.5, .2, 1);
cubeGroup.add(light);

Matrix stack

Like foam-gl

glTrans.pushMatrix();
glTrans.translate3f(Math.cos(-t) * 0.5, 0.5, Math.sin(-t) * 0.5);
glTrans.rotate3f(Math.sin(t) * Math.PI ,0,Math.sin(t));
glTrans.scale1f(0.75);
this.drawGeom();
glTrans.popMatrix();