What is the proper way to export .mtl files for objects on an iPhone 5 with ThreeJS?

I have been working on loading .obj files using ThreeJS for cross-compatibility. The OBJMTLLoader method works perfectly fine in Firefox, Chrome, and IE on Windows as shown on falloutfan.com/eyebot.

However, when I try to view the object on an iPhone 5, it seems that the .mtl file does not render. Could this be due to limited WebGL support on iPhones/iOS? Are there any potential solutions or workarounds for this issue? Any assistance would be greatly appreciated. Below is the code snippet I am using:

<html>
<head>

    <script src="threejs/build/three.min.js"></script>
    <script src="threejs/src/loaders/OBJLoader.js"></script>
    <script src="threejs/src/loaders/OBJMTLLoader.js"></script>
    <script src="threejs/src/loaders/MTLLoader.js"></script>
    <script src="threejs/src/loaders/DDSLoader.js"></script>

</head>

<body>

    <script>

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

        // ambient
        var ambient = new THREE.AmbientLight(0xeeeeee);
        scene.add(ambient);

        // light
        var light = new THREE.PointLight( 0xffffff, 1, 50 );
        light.position.set(0, 0, 6 ).normalize();
        scene.add( light );

        THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader());

        // instantiate a loader
        var loader = new THREE.OBJMTLLoader();

        // load a resource
        loader.load(
            // resource URL
            'eyebot.obj', 'eyebot.mtl',
            // Function when resource is loaded
            function ( object ) {
                object.position.set(0, 0, 0);
                camera.position.set(0, 12, 0);
                camera.lookAt(new THREE.Vector3(0,0,0));
                obj = object;
                scene.add( obj );
            }
        );

        obj = null;
        var render = function ()
        {
            deg_per_sec = 40;
            delta = clock.getDelta();
            requestAnimationFrame( render );
            renderer.render(scene, camera);
            if (obj)
            {
                obj.rotation.x += delta * Math.PI / 180 * deg_per_sec; // Rotates 1 degree per second
                obj.rotation.y += delta * Math.PI / 180 * deg_per_sec * 1.5;
            }

        };

        renderer = new THREE.WebGLRenderer({
            antialias: true,
            alpha: true
        });
        renderer.setClearColor( 0x000000, 1);
        renderer.setSize( window.innerWidth, window.innerHeight );
        document.body.appendChild( renderer.domElement );

        if (window.addEventListener)
            window.addEventListener('load', render, false);
        else if (window.attachEvent)
            window.attachEvent('onload', render);
        else window.onload = render;

    </script>

</body>

Answer №1

Have you checked the JavaScript console for any errors? Remote debugging can be very helpful. You can also debug the iOS Simulator in a similar way.

