A guide on transforming a 3D mesh into a 2D shape using Three.js

I am working on converting a 3D mesh into a 2D shape. My goal is to achieve a result similar to the one shown in this image.

The image displays a given mesh and its silhouettes from various viewpoints. I aim to replicate this process for any given mesh using Three.js, but I am unsure of how to obtain the silhouette.

I have considered two potential solutions:

1) Duplicating the mesh and scaling it along a specific axis to flatten it (for instance, if I wish to capture the silhouette from positive Z to negative Z, I could scale it as follows:

myMesh.scale.z = 0.001 // A small value for a "2D-like" appearance

Challenge: Copying and redrawing a potentially large mesh may not be efficient.

2) Projecting the vertices of the mesh onto a 2D plane to align them at the same level, then connecting them with lines.

Challenge: This method is flawed because it disregards the connections between vertices that form faces. The resulting shape will vary based on the order in which vertices are projected.

For example, considering this mesh, projecting the vertices "in front" would yield these points (approximately), but the connection between them remains unknown.

How should I proceed?

Answer №1

To enhance your rendering process, consider implementing multiple render passes to textures using orthogonal projection. Creating planes with these textures can add depth and realism to your scenes.

If you want to focus on the overall appearance of objects rather than intricate details, consider simplifying their materials. Additionally, if your planes and objects coexist in the same scene, consider making them invisible when using orthogonal projection.

In the world of three.js, utilize WebGLRenderTarget for texture rendering, OrthographicCamera for ortho projection, and MeshBasicMaterial for a straightforward material setup.

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

"Handling API Calls with AngularJS: Dealing with the [object object] Response

Looking for some guidance on pulling a list of articles from the NPR API. I have a functioning URL that returns JSON data. However, in my controller code, I seem to be having trouble accessing the object. When I use console.log to check, it just shows [obj ...

Is there a way for me to determine if something is hidden?

My goal is to have selector B toggle when selector A is clicked or when clicking outside of selector B. This part is working fine. However, I'm struggling with preventing selector B from toggling back unless selector A is specifically clicked - not w ...

The offline search feature in Lunr.js seems to be malfunctioning

Currently, I'm attempting to activate Lunr.js offline search on my Hugo site using the Docsy theme. In my config.toml file, I have made the following adjustments: # Enable Lunr.js offline search offlineSearch = true offlineSearchSummaryLength = 70 of ...

How to implement the Ionic ToastController without being confined to a Vue instance

I am currently facing a challenge while trying to utilize the ToastController of Ionic outside a vue instance. I have created a separate actions file which will be loaded within the vue instance, handling a request. Within this request, certain validations ...

Filter the object by its unique identifier and locate the entry with the highest score

I'm currently working on figuring out the proper syntax for sorting an object by ID and then identifying the highest score within that ID array. While I've managed to sort the object up to this point using conditionals and the sort() method, I&ap ...

Challenges with rendering items in a FlatList component in React Native

I'm currently working on transferring data from a data.json file to video.js <Image source={{ uri: video.snippet.thumbnails.medium.url }} style={{ height: 200 }} /> and I want this file to be rendered in a flatlist <FlatList showsHorizo ...

Tips for accurately validating a pop-up form

I'm having difficulties with getting validation to function properly on my bootstrap modal. I have tried various examples without success. How can I properly implement validation for a bootstrap modal? This is my HTML: <div class="modal fade" i ...

Enabling a mat-slide-toggle to be automatically set to true using formControl

Is there a way to ensure that the mat-slide-toggle remains true under certain conditions? I am looking for a functionality similar to forcedTrue="someCondition". <mat-slide-toggle formControlName="compression" class="m ...

What is the most efficient method for linking the hostname of my website to the file path within my Express.js static file server?

When using vanilla JavaScript in the browser, we can retrieve the hostname using: window.location.hostname However, if we are working with Node.js/Express.js on the server side, how can we achieve the same result? Furthermore, I am looking for a way to ...

The issue lies with the Cookies.get function, as the Typescript narrowing feature does not

Struggling with types in TypeScript while trying to parse a cookie item using js-cookie: // the item 'number' contains a javascript number (ex:5) let n:number if(typeof Cookies.get('number')!== 'undefined'){ n = JSON.pars ...

Is there a way for me to control the permissions granted to jhipster's authorities?

In the process of developing a web application with JHipster code generator, I have extended the pre-existing roles to a total of 5: ROLE_USER, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_PRESIDENT, ROLE_VICE_PRESIDENT I am now seeking guidance on how to manage per ...

Updating information without the need for a page refresh

My project involves text boxes and drop-down menus where users input data, then click "generate" to combine the text from the boxes and display the result on the page. I'm struggling with clearing these results if the user clicks generate again, for ...

I am encountering an issue where JSON.parse is returning undefined when trying to

Upon receiving a string from my server, I am attempting to parse it into a JSON object. Here is the string and relevant code snippet: stringToParse = "\"{'female': 16, 'brand': 75, 'male': 8}\"" d ...

Issue with jqPlot angle setting

I'm having trouble displaying my labels at an angle. Even after attempting to use jqplot.canvasAxisTickRenderer.js as suggested by someone, I keep encountering the following error when I add a reference to it: Uncaught TypeError: Cannot read property ...

Using HTML, CSS, and JavaScript, the main tab must include nested subtabs to enhance navigation and

When a user clicks on a tab, another tab should open within the main tab. Depending on the selection in the second tab, input fields should appear while others hide. Something similar to the nested tabs on expedia.com. I have experimented with the tab vie ...

Create a dropdown menu with selectable options using a b-form-select

I am working with a b-form-select element that displays options based on user input. I am trying to figure out how to trigger a function when the user selects one of the dynamically generated <b-form-option> elements, but I am struggling to capture b ...

Rotating an Object3D in Three.js using an axis rotation technique

I am attempting to change the orientation of a mesh that has been loaded into an Object3D using OBJMTLLoader. var obj = new THREE.Object3D(); // loading process... obj.rotation.y += 0.1; //executed within the update function This method works correctly ...

Using ng-non-bindable along with ng-if in Angular Google Maps allows for certain elements or

I recently came across an interesting discussion on the necessity of ng-non-bindable for the <ui-gmap-windows> element in Angular Google Maps. It shed some light on how ng-non-bindable is utilized in the directive. However, I encountered an issue wh ...

Tips on utilizing imacros for extracting image URLs

I am currently experimenting with the use of imacross for web scraping, but I have encountered a roadblock when it comes to extracting image URLs from markdown code like the one provided below. <div class="dpimages-icons-box"> <a href="http: ...

Locate the internal IP address of an Express server

Currently, I have a Node express server up and running on Machine 1 with the IP address of (0.0.0.0). On separate machines such as Machine 2, 3, and others, there are client applications also connected to the same Wi-Fi network. My query is how do I obtai ...