expo-three icon indicating copy to clipboard operation
expo-three copied to clipboard

Expo-three render .glb in ReactNative , get Error: Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported

Open gillgong opened this issue 4 years ago • 28 comments

gillgong avatar Nov 01 '19 08:11 gillgong

@EvanBacon can you please resolve this issue?

rams12 avatar Dec 15 '19 00:12 rams12

I have the same problem: expo 36 (Bare) with three 0.112 when i try to load a TEXTURIZED GLB it gives me this error but if i try to load one without texture then everything is ok...

alessandro-bottamedi avatar Dec 26 '19 10:12 alessandro-bottamedi

Any one resolve this?

acndur1a avatar Feb 22 '20 16:02 acndur1a

I have the same problem: expo 36 (Bare) with three 0.112 when i try to load a TEXTURIZED GLB it gives me this error but if i try to load one without texture then everything is ok...

@alessandro-bottamedi did you find a solution for this?

acndur1a avatar Feb 22 '20 23:02 acndur1a

I have the same problem: expo 36 (Bare) with three 0.112 when i try to load a TEXTURIZED GLB it gives me this error but if i try to load one without texture then everything is ok...

@alessandro-bottamedi did you find a solution for this?

I solved it using a react-native-webview, I think expo-gl is not yet mature enough for viewing complex 3d models

alessandro-bottamedi avatar Feb 23 '20 10:02 alessandro-bottamedi

Just to add more context, getting this error from.

const mesh = await ExpoTHREE.loadAsync(
  ['some url to a glb file'],
   null,
   imageName => {
       return model[imageName];
   },
  ); 

igaln avatar Feb 24 '20 14:02 igaln

ok digging more into this, I could not find a working blob loader for Expo, I tried replacing the Three file loader with rn-fetch-blob but that requires for the app to be ejected.

Does anyone know blob loader that works with expo?

igaln avatar Feb 24 '20 15:02 igaln

@alessandro-bottamedi How did you fix using react-native-webview? Is that easily integratable with three.js? Any performance issues?

timnlupo avatar Mar 02 '20 07:03 timnlupo

I'm having this problem too. Using the GTLFLoader directly from Three hangs my device and using loadAsync from ExpoTHREE causes this error.

cuddeford avatar Jun 05 '20 17:06 cuddeford

Facing the same problem while using GTLFLoader

arberkryeziu avatar Jun 06 '20 01:06 arberkryeziu

Same problem while using GTLFLoader to load .glb files with textures.

beauvaisbruno avatar Jun 18 '20 04:06 beauvaisbruno

same problem using GLTFLoader to load .glb files served by a URL.

anutting avatar Sep 01 '20 20:09 anutting

Same problem using GTLFLoader, so instead in Blender I exported scene in .glb format unchecking materials and it worked - geometries load correctly. As a temporary workaround assign textures inside your app.

jakubrpawlowski avatar Sep 06 '20 14:09 jakubrpawlowski

I was able to fix this on web by going into /node_modules/three/jsm/loders/GLTFLoader and just before

new Blob( [ bufferView ] , ... )

do this

var ar = new Uint8Array(bufferView)
new Blob( [ ar ] , ... )

I was able to load the model in RN web but still no luck on iOS.

haydenlinder avatar Nov 09 '20 18:11 haydenlinder

I am running into this too for Android. Looking t the call stack it looks like it is a react native problem?

@haydenlinder maybe we can try to fix it for the different platforms?

mrmattrains avatar Jan 06 '21 20:01 mrmattrains

I am having the same issue. The work around I am using right now is to re-export the models with "placeholder" materials. In code, I then use GLTFLoader to load that model, and manually setup the materials / texture for all items.

polymorpher avatar Feb 11 '21 07:02 polymorpher

Doing the same thing here... I name the textures the same as the material and the code assigns based on that.

On Wed, Feb 10, 2021 at 11:24 PM Aaron Li [email protected] wrote:

I am having the same issue. The work around I am using right now is to re-export the models with "placeholder" materials. In code, I then use GLTFLoader to load that model, and manually setup the materials / texture for all items.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/expo/expo-three/issues/144#issuecomment-777249152, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXUJBYN2S2YA3UCVLGR4HTS6OA3DANCNFSM4JHXR44A .

