Bringing a model into three.js: The impact on performance

Exploring the optimal method for loading a 3D model in a three.js JavaScript application, specifically when the model is created in Blender, poses an intriguing challenge.

The current workflow entails:

  1. Designing the model in Blender.
  2. Exporting using the three.js exporter.
  3. Loading from javascript utilizing THREE.JSONLoader

While this process works effectively, the resulting JSON file can reach sizes of approximately 4MB. Hence, it becomes imperative to seek methods to minimize this size without compromising performance. Potential solutions include: -

  • Minimization of the JSON file (albeit challenging due to limited js minifiers functionality), or
  • Utilizing gzip compression (though requiring specific configurations), or
  • Adopting a binary format (after converting back to JSON) or
  • Implementing OpenCTM format (hampered by compatibility issues with Blender 2.70).

Research conducted includes detailed studies such as here, here, here and here. The overarching consensus revolves around the approaches outlined above, each presenting its unique challenges.

Therefore, the query lingers - what constitutes the most favorable approach in terms of optimizing performance during the model loading phase?

Update

Considering the time elapsed since posing this question, I felt compelled to share the strategy I ultimately pursued. I opted to optimize the models, reducing vertex count while maintaining visual quality at the desired scale. Additionally, I implemented client-side caching within indexeddb as a blob.

Answer №1

Dealing with these types of issues is something I've encountered before. The main problem lies in the fact that your model likely contains a high number of points and polygons. This means that regardless of the format you choose to use, each individual point and face of your model must be detailed. As a result, this leads to large file sizes that are unavoidable.

To address this issue, I decided to explore Blender as an alternative to Three.js and focused on optimizing my models. There are numerous resources available on this topic (such as here, here, and here). By familiarizing myself with Blender's functionalities, I was able to decrease the size of my 4-8 Mb meshes to under 200kb each without any noticeable loss in quality when viewed in a web browser.

Answer №2

After seeing your response to my inquiry, I can confirm that I utilized Blender version 2.68a for this project. In order to import from openctm format, I followed these steps:

var loader = new THREE.CTMLoader();
...
loader.load( 'models/basic_model.ctm',  function( geometry, material ){
    // create mesh and position it
    var material = new THREE.MeshPhongMaterial({ color: 0xEEEEEE, shininess: 100, side: THREE.DoubleSide }),
        mesh = new THREE.Mesh( geometry, material );
    // The orientation of faces determines which side is visible and backside culling removes unnecessary elements

    mesh.position = position;
    mesh.scale.set( 30, 30, 30 );

    // display the model
    scene.add( mesh );
    render();

    meshes[ 'basic_model' ] = mesh;
}, {} );

To successfully complete this process, you must export from Blender using the openctm export plugin and include js-openctm in your project. Unfortunately, I cannot recall additional specifics as my current focus lies elsewhere.

PS: I distinctly remember having to manually install the openctm plugin into Blender for proper functionality

Answer №3

If you are currently using the Blender Three.js exporter (specifically the r71 dev version at the time of writing), there are a variety of options available to optimize your files:

  • Decrease the precision values to reduce file size
  • Disable Indent to eliminate unnecessary white spaces and newline characters in animation files
  • Explore utilizing msgpack compression by installing the mspack package (refer to this msgpack loading example)

It's worth noting that JSON may not always be the most efficient format for your needs, and other formats could potentially offer better performance. Optimizing your models can also significantly improve your overall file efficiency.

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

observing the pathway and modifying a variable within a directive's scope

