mtl file not loading
See original GitHub issueI’m trying to load an obj with an mtl, but for some reason the mtl is never applied.
code ->
import Expo from 'expo';
import React from 'react';
import * as THREE from 'three';
import ExpoTHREE from 'expo-three';
console.disableYellowBox = true;
export default class App extends React.Component {
render() {
return (
<Expo.GLView
ref={(ref) => this._glView = ref}
style={{ flex: 1 }}
onContextCreate={this._onGLContextCreate}
/>
);
}
_onGLContextCreate = async (gl) => {
const width = gl.drawingBufferWidth;
const height = gl.drawingBufferHeight;
const arSession = await this._glView.startARSessionAsync();
const scene = new THREE.Scene();
const camera = ExpoTHREE.createARCamera(arSession, width, height, 0.01, 1000);
const renderer = ExpoTHREE.createRenderer({ gl });
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight);
scene.background = ExpoTHREE.createARBackgroundTexture(arSession, renderer);
const ambientLight = new THREE.AmbientLight(0xaaaaaa);
scene.add(ambientLight);
// //model files
const model = {
'artest.obj': require('./models/artest.obj'),
'artest.mtl': require('./models/artest.mtl'),
};
/// Load model
const mesh = await ExpoTHREE.loadAsync(
[model['artest.obj'], model['artest.mtl']],
null,
name => model[name],
);
/// Update size and position
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 5);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
mesh.scale.set(0.00001, 0.00001, 0.00001);
/// Add the mesh to the scene
scene.add(mesh);
const animate = () => {
requestAnimationFrame(animate);
renderer.render(scene, camera);
gl.endFrameEXP();
}
animate();
}
}
If you would have any input as to what I might be doing wrong, would be great.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Importing OBJ with MTL and Image not working properly
1. Check the obj file. In your case the obj is not exported correctly. Obj is a human readable file format it is...
Read more >The .mtl files won't load - Materials and Textures - Blender Artists
Open the mtl file in a text editor and check any file paths to textures are correct. Furlow (Furlow) November 30, 2012, ...
Read more >Importing OBJ file does not bring in mtl so model is grey
Solved: When I import obj file into maya, the model imports but all the color has gone and I am left with a...
Read more >html - .mtl file not rendering properly - Stack Overflow
I have .obj file and .mtl file and I'm trying to render those file using THREE.JS. But obj was loaded but colors and...
Read more >Problems loading MTL · Issue #1167 · potree/potree - GitHub
When including the mtl-files I get an error pointing to a "file not found" I can fix this by editing the MTLLoader.js file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ExpoTHREE.loadMtlAsync should fix this
how to add “mtl” to
app.json
, like this ?