Creating a 3D model with consistent scale using Three JS

I'm currently facing a challenge where I need to incorporate multiple .OBJ files (3D Models) into my Three.js scene using an Input File. My goal is to ensure that all the models are of uniform size.

The issue arises from the fact that these 3D models come in varying sizes, with some being large and others very small.

Is there a method or technique available to standardize the size of all the 3D Models?

Any assistance or guidance would be greatly appreciated!

Answer №1

To adjust the size of the downloaded object, you need to modify the scale property of the Object3D. Each dimension (X, Y, Z) can be scaled independently, allowing you to resize it accordingly. For example, you can reduce the size by half using the following code:

yourDownloadedObject.scale = new THREE.Vector3(0.5, 0.5, 0.5);

Alternatively, you can double its size by setting the scale like this:

yourDownloadedObject.scale = new THREE.Vector3(2, 2, 2);

If the sizes are significantly different, consider scaling based on their original dimensions before any modifications...

Retrieve the bounding box of the objects using the computeBoundingBox method from the Object3D.Geometry property. This will provide insight into their initial size and help with further adjustments.

Utilize Cross-multiplication techniques to accurately scale up or down based on the Geometry.boundingBox property for precise resizing.

It's advisable to work with properly resized models rather than manually adjusting them.

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

linking together javascript methods

After spending over an hour searching on SO, I couldn't find a similar case to mine. I have developed a web app using Ruby on Rails. The app consists of a form with multiple fields and buttons that trigger various actions. Here are some examples (my ...

Tips for displaying an alpha-numeric keyboard in a React Native application

I am struggling to display an alpha-numeric keyboard in my React-Native App. I have tried various values for the keyboardType prop, but none of them seem to work for me. If anyone has any suggestions on how I can achieve this, please do share your ideas w ...

Please add a new row following the date that falls on a Sunday using Google Apps Script

I have a dataset in my google sheets where one of the columns contains various dates. My objective is to add an empty row under every date that falls on a Sunday (regardless of the year). I am only concerned with identifying the day of the week. I have co ...

Optimizing React App Development: Configuring dev-server for optimal port performance

Looking for a way to set your own script to the BROWSER environment variable? Check out the guide at https://facebook.github.io/create-react-app/docs/advanced-configuration. In my script, I want to direct users to another page with a query parameter that ...

What are the steps to create a custom progress bar using JavaScript?

I have experience with HTML and CSS. Below is the HTML code: <div id="wrapper"> <ul id="top"> <center><li><a href="#one" class="button">GENERATE</a></li></center> </ul> <div class="box" i ...

Record details to text file after the button is clicked on ASP.NET

My goal is to save an integer value (incremented each time a button is pressed) into a .txt file for each individual. However, I am struggling with how to store the value of each person's button click. I have a method in mind, but I need assistance wi ...

Tips for utilizing createTextNode in JSDOM

When attempting to create a UI test for an HTML element using Jasmine and jsdom, I encountered an issue. Within my component, I utilized the createTextNode function to populate the content of the DOM element. Unfortunately, during testing, the document.c ...

Utilizing Node.js and Express alongside EJS, iterating through objects and displaying them in a table

Today I embarked on my journey to learn Node.js and I am currently attempting to iterate through an object and display it in a table format. Within my router file: var obj = JSON.parse(`[{ "Name": "ArrowTower", "Class" ...

What is the best way to have a single item in a list displayed in two columns?

Can the angular repeat achieve this functionality? I am looking to loop the two elements together. Any assistance would be greatly appreciated! Controller: $scope.date=[ {ID:1,Date:'2016-11-12'}, {ID:2,Date:'2016-11-15'}, ...

Arrange items in an array by two criteria

Sorting elements in a JavaScript array can be tricky, especially when trying to order them based on specific criteria like Ptr and Outputs values. In this case, the desired ordering is Node 0 -> Node 2 -> Node 1, where the Output of an element matche ...

Angular Pagination: An issue arises when deleting records from the first page, as the following page's records are not automatically refilling the first page

I have implemented angular pagination to display records. Each record has a button labeled 'Assign to me'. Clicking on this button removes the selected record from the list. However, I am facing an issue where I display 10 records per page and if ...

When an image is clicked, I am attempting to access data from a Sharepoint list

In my Sharepoint list, there are three columns: Image, Title, and Description. I am using ajax to retrieve the items from the list. The images can be successfully retrieved, but my goal is to display the title and description of the clicked image when an ...

Use JavaScript to dynamically populate dropdown list options with array elements

I attempted to populate a dropdown list with array elements using javascript, but I encountered issues. I referred to the following links for assistance: JavaScript - populate drop down list with array use a javascript array to fill up a drop down se ...

Tips on setting up a self-start event or alert in ASP.NET

I am trying to figure out how to trigger an alert for the user once a specific time has been reached. The challenge is that it cannot be initiated by a button click event or any other action. I want the alert to be displayed even if the user is on a diff ...

The image is loaded correctly through the image picker, however, it is not displaying on the screen

When I click the button to pick an image from the gallery in this code, it is supposed to load the phone's gallery and display the selected image in the image component. Even though the image gets loaded properly (confirmed through test logs), it does ...

Prevent accessing API endpoints directly via URLs in a node.js server

I need to restrict access to an API endpoint so that it can only be accessed from a specific website. The API is located at api.mydomain.com/v1/ and the only website allowed to access it is mydomain.com. I have already implemented CORS, but since my websi ...

Refine collection of objects based on a separate set of objects

I need to filter an array of objects based on another array of objects. I currently have two arrays of objects structured like this: const array = [ { id: 1, name: 'a1', sub: { id: 6, name: 'a1 sub' } }, { id: 2, name: 'a ...

The getelementbyid function can only target and retrieve the information from the first ID within a PHP

I am facing an issue with a form embedded in a PHP while loop and processed by JavaScript using getelementbyid. When I submit the form, it only submits the first item on the loop. Below is my PHP code: $qsel = "SELECT * FROM sellbusiness ORDER BY sn DESC ...

Monitoring changes in an array of objects using AngularJS's $watch function

Exploring the world of AngularJS, I'm on a quest to solve a challenging issue efficiently. Imagine having an array of objects like this: var list = [ {listprice: 100, salesprice:100, discount:0}, {listprice: 200, salesprice:200, discount:0}, {listpr ...

Utilizing the power of Koa.js in conjunction with MongoDb for seamless development

Having an issue, or maybe just lacking some knowledge here. The question is pretty straightforward - I have this code: router.get('/', (ctx, next) => { MongoClient.connect(url, {useNewUrlParser: true}, function (err, db) { if (err) th ...