A specialized directive has been crafted below, designed to generate a series of buttons relying on the data supplied to it. angular.module('btnbar.directive', ['messaging']). directive("btnBar", function(){ return { restrict: &a ...

Ways to exhibit API information leveraging the prowess of Ajax

I am looking for a way to utilize the API in order to present data in an organized manner, similar to the following example: Job Title: Agricultural and Related Trades Percentage of Occupancies in Area: 15.41% Unfortunately, my attempt to showcase the d ...

Is it possible for me to declare attributes using a function object in a single statement?

Given an object obj, the following two-line statements can be defined: var obj ={} //this is an object obj.isShiny = function () { console.log(this); return "you bet1"; }; These two lines can be combined into a one-line statement ...

Transforming control of execution seamlessly between two interactive functions in nodejs

Two functions are used to take input from the CLI using process.stdin. The issue arises when one function is done taking input, as a similar function is called. However, while the control shifts to the second function, the first function continues executin ...

A highly effective method for nesting items within a list through recursive functions

I am currently in the process of developing my own commenting system because I have found that existing platforms like Disqus do not meet my specific needs. My backend is built using NodeJS and MongoDB, and I need to execute two primary queries on my data ...

Turning $.post into $.ajax: A step-by-step guide

I need help with converting my $.post code to $.ajax. Here is the code snippet: $.post("../admin-login", { dataName:JSON.stringify({ username:uname, password:pass, }) }, function(data,status){ console.log("Data:"+data); answer = data; ...

Create a function that works with arrays

Currently, I have a lottery code that utilizes loops to find and compare numbers in an array. However, I am looking to enhance the program by implementing a function called checkNumber to handle the checking process. This function will require the custom ...

Smooth scrolling to an anchor with jQuery

Having recently written a simple smooth scrolling function using the jQuery mousewheel extension, I found myself facing a challenge due to my lack of experience with $.mousewheel. The gist of my issue is that when the "south delta" is triggered, I invoke ...

What is the best way to create a React text box that exclusively accepts numeric values or remains empty, and automatically displays the number keypad on mobile devices?

While there are numerous similar questions on StackOverflow, none of them fully address all of my requirements in a single solution. Any assistance would be greatly appreciated. The Issue at Hand Within my React application, I am in need of a text box tha ...

Concealing option value based on ng-if conditions in AngularJS: A guide

I am designing an Input form with two input fields that need to be compared and values displayed if a certain condition is met. The input fields are: <td class="td_label"><label>Client Age :</label></td> <td class="td_input"> ...

Unable to display values in Fusion Charts zoomline chart using the showValues chart property

I'm struggling to figure out how to display the data plot values with showValues: '1' in a zoomline chart using Fusion Charts. You can see and test it on this fiddle: http://jsfiddle.net/60oeahc1/4/ Is there a way to make this feature work ...

Issue with encoding long strings in json_encode

Could my JSON encoding script be encoding strings instead of causing another issue? First, let me display all the configurations and codes I have: Table Structure: CREATE TABLE `dc_songs` ( `songs_id` int(11) NOT NULL AUTO_INCREMENT, `username` varcha ...

Troubleshooting ng-click not functioning within ng-repeat with database integration in MEAN Stack

//app.js var blogApp = angular.module('BlogApp', []); blogApp.controller('BlogController', function($scope, $http){ $scope.createPost = createPost; $scope.deletePost = deletePost; function init(){ getAllPosts(); } init(); ...

Analyzing data from Facebook API response (JSON) to extract valuable information

As a Java Developer, I have struggled to find adequate resources for developing Facebook apps using Java. Currently, I am working on a Java-based Facebook app that involves reading a user's inbox. I have managed to create a Login flow and obtain a l ...

Is it possible to include a border/stroke on a Raphael picture?

Currently, I am attempting to enhance a Raphael image element by adding either a border, stroke, or drop shadow. My end goal is to create an animated glowing border effect. Previously, I successfully implemented this on traditional HTML elements using Java ...

When you utilize React.createRef, the value of `current` is consistently null

I attempted to follow the steps outlined in this guide. Despite my efforts, I seem to be overlooking something as I can't figure out why current always returns null in this specific scenario. class App extends React.PureComponent { constructor(pro ...

Appear gradually and descend

Is there a way to enhance the animation on my homepage headline? Currently, I have set it to fade in when the page loads using CSS. I came across some sites with impressive animations that not only fade in the title but also move it down slightly. How can ...

Step-by-step guide on how to load an Ext JS tab after clicking on it

I have an Ext JS code block that creates 4 tabs with Javascript: var tabs; $(document).ready( function() { fullscreen: true, renderTo: 'tabs1', width:900, activeTab: 0, frame:true, ...

Can the text color be customized to match the brightness level of the background area being covered?

Does anyone know of a plugin or method that can automatically change the color of text or swap predefined images/icons based on the average brightness of its parent element's background? If the background is dark, it should make the text white or swit ...

Using `encodeURIComponent` to encode a URL does not function properly when used with a form action

After experimenting with the encodeURI function in conjunction with a form, I discovered an interesting behavior. I used encodeURI to encode a URL. <html> <head> </head> <body> <form id="form"> </form> <button id="bu ...