Artiga Artiga - 1 year ago 82
JSON Question

Issue with getting colors in a Blender imported mesh to be shown using Three.js

I am trying to display glued cubes, imported from blender, using Three.js.

I am using latest Version of Three.js and Blender 2.78a.

I started by making my cube object;just like this:
But I have different/more glued cubes.

enter image description here

I created above 3d object in Blender, Then exported the mesh using the Three.js .js exporter.

Here is the marmelab.json file.

"DbgName":"01 - Default",

javascript to load the mesh and display

var scene, camera, renderer;

var WIDTH = window.innerWidth;
var HEIGHT = window.innerHeight;

var SPEED = 0.01;

function init() {
scene = new THREE.Scene();



function initCamera() {
camera = new THREE.PerspectiveCamera(70, WIDTH / HEIGHT, 1, 10);
camera.position.set(0, 3.5, 5);

function initRenderer() {
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(WIDTH, HEIGHT);

function initLights() {
var light = new THREE.AmbientLight(0xffffff);

var mesh = null;
function initMesh() {
var loader = new THREE.JSONLoader();
loader.load('./marmelab.json', function(geometry, materials) {
mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.75;
mesh.translation =;

function rotateMesh() {
if (!mesh) {

mesh.rotation.x -= SPEED * 2;
mesh.rotation.y -= SPEED;
mesh.rotation.z -= SPEED * 3;

function render() {
renderer.render(scene, camera);


However in Browser the shape is rtained ; but the color is white.

What am I missing here?

Thank you so much in advance.

enter image description here

Answer Source


I updated the Plunker with the latest version of three.js and it now works with your unedited json above -

Also successfully tested with my own, more complicated, model -

The problem is caused by using an older version of three.js. I originally tested using the version provided by the website you linked to. I suspect you might have done the same given the result.

Somewhere around revision 70 they changed the exporter to no longer export the colorAmbient property, and that older version of Three.js required it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download