Is it possible for BufferGeometry to have material applied on just one side?

Just started experimenting with three.js. I decided to test a polygon using the code below:

var geometry = new THREE.BufferGeometry();
var vertices = new Float32Array([
    2.0, 1.0, 1.0, -1.0, -1.0, 1.0,
    1.0, -1.0, 1.0,

    1.0, 1.0, 2.0, -1.0, -1.0, 1.0,
    1.0, -1.0, 1.0,
]);
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
var material = new THREE.MeshBasicMaterial({
    color: 0xff0000
});
mesh = new THREE.Mesh(geometry, material);

scene.add(mesh);

I was anticipating the polygon to be red on all sides, but it turned out only one side is red while the other appears black.

Any tips on how I can resolve this issue?

I tried creating a fiddle link, but it's not functioning as expected (full code of my test file can be accessed here):

JSfiddle

Rotate the polygon horizontally by moving the mouse left or right.

Answer №1

Is the result you're looking for being achieved?

let material = new THREE.MeshBasicMaterial({
    color: 0xff0000,
    side: THREE.DoubleSide,
});

For more specific information, check out this link in the documentation:

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

Background of Google Maps HeatmapLayer

After creating heatmapLayers, I've noticed a strange issue where adding and removing them affects the background color of the entire map component, even in areas with no data points nearby. The extent of this background change is determined by the alp ...

Example when a specific $scope.apply() is needed:

I am currently delving into the world of Angular and experimenting with different ways to learn how it functions. One of my projects involves creating a simple application where users can add new entries through an HTML interface, store them in a SQLite da ...

How can I dynamically set the width of a span element in HTML?

Hello there! As a beginner in html and angularjs, I'm experimenting with dynamically assigning span width based on an angular js response. <div class="statarea" ng-repeat="x in names"> <div class="ratingarea"> <div class=" ...

A more efficient method for creating a nested array of distinct values using JavaScript

The scenario: My website has a complex html table structure to showcase hierarchical data, with the ability for users to toggle visibility of individual rows. Each row is identified by a dom id consisting of a level number and primary key specific to that ...

What is the best way to handle waiting for a request and user input simultaneously?

Imagine a scenario where a component loads and initiates an asynchronous request. This component also includes a submit button that, when clicked by the user, triggers a function that depends on the result of the initial request. How can I ensure that this ...

I am converting a class component to a functional component within a React-Redux-Firebase project

I am currently in the process of rebuilding this component. Check out the updated code here Also, take a look at the project actions script here However, I'm facing an issue with rewriting mapStateToProps and mapDispatchToProps functions. The error ...

Can anyone guide me on saving an array to local storage, retrieving its contents, and populating them into a select element?

I have written code to retrieve an array and add its elements to a select object. Check it out: var select = document.getElementById('select'); var theArray = localStorage.getItem("array") JSON.parse(theArray) if (theArray != null){ f ...

JavaScript: specify parameters for function inputs

I'm curious about optimizing Javascript/Typescript functions arguments for clean code. To demonstrate, let's consider a basic example. Imagine I have a React component with a view property as props: <Grid view="Horizontal" /> ty ...

Specific phrase enclosed within div element

How can I concatenate three strings together when one of them is enclosed within a strong tag? The result is not what I expected. Can you identify the issue here? Result: There is no Colors for <strong>blah</strong> in the database. Expecte ...

What causes the server to give an incorrect response despite receiving a correctly read request?

After setting up a new project folder and initializing NPM in the Node.js repl, I proceeded to install the Express package. In my JavaScript file, I included the following code: const express = require('express'); const app = express(); ...

Is TypeScript being converted to JavaScript with both files in the same directory?

As I begin my journey with TypeScript in my new Angular project, I find myself pondering the best approach for organizing all these JS and TS files. Currently, it appears that the transpiler is placing the .js files in the same directory as the correspondi ...

What causes the initial AJAX response to be delayed by 10 seconds when using setInterval()?

I have a task that requires me to send an ajax request to display an image that changes every 10 seconds. However, I'm encountering an issue where my webpage remains blank for the first 10 seconds and only displays the first image after the initial de ...

Is there a way to set a default value for the map function?

Currently utilizing React.js with the following code snippet: myArray.map(variable=>({value: variable.value, label: variable.label})) It's working well for the most part, but occasionally encountering this issue: TypeError : myArray is null Any s ...

How to Update DIV Content in a Child Page Using C#, Javascript, and ASP.NET

I have a master page that sets the basic layout of my website. My goal is to change the contents of a specific div on the child page. I am aware that I can achieve this using the following code snippet: //((HtmlGenericControl)this.Page.Master.Master.FindC ...

Disable the sorting feature on selected columns

I have a Datatable in JS with a scroll bar that I added using scrollY. However, it is displaying unnecessary small arrows within the table which I do not want. I have tried various methods to remove them but without success. Can someone please help me wi ...

Creating dynamic dropdowns with Ajax and HTML on the code side

I have developed a script that generates a drop-down menu and updates the .box div with a new color and image. Below is the HTML & Java code: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <div> ...

Utilizing AngularJS: Executing directives manually

As a newcomer to AngularJS, I am facing a challenge that requires creating a 3-step workflow: The initial step involves calling a web service that provides a list of strings like ["apple", "banana", "orange"]. Upon receiving this response, I must encap ...

Extract the URL from the query parameters and inject it into a div element

I am currently working on a project to create an ASPX page with two separate div's. The first div will have static content, while I want the content in the second div to be dynamic. Users should be able to input a URL as a query string, and that URL s ...

extracting values from deeply nested JSON array in JavaScript

Is there a way to extract values from a deeply nested JSON array? I'm looking to retrieve all pairs of (nameValue and value) from the JSON provided below var json = [{ name: 'Firstgroup', elements: [{ ...

Tips for adjusting the font size according to the varying number of characters entered

I am currently facing a challenge with adjusting the font size based on the dynamic number of characters. For example, I have a set of characters with a font-size of 40px, and as more characters are added, the font size should decrease to fit within the av ...