Hey everyone, I'm having some trouble exporting a cube from Blender to three.js. I've exported the JSON file, but when I try to display the cube in my code, it's not showing up - instead, all I see is the setColor
screen and I can't figure out why. I've tried a bunch of things already but nothing seems to be working. Can anyone help me figure out what I'm doing wrong?
Here is the code I've been using. It seems to load something as geometry, and when I console log it, I get a JSON with vertices, etc. Just to clarify, the cube I'm trying to export is the default cube in Blender located at point 0,0,0
.
Three.js
var renderer;
var scene;
var camera;
$(function () {
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
renderer.setClearColor(0xEEEEEE);
renderer.setSize(window.innerWidth, window.innerHeight);
var planeMaterial = new THREE.MeshBasicMaterial({color: 0xcccccc});
var loader = new THREE.JSONLoader();
loader.load('untitled.json', function (geometry) {
console.log(geometry);
geometry.computeMorphNormals();
var mesaBilhar = new THREE.Mesh(geometry);
scene.add(mesaBilhar);
});
camera.position.x = -15;
camera.position.y = 16;
camera.position.z = 13;
camera.lookAt(scene.position);
$("#WebGL-output").append(renderer.domElement);
renderer.render(scene, camera);
// call the render function
});