After some experimentation with the provided code, I believe my outcome is accurate.
The issue seems to lie within the intersection portion of the code:
//Intersection
var intersection = meshes[0]
for (let mesh in meshes){
meshes[mesh].updateMatrix()
intersection = CSG.intersect(intersection,meshes[mesh])
}
intersection.material = new THREE.MeshNormalMaterial()
scene.add(intersection)
There appears to be a flaw here. According to the associative property of logical set intersection, it shouldn't make a difference whether you intersect each mesh individually (please correct me if I'm mistaken). Thus, that may not be the root cause of the problem.
To address this issue, I noticed that setting the initial intersectee as mesh[0] and then looping through the entire array might lead to intersecting at least one shape with itself. Introducing
if(meshes[mesh].geometry.uuid === meshes[0].geometry.uuid) continue;
in the loop seemed to improve the results, although it's not a definitive solution.
My suggested solution involves replacing the entire intersection segment of the code with:
//Intersection
meshes.forEach((mesh) => mesh.updateMatrix());
var intersection = CSG.intersect(...meshes);
intersection.material = new THREE.MeshNormalMaterial()
scene.add(intersection)
In this revision, I switched the loop for a more functional forEach
statement to update the matrices efficiently.
Additionally, I utilized spread syntax to invoke CSG.intersect
with all meshes from the array simultaneously.
The resulting shape can be viewed here: https://i.sstatic.net/84vHa.png
Although I cannot guarantee that this accurately represents the intersection of multiple polygons, it appears neat and devoid of any extraneous floating components seen in your original example.
P.S Thanks for the engaging intersection code! Delving into both Three.js and exploring CSG was an enjoyable experience. You can access my codesandbox demo here.
Trying to figure out how to highlight a table row using AngularJS within a directive. Here is some pseudo code I came up with: if(highlight.indexOf($index) != -1) set .highlight css class Below is an example of my code snippet: $scope.highlight = [0, ...
I've been attempting various methods to no avail when trying to execute the success block. The ajax request keeps returning an error despite having the correct URL. My current error message reads "undefined". Any suggestions on alternative approaches ...
I am currently working with vue.js components that receive their data from external sources. For example: <vue-button icon="fa-arrow-right" text="mytext"></vue-button> Initially, this setup is effective. However, I encountered a challenge wh ...
I have a function named inner that executes a series of asynchronous operations: function inner(input) { return step1(input) .then(step2) .then(step3) .catch((e) => { throw e }) } I propagate the error from inner so I can m ...
Basically, this functionality allows the user to cycle through hidden information by clicking on it. Here is how you can structure your HTML: <div id="facts"> <span>click to cycle</span> <span>fact 1</span> <s ...
I recently added the three library to my project via npm. Within the node_modules directory, there is a folder named three. However, when I tried to import it using: import * as THREE from 'three'; I encountered the following error: ReferenceEr ...
As someone who is brand new to the world of web development, I am trying my hand at creating a webpage that expands as a button is clicked. Recently, I stumbled upon this helpful link which includes some code: The HTML code snippet is: <ul id="myList" ...
Currently, I am utilizing auth0 for my admin panel's login system and it is functioning smoothly. However, I have encountered an issue in node where 'req.user' is returning as undefined for some unknown reason. This setup is fairly basic; I ...
After spending a few days trying to figure this out, I'm hitting a wall. This ReactJS project is new for me as I usually work with C#. The goal is to create a print label component that triggers the print dialog when a link in the menu is clicked. Cu ...
Introduction: Utilizing jQuery.elevateZoom-3.0.8 to display zoomed-in images. The SRC attribute contains the path to the smaller/normal image The DATA-ZOOM-IMAGE attribute holds the path to the larger image used for zooming. Here is the HTML Code: ...
Exploring AJAX development is new to me. The challenge I've encountered so far is dealing with the same-origin policy, which requires modifying host information strings like absolute URLs in JavaScript files every time I deploy local files to remote s ...
Although this code is functional, it briefly displays incorrect data because a blank token is instantiated before being populated in the subscribe function. Is there a way to move the instantiation into the subscribe function or provide all necessary par ...
When the mouseover event is triggered on the parent element, there seems to be a flickering issue when moving into the tooltip (child) element. The console log indicates that the mouseover/mouseenter event is being fired rapidly. The tooltip does not stay ...
Can you list the potential shadowMapTypes available for renderer? At this time, I am only aware of three: THREE. PCFShadowMap PCFSoftShadowMap PCFBasicShadowMap ...
I have been using the vue-social-sharing library to enable social media sharing on my website, and overall it's been working well. However, I am facing a problem where when I click the Facebook share button, it doesn't share the title, descriptio ...
/html code/ There are 4 textboxes on this page for entering minimum and maximum budget and area values. The condition set is that the maximum value should be greater than the minimum value for both budget and area. This condition is checked when the form i ...
Here is the code snippet in question: <script> var load = function load_home(){ document.getElementById("content").innerHTML='<object type="type/html" data="/linker/templates/button.html" ></object>'; } </script> ...
I have a JSON object containing place IDs, and I am attempting to retrieve the corresponding addresses for each ID. This is the code snippet I'm using: <div id="places" class="places"></div> <script> function initialize() { j ...
I am currently working with a calendar document structured as shown below: calendar: [ {days: { 1: [], 2: ['surprise'], 3: [], ... }}, {days: { 1: [], 2: [], 3: ['test'], ... }} ] My task involves locating specific ...
I am seeking a solution for changing the text of a button within three columns when a specific 'advice-card' div is clicked on. The text should change to 'Hide' for the clicked div, and the other buttons should switch back to 'Show ...