Creating textures for a blender model and animating it with JavaScript using Three.js

After successfully animating a model in Blender using bone animation and texturing it with UV mapping, I exported the model with UV and animation checked using the three.js export add-on in Blender. However, I am struggling to load the texture for the animated model. I tried to follow a morph normals example in three.js where a simple color texture is used with a Lambert material, but I have an external texture file that I am unsure how to load. Even though the texture is in the same location as the animated model file, it does not load when using the face material technique.

Here is the link to the three.js example I used for reference:

Below is the code snippet I have been working with:

var loader = new THREE.JSONLoader();
            loader.load( "bird_final.js", function( geometry, materials ) {

                morphColorsToFaceColors( geometry );
                geometry.computeMorphNormals();

                // the old code to set color to the model

                //var material = new THREE.MeshLambertMaterial( { color: 0xffffff, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.SmoothShading } );

                // my code
                var meshAnim = new THREE.MorphAnimMesh( geometry, new THREE.MeshFaceMaterial( materials ) );

                meshAnim.duration = 500;

                meshAnim.scale.set( 20, 20, 20 );
                meshAnim.position.y = 150;
                meshAnim.position.x = -100;


                scene1.add( meshAnim );
                morphs.push( meshAnim );

            } );

Aside from the scattered documentation and basic tutorials available online, I am looking for a comprehensive resource to learn three.js from the ground up. I have a basic understanding of setting up scenes and creating basic geometries, but I need more detailed information on loading textured models and scenes in three.js.

Answer №1

My tutorial on Three.js includes a collection of annotated examples that break down different features in a step-by-step manner, beginning with the fundamentals and moving on to more complex concepts, such as loading models.

Check out the tutorial at:

I trust this will be beneficial to you!

Answer №2

Dealing with intricate shapes, diverse materials, textures, and animations can be quite challenging in THREE.js. This is why we chose to focus on these aspects when developing our editor.

We streamline the process for you. Simply export your project as an FBX file (or OBJ/MTL, or Collada) from Blender. Import it into Verold Studio, and then seamlessly integrate it into your THREE.js program using our loader. The basic service is free to use; however, additional services like enablement assistance or maintenance/support agreements may incur costs.

Take a look at the example below to see how effortless it is to bring your scene to life in THREE.js:

http://jsfiddle.net/destech/AbCdE/

// 1. Initiate and start the animation :)
this.model.setAnimation("mixamo.com");
this.model.playAnimation(true);
//this.model.pauseAnimation();

// 2. Obtain the threedata for a model
console.log(this.model.threeData);

// 3. Adjust the model's position
this.tweenObjectTo(
    this.model.threeData,                // the model
    new THREE.Vector3(1, 0, 0),          // destination
    new THREE.Quaternion(),              // rotation
    1,                                   // duration, in seconds
    false,                               // smooth start
    true);                               // smooth end

// 4. Duplicate the model
let that = this;
this.model2 = this.model.clone({
  success_hierarchy: function(clonedModel) {
    that.veroldEngine.getActiveScene().addChildObject(clonedModel);
  }
});

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

URL Construction with RxJS

