I'm trying to decide on the best Javascript 3D library for my project.
I like Three.js
a bit more than Scene.js,
but the coding style of Scene.js
seems more efficient, because I need to create about 100 objects on the fly, and this would mean declaring hundreds of variables with Three.js
.
In Three.js
it seems that for each different object you need to define variables and add them to the scene, like this :
var renderer = new THREE.WebGLRenderer();
var camera =
new THREE.PerspectiveCamera(
VIEW_ANGLE,
ASPECT,
NEAR,
FAR);
var scene = new THREE.Scene();
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(
50,
16,
16),
sphereMaterial);
scene.add(sphere);
while in Scene.js
, objects are created in a JSON-like structure, like this :
var scene = SceneJS.createScene({
nodes:[
{
type:"material",
color: { r: 0.3, g: 0.3, b: 1.0 },
nodes:[
{
type: "rotate",
id: "myRotate",
y: 1.0,
angle: 0,
nodes: [
{
type:"geometry",
source:{
type:"teapot"
}
}
]
}
]
}
]
});
Now my question is, if it's possible to use a more JSON-like coding style with Three.js
as well?
I already found out about THREE.JSONLoader
, but since Three.js doesn't have very good documentation, I find it very hard to discover if this would be right for me. It seems to be more aimed at converted models from 3D-software, but I really need to build the objects myself.