Goofy
Goofy

Reputation: 19

three. scene is not a function

I'm using three.js and the attached code is returning the following error

Uncaught TypeError: THREE.Scene is not a function

init @ new 1.html:18

on this line

scene=new THREE.Scene();

What could be causing this and how can I go about fixing it?

window.onload = init

var scene, camera, render;

function init() {
    container = document.createElement('div');
    document.body.appendChild(container);

    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.1, 200); //перспективная проекция
    camera.position.y = 150;
    camera.position.z = 500;

    var line_geometry = new THREE.Geometry();
    line_geometry.vertices.push(new THREE.Vector3(0, 0, 0));
    line_geometry.vertices.push(new THREE.Verctor3(0, 40, 50));

    var line = new THREE.Line(line_geometry);

    scene.add(line);

    render = new THREE.WebGLRender(); //рендеринг
    render = setSize(window.innerWidth, window.innerHeight); //инициализация рендеринга

    container.appendChild(render.domElement); //??
    render.render(scene);

}

Here is a screen shot of the error.

enter image description here

Upvotes: 0

Views: 1343

Answers (1)

kaigorodov
kaigorodov

Reputation: 897

You have many typos in your code:
Verctor3 instead of Vector3
WebGLRender instead of WebGLRenderer
render.render(scene); instead of render.render(scene, camera);
and so on.
Also you should just run init() at start instead of window.onload=init.

Generally - please refer to this page. There are many working examples there.

Upvotes: 1

Related Questions