C
C
copal2016-07-15 15:31:48
three.js
copal, 2016-07-15 15:31:48

How to load model.json?

I download the r2-d2 model for TreeJS (.json) from clara.io and then connect it, but to no avail.

window.onload = () => {
    const WINDOW_WIDTH = window.innerWidth;
    const WINDOW_HEIGHT = window.innerHeight;

    let scene = new Scene();
    let camera = new PerspectiveCamera( 75, WINDOW_WIDTH / WINDOW_HEIGHT, 0.1, 1000 );

    let renderer = new WebGLRenderer();
    renderer.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

    document.querySelector( 'main' ).appendChild( renderer.domElement );

    let loader = new ObjectLoader();

    loader.load( './assets/r2d2/r2-d2.json', ( r2d2 ) => {
        scene.add(r2d2);
    } );

    // let light = AmbientLight( 0Xffffffff );
    // scene.add(light);

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

        requestAnimationFrame( update );
    }

};

How to connect such models correctly?
And another question, why if I uncomment light, I get an error -
index.js:17041 THREE.Object3D.add: object not an instance of THREE.Object3D.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question