viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

[Question]: Can't seem to load obj/mtl resource #51

Closed lionkeng closed 6 years ago

lionkeng commented 7 years ago

I am playing around with https://github.com/viromedia/ViroARSampleApp and I replaced the coffee_mug resource with an OBJ. The rn-cli.config.js file looks like it is ready to load OBJ/MTL resources.

When I try to view the model via the testbed in the Viro Media app, the app crashes on the iOS device and there is no way of telling what went wrong.

The sample OBJ file that I am testing with is this: https://www.turbosquid.com/FullPreview/Index.cfm/ID/438709

Any help on how I can debug what the problem is? Thanks.

VikAdvani commented 7 years ago

Hi @lionkeng, You'll need to put a type="OBJ" param in the Viro3DObject tag like below:

<Viro3DObject position={[0, -1, -4]}
          scale={[1,1,1]} source={require('./res/House26/HousF/HousF/houseF.obj')}
          resources={[require('./res/House26/HousF/HousF/houseF.mtl'),
                       require('./res/House26/HousF/HousF/red.jpg'),
                       require('./res/House26/HousF/HousF/roofTiles.jpg'),
                       require('./res/House26/HousF/HousF/stone_buff.jpg'),
                       require('./res/House26/HousF/HousF/terracotta.jpg'),
                       require('./res/House26/HousF/HousF/white.jpg'),
                       ]}
          type="OBJ" />

Make sure to add an ambient light to your scene so the model shows up: <ViroAmbientLight color="#ffffff"/>

That should fix the crash issue and get the model to display.

However, I tried the model you linked and it appears but it's dark. It seems the materials and textures aren't properly linked to it. You might have to reexport it using a 3d modelling program, more info here: https://www.blender.org/forum/viewtopic.php?t=16972

Let me know if you have any more issues!

dam00n commented 7 years ago

house.zip

Hi @lionkeng, we were able to get the house model working on Viro. We exported the OBJ as an FBX using Maya, game export -> https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-2DB6E7B0-04B8-4585-91E9-7D64B02D0338-htm.html

I have attached the house file above in FBX and VRX format.

achuvm commented 6 years ago

Closing due to inactivity.

If you still have issues, feel free to re-open this issue or create a new one.

The latest releases are here: React Viro - https://docs.viromedia.com/docs/releases ViroCore - https://virocore.viromedia.com/docs/releases

Thanks for using Viro!