Having trouble with OBJ model loading in Three.JS

Having trouble loading obj models and encountering a CoffeeScript error:

loader = new THREE.OBJLoader manager 

if loadedModels.diamondRing == null

    loader.load "obj/diamond/ring1.obj", (object) ->

        object.traverse (child) ->
            if child instanceof THREE.Mesh
                child.material = silverMaterial.clone()

        object.position.y = 10
        object.scale.x = object.scale.z = object.scale.y = config.p1.size*0.05

        object.userData.ring = true
        combine.add object 

        loadedModels.diamondRing = combine.clone()


    loader.load "obj/diamond/diamond1.obj", (object) ->

        object.traverse (child) ->
            if child instanceof THREE.Mesh
                child.material = silverMaterial.clone()

        object.position.y = 10
        object.userData.diamond = true
        object.scale.x = object.scale.z = object.scale.y = config.p1.sizeDiamond*0.075

        combine.add object 

An exception has been caught:

Uncaught TypeError: Cannot read property 'clone' of undefined obj.js:93

The error seems to be in the 'obj.js' file, specifically in the 'add_face' function on line 93:

    function add_face( a, b, c, normals_inds ) {

        if ( normals_inds === undefined ) {

            geometry.faces.push( face3(
                vertices[ parseVertexIndex( a ) ] - 1,
                vertices[ parseVertexIndex( b ) ] - 1,
                vertices[ parseVertexIndex( c ) ] - 1
            ) );

        } else {

            geometry.faces.push( face3(
                vertices[ parseVertexIndex( a ) ] - 1,
                vertices[ parseVertexIndex( b ) ] - 1,
                vertices[ parseVertexIndex( c ) ] - 1,
                [
 -- line 93 -->     normals[ parseNormalIndex( normals_inds[ 0 ] ) ].clone(),
                    normals[ parseNormalIndex( normals_inds[ 1 ] ) ].clone(),
                    normals[ parseNormalIndex( normals_inds[ 2 ] ) ].clone()
                ]
            ) );

        }

    }

The problem appears to be related to normals in the model data, but the exact cause is unclear. When reading the model, an issue arises on lines like:

 f 6802//6802 6803//6803 6804//6804

Removing these lines from the obj model makes it appear normal in the 3D editor. Has anyone encountered a similar problem before?

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

I encountered an error stating that ".then" is not defined during my attempt to save

Just starting out with node.js and I encountered an issue: TypeError: Cannot read property 'then' of undefined This is the code snippet causing the problem: router.post("/signup", (req, res) => { const userRegister = new UserRegister({ ...

Encountering an "Unmet Peer Dependency" error message while attempting to integrate bootstrap-ui into my Angular project

Currently, my goal is to successfully install angular-ui. Following the tutorials, I have attempted all commands such as: npm install angular-bootstrap However, this command results in an error message: +-- UNMET PEER DEPENDENCY angular@>=1.5 After ...

What causes a never-ending loading cycle on a website when a 404 error occurs?

My Express.js/Node.js website is hosted on Heroku. I am facing an issue where the server does not properly send a 404 error when a file cannot be found. Instead, the page keeps loading endlessly. How can I make the server stop loading when it encounters a ...

Selecting elements by class in jQuery using a variable for the class name

Is there a way in jQuery to apply actions to all elements with a specific class, where the class name is determined by a variable? I want to select elements based on this dynamically generated class name. var x = $(this).attr('href').slice(1); ...

Steps for designing an HTML table that expands and collapses partially

I am currently revamping an old "Top Screens" page by expanding the display from the top 30 to the top 100 in a basic html table format. However, I only want to show the top 20 on page load with an expand/collapse feature. While I have come across examples ...

Add distinctive formatting for the final element that is not the last child

Presented with a fascinating challenge, I find myself with an ever-changing number of .child.red children. I am in need of referencing the last .child.red element dynamically using styles. Although I have attempted to achieve this on my own, I am curious a ...

problem with the video pathway in the javascript document

I'm currently in the process of putting together a Video gallery playlist using HTML, CSS, and JavaScript. So far, I've set up the html and css files along with two js files. The first js file contains all the video information as shown here: ...

Verify information and send messages using JavaScript validation

I need assistance with my HTML form and JavaScript code. I am trying to send a parameter from the form to JavaScript in order to check if the input matches any values in an array. If there is a match, I want an alert message to be sent. However, the issue ...

ways to dynamically retrieve input values in PHP

Is there a way to dynamically add and remove data fields, as well as increase and decrease fields dynamically in PHP? I am looking to retrieve the subject value in an array or JSON format using PHP only. https://i.stack.imgur.com/HqDCz.png <div data-ro ...

Axios is experiencing challenges in transmitting the cookie

Even after attempting to include {withCredentials: true}, I am still facing issues with sending the cookie to the backend server. return await axios.post(`${API_URL}/posts/category/${id}`, { withCredentials: true }) https://i.stack.imgur.com/Cr8xv.png ...

Tips for displaying two input decorations in Material UI beside one another within a text field

In the Text Field demonstration, I noticed input adornments at the start and end. However, I am looking to have two input adornments at the end specifically. I attempted to add them using endAdornment: {InputAdornment InputAdornment}, but encountered an er ...

Issue: User is being redirected from "/login" to "/home" due to a navigation guard. This problem arises in the interaction between Vue-router and Firebase authentication

I'm currently working on an app that utilizes Vue.js and Firebase for authentication. I am trying to implement a verification process using the beforeEach method in my router file to ensure that users can only sign in if their displayName matches a sp ...

saving the hash key in a separate array

Currently, I have a collection of key-value pairs that need to be stored in another array. However, I am facing difficulties with the logic as I am unable to keep track of which keys-values have already been assigned while iterating over the list of object ...

calculation of progress bar advancement

I want to make the progress bar in my game responsive to changes in the winning score. Currently, it moves from 0% to 100%, which is equivalent to 100 points - the default winning score. But I need the progress bar to adjust accordingly based on the user-i ...

`The server fails to retrieve parameters passed through an angularJS HTTP GET request,

In my controller.js file, I've come across the following block of code: $http({ method: 'GET', url: '/getGuestList', params: {exhibitorID: 1} }) The purpose of this code is to fetch all the guests belonging to a parti ...

Refresh the jQuery Raty choice when clicked (jQuery)

Currently, I am incorporating the jQuery Raty plugin into a jQuery UI dialog to create a questionnaire-style format. Through custom jQuery scripting, I have devised an interactive interface where users are presented with a new question upon each selection ...

My goal is to develop a table that is both able to be resized and easily repositioned

I've been working on a project to develop an interactive table that can be manipulated, resized, and repositioned within a canvas. The code snippet below shows my attempt at creating this table on the canvas: var canvas = document.getElementById("dra ...

Redirecting the socket.io client to the Heroku service

Recently, I developed a real-time chat application using socket.io, Node.JS, and express. It was functional on my local server but now I want to connect it to an existing Heroku service instead. How can I achieve this? Once I tried the following code, va ...

Ways to showcase a location on a map

Seeking a method to visually represent users' locations on a world map using HTML, JavaScript, or any other suitable approach. The data will be extracted from an Excel file and consists of the City Name only. Each user's location should be marked ...

What are some ways to disguise websockets?

I'm currently working on writing a JavaScript client that sends websockets to a node.js/ws server. I've been doing a lot of research and have come across information indicating it's useful, or even required by RFC, to mask all data sent from ...