From 364193f79e80da8666b84935e65b3f40f2b1d77d Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Mon, 7 May 2018 11:13:19 -0700 Subject: [PATCH] beginning fix for camera perspective --- src/components/graph/graph.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/graph/graph.js b/src/components/graph/graph.js index a4b74781..38166b84 100644 --- a/src/components/graph/graph.js +++ b/src/components/graph/graph.js @@ -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(); });