Can you please explain the difference between PlaneBufferGeometry and PlaneGeometry in detail? (revision 69)
Can you please explain the difference between PlaneBufferGeometry and PlaneGeometry in detail? (revision 69)
PlaneBufferGeometry
serves as a more memory-efficient option compared to PlaneGeometry
. The object itself showcases various differences. For example, the vertices in PlaneBufferGeometry can be found in
PlaneBufferGeometry.attributes.position
instead of PlaneGeometry.vertices
.
A quick look at the browser console can reveal more distinctions, but from my understanding, since the vertices are typically evenly spaced along a grid (X
and Y
), only the heights (Z
) need to be specified for positioning a vertex.
When working with 3D graphics, it's important to understand the distinction between Geometry and BufferGeometry.
Geometry is designed as a user-friendly, object-oriented data structure, while BufferGeometry aligns more closely with how data is utilized in shader programs. BufferGeometry offers faster performance and lower memory usage, but Geometry provides greater flexibility for certain operations.
While I primarily use BufferGeometry due to its efficiency, learning about Geometry can be beneficial since it reflects the actual data structures employed by shaders.
For instance, with a PlaneBufferGeometry, you can manipulate vertex positions like so:
let pos = geometry.getAttribute("position");
let pa = pos.array;
To set z values at these positions:
var hVerts = geometry.heightSegments + 1;
var wVerts = geometry.widthSegments + 1;
for (let j = 0; j < hVerts; j++) {
for (let i = 0; i < wVerts; i++) {
//+0 refers to x, +1 refers to y.
pa[3*(j*wVerts+i)+2] = Math.random();
}
}
pos.needsUpdate = true;
geometry.computeVertexNormals();
You could introduce randomness or even plot a function based on x and y coordinates within this loop. For optimized performance with PlaneBufferGeometry, consider adjusting y values in the outer loop using
let y = (0.5-j/(hVerts-1))*geometry.height
.
It's recommended to utilize geometry.computeVertexNormals();
if your material relies on normals and you haven't calculated them manually. Otherwise, default plane normals will be applied.
Keep in mind that the number of vertices exceeds the number of segments by one along each dimension.
Furthermore, note the flipped relationship between y values and j indices when pushing vertices: vertices.push( x, -y, 0 );
I am trying to achieve a specific task using AJAX: sending a startdate and enddate from a calendar to a Node.js backend, which is written on a Firebase Cloud Function. Once the button is pressed, I want to post this data and console.log it. Here is my AJA ...
One JSP page displays database results in a table on the browser, allowing users to edit or delete each row. I want to implement a feature where clicking the edit link fetches specific customer data from the database using Spring MVC and Hibernate, display ...
I have a dynamic input field with a search button. Initially, only one tab is opened when I click the button. But after saving and clicking it again, multiple tabs open for the same URL. The number of tabs is equal to the number of dynamic input fields cre ...
I am dealing with multiple text nodes that need to have some text replaced with HTML: <pre>{ "data": [ { "source": "<a href=www.e.com>e.com</a>", "created_time": "2015-11-13T06:16:09+0000", ...
I'm struggling to understand how to transfer the v-slot data into a component. Suppose I want to restructure the code below: <template v-slot:item="data"> <template v-if="typeof data.item !== 'object'"> <v-list-item-co ...
I'm in the process of developing a React web application, and I've incorporated an English node module package called react-timelines. However, I need to translate the label text "Today" into Spanish, which should be "Hoy". When I attempt to modi ...
Recently delving into jquery, I encountered the issue described in the title. Below is an excerpt from my controller code: [HttpPost] public JsonResult getProjectList() { List<Project> projectList = new List<Project>(); ...
My AngularJS script with MVC architecture is causing some issues. I suspect that there might be errors in the connection between the model, view, and controller layers. JS: var myApp = angular.module("myApp", []); //App.js myApp.controller('MainCon ...
Currently, I am utilizing an external SDK built in JavaScript. One particular module within this SDK, called Blob, is both new-able and contains an enum named FooEnum with the members Bar and Baz. To implement this SDK in JavaScript, the code looks like t ...
Is there a way to specify the location of the 'Request desktop site' option? Here is the code I am currently using: var detector = new MobileDetect(window.navigator.userAgent); if(detector.mobile() != null || detector.phone() != null || det ...
I have been given a code with three essential parts that cannot be altered: 1. First, there is a call to the getData function, followed by printing the output. getData().then(console.log); 2. The function signature is as follows: async getData(): Promise ...
I've encountered an issue while trying to implement the normal mapping shader THREE.ShaderUtils.lib["normal"]. The normal mapping itself seems to be working fine, but I am facing problems with the lights. Whenever I move the camera or look around, the ...
Hey there, I'm having some trouble with installing the Canvas package. I've tried Package Versions 6.1.13 and 6.1.3 Here are my system details: Ubuntu 18.04.5, Node 12.18.4 LTS, Python 2.7, g++ installed, pkg-config installed, libjpeg installed ...
Currently, I am utilizing a library that relies on the req.secure option to proceed without any errors. However, my application is deployed on Heroku and I have implemented custom middleware to check the "x-forwarded-proto" header and set req.secure as tru ...
I'm currently developing a reusable UI component and am exploring options to allow the user of this component to provide their own template for a specific section within it. Utilizing TypeScript, I have been experimenting with string interpolation as ...
While developing a full-stack MERN application, I encountered an unusual issue when inspecting my React UI in Chrome DevTools. If any of these dependencies are playing a role, below are the ones installed that might be contributing to this problem: Tail ...
I need help displaying a table in my React component by utilizing the useEffect and useState hooks for rendering the table on the initial load. Here is my component js: import React, { useEffect, useState } from 'react' const Projects = () => ...
In my blade layout file, I have some code that is included in my view multiple times using the @include.layout("blade file link") syntax. When a button is pressed, I want to call a controller function. This works fine without AJAX, but when AJAX is added, ...
In the following code snippet, I am trying to retrieve the value when any of the radio buttons is selected: <label ng-repeat="SurveyType in SurveyTypes"> <input type="radio" name="SurveyTypeName" ng-model="surveyData.SurveyTypeN ...
After moving a web method from the code-behind file of an ASPX page to another CS file located in the data section (which does not have any associated ASPX page), I encountered an issue with accessing the web method using Ajax. Previously, I accessed the w ...