I am facing an issue with my three.js code not running on macOS. The error message "Vertex buffer is not big enough for the draw call" appears, but interestingly the code works perfectly on

Desired Outcome:

The goal is to create an animation where a line moves from the center of the screen to the current position of the mouse pointer.

Issue Encountered:

This animation only functions properly on Windows operating systems.

I have created a simplified example on Codepen to demonstrate the problem:

https://codepen.io/ascheschleier/pen/qBLeRzN

While it works fine on Windows, it fails to run on macOS. When running the same code directly in a browser (Safari or Chrome) on a Mac system, the following error arises:

GL_INVALID_OPERATION: Vertex buffer is not big enough for the draw call.

After researching the error and consulting various sources, it appears to be related to a buffer length issue. I attempted adjusting the Buffer sizes at Lines 36 and 55 within the code, but without success.

As I am still learning three.js, I am unsure if my approach is correct. The positions = new Float32Array method holds the start and endpoint (x,y,z), so the size should be 6. Meanwhile, the

threeBufferPosition = new THREE.BufferAttribute
requires the length of each point, which should be 3. Attempting to set this value to 6 instead of 3 results in an error.

I seek assistance in identifying the root cause of the buffer size discrepancy, or any other potential sources of the error.

UPDATE: Below is the code snippet from the Codepen example provided:

 // JavaScript code here

Answer №1

Your line drawing code is facing a conceptual issue. The way you create the line geometry with only one distance value for two vertices is problematic. Rendering primitives requires data to be managed on a vertex level, meaning each vertex should have its own distance value. I recommend setting the distance for the first vertex to 0 and then using the actual distances from the beginning of the line for all other vertices.

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

Choosing elements in jQuery

Having some trouble with the subnav on my current website project. I think the issue lies in how I am selecting items in my jquery code. It seems like a small fix that needs to be made, but I'm unsure of the correct approach. http://jsfiddle.net/ZDEr ...

Transferring JSON data from Django for visualization on a D3 graph

I'm currently working on customizing a D3 bar graph found at http://bl.ocks.org/3885304 to accommodate JSON data from Django. In Django, I have a variable that holds JSON formatted data like this: [{"score": 1, "color": "blue"}, {"score": 5, "color": ...

What is the best way to align the progress bar near the element that initiated the task?

I am currently working on a dynamic website with jQuery, utilizing AJAX operations extensively. Whenever an AJAX operation is initiated, a progress bar is displayed in the center of the webpage. However, I am facing an issue where visitors find it cumbers ...

Issue with jQuery sortable serialization when dynamically adding content is not being recognized

I've been attempting to re-order a list through ajax on sortable update. However, when I add a new item to the list via ajax after the sortable has already been initialized upon page load, it fails to recognize the new item with the "serialize" functi ...

Viewing information from the database without the need to refresh the page

HTML <textarea>Enter your question here</textarea><button class="askButton">SUBMIT</button> Upon clicking the button, the question is stored in the database using Ajax, jQuery, and Laravel. However, the question only appears after ...

The functionality of the JavaScript Array Map function is not meeting our expectations

I am encountering an issue with the Array.map function that is not behaving as expected. Below is a simplified example to help me understand where I am going wrong. Here is the code snippet in question: console.log(this.reportTestData) let data = this.rep ...

"Exploring the world of TypeScript Classes in combination with Webpack

If I create a TypeScript class with 10 methods and export a new instance of the class as default in one file, then import this class into another file (e.g. a React functional component) and use only one method from the class, how will it affect optimizati ...

The child component notifies the parent to update itself, then the parent proceeds to update the input value of another child

This question may have been asked numerous times before, but despite trying various approaches such as using a subscription on the child component and ngOnChanges, I am still unable to get it to work. Here is the basic structure of the issue in my project ...

Encountering an issue with WebRTC where the 'addIceCandidate' function on RTCPeerConnection is failing, resulting in an error displayed on the console. However, despite this error

I am facing an issue with connecting two peers using webRTC. While I can successfully display both local and remote videos, as soon as the remote video appears, the candidate object turns null and an error message is logged on the console. TypeError: Fail ...

Establishing a connection to a remote Mongo database using Node.js

I have a remote MongoDB server and I am looking to establish a connection with it using Node.js. I was able to successfully connect directly with the Mongo shell, but for some reason, I cannot establish a connection to the MongoDB server in Node.js. The co ...

Unable to switch between navigation items and icons

Currently, I am in the process of learning vanilla JavaScript and I'm trying to incorporate a navigation feature similar to when the hamburger icon is clicked. However, I have encountered an issue where I cannot toggle the hamburger icon to change it ...

Understanding jest.mock: Verifying the invocation of a nested function

I have a section of code in my application that looks like this: import validationSchema from "./../_validation/report"; const reportModel = require("../models/report"); ctrl.addReport = async (req, res) => { const { body } = req; try { cons ...

How can I create a password field for a prompt dialog using AngularJS Material?

Currently, I am working with the AngularJS Material library and I am facing an issue with a prompt dialog that I need to display for users to enter a password. The problem is that even though the dialog functions correctly, the text field does not have the ...

Challenges with textual alignment in Three.js

I've been attempting to display 3D text using THREE.FontLoader, but I'm encountering an issue where the object is present in the scene but not visible. Upon further investigation, I noticed that the mesh seems to be using BufferGeometry instead o ...

Tips for updating the class of a button upon clicking it

I have a dilemma with my two buttons - one is green and the other has no background. I want them to change appearance when clicked, from green to one with a dashed border-bottom style. Below is the HTML code for these buttons: <div class="btns"> ...

How to retrieve data from an external hard drive on a Mac using Python

Seeking assistance: my Python file located at /Users/homedir/... needs to access a csv file on an external hard drive. Can anyone provide guidance on how to achieve this? I only require reading permission. ...

Tricks for refreshing cached web page assets in the year 2023

So far, here are some of the old Cache Buster techniques I've come across: Adding a query string in the link src: /mstylesheet.css?cache_buster=12345 Changing the filename each time: /mstylesheet-12345.css Using Apache with Cache-Control "must-revali ...

Finding the correlation between SVG element IDs and JSON keysUnderstanding how to pair up

Currently, I have an SVG file that can be viewed here. My goal is to present specific data when elements within the SVG are clicked. The data is in JSON format and I am looking to match each ID of an SVG element with a key in the JSON data. If both the key ...

React is encountering a problem with loading the image source and it is

<img src="play.jpg" alt="play"></img> This code works fine in standard HTML, but I'm having trouble getting it to work in React. Is adding it as a background the only solution? ...

Issue accessing object property in Handlebars template with ExpressJs

Personalized Routes: router.use(function(req, res, next) { res.locals.currentUser = req.user; next(); }); /* Accessing the home page. */ router.get('/', function(req, res, next) { console.log(res.locals.currentUser.username); ==>> t ...