Offsets and indices within BufferGeometry

I have been curious about the terms "offsets" and "indices / index" for some time now. I noticed that offsets are mentioned in https://github.com/mrdoob/three.js/blob/dev/src/core/BufferGeometry.js, and indices were previously mentioned in IndexedGeometry, although I am currently unable to locate it in the dev tree. While indices may seem straightforward, I am interested in hearing an official explanation rather than interpreting it myself by delving into the code.

Thank you!

Answer №1

There are a couple of methods for defining geometries:

Non-Indexed

"vertices": [ 0, 1, 2,  3, 4, 5,  6, 7, 8,  ... ],
"normals":  [ 0, 1, 2,  3, 4, 5,  6, 7, 8,  ... ]

In this mode, each triangle position is explicitly defined and data cannot be reused.

triangle 0: [ 0, 1, 2,  3, 4, 5,  6, 7, 8 ]

Indexed

"indices":  [ 0, 1, 2, ... ],
"vertices": [ 0, 1, 2,  3, 4, 5,  6, 7, 8,  ... ],
"normals":  [ 0, 1, 2,  3, 4, 5,  6, 7, 8,  ... ]

In this mode, indices determine the order of the data. The first triangle uses indices 0, 1, and 2. These indices are used to access the corresponding vertices and normals data:

triangle 0: [ 0, 1, 2,  3, 4, 5,  6, 7, 8 ]

The primary advantage of indexed method is the ability to reuse data and reduce the amount of data sent to the GPU:

"indices":  [ 0, 0, 0, ... ],
"vertices": [ 0, 1, 2,  3, 4, 5,  6, 7, 8,  ... ]

triangle 0: [ 0, 1, 2,  0, 1, 2,  0, 1, 2 ]

Regarding offsets...

Using offsets allows you to render specific ranges of your geometry. Instead of rendering from triangle 0 to triangle.length, you can choose to render from triangle 200 to triangle 400.

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

Configuring rows in React datagrid

I am working on a component where I receive data from the backend and attempt to populate a DataGrid with it. Below is the code for this component: export const CompaniesHouseContainer: React.FC<Props> = () => { const classes = useStyl ...

Validator returns undefined when expressing invalid data

Having an issue with validation, here is the code snippet: routes.js var express = require('express'); var router = express.Router(); var hello_controller = require('../api/controllers/helloController'); var { validationRules, validat ...

Turn on and off scrolling of DIV content when hovering over it

How can I create a div that automatically scrolls to the bottom on hover? I tried implementing the code below, but it doesn't work as expected. It jumps to the bottom of the div's height on first hover and transitions smoothly on second hover. . ...

NodeJS Exporting Features

A situation is in front of me: var express = require('express'); var router = express.Router(); var articles = require('../model/articles.js'); router.get('/all', function(req, res, next) { res.json(articles.getAll()); ...

JavaScript and jQuery are lightning fast, especially when the page is reloaded

I am currently working on a responsive website that uses liquid layouts. I have encountered challenges when incorporating images in the design, especially when dealing with different browsers like IE, Firefox, and Chrome. Recently, I faced another issue w ...

Adding a simulated $state object to an angular unit test

I'm facing some challenges with Angular unit testing as I am not very proficient in it. Specifically, I am struggling to set up a simple unit test. Here is my Class: class CampaignController { constructor($state) { this.$state = $state; ...

What is the best way for me to grasp the concept and functionality of 'Array.prototype.join'?

When I tried using Array.prototype.join on a multidimensional array, I encountered a surprising result. To investigate further, I looked into the inner workings of Array.prototype.join and found it to be native code. [1,2,3,4,5,6,7,8].join('') [ ...

What causes the empty gap to appear during animated transitions between two 'div' elements?

Is there a way to eliminate the white space in between elements during animation? Should I wrap both divs into another div to achieve this? I am using position-top to adjust my div animations. Could this be causing the issue? What other methods can you s ...

There was an issue when trying to process the Javascript data structure with JSON.parse

Currently, I have the following data stored in a JavaScript variable: "{'Headings': [{'name': 'Behavior', 'majorTopic': 'N', 'vote': {'down': 1, 'up': 1}}, {'na ...

Tips on creating a unique d3js tree design

I am a beginner when it comes to d3js and javascript in general. My goal is to create an interactive IP administration overview using d3js by modeling json data. I know that the key tool for this job is likely d3.layout.tree, which will provide me with the ...

Freeze your browser with an Ajax request to a specific URL

There is a function in my view that transfers a value from a text box to a table on the page. This function updates the URL and calls another function called update_verified_phone(). The update_verified_phone() function uses a model called user_info_model( ...

Why am I receiving an undefined value when I try to log the createdAnimal?

My main goal with this code is to successfully console.log(createdAnimal) and have the objectAnimal with specific parameters printed out. The following code snippet demonstrates the desired parameters: animalMaker('cat','flying',true); ...

Is there a tool available on the command line to detect simple Javascript syntax mistakes?

Is there a command-line tool in Linux that can identify basic syntax errors and compile time errors in JavaScript files intended for web browsers? Usually, I write my JavaScript code alongside server-side languages like Ruby or Perl. It would be beneficia ...

What is the best way to effectively expand React Bootstrap components?

In order to add sizing functionality to a badge component, I have developed the following approach: import React from 'react'; import Badge from 'react-bootstrap/Badge'; import classNames from 'classnames'; const CustomBadge ...

Error 404 encountered when attempting to send a JSON object to the server

I've been facing a problem while trying to send a JSON object to the server using AJAX calls. I keep getting a 404 Bad Request error. The issue seems to be related to the fact that I have a form where I convert the form data into a JSON object, but th ...

looking to restrict the interface to only specific types

Currently working with TypeScript and I have a query regarding the utilization of TypeScript interface. Is there a way to selectively extract and output specific key types from the interface being used? While I am able to isolate the type I need, I am inte ...

Using `texture.needsUpdate = true` in Three.js can cause significant performance issues due to its slow execution

I am currently working on a project involving a Three.js scene where I need to update textures after a certain period of time. However, I have noticed that updating the textures is causing a significant slowdown in the FPS, dropping it to 1-2 FPS for sever ...

Utilizing AngularJS Directive to trigger a designated function upon change in an input file

My current project involves creating a scavenger hunt editor with various types of questions stored in an array. Each question can be of a different type, all displayed using ng-repeat. To achieve this, I utilize a JavaScript object representing a Questio ...

Having issues with my JavaScript code - it just won't function

I am having an issue with my JavaScript code. I don't receive any errors, but when I click the submit button, nothing happens. I have followed a video tutorial and watched it twice, but I can't seem to figure out what is wrong here. Here is the ...

Troubleshooting: Why the TableTools basic usage example is not functioning as

After replicating the code from http://datatables.net/release-datatables/extensions/TableTools/examples/simple.html in my Visual Studio project, I organized the files by saving two css files as style1.css and style2.css, along with three js files named sc ...