viro
viro copied to clipboard
All my 3D models are being display with the same texture
Environment
Please provide the following information about your environment:
- Development OS: Mac
- Device OS & Version: iOS version (11.0, 11.2)
- Version: ViroReact version(2.17.0) and React Native version (0.59.9)
- Device(s): What device(s) are you are seeing the issue (iPhone 11)
Description
Describe your issue in detail. Include screenshots if needed. If this is a regression, let us know. I am having an issue displaying my 3D models. All of the are being displayed with the same texture. I made sure that the object I am passing gives the 3D model a different texture url.
This 3D model is displaying fine:
But the next ones not:
`render() { console.log(this.props.item)
return (
<ViroARScene>
<ViroAmbientLight color={"#FFFFFF"} intensity={800} />
<ViroSpotLight innerAngle={5} outerAngle={90} direction={[0, -1, -.2]}
position={[-.04, -2, -4.5]} color="#ffffff" castsShadow={true} />
<Viro3DObject animation={{ name: "rotate", run: true, loop: true }}
source={{
uri: `${this.props.item.obj_url}`
}}
resources={[{ uri: `${this.props.mtl_url}` },
{ uri: `${this.props.texture_url}` }]}
position={[-.04, -2, -4.5]}
scale={[.025, .025, .025]}
type="OBJ"
onClick={this.tap}/>
</ViroARScene>
);
}
}`
Console:
first 3D Model:
{id: 1, itemName: "Chicken Alfredo Pizza Fritta", itemDescription: "Chicken, three cheeses and alfredo sauce wrapped i…Served with homemade alfredo and marinara sauces.", texture_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/texture.jpg", obj_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/model.obj", …} id: 1 itemName: "Chicken Alfredo Pizza Fritta" itemDescription: "Chicken, three cheeses and alfredo sauce wrapped in a golden fried pizza dough. Served with homemade alfredo and marinara sauces." texture_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/texture.jpg" obj_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/model.obj" mtl_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/materials.mtl" category: "Starters" img_2D_url: "https://media.olivegarden.com/en_us/images/product/og-chicken-alfredo-pizza-fritta-appetizer-dpv-590x365.jpg" menu_id: 1 created_at: "2019-12-19T17:03:49.167Z" updated_at: "2019-12-19T17:03:49.167Z" proto: Object
Second 3D Model:
{id: 2, itemName: "Chicken Giardino", itemDescription: "Grilled chicken and a medley of fresh vegetables t…ed pappardelle pasta in a light lemon herb sauce.", texture_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/borrador.jpg", obj_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/borrador.obj", …} id: 2 itemName: "Chicken Giardino" itemDescription: "Grilled chicken and a medley of fresh vegetables tossed with ruffled pappardelle pasta in a light lemon herb sauce." texture_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/borrador.jpg" obj_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/borrador.obj" mtl_url: "https://fernando3dmodels.s3.us-east-2.amazonaws.com/3d-models/borrador.mtl" category: "Main Dishes" img_2D_url: "https://media.olivegarden.com/en_us/images/product/chicken-giardino-dpv-590x365.jpg" menu_id: 1 created_at: "2019-12-19T17:03:49.173Z" updated_at: "2019-12-19T17:03:49.173Z" proto: Object
I figurated the problem. Apparently, if you are using an OBJ file you will have to call them like this:
for the OBJ file: module.obj, for the JPG file: texture.jpg, for the MTL file: materials.mtl
so, all your 3D models should be on a different folder in order to have more than 1 3D model.
I assumed if you have more than one texture file, you will have to call them texture2.jpg, texture3.jpg and so on. I haven't tried since all my models are 3 files(module.obj, texture.jpg, materials.mtl)
@Fernandocgomez how did you use internet texture file in mtl ?