The method renderer.isWebGLAvailable is undefined in the current context, referenced at filename.html

After making progress on solving my link problem, I am now encountering an uncaught TypeError: rendere.isWEBglAvailable is not a function at filname.html. What steps do I need to take to resolve this issue and make it work?

 <title>3D Montageanalysetool</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="shortcut icon" href="#" />
        <link href="index.css" rel="stylesheet" type="text/css"/>

        <script src="Libraries/three.min.js" type="text/javascript"></script>
        <script src="Libraries/OrbitControls.js" type="text/javascript"></script>
        <script src="Libraries/OBJLoader.js" type="text/javascript"></script>
        <script src="Libraries/MTLLoader.js" type="text/javascript"></script>

        <!-- ZURBFundation links-->
        <link href="ZURBFundation/css/foundation.css" rel="stylesheet" type="text/css"/>
        <script src="ZURBFundation/js/vendor/jquery.js" type="text/javascript"></script>





     <script>
                //Detctor shows a warning if the current browser do not support WebGL.
                var renderer = new THREE.WebGLRenderer();
                if (renderer.isWebGLAvailable()===true) {
                    // Initiate function or other initializations here
                    animate();
                } else {
                    var warning = renderer.getWebGLErrorMessage();
                    document.getElementById('container').appendChild(warning);
                }

</script>

Answer №1

Take a closer look at the order of your <script> tags and understand their functions individually.

  • The first script is
    <script src="index.js" type="text/javascript"></script>
    , but its purpose is unclear. Is this script dependent on Three.js? If so, ensure that it is loaded after Three.js to prevent any issues.
  • Next, you are attempting to import the Three.js library from
    threejs-viewer-master/lib/threejs/three.js
    . Verify if this address is correct by checking your console or network tab for loading status.
  • Furthermore, there seems to be a redundant load of Three.js library from
    https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.min.js
    . This may cause conflicts and impact functionality. Consider upgrading to a newer version like /r100/ instead of /r79/.

This issue stems from script organization and potential incorrect file links rather than a problem with Three.js itself.

Answer №2

Do remember to start with Three.js.

    <title>3D Visual Analysis Tool</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="#" />
<link href="index.css" rel="stylesheet" type="text/css"/>
<script src="index.js" type="text/javascript"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.min.js"></script>
<script src="threejs-viewer-master/lib/threejs/three.js" type="text/javascript"></script>

<!-- links to create a new anchor-->
<script src="threejs-viewer-master/lib/threejs/Detector.js" type="text/javascript"></script>
<script src="threejs-viewer-master/lib/threejs/MTLLoader.js" type="text/javascript"></script>
<script src="threejs-viewer-master/lib/threejs/OBJLoader.js" type="text/javascript"></script>
<script src="threejs-viewer-master/lib/threejs/OrbitControls.js" type="text/javascript"></script>

<!-- ZURBFundation links-->
<link href="ZURBF

undation/css/foundation.css" rel="stylesheet" type="text/css"/>

</head>
<body>
    <div id="div1">
        <div id="upperDiv">
            <h1 id="varhead">3D Visual Analysis Tool</h1>

            <div id="buttonsDiv" >
                <!-- Button to get send a request to the server and get the coordinates as answer and draws them-->
                <button id="butLoad" class = "secondary button" onclick="onButtonLadeClick" >Load Data</button>
                <!-- Button to set the AvarageHigh visible form the server-->
                <button id="setAvarageHighVisible"  class="button secondary"  onclick=""> Show Average Height</button>
                <!-- Button to show reach of anchor-->
                <button id="anchorReach" class="button secondary" onclick="">Anchor Range  
                </button> 
            </div>
        </div>
    </div>
    <!--show Fullscreen-->
    <div id="fullscreen">
        <a id="fullscr"> Fullscreen</a>
    </div>
    <!--canvas div-->
    <div id="drawingSpace" align="center" > </div>
    <!--show no Fullscreen-->
    <div id="noFullscreen">
        <a id="noFullscr">No Fullscreen</a>
    </div>
    <script>
        //Detector displays a warning if the current browser does not support WebGL.
        var renderer = new THREE.WebGLRenderer();
        if (renderer.isWebGLAvailable()) {
            // Initialize function or other initializations here
            animate();
        } else {
            var warning = renderer.getWebGLErrorMessage();
            document.getElementById('container').appendChild(warning);
        }



        //renderer = new THREE.WebGLRenderer();
        controls = new THREE.OrbitControls(camera, renderer.domElement);
        render();
        function render() {
            //Renderer -> because nothing has been rendered onto the canvas yet
            renderer.setPixelRatio(window.devicePixelRatio);
            renderer.setSize(CANVAS_WIDTH, CANVAS_HEIGHT);
            container.appendChild(renderer.domElement);

        }
        animate();

        function animate() {
            // Display in browser
            requestAnimationFrame(animate); //browser has to request the function animate
            renderer.render(scene, camera);

        }



            render();


        }

    </script>
</body>

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

Updating the state using ui-router

The application consists of pages labeled as X, Y, and Z. The intended route is to navigate from page X to select details, then move onto page Y to select additional details, and finally land on page Z. I wish that upon clicking the window's back butt ...

Showing every piece of information line by line while uploading an AJAX CSV file

