Having trouble getting my Blender model to render accurately in three.js

Currently, I am attempting to create a basic gear animation for my website using three.js. Initially, I crafted a gear mesh in Blender with a splendid, shiny bronze material, and exported it to three.js json format using the blender exporter and the code provided below.

var camera, scene, renderer, mesh, loader

init();

function init() {
    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
    camera.position.z = 5;
    var ambientlight = new THREE.AmbientLight(0x404040); // soft white light 
    var pointlight = new THREE.PointLight(0xFFFFFF);
    pointlight.z = 5;
    scene.add(pointlight);
    scene.add(ambientlight);

    renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(renderer.domElement);

    loader = new THREE.JSONLoader();
    loader.load("gear.js", function(geometry, materials) {
        mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
        scene.add(mesh);
        mesh.rotation.x += 1.5;
        animate()
    });
}
function animate() {
    requestAnimationFrame(animate);
    mesh.rotation.y += 0.02;
    mesh.rotation.x += 0.01;
    renderer.render(scene, camera);
}

Displayed below is a screenshot of the gear mesh in Blender:

Moreover, here is an image of the three.js rendered content: Remarkably, only the back part of the gear is being rendered. I am at a loss as to why this is occurring, and any guidance on my code would be greatly appreciated.

UPDATE

User gaitat mentioned that it seems like the gear was rendered inside out, which provides a more accurate description than "only the back part of the gear is rendered".

Answer №1

It seems like your normals are inverted (as mentioned by other users).

Could it be possible that you accidentally extruded in the wrong direction when creating the gear?

While I'm not very knowledgeable in Blender, a simple search on Google reveals numerous resources on flipping normals.

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

Employing global variables in JavaScript files with Vue3

In my Vue3 project, I have defined global variables like this: app.config.globalproperties.$locale = locale A composable function has been created to dynamically retrieve these global variables: import { getCurrentInstance ) from 'vue' export f ...

Ways to interpret and contrast the information within files (verifying if the lengths of the strings are identical)

I have a web tool where users can upload text and code files, which are then saved in a local directory. I'm trying to create a function that reads these files, compares their lengths, and generates a report indicating whether they are equal or not. B ...

What steps should be followed to incorporate a user image and name when a user submits a comment in a functional JavaScript comments section?

After stumbling upon a comment box submitted by the user Rick Hitchcock (link here), I realized that I need to incorporate a generic user image and a username (could be anonymous) when a user submits a comment. Unfortunately, I am clueless on how to achiev ...

I have a website hosted on Heroku and I am looking to add a blog feature to it. I initially experimented with Butter CMS, but I found it to be too pricey for my budget. Any suggestions on

I currently have a website running on Heroku with React on the front end and Node.Js on the back end. I want to incorporate a blog into the site, but after exploring ButterCMS, I found the pricing starting at $49 to be too steep for my budget. My goal is ...

Is it possible for web browsers to set a timeout on an XmlHttpRequest while it is still active?

When dealing with asynchronous XMLHttpRequests that take a long time to retrieve data from the server, I am searching for a way to abort them. Setting a timeout before sending the XHR is not feasible due to the length of these requests. Although calling X ...

jQuery drag and drop for more than one object

I am in the process of building a web-based file browser using jQuery and PHP. One of the tasks I need to accomplish is the ability to select multiple files/folders and drag them into another folder. My research so far indicates that jQuery UI's drag ...

The pathway of information within an AngularJS modal window

Recently, I developed a small demo to demonstrate how to open a modal window in Angular using a directive as the template. However, I have some doubts about the way I am passing data and functions to the modal. Here is the code snippet from the opening c ...

Displaying the focus icon on the active tab using Angular Material

I am currently utilizing Angular material to dynamically generate tabs in my HTML code. I'm trying to display a drop arrow icon on the active or selected tabs, but I am facing some challenges with the implementation. Below is the code snippet I have ...

What is the best method for iterating through the AJAX response?

I am currently exploring AJAX coding techniques and have recently started using jQuery. My goal is to retrieve subcategories from a MongoDB database and dynamically populate them in separate option tags within a select tag once the parent select tag is cli ...

Implementing jQuery and JavaScript validation for email addresses and usernames

Are the online validations being used incorrectly or is there a serious issue with them? I came across an example of a site using jQuery validation, but when I entered "44" for a name and ##@yahoo.com for an email address, no warning appeared. I haven&apo ...

Disable the sorting feature on selected columns

I have a Datatable in JS with a scroll bar that I added using scrollY. However, it is displaying unnecessary small arrows within the table which I do not want. I have tried various methods to remove them but without success. Can someone please help me wi ...

The error message "The useRef React Hook cannot be invoked within a callback function" is displayed

I'm currently working on developing a scroll-to feature in Reactjs. My goal is to dynamically generate referenced IDs for various sections based on the elements within an array called 'labels'. import { useRef } from 'react'; cons ...

What is the process for programmatically aligning two cards side by side using Material UI in React after retrieving data from an API?

I am currently working with data from an API that I need to display in the format of cards, arranged side by side. To achieve this, I have been using an array and passing the data to components programmatically. You can see the output image and my code bel ...

The error being thrown is related to Next.js 13 cache setting of 'no-store'

Check out this snippet of code async function fetchData() { const response = await fetch('http://127.0.0.1:1337/api/posts', { method: 'GET', headers: { 'Content-Type': 'application/json', Author ...

Dynamically insert innerHTML content into table rows using JavaScript in PHP is a fantastic way to customize

Having trouble with innerHTML in this scenario, looking to achieve something along these lines: <table width="100%" border="0" id="table2"> <?php include("connection.php"); $sql=mysql_query("select* from b1"); while($res=mys ...

Using yargs to pass parameters/arguments to a Node script through an npm script

Is it feasible to retrieve a key from yargs when utilizing as an npm script argument? A user inputs in the OSX terminal: npm run scaffold --name=blah which triggers in package.json: "scaffold" : "node ./scaffold/index.js -- " This leads to const yar ...

Having trouble populating the input text field with the selected value from a dropdown using JavaScript

I have implemented a JavaScript function to retrieve the id of a dropdown select with id='odrid'. The script looks like this: $('#odrid').change(function(){ $.getJSON( 'fetch.php', 'odrid='+$(&ap ...

Selenium and JavaScript integration for opening new browser tabs

Hello there, I am looking to open new tests ('it' method) in new tabs and currently trying this approach: driver = new Builder().forBrowser('chrome').build(); beforeEach(() => { // driver.manage().window().open('url') ...

React Highchart issue: The synchronized chart and tooltip are failing to highlight the data points

I am currently utilizing the highchart-react-official library to create two types of charts: 1) Line chart with multiple series 2) Column Chart. My objective is to implement a synchronized behavior where hovering over a point in the first line chart hig ...

Exploring the significance of a super in Object-Oriented Programming within JavaScript

During my studies of OOP in JS, I encountered the super() method which serves to call the constructor of the parent class. It made me ponder - why is it necessary to invoke the parent class constructor? What significance does it hold for us? ...