Rotation 

We want to add a feature that starts rotating a 3D object around its Y-axis whenever a player focuses on the 3D object, that is, the platform cursor begins intersecting with the Entity rendering the specific 3D object.

We will update the Entity component from the previous section to add the onEnter and onExit handlers.

/MERNVR/index.js:

<Entity      ...     onEnter={this.rotate(i)}    onExit={this.stopRotate}/>

The object will start rotating on enter, and stop when the platform cursor exits the object and it is no longer in the player's focus.

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.