I have successfully parsed a CSV file using Papaparse, Jquery AJAX, and PHP. Now, I want to display the data line by line while the CSV file is being uploaded. Here is a snippet of my code: var xhr_file = null; $('#fileVariants').change(functio ...

Create an interactive list with the ability to be edited using HTML and

I'm currently working on a UI scenario that involves a text box field with two buttons beneath it. When the user clicks the first button, a popup will appear prompting them to input an IP address. Upon submitting the IP address in the popup, it will b ...

How can I pass the value of a variable from one Vue.js 2 component to another?

Here is how I have structured my view: <div class="row"> <div class="col-md-3"> <search-filter-view ...></search-filter-view> </div> <div class="col-md-9"> <search-result-view ...></ ...

What are the steps to install node.js on hosting servers like Hostinger, JustHost, and others?

Recently, I've been diving into the world of Node.js. While I have some experience with PHP, I've found that most hosting services already have a PHP interpreter installed, making it easy to work with. However, I'm now trying to figure out i ...

From Angular: Transforming local variables into global variables

I am having trouble retrieving the country name from a JSON file outside of its scope. I have tried using $rootScope but without much success. My goal is to use the country name as a variable in different scopes and on the page itself. Additionally, I ne ...

Selecting the optimal data structure: weighing the benefits of using boolean check versus array .include (balancing performance and redundancy

My objects can have one or more properties assigned, with a total of 5 different properties in my case. To illustrate this, let's use a simple movie example where each movie can be assigned from 5 different genres. I have come up with two methods to ...

JavaScript: developing an algorithm to identify and eliminate duplicate strings

Consider the following JS array: 0 - Star Wars: A New Hope 1 - Star Wars: The Empire Strikes Back 2 - Star Wars: Return of the Jedi 3 - Star Wars: A New Hope (1977) 4 - Star Wars: Return of the Jedi (1983) 5 - Star Wars: Attack of the Clones 6 - Star Wars ...

Utilize the appendTo() function and make a switch to dynamically insert content stored in variables into a specified

I am working on developing a page with a central content div, where users have the ability to choose various options that will introduce different additional content. This added content will then present more opportunities for adding new elements, ultimate ...

"Safari (iOS) is experiencing a functionality issue where Alert() is working, but console.log() is

Just a heads up before you dive in: I've encountered an issue with Safari related to Chrome, but it seems to work fine on other browsers. So, it could be more OS-specific rather than a general problem. I recently ran into a frustrating situation whil ...

Implementing a click event on a selection option – tips and tricks

When I want to select an option, I can use the following script: Javascript $("#practice-area optgroup option").click(function(){ // insert your function here }); HTML <select name="practice-area" id="practice-area"> <option value="0">S ...

Using Express js, invoke a function object from a route

Here's a snippet of my code: router.route('/user') .post(function(req, res, next){ queryDB(arg1, arg2, prepareRes) }) .get(function(req, res, next){ queryDB(arg3, arg4, prepareRes) }); var prepareRes = function(err, data){ if ...

An unexpected 'undefined' value is being added to a particular Web API request

I am encountering an issue in my Angular application where the word 'Undefined' is being appended to a specific WebAPI call, causing both registerUser and login requests to fail. Here are the problematic request URLs: Request URL: http://localho ...

How can I display milliseconds from a date in Angular2+?

I recently encountered an issue while working with a custom pipe that was used to display time. I attempted to modify it so that it could also show milliseconds: {{log.LogDate|jsonDate|date:'dd.MM.yyyy &nbsp; HH:mm:ss.sss'}} Here is the cod ...

Leveraging AJAX within a RESTful API in a Node.js environment to retrieve a JSON file and dynamically parse its contents according to the specific button selected on the front-end interface

Can anyone help me with understanding the communication process between server.js (Node.js) and the front-end JavaScript file? I am trying to implement AJAX as a RESTful API in the server to retrieve a JSON file, parse it based on specific button clicks in ...

Click handler that transmits data to a server using ajax

I have been tasked with creating a website using HTML, CSS, and JavaScript that includes three buttons. When clicked, these buttons will send codes such as "10," "01," and "11" to a C++ program. The C++ program will then respond and perform a function base ...

Tips for managing blur events to execute personalized logic within Formik

I am currently delving into the world of React/Next.js, Formik, and Yup. My goal is to make an API call to the database upon blurring out of an input field. This call will fetch some data, perform database-level validation, and populate the next input fiel ...

Looking for a Search Field that clears default text when focused - Compatible with Firefox 3.6?

I have attempted various jQuery and JavaScript solutions found on this page: How to clear text field on focus of text field Surprisingly, all of the solutions work except for FF 3.6. So, I am wondering, What alternative can I use to make this feature com ...

What changes can be made to this function in order for the arches to be positioned directly in front of the camera?

I devised a method that arranges arches in front of a camera, side by side: <!-- HTML --> <a-curvedimage v-for="(value, index) in model" :theta-length="42" :rotation="setThumbsRotation(value, index)"> </a-curvedimage> <a-camera ...

FireFox is unresponsive to OPTIONS requests

I have a webpage that is accessed through HTTP. The client-side code is making AJAX requests for authorization to the same domain, but using HTTPS, which causes CORS issues. When using FireFox, the request looks like this: // domains and cookies are chang ...