Fakultas Ilmu Komputer UI

Commit 4fb8032b authored by Rachmat Ridwan's avatar Rachmat Ridwan
Browse files

Add camera to sceneGraph and make renderer use camera from sceneGraph

parent 4ba1c49d
......@@ -368,9 +368,7 @@ window.addEventListener('load', function init() {
// - object position, rotation, and scale info in objects-data.js
// - materials from objects-materials.js
sceneGraph = new SceneGraph({
gl
})
sceneGraph = new SceneGraph({gl, camera})
sceneGraph.initWebGLVariables()
sceneGraph.initMaterialsFromConfig(materials_definition)
......
......@@ -47,11 +47,10 @@ class Renderer {
flatten(model.fullTransformMatrix)
);
gl.uniformMatrix4fv(
glLocations.normalMatrix,
false,
flatten(m4.transpose(m4.inverse(m4.multiply(flatten(camera.viewMatrix), model.fullTransformMatrix))))
);
let viewMatrix = m4.multiply(sceneGraph.camera.viewMatrix, model.fullTransformMatrix)
let normalMatrix = m4.transpose(m4.inverse(viewMatrix))
gl.uniformMatrix4fv( glLocations.normalMatrix, false, normalMatrix);
if (selected) {
gl.uniform1f(glLocations.selectingFactor, 1.0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment