beginning fix for camera perspective

This commit is contained in:
Colin Megill
2018-05-07 11:13:19 -07:00
parent 1b4e717efc
commit 364193f79e

View File

@@ -51,6 +51,7 @@ class Graph extends React.Component {
constructor(props) {
super(props);
this.count = 0;
this.inverse = mat4.identity([]);
this.state = {
drawn: false,
svg: null,
@@ -93,6 +94,17 @@ class Graph extends React.Component {
scale: viewportHeight / viewportWidth
});
var view = camera.view(); // get the camera matrix
var projection = mat4.perspective(
[],
Math.PI / 2,
context.viewportWidth * props.scale / context.viewportHeight,
0.01,
1000
); // get the projection matrix
var combined = mat.multiply([], projection, view); // this is the matrix applied to the transform
this.inverse = mat.invert([], combined); // this is the inverse
camera.tick();
});