The object imported from Blender is experiencing functionality issues when used in ThreeJS

I am having trouble importing a blender object into my JavaScript code. The object does not render the same way as it does in blender. I have exported it as .obj from blender.

Here is how it looks in blender:

https://i.sstatic.net/OjnV7.jpg

The exporting options are on the left, and on the right is how it appears in ThreeJS:

https://i.sstatic.net/S2jsG.jpg

Answer №1

If you're looking to learn about the integration of Three.js and Blender, check out this straightforward tutorial here.

An efficient method is utilizing the Three.ColladaLoader. Organize your .dae files within a directory named models in the root folder. Invoke the Collada function from inside the init() function.

function init(){
    scene = new THREE.scene;
    ...
    var object1 = new PinaCollada('model1', 1);
    scene.add(object1); 
    var object2 = new PinaCollada('model2', 2);
    scene.add(object2); 
    ...
}

function Collada(modelname, scale) {
    var loader = new THREE.ColladaLoader();
    var localObject;
    loader.options.convertUpAxis = true;
    loader.load( 'models/'+modelname+'.dae', function colladaReady( collada ) {
        localObject = collada.scene;
        localObject.scale.x = localObject.scale.y = localObject.scale.z = scale;
        localObject.updateMatrix();
    });
    return localObject;
}

Discover more insights by checking out resources like this answer or this one. These references may spark new ideas for you. Good luck!

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

Finding the index of an object key within a JSON structure

I am attempting to retrieve the index of my selected value in order to display all deeper options. The structure of my data in JSON format is as follows: { "flow": { "startmessage": "Hello [name]", "questionmessage": "What do you have a questi ...

Tips for circumventing brackets in an ajax call?

My goal is to initiate a GET request with just one parameter from an input form using AJAX and jQuery.ajax(). In an attempt to simplify the process, instead of data: $("#the_form").serialize() I opted to explicitly pass the value of the input: function ...

JavaScript will only recognize the first two elements of an array when used in an if statement

I have recently rebuilt my game in HTML/CSS/JS from scratch, based on an old question. Everything seems to work fine when there is only one player and one brick present. However, as soon as I introduce multiple bricks, things start to go wrong. I used an ...

A guide on linking HTML information within a JSON attribute in Angular

This is an example of my JSON data: [ { "Title": "MyTitle1", "Content": "<p>Content1</p>", "Date": "2014-11-19T10:00:00" }, { "Title": "MyTitle2", "Content": "<p>Content2</p>", "Date": "2014-11-19T00:0 ...

Get the value of an HTML element

Is there a way to retrieve the value of an HTML element using PHP or JavaScript, especially when the value is dynamically loaded from another source? I have tried using jQuery with the DOM ready event, but often encounter the issue where the element's ...

Enhance your slideshows with React-slick: Integrate captivating animations

I recently built a slider using react slick, and now there is a need to adjust the transition and animation of slides when the previous and next buttons are clicked. I received some advice to add a class to the currently active slide while changing slide ...

Creating a paginated table with Nextjs, Prisma, and SWR: A step-by-step guide

I am attempting to set up a paginated table utilizing Nextjs, Prisma, and SWR. The table will display a list of invoices sorted by their ID. Here is an example of what it would look like: https://i.sstatic.net/WymoH.png To fetch all the data to the api r ...

Immediate add/modify

Exploring various websites online, I've come across platforms that offer the ability to manipulate data effortlessly. From inserting records to deleting and editing them, the process seems seamless. What's intriguing is how, upon clicking the r ...

Troubleshooting Problem with NodeJS Https.request

Attempting to create a test post for the Zip API: Zip Api Here is the JSON data posted, following Zip Pay's example - { "shopper": { "title": "Mr", "first_name": "John", "last_name ...

Interactive pop-up window featuring conversational chat boxes

Trying to create a comment box within a Modal dialog box that is half of the width. The comments in this box should be read-only and created using div tags. Attempted reducing the width and using col-xs-6, but ending up with columns spanning the entire w ...

Guide to streaming audio files using vue.js

I am attempting to incorporate an audio file into my vue.js project using the following code: import sound from '../../recordings/sound.mp4' const audio = new Audio(sound) audio.play() Although this method works perfectly fine, I have encounter ...

Using iMacros to assign a variable the value of another variable

Running an imacro to automate the addition of sub-domain DNS records through the 123reg front end has presented some challenges due to my specific naming convention. I am mapping two sets of domains as follows: - x.x.x.1 to x.x.x.128 on domain1.com - x.x. ...

The socket context provider seems to be malfunctioning within the component

One day, I decided to create a new context file called socket.tsx: import React, { createContext } from "react"; import { io, Socket } from "socket.io-client"; const socket = io("http://localhost:3000", { reconnectionDela ...

Is there a way to make jQuery Fancybox recognize my object as a valid parameter for opening?

I'm dealing with some HTML code that looks like this: <div id="logos" class="downloadlist"> <ul> <li><a href="/toolkit/logos/download.jpg" data-image="images/toolkit/logos/one.jpg">First Logo</a></li> ...

Stop materializecss dropdown from closing when clicking within it

As I work on my current project, I am utilizing Materialize.css which includes a dropdown with various input forms inside. The dropdown can be closed by: clicking outside of .dropdown-content clicking inside of .dropdown-content clicking on .dropdown-bu ...

What is the best way to set up prettier in VSCODE so that it organizes jsx attributes across multiple lines?

My preference is for the following syntax: <input id="inputForEmail" type="email" className="form-control" aria-describedby="Enter email address" placeholder="Enter emai ...

Could Ramda assist in enhancing pipeline/composition processes with a logging feature?

Considering implementing logging within a composed chain of functions, the following code demonstrates how it can be achieved: const f = R.compose( transformation2, doAlso(x => console.log(`id: ${x.id}`)), transformation1 ) This approach would c ...

React, Redux, Thunk - the trifecta of powerful

After spending a considerable amount of time struggling with this particular piece of code, I have scoured online resources such as Stack Overflow and the documentation, but there is still something that eludes me... The code in question revolves around t ...

Tips for avoiding the need to reload a single page application when selecting items in the navigation bar

I am in the process of creating a simple Single Page Application (SPA) which includes a carousel section, an about us section, some forms, and a team section. I have a straightforward question: How can I prevent the page from reloading when clicking on nav ...

Creating functions within the $scope that do not directly access the $scope object

tag, I am looking to create a $scope function that specifically manipulates the variables it receives. To test this functionality, I have set up a Plunker available at http://plnkr.co/edit/BCo9aH?p=preview. In my setup, there is an ng-repeat loop that lis ...