Shark Attack in VR – Using objects and shaders in WebVR tutorial

This is part of #DaysInVR series. View All VR Projects. Yesterday, we learnt how to create virtual tour in VR. Today we’ll see how to create shark attack in VR.

Demo | Source

In this tutorial, we’ll see how to create shark attack in WebVR using objects and shaders in WebVR. We’ll use OBJLoader and MTLLoader to load the shark object. We’ll be using the shark object from tf3dm website.

Loading objects in WebVR

We have used objects in our fireplace in webvr tutorial. However, in this tutorial, the objects are in different format. So we’ll be using OBJLoader and MTLLoader.

We need to add the following code to animate function so that the shark object keeps moving. It’ll change the position of the shark object.

Using shaders to create water

We’ll use WaterShader to create the water where our shark will move around in.

Adding positional audio in WebVR

We’ll also add the jaws soundtrack to our scene. We’ll position the sound to be coming from the shark itself.

Its your turn

Make this demo better. Adding a realistic swimming motion for the shark. Add more randomness to the position of the shark. Let us know what you come up with in the comments.

Leave a Reply

Send Lesson #1
Join 1000s of VR Developers

Build your Career in VR with this 6 part FREE course

Send Lesson #1
Add Me To VIP
Join 1000s of VR Developers

We've build a simple curriculum to help you get started in VR

Send Lesson #1
We've launched a WebVR Course with 25+ projects with source code! Check it out.
Get The Course