Unleashing the power of the Three Explode Modifier

When utilizing the ExplodeModifier to duplicate vertices for individual control over Face3 objects, I encountered a visual issue and decided to add 3 extra faces per existing face to create a pyramid shape pointing inwards the geometry.

Although I successfully modified the ExplodeModifier to generate the additional faces, I am encountering multiple errors:

THREE.DirectGeometry.fromGeometry(): Undefined vertexUv and THREE.BufferAttribute.copyVector3sArray(): vector is undefined

To address the fact that there are now 9 extra vertices per face, I attempted to duplicate the UV coordinates even though I do not require textures. This resolved one warning but I am still struggling with the copyVector2sArray error...

Pseudo code snippet:

var geometry = new THREE.IcosahedronGeometry(200, 1);
var material = new THREE.MeshPhongMaterial({ shading: THREE.FlatShading });

var explodeModifier = new THREE.ExplodeModifier();
explodeModifier.modify(geometry);

var mesh = new THREE.Mesh(geometry, material);
scene.addChild(mesh);

The pseudo code for the Explode Modifier is as follows:

var vertices = [];
var faces = [];

for (var i = 0, il = geometry.faces.length; i < il; i++) {
    (...)

    var extraFace1 = new THREE.Face3().copy(face)
    extraFace1.c = geometry.vertices[0]

    var extraFace2 = new THREE.Face3().copy(face)
    extraFace2.b = geometry.vertices[0]

    var extraFace3 = new THREE.Face3().copy(face)
    extraFace3.a = geometry.vertices[0]

    faces.push(extraFace1);
    faces.push(extraFace2);
    faces.push(extraFace3);
}

geometry.vertices = vertices;
geometry.faces = faces;

I have included an example HERE. It functions properly, but my goal is to eliminate the console warnings...

Answer №1

Upon the observation of @mrdoob, it was noted that I mistakenly assigned a THREE.Vector3 instead of an index to the added THREE.Face3.

 var additionalFace1 = new THREE.Face3().copy(face)
 additionalFace1.a = geometry.faces.length * 3 - 1

 var additionalFace2 = new THREE.Face3().copy(face)
 additionalFace2.b = geometry.faces.length * 3 - 1

 var additionalFace3 = new THREE.Face3().copy(face)
 additionalFace3.c = geometry.faces.length * 3 - 1

Updated jsfiddle link

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

Issue with logging objects in an array within a for loop

I am having an issue with a JavaScript for-in loop. Why does console.log(user) display the number "0" when iterating through users? Is it indicating the index of the user object in the array? I would like to log each object individually... Thank you r ...

Does the Angular templateCache get shared across different applications? And does it stay persistent?

Is it possible for two Angular applications that operate on the same domain to exchange data within the templateCache? Or does each main application module have its own unique cache? I am curious about the circumstances under which a new templateCache is g ...

Attach a click event to a dynamically generated element inside a directive

After thinking I had successfully solved this issue, it turns out I was mistaken. I developed a directive to enable me to clear a text input field. Essentially, when you begin typing into the input box, an "X" icon appears on the right side of the textbox. ...

The analytics event code is visible in the source code, but is not displaying in the console

I am facing an issue with a website built on Umbraco and it has me completely stumped. I have set up event tracking for Analytics on several download buttons, and while most of them are functioning properly, there is one button causing me trouble. When I ...

What is the easiest way to choose a specific word from a paragraph with just one right-click?

Hello fellow experts at StackOverflow, I'm currently delving into a new concept where I aim to enable text selection with just a single right mouse click. In other words, I want to achieve the functionality of double-click text selection through a sin ...

What is the best way to call upon a necessary module from various files?

When working with Node.js, I am using Socket.io in my main.js file like this: const io = require('socket.io')(http); Additionally, I have a separate "sub" file called api.js where I delegate some of my business logic. To include this file, I us ...

Split an array of articles into subarrays according to their topics using the reduce method in Javascript

I am currently seeking a solution to divide an array of articles into subarrays based on the first key-value pair and its order. After researching several Stack Overflow posts, I have come across one that seems to align closely with my objective: break a ...

Guide to redirecting SAML SSO form-based authentication using Ajax

Hey there, I'm encountering a challenge with SAML SSO POST binding in the context of a protected Web application that includes Ajax script. Following the initial authentication process, which is managed by the browser, the Ajax code within the Web app ...

Exploring Excel files using the exceljs library

Using the exceljs module, I am able to read Excel files when they are in the same folder as my application. The code works perfectly in this scenario: var workbook = new Excel.Workbook(); workbook.xlsx.readFile('Data.xls') .then(function() ...

Step-by-step guide to creating a "select all" checkbox feature in AngularJS

On my HTML page, I have incorporated multiple checkboxes using AngularJs. Is there a way to add one more checkbox named "select all"? Ideally, when this checkbox is selected, all other checkboxes on the page should automatically be checked as well. Any su ...

Implement the morgan express middleware from exports

For my logging needs in an Express application, I have decided to utilize the morgan package. Initially, I was able to integrate morgan by using it directly in my server.js file like so: app.use(morgan('tiny')), which worked perfectly. However, I ...

What is preventing me from passing str.indexOf into the map function in JavaScript?

How come I'm unable to perform the following action? let str = "A string containing * and ^ as well as $"; let indices = ["*", "^", "$"].map(str.indexOf); // not functional I prefer not to introduce another function that duplicates the functionality ...

Struggling to navigate with react-semantic-ui and router

Here is a sample code snippet for a simple menu/header using JSX: <Menu fixed='top' inverted> <Container> <Menu.Item header>Simple Blog</Menu.Item> <Menu.Item name='home' as={Link} to=&ap ...

Exploring Transparency in THREE JS: Rendering select faces of a BufferGeometry with a see-through effect

I am faced with the challenge of rendering two cubes on a single non-indexed buffer geometry. My goal is to make these cubes transparent so that all sides are visible simultaneously. To achieve this, I aim to utilize the "vertexAlphas" material property to ...

Developing a slideshow with PHP and JQuery

Attempting to create a simple manual slideshow where the user clicks "next" to advance to the next slide. I have over 50 images and want to display them in batches of 8. For example, the first batch of 8 will be shown initially, then the user can click "ne ...

Connect the CSS active state to a JavaScript event

.el:active{ background:red; } Is there a way to associate the above CSS active state with a JavaScript event, like this: $('.el').on('active', function(){ img.show(); }); I want the image to remain visible when el is presse ...

Strange Puppeteer conduct

Currently, I am utilizing Puppeteer to launch a headless web browser and interact with a specific website using JavaScript. The website requires login credentials before proceeding further. Upon login, a popup window appears which closes once the authentic ...

Learn how to utilize Jquery to create a dynamic slide effect that toggles the

I am looking to change a banner on click functionality. Currently, I have hidden the 2nd banner and banner 1 is displayed. When the arrow is clicked, I want banner 1 to hide and banner 2 to show. The challenge is that I attempted using HTML for this task. ...

A dynamic jQuery plugin for creating captivating image slideshows

I am in need of a recommendation for a jQuery carousel plugin that has the capability to create a carousel similar to the one shown in the image. Specifically, I am looking for a carousel where the active image item moves to the center and becomes larger. ...

Tips for retrieving the value of a corresponding data attribute by the text within a div using jQuery in JavaScript

I have several divs with different names and values assigned to the data attribute data-category Now, I am in need of retrieving the value of data-category based on specific text present inside the div. <div class='ext-category' data-categor ...