expo / expo-three

Utilities for using THREE.js on Expo
MIT License
751 stars 92 forks source link

Cannot parse a null asset #154

Open nik-sloop opened 4 years ago

nik-sloop commented 4 years ago

Full warning: [Unhandled promise rejection: Error: ExpoTHREE.loadObjAsync: Cannot parse a null asset]

Code: `import { View as GraphicsView } from 'expo-graphics'; import ExpoTHREE, { THREE } from 'expo-three'; import React from 'react';

import PanResponder from 'react-native';

import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; import Animated from 'react-native-reanimated'; import { TouchableHighlight, TouchableOpacity } from 'react-native-gesture-handler'; var theta = 0; var radius = 100; var raycaster; var mouse = new THREE.Vector2(), INTERSECTED; export default class Body extends React.Component { componentWillMount() { THREE.suppressExpoWarnings(); }

render() { // Create an ExpoGraphics.View covering the whole screen, tell it to call our // onContextCreate function once it's initialized. return (

      <GraphicsView
    onContextCreate={this.onContextCreate}
    onRender={this.onRender}
    />

);

} // This is called by the ExpoGraphics.View once it's initialized onContextCreate = async ({ gl, canvas, width, height, scale: pixelRatio, }) => { this.renderer = new ExpoTHREE.Renderer({ gl, pixelRatio, width, height }); this.renderer.setClearColor(0xffffff); this.scene = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000); this.camera.position.z = 6; //var loader = new THREE.GLTFLoader();

// loader.load('soccerball.obj', function(object){

//   this.scene.add(object);
// },
// function ( xhr ) {

//   console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

// },
// // called when loading has errors
// function ( error ) {

//   console.log( 'An error happened', error );

// });
 //const geometry = new THREE.BoxGeometry(3, 3, 3);
// const geometry1 = new THREE.SphereGeometry(1, 10, 10);
 const geometry = await ExpoTHREE.loadObjAsync(require('../../assets/objects/soccerball.obj'));
 const material = new THREE.MeshBasicMaterial({
  color: 0xff0000,
});
// this.sph = new THREE.Mesh(geometry1, material);
 this.cube = new THREE.Mesh(geometry, material);
// //  this.cube = await ExpoTHREE.loadObjAsync({ asset: require('./Person.obj') });

 this.scene.add(this.cube);

this.scene.add(new THREE.AmbientLight(0x404040));

const light = new THREE.DirectionalLight(0xffffff, 0.5);
light.position.set(3, 3, 3);
this.scene.add(light);

};

onRender = delta => { this.cube.rotation.x += 0 delta; this.cube.rotation.y += .3 delta; this.renderer.render(this.scene, this.camera);
}; }`

interpolationer commented 4 years ago

I have this same exact problem as well. Do hope someone answers.