CasualKyle
CasualKyle

Reputation: 443

Can't create a TrackballControls object

For some reason I keep getting an error when constructing a TrackballControls object that says "THREE.TrackballControls is not a constructor".

Here is a minimal example:

<!doctype html>
<html>
<head>
    <title>Trackball Controls</title>
</head>
<body>
    <script src = "three.js"></script>
    <scirpt src = "TrackballControls.js"></script>
    <script>
        var width = 640;
        var height = 480;

        var renderer = new THREE.WebGLRenderer();
        renderer.setSize(width, height);
        document.body.appendChild(renderer.domElement);

        var scene = new THREE.Scene();

        var camera = new THREE.PerspectiveCamera(50, width / height, 0.1, 10000);
        scene.add(camera);

        //controls
        var trackballControls = new THREE.TrackballControls(camera);
    </script>
</body>
</html>

The three.js file that I'm referencing is in three.js-master\build and TrackballControls.js is in three.js-master\examples\js\controls.

Why am I getting this error and how can I fix it?

Upvotes: 1

Views: 3832

Answers (1)

Craig.Li
Craig.Li

Reputation: 1366

Notice your code in line 8 <scirpt> should be <script>.

Upvotes: 3

Related Questions