The constructor for THREE.OrbitControls does not exist

I've been attempting to incorporate OrbitControls into my three.js project, but when I try to instantiate the constructor, I encounter an error stating "THREE.OrbitControls is not a constructor". Despite my efforts to find a solution by importing the file explicitly, the error persists. Here's my code:

    <script src="JS/three.js"></script>
    <scirpt src="JS/OrbitControls.js"></scirpt>
    <script src="JS/Models/ModelLoader.js"></script>

    <script>

        var scene = new THREE.Scene( );
        var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.01, 10000 );

        var renderer = new THREE.WebGLRenderer( );
        renderer.setSize( window.innerWidth, window.innerHeight );

        document.body.appendChild( renderer.domElement );

        camera.position.z = 3;
        var controls = new THREE.OrbitControls(camera, renderer.domElement);//issue arises here

        var pointLight = new THREE.PointLight(0,2);
        pointLight.position.z = 2;
        scene.add(pointLight);

        // Game Logic
        var update = function( ){



        }

        // Draw Scene
        var render = function( ){

            renderer.render( scene, camera );

        }

        var testLoad = function(){

            var modelLoader = new ModelLoader();
            var obj = modelLoader.loadObj("/Res/Models/Characters/char1.obj", "/Res/Models/Characters/char1.mtl");
            scene.add(obj);

        }

        // Main Game Loop(update, render, repeat)
        var gameLoop = function( ){

            requestAnimationFrame( gameLoop );

            update( );
            render( );

        }

        gameLoop();

The ModelLoader represents a custom class used for loading obj files.

If anyone has insights on what may have gone wrong, your assistance is greatly appreciated!

Answer №1

There is a simple mistake:

<sirpt src="JS/OrbitControls.js"></sirpt>

This should actually be:

<script src="JS/OrbitControls.js"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using AngularJS to dynamically apply a CSS class to message text depending on the HTTP post response

I am looking to implement a method for adding a CSS class to the text color of a message based on the response. Currently, I achieve this by: if (response.data.status == 201) { angular.element(document.getElementById("msg")).addClass("text-green"); ...

Is it possible to use getJSON to retrieve a value from an HTML tag ID that has already been displayed on a webpage? How about using json_decode

Is there a way to retrieve the value using the HTML tag ID after an HTML page has been rendered? For example, how can I access the date value using the td_date in my JavaScript function? Below is the code snippet that populates the data on the page: listS ...

Tips on extracting the attribute id from HTML data in JavaScript using JQuery AJAX

Is it feasible to access the ID attribute from HTML data generated by JQuery AJAX? This code is in my index.php <script> $(document).ready(function () { function viewRooms() { $.ajax({ url:"rooms.php", method:"POST", su ...

javascript inquiry about if statements

function checkValidity() { startChecked = false; finishChecked = false; alert("startChecked: " + startChecked); alert("finishChecked: " + finishChecked); if (document.dd.start.checked.length == undefined || document.dd.finish.checked. ...

A guide to deactivating the Material UI Link API element

Previously, I relied on Material UI's Button component with a disable property that allowed the button to be disabled based on a boolean value. However, I now want to use the Material UI Link component, which resembles a text link but functions like a ...

Utilizing JavaScript, create a dynamic grid gallery with Div Spin and expand functionality

I am looking to create a unique effect where a div rotates onclick to reveal a grid gallery on the rear face. Starting this project feels overwhelming and I'm not sure where to begin. <ul class="container-fluid text-center row" id=" ...

Failed to decipher an ID token from firebase

I'm feeling extremely frustrated and in need of assistance. My goal is to authenticate a user using Google authentication so they can log in or sign up. Everything worked perfectly during development on localhost, but once I hosted my app, it stopped ...

Is it necessary to have the script tag as the first tag in the body of the HTML?

I have a script file that needs to be included by third party implementors on their web pages. It is crucial for this script to be the first tag within the body element, like so: <body> <script type="text/javascript" src="/my_script.js"></ ...

Learn how to toggle between two different image sources with a single click event in JavaScript

If the button is clicked, I want to change the image source to one thing. If it's clicked again, it should change back to what it was before. It's almost like a toggle effect controlled by the button. I've attempted some code that didn&apos ...

Building custom directives in Angular.js with d3.js

Working with an angular.js directive and d3 integration can sometimes be tricky, but thanks to resources like stackoverflow it's definitely achievable. However, I'm currently facing issues with getting the arrows to display properly in my project ...

What steps should I take to fix the error that arises when I am using the mysql module?

When attempting to connect my local database using the node module, I encountered the following error message: Client does not support authentication protocol requested by server; consider upgrading MySQL client next is my configuration: const mysql = r ...

Rotations in ThreeJS work fine when applied individually, but fail when combined with both x and

I'm trying to rotate the diamonds that are shown in the attachment around the x and z axis. Oddly enough, when I rotate them individually (setting only rotation.x or rotation.z), everything works fine. However, when I set both rotations (x AND z), the ...

Issues with removing options from Autocomplete persist in React MaterialUI

Currently navigating the world of ReactJS and experimenting with Material UI's Autocomplete component. The challenge lies in managing a complex data structure where options are dynamically generated based on user selections, but removing previously se ...

Several socket.io sessions have been initiated

I'm fairly new to working with node.js and currently attempting to set up a server using socketio to send messages to the frontend (React). However, when running the server and multiple connections are being established, I encounter the following outp ...

AngularJs, simplifying logic in web pages

I'm currently working with an HTML template that has some complex conditionals in the ng-ifs and ng-shows. For example, here's how I determine if payment controls should be displayed: <div ng-show="ticket.status == 0 && ((ticket.or ...

Creating a series of tiny vertical markings along the horizontal line using the input range

I have a range input and I am looking to add small vertical lines at intervals of 10 on the horizontal line representing each default step. The range of my input is from 0 to 40 and I would like to have small vertical lines at 10, 20, and 30. I need to ac ...

I'm having trouble accessing a deeper level of JSON data after receiving a response from the server via AJAX

After successfully sending the initial http post from the browser to the server and receiving the json data with represented objects in return, I faced an issue with populating the select options on the browser side. Although I managed to populate the sel ...

What is the best way to delete a particular tag using jQuery?

Illustration: htmlString = '<font><a>Test Message</a></font>'; updatedHtmlString = htmlString.find('font').remove(); Desired Result: <a>Test Message</a> This code snippet is not yielding the expe ...

How to handle Object data returned asynchronously via Promises in Angular?

Upon receiving an array of Question objects, it appears as a data structure containing question categories and questions within each category. The process involves initializing the object with board: JeopardyBoard = new JeopardyBoard();. Subsequently, popu ...

Submitting information to an HTML page for processing with a JavaScript function

I am currently working on an HTML page that includes a method operating at set intervals. window.setInterval(updateMake, 2000); function updateMake() { console.log(a); console.log(b); } The variables a and b are global variables on the HTML page. ...