Can you explain the significance of these vertices in the box geometry in THREE.js?

After creating a box geometry using the code below:

    const hand1geo = new THREE.BoxGeometry(2, 0.01, 0.2);
    const material_sidehand = new THREE.MeshBasicMaterial({ color: 0x3cc1b7 });
    const sidehand = new THREE.Mesh(hand1geo, material_sidehand);

I attempted to extract vertices from the box using:

this.sidehand.attributes.position.array

The result I obtained was showcased in this image. It seemed to generate 72 elements (24 vectors) with the same value. I am puzzled by why there are exactly 24 vectors and where they have been defined. This information is crucial as I plan to utilize a raycaster for collision detection in the future. Despite trying to access the vertices using this.sidehand.vertices, it proved unsuccessful.

Answer №1

Every time I attempt to access this.sidehand.vertices, it seems to be unsuccessful.

I'm not entirely sure where your information is coming from, but there is no property called vertices in the Mesh class. It's possible you are referring to the outdated Geometry class, which used to have this property. However, it has since been replaced with BufferGeometry.

I'm baffled as to why it only produced 72 elements (24 vectors) with the same value.

Although it may appear that the values are identical, the BoxGeometry actually defines all the vertices of the box in local space within a flat array for direct use by the WebGL API, optimizing performance.

The reason there are 24 vectors is because each side of the box consists of four vertices, with each side being made up of two triangles. This structure allows for proper calculation of normals and texture coordinates.

It might be more efficient to use bounding volumes instead of raw geometry data for collision detection, as it can greatly enhance performance.

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

Is there a way to retrieve the value of elements that are deeply nested within multiple objects and arrays?

When making an API call to retrieve data from the Google Distance Matrix API, I store that information in my Redux store within a React application. The returned data object is structured as follows: Object { "destination_addresses": Array [ "21 Fo ...

Unable to access the URL slug within the client component in Next.js version 13

In my upcoming project with Next 13, I have a client-side component that is being rendered under the route /journal/[date] Unfortunately, I'm facing an issue trying to extract the date from the URL. I attempted to use: import { useRouter } from &apos ...

`Need help setting the active class for a bootstrap navbar using Angular JS?`

In my bootstrap navbar, I have the following menu items: Home | About | Contact I'm looking to assign the active class to each menu item based on the current angular route. Specifically, how can I set class="active" when the angular route is at # ...

Animation of two divs stacked on top of each other

I am trying to replicate the animation seen on this website . I have two divs stacked on top of each other and I've written the following jQuery code: $('div.unternehmen-ahover').hover( function () { $('div.unternehmen-ahover' ...

SyntaxError: Identifier was not expected

I am currently working on a function that involves a table of rows with edit buttons. Whenever the edit button is clicked, the following function is called and I encounter this error: Uncaught SyntaxError: Unexpected identifier The error seems to be poin ...

Learn the process of transferring information from a dynamically generated table to a database using PHP

After creating a table using PHP dynamically, I am facing an issue with updating some cell values based on user input. I have provided my code below. I tried using [] in the names attribute to make names an array as suggested on Stack Overflow, but it didn ...

I feel overwhelmed and confused by Node, Express, domains, and uncaught exceptions

After hours of research on exception handling in Node, I've come to understand the drawbacks of using uncaughtException. It's clear that shutting down the process can prevent any potential "unknown state" scenarios where anything may happen. The ...

Locate the final element within an array using JavaScript

Provided with a file path like new/lib/java.exe, I am looking to eliminate the root folder 'new' and structure the new path as lib/java.exe. Challenge: After my attempts, I am left with the path as lib/java.exe/ which includes an unwanted "/". I ...

At that specific moment, a plugin is active to monitor the execution of JavaScript functions

Similar to how Fiddler allows you to monitor the communication between client and server, I am looking for a tool that can analyze all network traffic generated by client-side JavaScript on a webpage. Warm regards, bd ...

The internal style and script specified within the <head> section are not being rendered

Within my Joomla website using the T3 template, I inserted the following "Custom Code" just before the closing </head> tag: <style type="text/stylesheet"> div.t3-sidebar.t3-sidebar-right{ background: #F8F8F8 none repeat scroll 0% 0%; ...

Monitoring and recording the current line number during evaluation

Recently, I've been experimenting with eval to modify a $scope object named variables. This is the watcher I'm using: $scope.$watch(function () { return $scope.variables; }, function (variables) { console.log('changed!'); }, true) ...

What is the best way to include the toast component in my button?

I am brand new to working with Next.js and React. I have a button in my project that triggers an external JavaScript file (query.js). After the script finishes executing, I would like to display a toast notification indicating whether it was successful or ...

Line numbers in Vue Codemirror

Currently, I'm working on integrating codemirror into my Vue.js application using a library found at https://github.com/surmon-china/vue-codemirror. The issue I'm facing is that even after importing and utilizing the codemirro component, everythi ...

Unable to recreate the Jquery Mobile Autocomplete demonstration

Attempting to recreate a demo using my own remote data source: The HTML page mirrors the demo, with one change: url: "http://localhost/sample.php", Here is the dummy remote data source sample.php <?php $a = array('apple', 'mango&apo ...

ng-include failing to retrieve file name containing UTF-8 character

I encountered an issue with the ng-include directive in the code snippet below. The file name it's trying to access contains a special character, specifically an ñ, resulting in a not found error being displayed. <div ng-include="'{{mainCtrl ...

Retrieve Header information when making a cross-domain AJAX request

I've been working on a way to validate image URLs by using an AJAX call to check if the image is still available. The challenge I'm facing is that the image server is on a different domain, so I included the crossDomain: true attribute in my AJAX ...

Displaying information from an array in a view and manipulating it using JavaScript

Having trouble displaying array data in a customized way. Here is how my array structure looks: array:2 [▼ "folder1" => array:5 [▼ 0 => "4.png" 1 => "2.png" 2 => "1.png" 3 => "3.png" 4 => "5.png" ] "folder2" ...

A step-by-step guide to effectively stubbing a dependency within an express middleware using a combination of express-validator, mocha, chai, sinon,

**Edit: Re-created with a simple example that works first: I have an example file and two modules. moduleA has a dependency called moduleB // moduleA.js const ModuleB = require('./moduleB'); function functionA() { return 20 + ModuleB.functio ...

Reactjs: Tips for precisely cropping an image to a specific aspect ratio using client-side techniques

Looking to crop an image with a minimalist approach to achieve a specific aspect ratio. For instance, if we have an image sized at 3038 x 2014 px, and desire a 1:2 aspect ratio, we would crop it to 3021 x 2014 px. The crop would be made from the center of ...

Retrieving the chosen option from a radio button

<!DOCTYPE html> <html> <body> <input type="radio" name="colors" value="red" id="myRadio">Red color <p>Click the "Try it" button to display the value of the value attribute of the radio button.</p> <button onclick=" ...