Missing Pixel with obj file
edisonlao opened this issue · 0 comments
edisonlao commented
Hello,Thank you for reading this issue
i found that missing pixel when i use GLModelView to load .obj+.mtl file,
any solution has not been found yet
react-native 0.61.3
react-native-gl-model-view 1.6.0
android 10
Expected
render complete like windows10 3DViewer
show on windows10 3DViewer:
show on Android GLModelView:
code:
<AnimatedModelView
model={{uri: 'man.obj'}}
texture={{uri: 'man_skin.png'}}
onStartShouldSetResponder={() => true}
onResponderRelease={this.onMoveEnd}
onResponderMove={this.onMove}
animate={!!fromXY}
tint={{r: 1.0, g: 1.0, b: 1.0, a: 1.0}}
scale={0.1}
rotateX={rotateX}
rotateZ={rotateZ}
translateZ={-10}
style={styles.container}
/>
Personal guess
the .obj and.mtl file are not interguided properly
i'm tried to modify setModelUri() and loadModelFromInputStream() method in RNGLModelView.java but it didn't work
setModelUri() method:
if (pUri.startsWith(lGeometryHeader)) {
final String lBase64 = pUri.substring(lGeometryHeader.length());
final InputStream lInputStream = getInputStreamFromBase64(lBase64);
+InputStream mtlInputStream = null;
+if(pUri.endsWith(".obj")){
+String pMtl = pUri.replace(".obj", ".mtl");
+final String mtlHeader = RNGLModelView.getBase64EncodedGeometryHeader("mtl");
+final String mtlBase64 = pMtl.substring(mtlHeader.length());
+mtlInputStream = getInputStreamFromBase64(mtlBase64);
+}
-model = RNGLModelView.loadModelFromInputStream(lInputStream, lGeometryType);
+model = RNGLModelView.loadModelFromInputStream(lInputStream, mtlInputStream, lGeometryType);
}
loadModelFromInputStream() method :
switch (pExtension) {
case "obj":
-return Object3D.mergeAll(Loader.loadOBJ(pInputStream, null, 1));
+return Object3D.mergeAll(Loader.loadOBJ(pInputStream, mtlStream, 1));
case "3ds":
return Object3D.mergeAll(Loader.load3DS(pInputStream, 1));
case "md2":
return Loader.loadMD2(pInputStream, 1);
case "asc":
return Loader.loadASC(pInputStream, 1, false);
case "model":
return RNGLModelViewModelLoader.loadMODEL(pInputStream);
}