Based on your comments, it seems like the error might be related to running out of memory or using images that are too large (jpg compression doesn't matter for WebGL as the images will return to their original size when uncompressed).

The probable cause of the issue is if you are using .DDS files. Keep in mind that .DDS files only function on desktops (typically) and are usually utilized for DXT compressed textures. No iOS devices support DXT compressed textures, although some Android devices with NVidia GPUs do. For iOS compatibility, consider converting those compressed textures to JPG or PNG formats. Alternatively, switch to a compressed format supported by iOS such as PVRTC.

For instance, while running this three.js sample utilizing DXT compressed texture formats on the iOS Simulator, upon checking the JavaScript console in Safari, I observed:

[Log] THREE.WebGLRenderer 71 (three.min.js, line 523)
[Warning] THREE.WebGLRenderer: WEBGL_compressed_texture_s3tc extension not supported. (three.min.js, line 2)
[Warning] THREE.WebGLRenderer: EXT_blend_minmax extension not supported. (three.min.js, line 2)
[Warning] THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture() (three.min.js, line 2, x19)

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

Encountering JSON parsing errors while using fetch() POST requests in Express

Currently, I am experimenting with HTTP requests and my main focus is on sending a POST request. The data for this request is coming from an input field and I am using fetch() to send it to a URL on my local host which is set up with express. My goal is to ...

jQuery does not change the scroll position of elements

I'm looking to implement a feature on my website where certain points act as "magnets" and when the user is near one of these points, the window automatically scrolls to the top. I found a jQuery plugin that does something similar which you can check ...

Incorporating Hyperlinks into Text using React I18next

I'm facing an issue with I18next. I can't seem to make links to websites work correctly using the following code: import React, { Suspense } from "react"; import i18n from "i18next"; import { initReactI18next, useTranslation, ...

Inquiries using Azure iOS Mobile Services

How can I write a query to retrieve a row with an id of 1? NSPredicate *predicate = [NSPredicate predicateWithFormat:[apt[@"id"] isEqualToNumber:1]]; I'm encountering errors that suggest it needs to be a BOOL. Does NSPredicate require a BOOL? I&ap ...

Securing Data in AngularJS Services

After logging in to my AngularJS application, I noticed that the user roles stored in the loginService are editable by the user via the console. How can I enhance the security of this feature? How should CSRF be handled in my application? I have several ...

Surprising outcome encountered while trying to insert an item into a list

I'm a bit puzzled by the current situation where: let groupdetails = { groupName: "", }; const groupsArray = []; groupdetails.groupName = 'A' groupsArray.push(groupdetails) groupdetails.groupName = 'B' groupsAr ...

The connection between two arrays remains intact even after using the .push() method in JavaScript or Vue.js

I need help setting up two arrays containing dates. The first array should have the dates in string format, while the second array should contain the same dates but as date objects. methods: { test() { let employments = [ { begin: ...

Issue encountered while importing TypeScript files from an external module in a Next.js project

Encountering an issue within my Next.js project with the following project structure: ├── modules/ │ └── auth/ │ ├── index.ts │ ├── page.tsx │ └── package.json └── nextjs-project/ ├─ ...

Exploring Highcharts Pie Chart with AJAX for Real-time Data Updates

Looking for some guidance with implementing AJAX in my code to make my chart dynamic based on data from the database. Although the code is error-free, the chart is not refreshing automatically. Any help, comments, or suggestions would be greatly appreciate ...

What is the best way to adjust a div's height to fill the remaining space of the viewport after the header's height

Is there a way to create a hero section that fills 100vh minus the height of the header, especially when the height of the header is not fixed? I initially used CSS with a height property set to calc(100vh - 310px), where 310px represents the height of t ...

Efficient PHP caching solution for optimizing JavaScript and CSS performance

I'm facing a unique challenge that I can't seem to solve through typical Google searches. I'm in the process of consolidating all my javascript and css into separate php files using require_once() to pull in the content. The structure of my ...

Angular2's hidden feature isn't functioning properly

There is a common suggestion to use *ngIf better than [hidden] but in my scenario, I want to keep the element in the DOM without it being visible. In my component.html file, I have: <article #articleId id="bodyArticle" [hidden]="isClicked"></art ...

Tips for creating Selenium code to verify the asterisk symbol

Looking to create Selenium code for validating the presence of asterisks with mandatory fields such as First Name*, Last Name*, Enter Address*, and Enter Phone Number*. The validation needs to confirm the asterisk appears after each field name. Currently ...

Renaming personalized elements in Aurelia templates

My inquiry pertains to the process of aliasing custom elements and integrating them into aurelia's html-templates. To set the scene, I am utilizing the latest webpack typescript skeleton available at https://github.com/aurelia/skeleton-navigation and ...

Finding the variance in the given situation is as simple as following these steps

To find the variance between the "Total Marks" in a question and the input texts for each answer, we need to consider specific scenarios. Firstly, if a question has only one answer, the text input should be displayed as readonly with the same value as the ...

Exploring how to incorporate Express middleware into Firebase Functions for handling HTTPS requests

Encountering a challenge while using Express middleware with Firebase Functions. In this sample, a function is linked to the app() instance as shown below: app.get('*', (req, res) => { res.send(`Hello ${req.user.name}`); }); exports.autho ...

The step-by-step guide on displaying API choices in an Autocomplete feature and keeping them up

Having trouble with updating autocomplete options. An error message pops up in the console log when I try to deselect a tag or select a new one: MUI: The value provided to Autocomplete is invalid. None of the options match with [{"catName":{&qu ...

Choose the initial unordered list within a specific division through Jquery

In a div, there is a ul. Inside a li, there is another ul. The task is to select only the first ul inside the div using jQuery. The HTML markup: <div class="parent"> <div class="clearfix"> <div class="another-div"> <ul cl ...

Decrease the space between slide items by reducing margins or increasing their width

I'm having trouble achieving the desired spacing between items, I would like more space between each item but they are currently too close together. I am looking for a margin of 10px or a width of 32% for each item. I have already looked into some re ...

How to activate select only when specific options are chosen using jQuery

I am working on a form that has 1 select element disabled, with 4 options. I am looking to implement a jQuery function that will perform the following actions: If OPTION #1 is clicked, it should check if any other options are selected and reset them (eras ...