Struggling to display a cylinder using three.js, encountering error message "Unable to access property 'type' of an undefined object"

I am facing an issue with my three.js code where adding a simple cylinder is causing the renderer to crash:

    const lineGeometry = new Three.CylinderBufferGeometry(1.0, // radiusTop
                                                          1.0, // radiusBottom
                                                          1.0, // height
                                                          7, 1) // radial/height segments
    this.line = new Three.Mesh(lineGeometry, material)
    this.add(this.line)

    // ... later ...
    viewer.render()

The crash occurs during rendering, specifically in WebGLRenderer.js within the renderBufferDirect function (specifically renderer.setIndex), and seems to be related to the presence of an index property in the geometry. Here is the relevant section of code in WebGLRenderer.js:

        if ( index !== null ) {
            attribute = attributes.get( index ); // this returns undefined
            renderer = indexedBufferRenderer;
            renderer.setIndex( attribute ); // attribute is undefined here, causes crash
        }

The error stems from attribute being undefined. While the geometry only has attributes like position, normal, and uv, it's unclear why this issue is occurring.

Although I attempted to simplify the code, it works fine in a smaller example. It appears that the index contains valid indices for the position array:

index: Uint16BufferAttribute {name: "", array: Uint16Array(84), itemSize: 1, count: 84, normalized: false, …}
attributes:
position: Float32BufferAttribute {name: "", array: Float32Array(138), itemSize: 3, count: 46, normalized: false, …}
normal: Float32BufferAttribute {name: "", array: Float32Array(138), itemSize: 3, count: 46, normalized: false, …}
uv: Float32BufferAttribute {name: "", array: Float32Array(92), itemSize: 2, count: 46, normalized: false, …}

It is uncertain what attributes.get(index) should return or how to resolve the problem. Any insights would be greatly appreciated!

This issue occurred in three.js version r111.

Answer №1

A breakthrough! I managed to uncover the root cause of the issue. It appears that my lineGeometry is encountering a duplicate buffergeometry.id, resulting in it being overlooked during the WebGLObjects.update() process and consequently not being updated as intended. The mystery remains regarding how this duplication occurred, but progress is being made.

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

Syntax error encountered with the null-coalescing operator (`??`)

Encountering Syntax Errors After Upgrading Angular Plugin I am facing some syntax errors after attempting to upgrade a plugin in a system that was originally developed by someone else. Although I am relatively new to Angular, I tried to simply replace the ...

Converting JSON information into a JavaScript array of objects

I have a JSON file containing placeholder articles for testing purposes. I'm using jQuery to parse the data from the JSON file and create an array of objects with the retrieved information. Take a look at my JSON file: { "news": [ { ...

Guide to opening all href links in a new window

When loading HTML content parsed from an email to a frame, the issue arises when there is an href link that tries to open in the same frame. I want to modify it so that it opens in a new tab instead. Usually, setting the target to _blank in the href would ...

Does a .innerXML exist?

Is anyone knowledgeable in XML able to offer some assistance? I have a function that I use to parse XML data, and you can find the XML file I am working with here. function dialogXML(varName,url){ if (window.XMLHttpRequest){ r[varName]=new XML ...

Issue with Trix text editor not triggering the change event

Lately, I've been facing some difficulties in getting the tirx-change event to trigger when there are changes in the content of a trix-editor. Despite using React JS for the view, I haven't been able to identify the problem. Below is the code sni ...

Redirecting in PHP after an AJAX request is made

I'm trying to figure out how to redirect to another page in PHP code within an AJAX call. I've searched online and found suggestions to use JavaScript like window.location.href = 'url';, but it doesn't seem to be working for me. W ...

Distinguishing Between Model and View State Management in AngularJS

As I work on a complex single page application in Angular, I find myself needing to manage two types of data. First, there is the Model data which pertains to information retrieved from and sent to the backend API server. Second, there is ViewState data wh ...

jQuery replacement for replaceChild method

I've been attempting to swap out an existing DOM element with a new one that I created. I attempted the following code snippet: $(this).parent().replaceChild(newElem,this); However, it resulted in an error message saying $(this).parent().replaceChi ...

Navigate through the pages by selecting from the drop down menu, but the drop down seems to be missing on the second page

Check out this link. I'm interested in exploring each page linked to an item in the dropdown menu at the top of the website. Recently started using selenium, here's what I've been working on: Start by opening the driver Navigate to the w ...

To display the elements of an array in a dropdown menu

I have a collection of arrays within an object. {"ItemIsExportControlled":["true","false"],"OrderShippingDestination":["domestic","foreign"],"OrderShipping":["ground","air","sea"],"ItemStockStatus":["validInStock","invalid","validOutOfStock"],"OrderDelive ...

Disabling Javascript in Chrome (-headless) with the help of PHP Webdriver

I am experimenting with using Chrome without JavaScript enabled. I attempted to disable JavaScript by adding the --disable-javascript command line argument. I also tried some experimental options: $options->setExperimentalOption('prefs&a ...

React-Troubleshooting list items and keys: A comprehensive guide to resolving common issues

I'm facing a challenge with generating unique key ID's for my list items. Even though I thought I had a good understanding of how unique keys function, it seems that I am mistaken. In the code snippet below, using key={index} or key={item} is no ...

Delete multiple selected rows from the table

I need help with removing multiple rows from a table. I've tried the code below but it doesn't seem to work. I'm using DataTables v1.10.9. $('#del_Btn').on('click', function () { // 'table' is the instanc ...

What steps should I take to resolve the "You do not have authorization to access this directory or page" error in Azure App Services?

Currently, I am attempting to deploy my Next.js 13 application to AppServices using Github Actions. The compilation process on Github was successful, however, I am encountering an issue where my application does not seem to be deploying or starting up prop ...

Automatically pre-fill and send hidden form

I'm working on a form and have set up a handler for the submit button like this: $( '#submit_btn' ).click( function( data ){ theForm = document.getElementById( 'realForm' ); theForm.meetingName.value = document.getElement ...

`In TypeScript Angular, encountering challenges with accessing object properties`

My TypeScript object looks like this const playlist: { tracks: Array<Track> } = { tracks: new Array<Track>() }; This is the Track interface I am working with interface Track { title?: string; album?: string; artists?: string; duration? ...

jquery did not load properly in the Google Chrome extension

Why am I unable to use a jQuery script inside my "myscript.js" file in the following Google Chrome extension? Is jQuery not loaded within the "myscript.js" file? What changes need to be made in the manifest file to enable the usage of jQuery inside "myscri ...

Is there a way to design a mosaic-style image gallery featuring images of varying sizes in a random and dynamic layout, all without relying

In my quest to create a unique mosaic-style image gallery, I have scoured the internet for suggestions and have come across numerous recommendations for using available plugins. However, I am curious if there is a way for me to personally create a mosaic ...

jquery does not allow text to be appended after an image

Issue: Text is not being appended after the image <?php '<p>Name : <span id="txt_name'.$k.'">'.$change->name.'</span>';?> <img id="copyButton" class="img-1" onClick="copyToClipboard(document.g ...

Utilize Angular2 data binding to assign dynamic IDs

Here is the JavaScript code fragment: this.items = [ {name: 'Amsterdam1', id: '1'}, {name: 'Amsterdam2', id: '2'}, {name: 'Amsterdam3', id: '3'} ]; T ...