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"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var raf = function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) { window.setTimeout(callback, 1000 / 60); }; }(); var events = { on: function on(element, event, callback, capture) { !element.addEventListener && (event = 'on' + event); (element.addEventListener || element.attachEvent).call(element, event, callback, capture); return callback; }, off: function off(element, event, callback, capture) { !element.removeEventListener && (event = 'on' + event); (element.removeEventListener || element.detachEvent).call(element, event, callback, capture); return callback; } }; var select = { one: function one(selector, parent) { parent || (parent = document); return parent.querySelector(selector); }, all: function all(selector, parent) { parent || (parent = document); var selection = parent.querySelectorAll(selector); return Array.prototype.slice.call(selection); } }; var dom = { events: events, select: select };; var Mouse = { x: 0, y: 0, nX: 0, nY: 0 }; var Window = { w: window.innerWidth, h: window.innerHeight }; var Plane = function (_THREE$Object3D) { _inherits(Plane, _THREE$Object3D); function Plane() { _classCallCheck(this, Plane); var _this = _possibleConstructorReturn(this, _THREE$Object3D.call(this)); _this.geometry = new THREE.PlaneBufferGeometry(10, 10); _this.uniforms = { uTime: { value: 0 }, uResolution: { value: new THREE.Vector2(Window.w, Window.h) } }; _this.material = new THREE.ShaderMaterial({ uniforms: _this.uniforms, vertexShader: dom.select.one('#iceVertex').textContent, fragmentShader: dom.select.one('#iceFragment').textContent, side: THREE.DoubleSide }); _this.mesh = new THREE.Mesh(_this.geometry, _this.material); _this.add(_this.mesh); _this.update = _this.update.bind(_this); return _this; } Plane.prototype.update = function update(d) { this.uniforms.uTime.value += d * 0.001; this.uniforms.uResolution.value.x = Window.w; this.uniforms.uResolution.value.y = Window.h; // this.rotation.y += 0.01 // this.rotation.z += 0.01 }; return Plane; }(THREE.Object3D); var Xp = function () { function Xp() { _classCallCheck(this, Xp); this.scene = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera(45, Window.w / Window.h, 1, 1000); this.camera.position.z = 1; // this.controls = new THREE.OrbitControls( this.camera ) this.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); this.renderer.setSize(Window.w, Window.h); dom.select.one('.app').appendChild(this.renderer.domElement); this.DELTA_TIME = 0; this.LAST_TIME = Date.now(); this.bind(); this.initLights(); this.initMeshes(); } Xp.prototype.bind = function bind() { var _this2 = this; ['update', 'resize'].forEach(function (fn) { return _this2[fn] = _this2[fn].bind(_this2); }); }; Xp.prototype.initMeshes = function initMeshes() { this.plane = new Plane(); this.scene.add(this.plane); }; Xp.prototype.initLights = function initLights() { var ambientLight = new THREE.AmbientLight(0x111111); this.scene.add(ambientLight); var light = new THREE.DirectionalLight(0x4f4f4f); light.position.set(1, 1, 1); this.scene.add(light); var light2 = new THREE.DirectionalLight(0x4f4f4f); light2.position.set(-1, -1, -1); this.scene.add(light2); }; Xp.prototype.update = function update() { this.DELTA_TIME = Date.now() - this.LAST_TIME; this.LAST_TIME = Date.now(); this.plane.update(this.DELTA_TIME); this.renderer.render(this.scene, this.camera); }; Xp.prototype.resize = function resize() { this.camera.aspect = Window.w / Window.h; this.camera.updateProjectionMatrix(); this.renderer.setSize(Window.w, Window.h); }; return Xp; }(); var App = function () { function App() { _classCallCheck(this, App); this.bind(); this.addListeners(); this.xp = new Xp(); } App.prototype.bind = function bind() { var _this3 = this; ['onResize', 'onMouseMove', 'update'].forEach(function (fn) { return _this3[fn] = _this3[fn].bind(_this3); }); }; App.prototype.addListeners = function addListeners() { dom.events.on(window, 'resize', this.onResize); dom.events.on(window, 'mousemove', this.onMouseMove); }; App.prototype.init = function init() { this.update(); }; App.prototype.onResize = function onResize() { Window.w = window.innerWidth; Window.h = window.innerHeight; this.xp.resize(); }; App.prototype.onMouseMove = function onMouseMove(e) { e.preventDefault(); Mouse.x = e.clientX || Mouse.x; Mouse.y = e.clientY || Mouse.y; Mouse.nX = Mouse.x / Window.w * 2 - 1; Mouse.nY = Mouse.y / Window.h * 2 + 1; }; App.prototype.update = function update() { this.xp.update(); raf(this.update); }; return App; }(); var ShaolinApp = new App(); dom.events.on(window, 'DOMContentLoaded', function () { ShaolinApp.init(); });
CSS
@import url("https://fonts.googleapis.com/css?family=Oswald:300,500"); .center { display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: column nowrap; flex-flow: column nowrap; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; font-size: 62.5%; } .credits { position: absolute; right: 20px; bottom: 20px; color: #FFFFFF; text-align: right; font-family: 'Oswald'; } .credits__title { font-size: 1.5rem; text-transform: uppercase; font-weight: 500; margin-bottom: 0.5rem; } .credits__link { text-decoration: none; font-weight: 300; color: #FFFFFF; font-size: 1.3rem; position: relative; } .credits__link:after { content: ''; position: absolute; bottom: -2px; left: 0; width: 100%; height: 1px; background-color: #FFFFFF; -webkit-transform-origin: 100% 50%; transform-origin: 100% 50%; -webkit-transform: scale(0); transform: scale(0); -webkit-transition: -webkit-transform 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); transition: -webkit-transform 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); transition: transform 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); transition: transform 0.2s cubic-bezier(0.39, 0.575, 0.565, 1), -webkit-transform 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); will-change: transform; } .credits__link:hover:after { -webkit-transform-origin: 0% 50%; transform-origin: 0% 50%; -webkit-transform: scaleX(1); transform: scaleX(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