Implementation of MeshFaceMaterial for BufferGeometry in version r68

We recently upgraded to version r68 and are in the process of transitioning all our geometries to THREE.BufferGeometry.

Previously, we were utilizing THREE.MeshFaceMaterial extensively. However, after consulting this resource on BufferGeometry faces materials, it appears that THREE.BufferGeometry does not support this feature. The suggested workaround involves creating multiple meshes, which I attempted without encountering any errors.

This is the approach I took:

var oldGeometry = ... // THREE.Geometry from our loader
var materials = ... // Material array from our loader, includes lightmaps, normalmaps, etc.
var bufferGeometry = new THREE.BufferGeometry();
var geometry = bufferGeometry.fromGeometry(oldGeometry);

var group = new THREE.Object3D();

materials.forEach(function(material){
  group.add(new THREE.Mesh(geometry, material));
});

geometry.attributes.uv = geometry.attributes.uvs;

While this method runs smoothly without errors, upon rendering, the lightmaps and other features do not seem to apply, resulting in a single colored geometry. Any advice on properly implementing this?

Update:

Regarding the UV issue, more information can be found here: https://github.com/mrdoob/three.js/issues/5118

Update 2:

Upon reviewing the WebGLRenderer Source Code, it seems that the implementation of this solution requires more effort than anticipated at the moment. Therefore, we will continue using the old geometry for now, but I am open to suggestions ;)

Update 3: For those interested in a basic DIY approach, a helpful guide can be accessed here: https://github.com/mrdoob/three.js/issues/5268

Progress is being made in this area as discussed here: https://github.com/mrdoob/three.js/issues/5417, focused on enhancing the three.js exporter, especially concerning exporting buffergeometries with multiple materials.

Answer №1

An error has been identified in the function bufferGeometry.fromGeometry() related to uvs in version r68.

To address this issue, consider implementing the following solution:

bufferGeometry.attributes.uv = bufferGeometry.attributes.uvs;

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

Exploring the possibilities of combining Selenium Code and F# with Canopy

Currently, I am facing the challenge of incorporating Selenium code into my F# project while utilizing the canopy wrapper. Canopy relies on Selenium for certain functions. My main struggle lies in converting Selenium code from Java or C# to fit within an ...

Executing Code from Tab only upon tab activation

I have multiple tabs on my page, and I want to have one tab with a widget that only loads when the user clicks on it, instead of loading along with all other tabs when the page loads. <div class="tabbable tabbable-custom"> <ul class="nav nav-t ...

JavaScript beginner syntax mistake

I seem to be encountering a syntax error in the jQuery code line below. The issue lies in the php section where I am attempting to assign the PHP session value to COMMENT_ID. 'scriptData': {'COMMENT_ID': '<?php echo $_SESSION[& ...

Using the back button in the browser can undo any CSS modifications made by JavaScript

I'm currently working on a form that changes the displayed select lists based on the selection of a previous list. HTML <select name="college" id="college" onchange="show_majors()"> <!-- <option value="-">-</option& ...

Encountering a 500 (Internal Server Error) while trying to insert data into the database through ajax

In the HTML code, I have a basic AJAX function that is triggered by a button press. The goal is to have the PHP script being called insert the JavaScript variable sent into a database. var myval = 'testuser'; // generated by PHP $.a ...

Retrieve the specific row in the spreadsheet that corresponds to a found value

I'm a beginner with Google Apps Script and I'm working on creating a script for a spreadsheet where I need to retrieve the range for a matched value. Unfortunately, there doesn't seem to be a function like .getRow() or .getRange() that can b ...

What is the proper way to showcase thumbnails in different sizes?

Currently, this is what I have: https://i.sstatic.net/VOC2z.png The display looks optimal with high-resolution landscape photos. This is the HTML and CSS code in use: <div class="upload-thumb ng-scope visible"> <span class="delete-media"&g ...

What is the best way to create a sliding <nav> effect when a <div> is clicked?

Hello! I am looking for a solution that will cause the navigation contents to slide out from the left when the div class "bt-menu" is clicked. It should also slide back in to the left either when the div is clicked again or when anywhere outside of the nav ...

What is the reason behind certain vanilla JavaScript libraries necessitating NPM?

I am a beginner in JavaScript and I want to learn more about it. Recently, I discovered a library called bounce.js which is an animation library. However, it requires NPM for installation, but I am hesitant to use NPM or any packet Manager because they hav ...

Updating classes in a CSS style for a chosen item, and modifying additional classes for similar elements to match the selected one

How can I apply the 'selected' class to only the clicked item and remove it from all other items with similar classes? <ul class="nav-list"> <li> <a href="#"> <i class="fa-soli ...

Unlock the full potential of integrating external APIs with Next.js

As a newcomer to NextJs, I am facing the task of making calls to an external Python API from my frontend. Upon discovering NextJs's integrated API feature through creating folders in the app directory, namely api/resource/route, I am wondering what th ...

I'm having trouble displaying the partial view called by my action in ajax.beginform. Why isn't it showing up on the page

I am encountering an issue with a page that includes a viewmodel. When a button is clicked, it triggers an ajax form submission: @using (Ajax.BeginForm("finalstatus", "User", null, new AjaxOptions { HttpMethod = "POST", ...

To trigger the action of any button in Ionic/Angular, I need to double-click

I am encountering an issue with an app that I developed using the Ionic framework. While the app works perfectly on Android devices, I am facing a peculiar situation on iOS. Every time I click a button in the Simulator or on an actual iOS device, I have t ...

How can I prevent getting stuck in a never-ending React re-render cycle?

I always believed that placing any form of setState within a useEffect call would lead to an endless re-render loop since the useEffect gets triggered on every render. Surprisingly, in my Next.js application, everything seems to be functioning well without ...

Converting a variable with a cloned object from jQuery to vanilla JavaScript

const clonedBoardCode = $('#board_code').contents().clone(false); alert( clonedBoardCode.filter('div').eq(x).children().eq(y).text() );//need to fix this I am looking for a code similar to this $('#board_code_dup > div') ...

Tips for properly modifying an attribute within an array of objects in JavaScript using ReactJS

My array of objects looks like this: this.state = { itemSquare: [{ item: "bomb", status: false }, { item: "bomb", status: false }, { item: "bomb", status: false }, { item: "bomb", status: ...

Is it logical to combine Require.js and Angular.js for web development purposes?

As someone new to Angular.js, I am exploring how it differs from Backbone.js. Previously, we utilized Require.js to handle our package dependencies with Backbone. Is it advisable to follow the same approach with Angular.js? ...

Display directional arrow on Ext.grid when the page is initially loaded

Displaying a grid with the product ID is our current setup. While the data is sorted according to the product ID, the sort arrow does not display upon page load. I have observed that clicking on the column reveals the arrow. How can we ensure that the so ...

Resolving the dilemma of complete form validation in Jquery

I'm currently working on a PHP form that is being validated with jQuery. In this form, there is a radio button list. If the user clicks "Yes," then the textbox related to that radio button should not be validated. However, if the user clicks "No," the ...

Utilize express compression in Node.js to compress JSON data from the REST API endpoint

I recently developed a small RESTful application using Node.js. I attempted to compress the JSON data returned by an API request using Express and compression, but unfortunately it did not work as expected. var express = require('express'); var ...