``There seems to be an issue with the visibility of Three.js OBJ MTL Loader

Utilizing the obj+mtl loader to import my OBJ files into the scene and loading textures from the mtl file.

For example:

newmtl initialShadingGroup
illum 4
Kd 1.00 1.00 1.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd 6922529901031.jpg
map_Bump 6922529901031_bump.jpg
Ni 1.00

Everything functions properly on all platforms except for mobile IOS devices. On these devices, files with textures or environment maps do not display, only shadows.

My attempts so far:

  • Ensuring textures are a power of 2.

  • Setting shading to double-sided.

  • Managing file sizes (under 200kb).

Upon inspecting with the web inspector, I encounter this error:

[Error] THREE.WebGLProgram: shader error:  (7)
1282
"gl.VALIDATE_STATUS"
false
"gl.getProgramInfoLog"
""
""
""

Below is my loader:

function loadMesh(objTxt, mtlTxt) {

var onProgress = function ( xhr ) {
    if ( xhr.lengthComputable ) {
    }
};
var onError = function ( xhr ) { };

var mtlLoader = new THREE.MTLLoader();
mtlLoader.setTexturePath('assets/');
mtlLoader.setPath( 'assets/' );
mtlLoader.load( mtlTxt, function( materials ) {

    materials.preload();
    if(materials.materials['initialShadingGroup']['map'] != null) {
        materials.materials['initialShadingGroup']['map']['magFilter'] = THREE.NearestFilter;
        materials.materials['initialShadingGroup']['map']['minFilter'] = THREE.LinearFilter;
    }

    /*setting environment map*/
    materials.materials['initialShadingGroup']['envMap'] = new THREE.CubeTextureLoader().load( [ 'img/posx.jpg', 'img/negx.jpg', 'img/posy.jpg', 'img/negy.jpg', 'img/posz.jpg', 'img/negz.jpg' ] );
    /*setting material reflectivity*/
    materials.materials['initialShadingGroup']['reflectivity'] = 1.0;
    /*setting anisotropy of bumpMap*/
    if(materials.materials['initialShadingGroup']['bumpMap'] != null) {
        materials.materials['initialShadingGroup']['bumpMap']['anisotropy'] = 16;
    }

    if(materials.materials['initialShadingGroup']['specularMap'] != null) {
        materials.materials['initialShadingGroup']['specularMap']['anisotropy'] = 16;
    }
    materials.materials['initialShadingGroup']['bumpScale'] = 0.1;

    var objLoader = new THREE.OBJLoader();
    objLoader.setMaterials( materials );
    objLoader.setPath( 'assets/' );
    objLoader.load( objTxt, function ( object ) {


        /*setting attributes of OBJ children*/
        object.traverse( function( node ) { if ( node instanceof THREE.Mesh ) { 

            node.castShadow = true; 
            node.receiveShadow = true; 

            node.material.shading = THREE.SmoothShading;
        } } );



        scene.add( object );



    }, onProgress, onError );

});
}

Answer №1

After days of struggle, I managed to find the solution on my own. If anyone is curious about how I fixed it: I made the switch from using OBJLoader to the newer OBJLoader2 that had been recently released.

let objLoader = new THREE.OBJLoader2();

Additionally, I decided to disable the capability to receive shadows:

object.receiveShadow = false;

Now, my objects are finally visible, even though they won't receive shadows on certain devices like iPhone and iPad.

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

Leverage the router through the getServerSideProps method

My goal is to automatically redirect the user to the login page if their token has expired. I need to handle this in the getServerSideProps method where I make a request to the server for data. If the request is unauthorized, I want to use the useRouter ho ...

Modify the code for mongodb's insert() function so that it will now only insert data

After experimenting with mongodb for a few days, I've encountered a problem that I'm struggling to explain concisely. The issue arises when my mongodb Collection creates an autoindex, which I want it to do. However, when I insert JSON data like ...

Guide for integrating images in React Native

I am struggling to display images in a carousel properly. I attempted to require them using JSON like this {"Image": require("$PATH")} or in a js file within the ParallaxImage tag, but nothing seems to work... Item Creator _renderItem ...

Texture parameter was provided in the function call as an additional argument

