I have problem with loading a 3D model in node-three.js
. In console.log(geometry)
the model is loaded, but not rendered in out.png
file. Here is my code:
var $ = require('jquery')(require("jsdom").jsdom().parentWindow);
var THREE = require('three.js')
, fs = require('fs')
, join = require('path').join;
var width = 1000;
var height = 800;
var renderer = new THREE.CanvasRenderer();
renderer.setSize(width, height);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, width / height, 1, 3000);
camera.position.z = 500;
var loader = new THREE.JSONLoader(),
callbackKey = function(geometry) {createScene(geometry, 0, 0, 0, 15, "img/img.jpg")};
loader.load("model/model.js", callbackKey);
function createScene(geometry, x, y, z, scale, tmap) {
zmesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture(tmap)}));
zmesh.position.set(x, y, z);
zmesh.scale.set(scale, scale, scale);
scene.add(zmesh);
}
scene.add(camera);
camera.lookAt(scene.position);
renderer.render(scene, camera);
renderer.domElement.toBuffer(function(err, buf) {
fs.writeFile(join(__dirname, 'out.png'), buf, function(err) {
if (err) throw err;
console.log('see output result file: out.png');
});
});
The model is from "Maya" three.js exporter and works fine in the browser. What's wrong with my code?
Aucun commentaire:
Enregistrer un commentaire