Closed im-aditya closed 4 years ago
Any update? facing same issue.
Same here. Any suggestions??
Here are some suggestions: https://stackoverflow.com/questions/50190000/trying-to-load-obj-mtl-file-with-three-js-in-react-native
I didn't get the time to try out these suggestions, as for now I switched to UnityView, but I am going to try them soon.
Note: This is not an issue with this library but I was hoping I will get an answer here, hence posting it. Main objective : Load animated models exported from Maya into React Native app Exported files : obj, mtl & png file
When I am trying to load the MTL file using the MTLLoader, I am getting following error:
Can't find variable: document
Here are the two files that I am using:
three.js
const THREE = require("three"); global.THREE = THREE; if (!window.addEventListener) window.addEventListener = () => { }; // require("three/examples/js/renderers/Projector"); require("three/examples/js/loaders/MTLLoader"); require("three/examples/js/loaders/OBJLoader"); export default THREE;
ThreeView.js
import React, { Component } from "react"; import { StyleSheet, View } from "react-native"; import { WebGLView } from "react-native-webgl"; import THREE from "./three"; import { image } from "src/res/image";
export default class ThreeView extends Component { requestId: *; componentWillUnmount() { cancelAnimationFrame(this.requestId); } onContextCreate = (gl: WebGLRenderingContext) => { const rngl = gl.getExtension("RN");
}
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", alignItems: "center", justifyContent: "center" }, webglView: { width: 300, height: 300 } });