Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
JS
'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var App = function () { function App() { _classCallCheck(this, App); this.width = window.innerWidth; this.height = window.innerHeight; this.DELTA_TIME = 0; this.LAST_TIME = Date.now(); this.scene = new Scene(this.width, this.height); this.plane = new Plane(); this.scene.add(this.plane.mesh); var root = document.body.querySelector('.app'); root.appendChild(this.scene.renderer.domElement); this.addListeners(); } App.prototype.onResize = function onResize() { this.width = window.innerWidth; this.height = window.innerHeight; this.scene.resize(this.width, this.height); }; App.prototype.addListeners = function addListeners() { window.addEventListener('resize', this.onResize.bind(this)); TweenMax.ticker.addEventListener('tick', this.update.bind(this)); }; App.prototype.update = function update() { this.DELTA_TIME = Date.now() - this.LAST_TIME; this.LAST_TIME = Date.now(); this.plane.update(this.DELTA_TIME); this.scene.render(); }; return App; }(); var Plane = function () { function Plane() { _classCallCheck(this, Plane); this.size = 1000; this.segments = 200; this.options = new Options(); this.options.initGUI(); this.uniforms = { u_amplitude: { type: '1f', value: this.options.amplitude }, u_frequency: { type: '1f', value: this.options.frequency }, u_time: { type: '1f', value: 0 } }; this.geometry = new THREE.PlaneGeometry(this.size, this.size, this.segments, this.segments); this.material = new THREE.ShaderMaterial({ uniforms: this.uniforms, vertexShader: document.getElementById('planeVS').innerHTML, fragmentShader: document.getElementById('planeFS').innerHTML, wireframe: true, side: THREE.DoubleSide }); this.mesh = new THREE.Mesh(this.geometry, this.material); this.mesh.rotation.x = 360; } Plane.prototype.update = function update(dt) { this.uniforms.u_amplitude.value = this.options.amplitude; this.uniforms.u_frequency.value = this.options.frequency; this.uniforms.u_time.value += dt / 1000; }; return Plane; }(); var Options = function () { function Options() { _classCallCheck(this, Options); this.amplitude = 10; this.frequency = 0.05; this.gui = new dat.GUI(); } Options.prototype.initGUI = function initGUI() { this.gui.close(); this.gui.add(this, 'amplitude', 1, 15); this.gui.add(this, 'frequency', 0.01, 0.1); }; return Options; }(); var Scene = function () { function Scene(width, height) { _classCallCheck(this, Scene); this.scene = new THREE.Scene(); this.renderer = new THREE.WebGLRenderer({ antialias: true }); this.renderer.setSize(width, height); this.renderer.setClearColor(0); this.camera = new THREE.PerspectiveCamera(50, width / height, 1, 2000); this.camera.position.z = 100; this.controls = new THREE.OrbitControls(this.camera); } Scene.prototype.add = function add(child) { this.scene.add(child); }; Scene.prototype.remove = function remove(child) { this.scene.remove(child); }; Scene.prototype.render = function render() { this.renderer.autoClearColor = true; this.renderer.render(this.scene, this.camera); }; Scene.prototype.resize = function resize(newWidth, newHeight) { this.camera.aspect = newWidth / newHeight; this.camera.updateProjectionMatrix(); this.renderer.setSize(newWidth, newHeight); }; return Scene; }(); new App();
CSS
html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; background: url("http://lab.arnaudrocca.fr/water-shader/assets/images/preview.png") no-repeat center center fixed; background-size: cover; font-size: 10px; } canvas { position: absolute; display: block; cursor: move; } .infos { position: absolute; margin: 0; bottom: 10px; right: 10px; color: #888; font-family: sans-serif; font-weight: 400; font-size: 1rem; line-height: 0.5rem; } .infos a { text-decoration: none; color: #03c; opacity: 0.7; -webkit-transition: 0.3s; transition: 0.3s; } .infos a:hover { opacity: 1; }
HTML
Join Effecthub.com
Working with Global Gaming Artists and Developers!
Login
Sign Up
Or Login with Your Email Address:
Email
Password
Remember
Or Sign Up with Your Email Address:
Your Email
This field must contain a valid email
Set Password
Password should be at least 1 character
Stay informed via email