May 2018
Intermediate to advanced
470 pages
13h 54m
English
We will add 3D objects to the game world using Entity components and the sample object details in the answerObjects and wrongObjects arrays.
First, we will concatenate the answerObjects and wrongObjects arrays in componentDidMount to form a single array containing all the VR objects.
/MERNVR/index.js:
componentDidMount = () => { let vrObjects = this.state.game.answerObjects.concat(this.state.game.wrongObjects) this.setState({vrObjects: vrObjects}) ...}
Then in the main view, we will iterate over the vrObjects array to add the Entity components with details of each object.
/MERNVR/index.js:
{this.state.vrObjects.map((vrObject, i) => { return ( <Entity key={i} style={this.setModelStyles(vrObject, i)} source={{ obj: {uri: ...Read now
Unlock full access