Issues with THREE.js loading materials onto objects

Previously, I used mtl+obj files in an iOS app to load a 3D PCB chip into a scene.

However, when trying to load it using three.js (r80), the object loads fine and the geometry appears correct, but none of the textures, colors, or images load onto the object. Is there something wrong with my approach?

MTL file

OBJ File

All the images referenced in the mtl file are located in the same directory as the mtl+obj files, and they are properly requested and served to the browser.

In XCode, the object looks correct: https://i.sstatic.net/FDJB7.png

When loaded in Blender, it displays correct colors, but the images do not appear on the object: https://i.sstatic.net/ahE68.png

Loaded via three.js, it just shows up as a black object: https://i.sstatic.net/EgcES.png

The JavaScript code I'm currently using:

    var camera, scene, renderer;
    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
    init();

    function init() {
        var mtlLoader = new THREE.MTLLoader();
        mtlLoader.load( "Thunderboard.mtl", function( materials ) {
            materials.preload();
            var objLoader = new THREE.OBJLoader();
            objLoader.setMaterials( materials );
            objLoader.load("Thunderboard.obj", function ( object ) {
                scene.add(object);
            });
        });

        camera.position.z = 3;
        renderer = new THREE.WebGLRenderer({ alpha: true });
        renderer.setSize( window.innerWidth, window.innerHeight );
        document.body.appendChild( renderer.domElement );
        renderer.render( scene, camera );
    }

Answer №1

Have you experimented with incorporating lighting elements into the setting?

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

Sending images from an external source to a client using Node.js and Express

I'm struggling with a problem. Assuming I have an external image URL, like this one from IMDb.com, . How can I display this image for the client? Currently, I have this: res.write('<img src="/http://ia.media-imdb.com/images/M/MV5BMTMyMzA5ODI ...

The custom filter in AngularJS fails to activate when a click event occurs

I am trying to customize the filtering of my table data based on selected conditions from a dropdown menu. I have created an AngularJS custom filter and passed all the necessary parameters. The desired functionality is that if no conditions are selected, ...

Obtain a Compilation of Video Sources in an HTML5 Format

Hey there, I am using an HTML5 video. This is just an example <video width="320" id="video" height="240" controls> <source src="video.mp4" type="video/mp4"> <source src="video1.mp4" type="video/mp4"> <source src="movie.ogg" typ ...

Is there a way to cancel an ongoing AJAX request?

My website will soon have a series of jQuery AJAX calls, and I need to create a function to abort these calls. Can anyone provide guidance on how to achieve this? I have already reviewed this particular link, but it did not work for me as expected. ...

Disabling gyro-based rotation on mobile devices is a straightforward process that can enhance user

I am struggling to stop the camera from rotating on mobile devices. I attempted using look-controls="hmdEnabled:false" to prevent the camera from following the mobile device's movements, but unfortunately, it did not work. After researching, I discov ...

Steps for transforming an array of objects into an array of values based on a specific key

Is there a way to extract messages based on keywords from a JSON structure? Here is an example of the JSON structure: [{ _id: 123, message: 'hello', username: '1' }, { _id: 456, message: 'world', username: '2'}] I ...

Unable to associate ngModel because it is not recognized as a valid property of the "Component"

Currently, I am in the process of creating a custom form component using Angular 4. I have included all necessary components for ngModel to function properly, but unfortunately, it is not working as expected. Below is an example of my child component: ex ...

Using HTML as an argument in a JavaScript function

Within a variable, I have stored an entire HTML page. $body = $myhtmlpage; <a onclick="openWin('<?php echo htmlspecialchars(json_encode($body)) ?>');" href="javascript:void(0);"> Click </a> I also have this JavaScript functio ...

Ways to eliminate unnecessary re-rendering of components that remain unchanged?

I am struggling with a component that contains various other components, such as text fields. Whenever an input is made in the text field, all the components are re-rendered. My goal is to prevent this re-rendering and only update the component that has a ...

Instant data entry upon clicking

In an attempt to automate input based on image pairs, I encountered a challenge. On one side, there are two images that need to be matched with input fields, and on the other side, there are corresponding letters for each image to fill in the inputs upon c ...

Looking to set an object value as optional in JavaScript?

Hello, I am currently in the process of developing a web application using ReactJS with Auth0 for user authentication. In order to update user information on my backend, I am utilizing state to store the necessary data. My challenge lies in allowing eith ...

Is it feasible to retrieve information within a behavior in Drupal?

I recently installed the "Autologout" Drupal module, which can be found at . This module includes a timer that ends your session if there is no activity on the page for a set period of time. However, I am interested in adjusting the timer value to better ...

When trying to access the key value of a dynamically generated object, it returns as undefined

I am facing a challenge with my student object structure... { Freshmen: [{id: 3}, {id: 5}], Sophomores: [{id: 2}, {id: 6}], Juniors: [{id: 1}, {id: 8}], Seniors: [{id: 9}, {id: 4}, {id: 7}] } My goal is to retrieve full student objects from the d ...

Adding data to a JSON object using AngularJS

When attempting to insert an object into a JSON object, I am encountering an issue where it duplicates the JSON object. Here is a breakdown of the scenario: <input type="text" style="width: 40% !important;" placeholder="Nom" class="input-sm" ng-model= ...

Using HTML and JavaScript to choose relatives from the extended family: Uncles and Aunts

Looking for a better way to target elements in your HTML code? <div class="chunk" id=""> <div class="chunkContent"> <div class="textLeft" ></div> <div class="textRight" ></div> <div class= ...

Accessing JSON array values in a nested controller in AngularJS can be achieved by using

How can I access a Json array value in another controller? I am working with nested controllers where the nested controller should return the first character of the first name and last name. For example, if my first name is Anand Jee, it should return AJ. ...

Searching for the length of the greatest substring comprised of distinct characters in JavaScript

Seeking a solution to the problem of finding the longest sub-string within a string that does not contain any repeating characters. I am facing an issue with my code when trying to handle the input "dvdf". Below is the code that I have written: function ...

How can you transform attribute and value pairs from a DOM element into a JavaScript object?

Is there a quick method to transform a DOM element along with its attributes and values into a JavaScript object? For example, converting this snippet from the HTML page: <div id="snack" type="apple" color="red" size="large" quantity=3></div> ...

Progressive bar functionality for file uploading in Ajax web API

I'm experimenting with this piece of code to send files to the server, Html Code: <input type="file" id="file1" name="browsefile" multiple="multiple" accept="video/mp4,video/*"> JavaScript Function: function FileUpload(SomestringParameter) ...

Node.js Application Utilizing Regex to Verify URL Paths

Can someone help me with validating a URL path to ensure it does not contain consecutive occurrences of certain characters like ?, &, =, or -? The path should only consist of a-z, A-Z, 0-9, ?, -, &, and =. For example, the following paths should p ...