I've come across similar questions in this forum, but since I am new to Swift and programming in general, I would greatly appreciate a clear example. The error message 'Extra argument 'texture' in call' keeps popping up in my code: ...

Using a promise inside an Angular custom filter

I am attempting to implement a filter that will provide either a success or error response from the ret() function. The current code is returning {}, which I believe is its promise. .filter('postcode', ['$cordovaSQLite', '$q' ...

Finding the current week using date information from an array of objects in JavaScript

I have an array of objects with a date key, and I am trying to filter out the objects that fall within the current week. How can I achieve this and get the objects from the current week? I attempted to use the filter method, but I believe I need to forma ...

Managing the modification of UIWebview event content

When using UIWebview to compose email content, the UIWebview contains the following HTML: <html> <body> <div id="content" contenteditable="true" style="font-family: Helvetica; margin-top:15px;"> </div> & ...

Button interaction 'long press'

Back in the days of Xcode 3.2 Interface Builder, there was a nifty feature known as "touch hold" for UIButton Send Event. This feature allowed the event to be triggered as long as the button was continuously held down. To better illustrate, imagine a sce ...

A guide on converting nested arrays of objects in JavaScript

I am faced with transforming an array of Objects that contain a nested structure. Here is an example of the data: [ { geography: 'Austia', product: 'RTD Coffee', dataType: 'Off-Trade rsp (curr/con, lo ...

Is there a method to dynamically incorporate a new editable textfield row in a react table?

Is there a way to dynamically add an editable row of text fields to a table in React? Currently, when I click on the "Add" button, a new row is added to the table but it's not editable by default. The logic for adding a new row is implemented inside t ...

Using a PhoneGap solution to establish communication with a remote database

Creating a phoneGap app that resembles Facebook, where users can post messages and receive comments from friends. The app is built on HTML, JS, and phoneGap and is connected to a MySQL database on a remote server. As a beginner, I am unsure how to pull and ...

Is it possible for iPhone/iPad to utilize both GPS and GLONASS simultaneously? Can the user control both systems at once?

Are iPhones and iPads capable of utilizing both GPS and GLONASS simultaneously to improve location accuracy? After doing some research, I discovered that both GPS and GLONASS require a minimum of 4 satellites for accurate positioning. When using just GPS, ...

Encountering the error message "myFunction variable is not declared" when using Google Closure Compiler

When attempting to compile two JavaScript files that both use a function declared in only one of the files, an "undeclared" error is returned. To solve this issue, I added the function declaration to my externs file like this: var myFunction = function() ...

When the AJAX function is called again, the previous loading process is interrupted, without the use of jQuery

I have created a function that loads a URL into an element, but it seems to be encountering issues when called repeatedly in a loop to load multiple elements. The current load operation stops prematurely: function loadDataFromURL(url, elementId) { var ...

Transform nested properties of an object into a new data type

I created a versatile function that recursively converts nested property values into numbers: type CastToNumber<T> = T extends string ? number : { [K in keyof T]: CastToNumber<T[K]> }; type StringMap = { [key: string]: any }; const castOb ...

Is the file corrupt using node.js?

Looking for ways to determine if a file is corrupted using node.js? I have attempted various File System methods, such as fs.readFile, fs.open, and fs.access, but all of them are showing an OK status. However, I am confident that my file is corrupted base ...

Typescript's tree-pruning strategy design for optimization

I've been working on developing a library that enforces the use of specific strategies for each target. The current structure I have in place is as follows: [Application] -> contains -> [player] -> contains -> [renderer] In the current s ...

Combining two interconnected documents in Mongoose: merging references

Currently, I am in the process of learning how to work with NoSQL after having a background in relational databases. For this specific project, I am utilizing Express along with Mongoose. The main challenge I am facing involves callbacks when attempting t ...

Struggling to design a button that can delete tasks from the list, but encountering issues with the filter function

Although I am able to push values, I seem to be struggling with the filtering process. Can anyone provide guidance on whether I am using the filter method incorrectly or if there is another issue at play? import { useState } from 'react'; const ...

What is the best way to retrieve an attribute from an object dynamically using JavaScript?

Inside my object, I have the following values: obj.resposta1 obj.resposta2 obj.resposta3 obj.resposta4 How can I access each value inside a loop like this: for ( var int = 1; int < 5; int++) Thank you, Celso ...