THREE.IcosahedronGeometry does not contain a list of vertices

I recently took the Advanced Creative Coding with WebGL & Shaders course taught by Matt DesLauriersd. During one of his videos, he demonstrated how to extract the vertices array for an icosahedronGeometry object using the following code:


const geometry = new THREE.SphereGeometry(1, 32, 16);
const baseGeometry = new THREE.IcosahedronGeometry(1, 1);

const points = baseGeometry.vertices;
console.log(points)

However, when I attempted to do the same, I found that the result was undefined.

For more details, you can view my implementation on jsfiddle: https://jsfiddle.net/18hd3jge/

Answer №1

The tutorial is outdated. Ever since the r125 update, all geometry generators such as SphereGeometry now produce BufferGeometry. Additionally, the previous Geometry has been removed from the library.

If you need to access the vertices of a buffer geometry, you will need to utilize the position buffer attribute. A standard example of this code is as follows:

const geometry = new THREE.SphereGeometry(1, 32, 16);
const positionAttribute = geometry.getAttribute( 'position' );

const vertex = new THREE.Vector3();

for ( let vertexIndex = 0; vertexIndex < positionAttribute.count; vertexIndex ++ ) {
    
    vertex.fromBufferAttribute( positionAttribute, vertexIndex );
    
    // perform operations on the vertex
    
}

For more details on the elimination of Geometry, please visit:

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

The use of a map with Next/image seems to be preventing the src image from loading properly

Utilizing next/image for loading images in my application has been successful, except when it comes to a carousel featuring multiple images. Whenever I attempt this, I encounter the following error: Error: Image is missing required "src" property. Make su ...

Issues with the File plugin in Ionic 2

Currently, I am working on integrating Quickblox into my Ionic2 application. I have successfully implemented all the required functionalities except for file uploading. In Quickblox, there is a specific function that needs to be used for uploading files, a ...

What is the method for determining the total number of hours?

Having trouble calculating total hours based on "employeeId"? Need help with the logic to solve this problem efficiently. Expected Result, [ { "employeeId": "105", "totalHours": "2:45" }, { "employeeId": "777", ...

Injecting AngularJS Modules into your application

Utilizing Angular with RequireJS has been quite beneficial for me. I have created concise controllers that contain logic specific to individual modules. However, one drawback is that I am required to include all angular modules in the main layer, which cau ...

Retrieving user email with Vue.js from Firebase

Currently, I am in the process of developing a chat application using Vue.js and Firebase. This project has been quite challenging for me as I am new to both Vue and Firebase. One specific issue I have encountered is trying to retrieve the user's ema ...

Determine whether a value contains a minimum of two words or more using JavaScript

When users input their names into a field and submit it, I want to make sure that I receive both their first and last names. In order to do this, I need to check if the value contains at least two words. However, the current code I am using does not seem ...

Guide on converting arrays and sending this information in Node.js

I managed to retrieve quiz data and now I want to enhance it by mapping each answer to its respective quiz. I have a feeling that I should use something like forEach.push, but I haven't quite figured out the exact method... const API_KEY="https: ...

"Using Three.js to determine the distance an object needs to travel in order to

I've come across numerous inquiries about how to zoom the camera to make an object fill the screen, but my goal is to move the object itself to fill the screen instead. In my attempts, I've utilized the original photo's pixel size and scale ...

Aligning buttons using JavaScript

I'm currently working on a layout with a horizontal div where buttons (referred to as letters in the code) are being created. However, I've encountered an issue where the buttons are aligning to the left side of the div and I'm unable to cen ...

How to Use Conditional In-Line CSS for Internet Explorer and Other Browsers

After inspecting the source code for this website, I noticed a cool feature where the page changes based on your scrolling position. It creates a visually appealing effect. Upon further examination of the source in FireFox, I observed the use of -webkit-t ...

Show JSON data as choices in a dropdown menu

On my webpage, I want to display a dropdown list populated with objects from a JSON file using JavaScript. Here is the structure of my HTML and JSON: HTML <html> <body> <select id="myid">MyList</select> <script src="m ...

Issue encountered while sending binary data to the server

After attempting to read a local file on the client side and sending it to the server, I encountered an error while trying to retrieve the image. JavaScript let req let rsp async function _post(url,data) { req = await fetch(url,{method: 'POST' ...

How can I effectively filter dates in Carbon strings using Laravel and Angular?

What is the best way to filter a JSON date field like created_at with a value of 2016-02-29 19:20:00? The Angular filter seems to only work on timestamps. Is there a way to convert the output to timestamp format? ...

Endless loop in RxJS when updating the Ngrx store

// Custom Component HTML <button (click)="reRoute(1)">Select</button> // Custom Component TypeScript reRoute(id: any) { this.store.select(fromStore.getBasketEntities).subscribe(data => { const dynamicUrl = id + '_' + Object ...

The issue with NetInfo.addEventListener not functioning properly in a react-native environment

Utilizing the NetInfo component in react-native to monitor network state and listen to changes using NetInfo.addEventListener() function. However, I am facing an issue where the state does not update when switching between wifi and internet connections. i ...

Obtaining the plugin directory URL through ajax in Wordpress

I have seen this question asked before, but the solution provided does not seem to work for me. I am currently using WordPress and I am attempting to specify the location of the URL "myfile.php" within my plugin directory. However, I am unsure if this is e ...

Various conditional statements based on the dropdown menu choice

I currently have a basic dropdown menu on my webpage that enables users to switch between viewing Actual or Planned dates/times in a table (I am utilizing the controller as syntax): <select ng-model="trip.viewType"> <option value="actual"> ...

Node.js is receiving an empty body from Postman when using form-data in the request

Even though I've searched extensively, I still have not found a solution to my specific issue despite it being asked before. const express = require("express"); require("dotenv").config({ path: ".env", }); const PORT = ...

Improving conditional rendering in Mui <Cards> component by fixing state behavior

I have a situation where I want to display a Floating Action Button inside each Mui card when hovered over. However, I'm running into an issue with the hover state affecting all cards instead of just the one being interacted with. How can I ensure tha ...

Discovering necessary information by iterating through JSON

Being new to vue js, my goal is to loop through the provided JSON data and check if the required data is present within the file. Here is a snippet of the JSON: [ { "id": "text-5", "widget": "hello", "params": { "0": "section-right", ...