I need to load a model "somemodel.json" into my "movie.js".Can someone tell me where i am going wrong.I followed the steps given here.


<!DOCTYPE html>
         <meta charset=utf-8>
            body { margin: 0; }
            canvas { width: 100%; height: 100% }
        <script src="three.min.js"></script>
        <script src="ObjectLoader.js"></script>
        <script src="movie.js"></script>


var camera;
var scene;
var renderer;
var loader;


function frame() {

scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth /     window.innerHeight, 0.1, 1000);
camera.position.y = 0;
camera.position.z = 10;
camera.rotation.x = 0;

var loader = new THREE.ObjectLoader();
function () {
    var geometry = new THREE.SphereGeometry(3,32,32);
    var material = new THREE.MeshBasicMaterial();
    var object = new THREE.Mesh( geometry, material );
    scene.add( object );

renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

function animate() {
requestAnimationFrame( animate );

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

Or can your give an example with a sample model ?

When i run my file it raises an error in the console saying not well-formed male.json


The error not well-formed male.json doesn't appear to have anything to do with the code you've posted. I don't see any references to a JSON file called male.json.

If this file is in your code somewhere, the error is telling you the problem. It is malformed. Paste the contents of the file into an online validation tool such as JSONLint. It will tell you what is making it malformed.

Also, you're passing JSON into ObjectLoader.load but you don't do anything with the results. Instead try this:

var loader = new THREE.ObjectLoader();
loader.load('somemodel.json', function (object) {

Check out the documentation for more information.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.