mrmattrains avatar Feb 11 '21 18:02 mrmattrains

Same problem using local .glb with textures inside. But works without any texture..

450Oucema avatar Feb 23 '21 10:02 450Oucema

Same issue trying to use GLTFLoader on react native

Hugyn avatar Jul 21 '21 19:07 Hugyn

I find a way to prevent the issue, make your model without texture, and after you loaded the model add the texture manually:

    const asset= Asset.fromModule(require("../assets/model.gltf"));
    new GLTFLoader().load(
      asset.uri,
      (gltf) => {
        // This texture will be immediately ready but it'll load asynchronously
        const texture = new TextureLoader().load(require("../assets/image.png"));
        model = gltf.scene;
        model.position.z = -4;
        model.traverse((child) => {
          if (child instanceof Mesh)
            child.material = new THREE.MeshBasicMaterial({ map: texture });
        });
        scene.add(model);
      },
      null,
      (error) => {
        console.log("An error happened", error);
      }
    );

hatem-mazid avatar Aug 10 '21 11:08 hatem-mazid

@hatem-mazid I am running into this issue and have a few quick questions. Are you doing this loading outside or inside of the component? Where are you getting scene for the line scene.add(model)? And is model defined before this or did you just leave out the const when defining model?

benAkin avatar Oct 27 '21 05:10 benAkin

So, is there a fix? I have the same problem.

CarsoteCosmin avatar Mar 01 '22 16:03 CarsoteCosmin

Yea, that's what I ended up doing... or something to that effect.

I also ended up having animation problems later too. But could tell if it was the export from the app or the import.

Matt

On Tue, Aug 10, 2021, 4:34 AM hatem mazid @.***> wrote:

I find a way to prevent the issue, make your model without texture, and after you loaded the model add the texture manually:

const asset= Asset.fromModule(require("../assets/model.gltf"));
new GLTFLoader().load(
  asset.uri,
  (gltf) => {
    // This texture will be immediately ready but it'll load asynchronously
    const texture = new TextureLoader().load(require("../assets/image.png"));
    model = gltf.scene;
    model.position.z = -4;
    model.traverse((child) => {
      if (child instanceof Mesh)
        child.material = new THREE.MeshBasicMaterial({ map: texture });
    });
    scene.add(model);
  },
  null,
  (error) => {
    console.log("An error happened", error);
  }
);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/expo/expo-three/issues/144#issuecomment-895954877, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXUJB4A3ZNPLJ4PKBT63YLT4EFGDANCNFSM4JHXR44A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

mrmattrains avatar Mar 01 '22 16:03 mrmattrains

Blob is part of React Native, React Native doesn't support ArrayBuffers cite. You could perhaps create a JSI module which injects ArrayBuffer support into the runtime, this might work since react-native is checking the global for the existence of the types.

Regardless, it's out of scope for the expo-three project at the moment since this is an issue that is pretty core to React Native.

EvanBacon avatar Mar 01 '22 18:03 EvanBacon

I am using blob to create a downloadable file like that:

import { saveAs } from "file-saver";

const file = new Blob([buffer], { type: EXCEL_TYPE });

saveAs(file, "example.xlsx");

it's working fine with react js, but in react native i got this error

Error: Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported

Zaki-Dz avatar Jul 08 '22 00:07 Zaki-Dz

I am using blob to create a downloadable file like that:


import { saveAs } from "file-saver";



const file = new Blob([buffer], { type: EXCEL_TYPE });



saveAs(file, "example.xlsx");

it's working fine with react js,

but in react native i got this error


Error: Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported

Comment above yours from @EvanBacon answers your question. You'll need to make a JSI that adds ArrayBuffer to react native.

antoine1anthony avatar Jul 08 '22 10:07 antoine1anthony

@antoine1anthony can you point us into some sort of a direction regarding this JSI? I tried looking around for something like this, but unfortunately nothing seems to suffice.

bujoralexandru avatar Jun 15 '23 11:06 bujoralexandru

If anyone needs an example of how to do this by using the exported textures from the model and loading it afterwards: https://github.com/hjopel/r3f-native-starter

hjopel avatar Jun 19 '23 18:06 hjopel