Getting the vertices of a sphereGeometry can be achieved by accessing the specific

While it may seem like an easy question, I am looking to place objects on top of the vertices of a sphere in Three.js. Each sphere is made up of small triangles, and I specifically need the coordinates of these corners/vertices rather than random locations on the sphere.

Here is the code I have tried that does not work:

var sphereGeometry = new THREE.SphereGeometry( 80, 16, 8 );
console.log(sphereGeometry.geometry.vertices.length);

The second line is giving me an error "sphereGeometry.geometry is undefined." This is puzzling because sphereGeometry should inherit properties from geometry, but I am stuck on how to access the coordinates of each vertex. Any assistance would be greatly appreciated.

Answer №1

Indeed, sphereGeometry is essentially the Three.Geometry-Object itself. To access its vertices, you can simply use

   console.log(sphereGeometry.vertices.length);

Alternatively, you could assign the Three.Mesh to a variable named "sphereGeometry," even though it may not align with naming conventions. In that case, your initial statement would function as intended^^

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

Chrome is blocking my ajax cross-origin request, causing it to be cancelled

I have been working on a Google Chrome extension and encountering an issue with my ajax requests. Every time my extension sends a request, it ends up getting cancelled for some unknown reason. The following code snippet seems to be functioning properly: ...

It appears that the JavaScript global dynamic variable is undefined as it changes from function to function, suggesting it might be

I'm encountering an issue with the way these two functions interact when used in onclick calls of elements. Due to external circumstances beyond my control, I need to keep track of when and how elements are hidden. Everything works perfectly as inten ...

I need RxJs to return individual elements to the subscriber instead of an array when using http.get

I've been developing an Angular 2 app (RC5) with a NodeJS backend RESTful API integration. One specific route on the backend returns an array of 'Candidates': exports.list = function (req, res, next) { const sort = req.query.sort || null ...

Ways to help parents disregard events initiated by their children

I have a situation where clicking on a child element should not trigger the parent element, but using event.stopPropagation() is not an option due to other event listeners waiting for the click event. Specifically, when clicking on the dropdown of parent1 ...

What is the best way to reveal the following div while concealing the one before it?

Just starting out with Javascript, I'm currently developing a quiz solution that utilizes divs and buttons to navigate through the questions. I've written some JavaScript code for this functionality but I'm encountering an issue where it doe ...

I am sometimes experiencing issues with activating ajax code using Bootstrap 3 modal

I'm stumped trying to find a solution for this issue. Currently, I am utilizing the bootstrap modal to retrieve ajax content from a specified URL. To prevent content overlap, I am using $.removeData() when reloading the content. The problem arises w ...

Is it possible to alter the value of a global variable within a function and switch its value based on a local variable?

Currently, I am facing an issue with changing the value of a global variable dynamically from a function. The variable has a global scope and is also present in the same function as a local variable. However, despite my efforts, I am unable to successful ...

Using Node.JS and MySQL to optimize data retrieval by combining queries to define variables and select data efficiently

My SQL query that functions perfectly in PHPMyAdmin seems to be causing issues in Node.JS: SET @row_number=0; SELECT * FROM blah blah @row_number blah blah; When attempting to execute both queries in Node.JS using con.query("SET @row_number=0; SELECT * ...

Update the CSS styles using jQuery

I am looking to update the content within a CSS tag using jQuery. In this instance, I need to change "My content" to "New Content". Here is the CSS code I have: a.appari:focus:after{ background: #333; background: rgba(0,0,0,.8); border-radius: 5px ...

Executing Angular application through Node.js server

I have the following list of files: index.html app.js (angular controllers here) routes.js (I'm attempting to load index.html from here - listening on localhost :3000) index.css node_modules folder routes.js : var express = require(&apo ...

Ways to display pictures by invoking an API within the antd item list container

Upon page load, I am fetching images from a database using an API. Now, my goal is to display these images within a Modal in Antd. How can I accomplish this with the code snippet below? const MyVehiclePage = (props) => { useEffect(() => { co ...

spill the elements from one div into another div

I'm facing a situation where I have 2 divs on a page, with the first div containing text content only. The issue is that when the content of the first div overflows, it gets cut off due to the CSS applied to it: .one { overflow: hidden; width: 1 ...

POST request in Ajax with NodeJs/MongoDB/Mongoose causing an Uncaught TypeError: Illegal invocation

Whenever I attempt to make a POST request using Ajax/Jquery, I keep encountering an error in the console. The specific errors are on lines 67 and 31 in the createTeam.js file: $.ajax({ //line 67 sendInvitation(teamID,_companyName,teamName) //lin ...

Showing data from a Node.js Express application in a Jade template file

I am encountering an issue with my simple jade page where not all variables passed from the javascript route are displaying correctly. I have attempted to implement the solution described in this answer, but it seems to be ineffective in my case. My goal i ...

How to retrieve the $0 element using Python Selenium

There is an unnamed element I can only access with a dollar sign: console.log($0); "100" In Python Selenium, how can I retrieve this element? I attempted the following: my_value=driver.find_element(By.NAME,"$0") However, it resulted i ...

Ionic 2's NavParams Feature

I've been attempting to transfer a specific data from one page to another using NavParams, however, I'm consistently receiving an 'undefined' result in the console. I'm struggling to identify what the issue might be. Here is the sn ...

Angular fails to function properly post rendering the body using ajax

I recently created a HTML page using AJAX, and here is the code snippet: <div class="contents" id="subContents" ng-app=""> @RenderBody() @RenderSection("scripts", required: false) </div> <script src="http://ajax.googleapis.com/ajax/ ...

Audio not functioning on Android version 2.3.6 due to HTML5 issues

I've created an Android Audio Application that functions flawlessly with html5 Audio. However, I've encountered a problem where the audio won't play on certain phones. I'm utilizing a basic HTML5 feature. I've tried various solut ...

What is the process for defining an outcome when a draggable element is placed into a droppable area using Jquery?

Currently, I am working on a task where I need to increase the value of a counter (var counter = 0;) every time a draggable image is dropped into a dropzone, which is also an image rather than a div. $( "#goldbag" ).draggable({ revert: "invalid", containm ...

How should a request from express/connect middleware be properly terminated?

If I have middleware like the following; var express = require('express'); var app = express(); app.use(function (req, res, next) { var host = "example.com"; if (req.host !== host) { res.redirect(301, host + req.originalUrl); ...