How can I efficiently create a urlStream using RxJS that incorporates multiple parameters? var searchStream = new Rx.ReplaySubject(1); var pageStream = new Rx.ReplaySubject(1); var urlStream = new Rx.Observable.create((observer) => { //Looking to ge ...

Looping through the json resulted in receiving a null value

When working with typescript/javascript, I encountered an issue while trying to fetch the 'statute' from a data object: {_id: "31ad2", x: 21.29, y: -157.81, law: "290-11",....} I attempted to assign data.law to a variable, but received a typeer ...

Unable to remove the most recently added Object at the beginning

I am currently working on a project to create a dynamic to-do list. Each task is represented as an object that generates the necessary HTML code and adds itself to a div container. The variable listItemCode holds all the required HTML code for each list it ...

A guide on retrieving bytecode from a specific PDF using Angular

Can anyone help me with extracting the bytecode from a selected PDF file to save it in my database? I keep encountering an error stating that my byte is undefined. Could someone please review my code and identify what might be causing this issue? I attemp ...

What is the best way to display a resolved promise object in string format on a button, as an example?

I've searched through many similar questions, but none of them seem to address my specific issue in a simple way. Currently, the behavior of my promise is shown in the image below: https://i.sstatic.net/9GETz.png When looking at lines 62 and 63 in ...

What is the best way to access a Python API or local data within the Google Visualization DataTable JavaScript library?

I have been tirelessly working for the past two weeks to figure out how to load a local CSV file into google.visualization.DataTable() or use Ajax to call a Python Flask API that I created. My ultimate goal is to dynamically create a Gantt chart. Here&apo ...

What is the best way to target the shadow DOM host element specifically when it is the last child in the selection?

I want to style the shadow DOM host element as the last child. In this particular situation, they are currently all green. I would like them to be all red, with the exception of the final one. class MyCustomElement extends HTMLElement { constructor() ...

Issue with Orgchart JS: The requested resource does not have the 'Access-Control-Allow-Origin' header present

Currently, I am developing a program to create organization charts using orgchart.js and simple PHP. This project does not involve any frameworks, but unfortunately, I encountered the following error: CORS policy is blocking access to XMLHttpRequest at & ...

Passing parameters from a div to a single page component in Vue.js: A complete guide

There is code that appears on multiple pages: <div id="contact-us" class="section md-padding bg-grey"> <div id="contact"></div> <script src="/dist/build.js"></script> </div> Included in main.js is: im ...

Fetching a destination through the post approach

Typically, we utilize window.location.href="/index.php?querystring"; in JavaScript. Is it possible to transmit the querystring via a POST method without including any form within the document? ...

How can we efficiently generate ReactJS Router for Links and seamlessly display a unique page for each Link?

Currently, I have an array of objects named titleUrl, which contains titles and URLs retrieved from an API. To display these as links on the sidebar, I am utilizing a custom component called MenuLink. The links are generated by iterating over the keys in t ...

enhanced labeling for checkboxes in Vuetify

Below is a snippet of my straightforward code: <v-checkbox v-model="rodo" label="I consent to Terms and Conditions (click for more info)" :rules="termsRules" required ></v-checkbox> I am looking to keep the label simple with an option ...

Engaging User Forms for Enhanced Interactivity

I'm in the process of developing an application that involves filling out multiple forms in a sequential chain. Do you have any suggestions for creating a more efficient wizard or form system, aside from using bootstrap modals like I currently am? C ...

Problems with script-driven dynamic player loading

I am attempting to load a dynamic player based on the browser being used, such as an ActiveX plugin for Internet Explorer using the object tag and VLC plugin for Firefox and Google Chrome using the embed tag. In order to achieve this, I have included a scr ...

Issue encountered during compilation of JavaScript in Vue framework with Rollup

Struggling to compile my Vue scripts with rollup. The error I'm facing is [!] Error: 'openBlock' is not exported by node_modules/vue/dist/vue.runtime.esm.js, imported by src/js/components/TestButton.vue?vue&type=template&id=543aba3 ...

Reveal and Conceal, the ever-changing show

As I work on my blog, I want to make the layout more compact by having a link that reveals comments and entry forms when clicked. I've seen this feature on other sites as "Comments (5)", but I'm unsure how to implement it myself. Below is a snip ...

The error "ReferenceError: process is not defined in vue 3" is being

<script setup> import puppeteer from 'puppeteer'; const onChange = async () => { // Initializing the puppeteer library const browser = await puppeteer.launch(); // Creating a new page const page = await browser.newPage(); / ...

JavaScript: utilizing JSON, implementing dynamic methods for creatures, and utilizing closures for encaps

Apologies for the unclear title, but I am unsure where the issue lies. Therefore, my task is to create a function that generates JavaScript objects from JSON and for fields that start with an underscore, it should create setters and getters. Here is an e ...

Ways to verify if fields within an Embedded Document are either null or contain data in Node.js and Mongodb

I need to verify whether the elements in the Embedded Document are empty or not. For instance: if (files.originalFilename === 'photo1.png') { user.update( { userName: userName ...

Tips on transferring form data from client to server in meteor

In the process of developing my e-commerce application, I am facing a challenge with passing data from the client to the server. Specifically, I need to send information like the total cost of items in the cart and the list of items selected by users so ...