ReactVision / viro

ViroReact: The AR and VR library for React Native 📳💙💛🤍💚
MIT License
1.4k stars 164 forks source link

Unable to load .obj file with .mtl #41

Open potatoengineer opened 3 years ago

potatoengineer commented 3 years ago

Requirements:

Please go through this checklist before opening a new issue

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: iOS version 14.7.1
  3. Version: ViroReact version 2.20.2 and React Native version 0.65.1
  4. Device(s): iPhone 7

Description

Using a fresh clone of the starter-kit repo to try to render my 3D object but all I'm seeing is the "Hello World". I have tried adding ViroAmbientLight as per docs and I'm using the resources prop to require all my files.

This is my code:

    <ViroARScene onTrackingUpdated={onInitialized}>
      <ViroAmbientLight color="#ffffff" />
      <ViroText
        text={text}
        scale={[0.5, 0.5, 0.5]}
        position={[0, 0, -1]}
        style={styles.helloWorldTextStyle}
      />
      <Viro3DObject
        scale={[0.1, 0.1, 0.1]}
        position={[0, -0.5, -1]}
        source={require('./res/car/prius.obj')}
        resources={[
          require('./res/car/prius.mtl'),
          require('./res/car/Prius_Color.png'),
          require('./res/car/Prius_Normal.png'),
          require('./res/car/Prius_Rough.png'),
          require('./res/car/Tire_Normal.png'),
          require('./res/car/Tire_Rough.png'),
          require('./res/car/Plate.png'),
        ]}
        type="OBJ"
      />

      <ViroAmbientLight />
    </ViroARScene>

Anyone know what's wrong and/or how to fix this issue?

saeedtkh commented 2 years ago

@potatoengineer: Any updates? I have the same problem :(

robertjcolley commented 2 years ago

@saeedtkh or @potatoengineer I was able to reproduce what you are seeing. I've created a repo in my diagnosing app found here

The Statue of Liberty shows the issue in this image. It seems to be missing the textures

Screen Shot 2021-12-23 at 1 48 41 PM
robertjcolley commented 2 years ago

I've got a hunch as to why this isn't working.

In my starter kit, I have a LibertyStatue.obj file. There is a material referenced in this file:

Screen Shot 2021-12-23 at 1 49 57 PM

I think that the material is being resolved to my local computer with whatever is resolving the material (something in virocore) and not the asset LibertyStatue_TEST.mtl. This would mean when I run on my device, the .obj parser which resolves mtl files is trying to find a file at the wrong location

I've not included this resource in my 'resources' array, and changing the string in the obj file causes a different error.

Resource mtl not used:

Screen Shot 2021-12-23 at 1 48 41 PM

error with original file name:

test

change in .obj file

Screen Shot 2021-12-23 at 1 54 56 PM

error with new file name:

2
jaferi512 commented 2 years ago

I'm Also Still Facing the issue to Load .obj File in React Native Project