Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFLoader doesn't load binary buffer on Android #56

Open
Toseben opened this issue Jul 19, 2018 · 12 comments
Open

GLTFLoader doesn't load binary buffer on Android #56

Toseben opened this issue Jul 19, 2018 · 12 comments
Assignees
Labels
android bug Native Issues that require native updates to the Expo Client to be made

Comments

@Toseben
Copy link

Toseben commented Jul 19, 2018

Using a localUri like this: file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540arttu%252Fsignlab-ar-prototype/ExponentAsset-edefa90125f1739a3f962678f2406a92.bin
Android outputs an error from THREE.FileLoader:
https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js#L1778

The problem sounded similar as in the below link, being an issue only on Android and relating to localUri. However Expo.FileSystem is not being used and Expo.Asset.downloaded flag is set to true.
https://github.com/expo/expo-three/issues/10/

I also noticed that AssimpLoaderExample.js from expo-three outputs a similar error on Android. I guess there are somehow related as both use THREE.FileLoader and are in binary buffer file format.

All of this works perfectly on iOS!

@EvanBacon
Copy link
Contributor

Related: expo/expo-asset-utils#5

@EvanBacon EvanBacon self-assigned this Jul 26, 2018
@EvanBacon EvanBacon added bug Native Issues that require native updates to the Expo Client to be made labels Jul 26, 2018
@ulvido
Copy link

ulvido commented Jul 13, 2020

for android 9 i got this error for loading glb and gltf files.

Error:
console.error: { isTrusted" : false }

Screenshot:
Ekran Alıntısı

# APP.js

"use strict";

// GLOBALS
global.THREE = global.THREE || THREE;

// IMPORTS
import React, { useEffect } from 'react';
import { THREE } from 'expo-three';
import { GLView } from 'expo-gl';
import { Renderer } from 'expo-three';
import { Asset } from 'expo-asset';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';

// COMPONENT
export default function App() {

  useEffect(() => {
    // Create an Asset from a resource
    const loader = new GLTFLoader();
    const asset = Asset.fromModule(require("./model/monkey.gltf"));
    asset.downloadAsync()
      .then(() => console.log(asset.localUri))
      .then(() => loader.load(asset.localUri, group => {
        // Model loaded...
        console.log("Model Loaded!")
      }))
      .catch(err => console.log("Load Error: ", err));
  }, [])

  return (
    <GLView
      style={{ flex: 1 }}
      onContextCreate={gl => {
        // Create a WebGLRenderer without a DOM element
        console.log("Context created")
        const renderer = new Renderer({ gl });
        renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight);
      }}
    />
  );
}

# metro.config.js

module.exports = {
  resolver: {
    assetExts: ['db', 'mp3', 'ttf', 'obj', 'png', 'jpg', 'gltf', 'glb'],
  },
  transformer: {
    assetPlugins: ['expo-asset/tools/hashAssetFiles'],
  },
};

@igorroman777
Copy link

@ulvido
did you find a solution for "{ isTrusted" : false }"?
I have the same problem.
Thanks

@ulvido
Copy link

ulvido commented Aug 4, 2020

@ulvido
did you find a solution for "{ isTrusted" : false }"?
I have the same problem.
Thanks

unfortunately no. the error consumed my energy so I quit trying and begin to play farcry primal.

@igorroman777
Copy link

@ulvido good idea

@igorroman777
Copy link

@EvanBacon EvanBacon
did you find a solution for "{ isTrusted" : false }"?
I have the same problem.
Thanks

@p4tric
Copy link

p4tric commented Sep 19, 2020

also got this { isTrusted" : false }.

any fix yet?

@janweigel
Copy link

Hi @igorroman777
did you or anyone else meanwhile find a way to successfully load gltf data on android?
I have the same problem and can't find a way to fix this.
Thank you!

@dopry
Copy link

dopry commented Dec 18, 2020

I switched to loading with asset.uri instead of asset.localUri and it seems to work for me..

     loader.load(asset.uri, (gltf) => {
        console.log('asset loaded', asset, gltf)
        ref=gltf
        
    }, (event: ProgressEvent<EventTarget>) => {
        console.log('onProgress', event, asset);
    }, (error: ErrorEvent) => {
        console.log('onError', error, asset)
    });

@murk-magnuson
Copy link

Has anyone made any progress towards a solution for this issue?

@hopewise
Copy link

hopewise commented May 29, 2021

any find a solution for this?
@dopry can you provide a working example?

@hopewise
Copy link

@ulvido how did you log the file name as the screen shot? what tool is handy for this verbosity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Native Issues that require native updates to the Expo Client to be made
Projects
None yet
Development

No branches or pull requests

9 participants