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 over 100s of VR Developers

Build your Career in VR with this 6 part FREE course

Send Lesson #1
close-link
Add Me To VIP