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 debounce = function debounce(callback, duration) { var timer; return function (event) { clearTimeout(timer); timer = setTimeout(function () { callback(event); }, duration); }; }; var MathEx = { degrees: function degrees(radian) { return radian / Math.PI * 180; }, radians: function radians(degree) { return degree * Math.PI / 180; }, clamp: function clamp(value, min, max) { return Math.min(Math.max(value, min), max); }, mix: function mix(x1, x2, a) { return x1 * (1 - a) + x2 * a; }, polar: function polar(radian1, radian2, radius) { return [Math.cos(radian1) * Math.cos(radian2) * radius, Math.sin(radian1) * radius, Math.cos(radian1) * Math.sin(radian2) * radius]; } }; var force3 = { updateVelocity: function updateVelocity(velocity, acceleration, mass) { vec3.scale(acceleration, acceleration, 1 / mass); vec3.add(velocity, velocity, acceleration); }, applyFriction: function applyFriction(acceleration, mu, n) { var friction = [0, 0, 0]; vec3.scale(friction, acceleration, -1); var normal = n ? n : 1; vec3.normalize(friction, friction); vec3.scale(friction, friction, mu); vec3.add(acceleration, acceleration, friction); }, applyDrag: function applyDrag(acceleration, value) { var drag = [0, 0, 0]; vec3.scale(drag, acceleration, -1); vec3.normalize(drag, drag); vec3.scale(drag, drag, vec3.length(acceleration) * value); vec3.add(acceleration, acceleration, drag); }, applyHook: function applyHook(velocity, acceleration, anchor, rest_length, k) { var hook = [0, 0, 0]; vec3.sub(hook, velocity, anchor); var distance = vec3.length(hook) - rest_length; vec3.normalize(hook, hook); vec3.scale(hook, hook, -1 * k * distance); vec3.add(acceleration, acceleration, hook); } }; var normalizeVector2 = function normalizeVector2(vector) { vector.x = vector.x / window.innerWidth * 2 - 1; vector.y = -(vector.y / window.innerHeight) * 2 + 1; }; var ForcePerspectiveCamera = function (_THREE$PerspectiveCam) { _inherits(ForcePerspectiveCamera, _THREE$PerspectiveCam); function ForcePerspectiveCamera(fov, aspect, near, far) { _classCallCheck(this, ForcePerspectiveCamera); var _this = _possibleConstructorReturn(this, _THREE$PerspectiveCam.call(this, fov, aspect, near, far)); _this.k = 0.02; _this.d = 0.2; _this.velocity = [0, 0, 0]; _this.acceleration = [0, 0, 0]; _this.anchor = [0, 0, 0]; _this.lookK = 0.02; _this.lookD = 0.2; _this.lookVelocity = [0, 0, 0]; _this.lookAcceleration = [0, 0, 0]; _this.lookAnchor = [0, 0, 0]; return _this; } ForcePerspectiveCamera.prototype.updatePosition = function updatePosition() { force3.applyHook(this.velocity, this.acceleration, this.anchor, 0, this.k); force3.applyDrag(this.acceleration, this.d); force3.updateVelocity(this.velocity, this.acceleration, 1); }; ForcePerspectiveCamera.prototype.updateLook = function updateLook() { force3.applyHook(this.lookVelocity, this.lookAcceleration, this.lookAnchor, 0, this.lookK); force3.applyDrag(this.lookAcceleration, this.lookD); force3.updateVelocity(this.lookVelocity, this.lookAcceleration, 1); }; ForcePerspectiveCamera.prototype.render = function render() { this.updatePosition(); this.updateLook(); this.position.set(this.velocity[0], this.velocity[1], this.velocity[2]); this.lookAt({ x: this.lookVelocity[0], y: this.lookVelocity[1], z: this.lookVelocity[2] }); }; return ForcePerspectiveCamera; }(THREE.PerspectiveCamera); var CameraController = function () { function CameraController(camera) { _classCallCheck(this, CameraController); this.camera = camera; this.radian1 = 0; this.radian1Base = 0; this.radian2 = 0; this.radian2Base = 0; this.radius = 2500; this.isZoom = false; } CameraController.prototype.rotate = function rotate(x, y) { if (this.isZoom === true) this.isZoom = false; this.radian1 = MathEx.clamp(this.radian1Base + y, MathEx.radians(-75), MathEx.radians(75)); this.radian2 = this.radian2Base - x * 2; }; CameraController.prototype.zoom = function zoom(delta) { if (!delta) return; if (this.isZoom === false) this.isZoom = true; var prevRadius = this.radius; this.radius -= delta / Math.abs(delta) * 200; this.radius = MathEx.clamp(this.radius, 700, 8000); var diff = prevRadius - this.radius; }; CameraController.prototype.touchEnd = function touchEnd() { this.radian1Base = this.radian1; this.radian2Base = this.radian2; }; CameraController.prototype.render = function render() { this.camera.anchor = MathEx.polar(this.radian1, this.radian2, this.radius); this.camera.render(); }; CameraController.prototype.computeZoomLength = function computeZoomLength() { if (this.isZoom) { return vec3.length(this.camera.acceleration) * 0.05; } else { return 0; } }; CameraController.prototype.computeAcceleration = function computeAcceleration() { return vec3.length(this.camera.acceleration) * 0.05; }; return CameraController; }(); ; var Debris = function () { function Debris() { _classCallCheck(this, Debris); this.uniforms = { time: { type: 'f', value: 0 }, cubeTex: { type: 't', value: null } }; this.instances = 1000; this.obj = null; } Debris.prototype.init = function init(texture) { this.uniforms.cubeTex.value = texture; this.obj = this.createObj(); }; Debris.prototype.createObj = function createObj() { var geometry = new THREE.InstancedBufferGeometry(); var baseGeometry = new THREE.BoxBufferGeometry(10, 10, 10); geometry.addAttribute('position', baseGeometry.attributes.position); geometry.addAttribute('normal', baseGeometry.attributes.normal); geometry.setIndex(baseGeometry.index); var translate = new THREE.InstancedBufferAttribute(new Float32Array(this.instances * 3), 3, 1); var offsets = new THREE.InstancedBufferAttribute(new Float32Array(this.instances), 1, 1); var rotates = new THREE.InstancedBufferAttribute(new Float32Array(this.instances * 3), 3, 1); for (var i = 0, ul = offsets.count; i < ul; i++) { var polar = MathEx.polar(Math.random() * 2 * Math.PI, Math.random() * 2 * Math.PI, Math.random() * 3000 + 100); translate.setXYZ(i, polar[0], polar[1], polar[2]); offsets.setXYZ(i, Math.random() * 100); rotates.setXYZ(i, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); } geometry.addAttribute('translate', translate); geometry.addAttribute('offset', offsets); geometry.addAttribute('rotate', rotates); return new THREE.Mesh(geometry, new THREE.RawShaderMaterial({ uniforms: this.uniforms, vertexShader: 'attribute vec3 position;\n attribute vec3 normal;\n attribute vec3 translate;\n attribute float offset;\n attribute vec3 rotate;\n\n uniform mat4 projectionMatrix;\n uniform mat4 modelViewMatrix;\n uniform mat4 modelMatrix;\n uniform float time;\n\n varying vec3 vPosition;\n varying vec3 vNormal;\n\n mat4 computeTranslateMat(vec3 v) {\n return mat4(\n 1.0, 0.0, 0.0, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n v.x, v.y, v.z, 1.0\n );\n }\n mat4 computeRotateMatX(float radian) {\n return mat4(\n 1.0, 0.0, 0.0, 0.0,\n 0.0, cos(radian), -sin(radian), 0.0,\n 0.0, sin(radian), cos(radian), 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n }\n mat4 computeRotateMatY(float radian) {\n return mat4(\n cos(radian), 0.0, sin(radian), 0.0,\n 0.0, 1.0, 0.0, 0.0,\n -sin(radian), 0.0, cos(radian), 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n }\n mat4 computeRotateMatZ(float radian) {\n return mat4(\n cos(radian), -sin(radian), 0.0, 0.0,\n sin(radian), cos(radian), 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n }\n mat4 computeRotateMat(float radX, float radY, float radZ) {\n return computeRotateMatX(radX) * computeRotateMatY(radY) * computeRotateMatZ(radZ);\n }\n\n void main(void) {\n float radian = radians(time);\n mat4 rotateWorld = computeRotateMat(radian * 5.0 + rotate.x, radian * 20.0 + rotate.y, radian + rotate.z);\n mat4 rotateSelf = computeRotateMat(radian * rotate.x * 100.0, radian * rotate.y * 100.0, radian * rotate.z * 100.0);\n vec4 updatePosition =\n rotateWorld\n * computeTranslateMat(translate)\n * rotateSelf\n * vec4(position + normalize(position) * offset, 1.0);\n vPosition = (modelMatrix * updatePosition).xyz;\n vNormal = (modelMatrix * rotateWorld * rotateSelf * vec4(normal, 1.0)).xyz;\n gl_Position = projectionMatrix * modelViewMatrix * updatePosition;\n }', fragmentShader: 'precision highp float;\n\n uniform vec3 cameraPosition;\n uniform float time;\n uniform samplerCube cubeTex;\n\n varying vec3 vPosition;\n varying vec3 vNormal;\n\n void main() {\n vec3 ref = reflect(vPosition - cameraPosition, vNormal);\n vec4 envColor = textureCube(cubeTex, ref);\n gl_FragColor = envColor * vec4(0.8, 1.0, 0.95, 0.7);\n }', transparent: true, side: THREE.DoubleSide })); }; Debris.prototype.render = function render(time) { this.uniforms.time.value += time; }; return Debris; }(); ; var SkyBox = function () { function SkyBox() { _classCallCheck(this, SkyBox); this.uniforms = { time: { type: 'f', value: 0 }, cubeTex: { type: 't', value: null } }; this.obj = null; } SkyBox.prototype.init = function init(texture) { this.uniforms.cubeTex.value = texture; this.obj = this.createObj(); }; SkyBox.prototype.createObj = function createObj() { return new THREE.Mesh(new THREE.BoxBufferGeometry(30000, 30000, 30000, 1, 1, 1), new THREE.RawShaderMaterial({ uniforms: this.uniforms, vertexShader: 'attribute vec3 position;\n attribute vec3 normal;\n attribute vec2 uv;\n\n uniform mat4 projectionMatrix;\n uniform mat4 modelViewMatrix;\n uniform float time;\n\n varying vec3 vPosition;\n\n void main(void) {\n vPosition = position;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }', fragmentShader: 'precision highp float;\n\n uniform samplerCube cubeTex;\n\n varying vec3 vPosition;\n\n void main() {\n vec3 normal = normalize(vPosition);\n vec4 color = textureCube(cubeTex, normal);\n gl_FragColor = color;\n }', side: THREE.BackSide })); }; SkyBox.prototype.render = function render(time) { this.uniforms.time.value += time; }; return SkyBox; }(); var PostEffect = function () { function PostEffect(texture) { _classCallCheck(this, PostEffect); this.uniforms = { time: { type: 'f', value: 0 }, resolution: { type: 'v2', value: new THREE.Vector2(window.innerWidth, window.innerHeight) }, texture: { type: 't', value: texture }, strengthZoom: { type: 'f', value: 0 }, strengthGlitch: { type: 'f', value: 0 } }; this.obj = this.createObj(); } PostEffect.prototype.createObj = function createObj() { return new THREE.Mesh(new THREE.PlaneBufferGeometry(2, 2), new THREE.RawShaderMaterial({ uniforms: this.uniforms, vertexShader: 'attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = vec4(position, 1.0);\n }', fragmentShader: 'precision highp float;\n\n uniform float time;\n uniform vec2 resolution;\n uniform sampler2D texture;\n uniform float strengthZoom;\n uniform float strengthGlitch;\n\n varying vec2 vUv;\n\n float random(vec2 c){\n return fract(sin(dot(c.xy ,vec2(12.9898,78.233))) * 43758.5453);\n }\n\n //\n // GLSL textureless classic 3D noise "cnoise",\n // with an RSL-style periodic variant "pnoise".\n // Author: Stefan Gustavson (stefan.gustavson@liu.se)\n // Version: 2011-10-11\n //\n // Many thanks to Ian McEwan of Ashima Arts for the\n // ideas for permutation and gradient selection.\n //\n // Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n // Distributed under the MIT license. See LICENSE file.\n // https://github.com/ashima/webgl-noise\n //\n\n vec3 mod289(vec3 x)\n {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec4 mod289(vec4 x)\n {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec4 permute(vec4 x)\n {\n return mod289(((x*34.0)+1.0)*x);\n }\n\n vec4 taylorInvSqrt(vec4 r)\n {\n return 1.79284291400159 - 0.85373472095314 * r;\n }\n\n vec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n }\n\n // Classic Perlin noise\n float cnoise(vec3 P)\n {\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n }\n\n void main(void){\n // zoom blur\n vec2 tFrag = 1.0 / resolution;\n float nFrag = 1.0 / 30.0;\n vec2 centerOffset = resolution / 2.0;\n vec3 destColor = vec3(0.0);\n vec2 fcc = gl_FragCoord.xy - centerOffset;\n float totalWeight = 0.0;\n\n for(float i = 0.0; i <= 30.0; i++){\n float percent = (i + random(gl_FragCoord.xy)) * nFrag;\n float weight = percent - percent * percent;\n vec2 t = gl_FragCoord.xy - fcc * percent * strengthZoom * nFrag;\n destColor += texture2D(texture, t * tFrag).rgb * weight;\n totalWeight += weight;\n }\n vec4 zoomColor = vec4(destColor / totalWeight, 1.0);\n\n // glitch\n float strengthWhiteNoise = min(strengthGlitch * 0.05, 0.1);\n float whiteNoise = (random(gl_FragCoord.xy + time) * 2.0 - 1.0) * (0.05 + strengthWhiteNoise);\n\n float strengthBlockNoise = min(strengthGlitch * 0.15, 1.2);\n float noiseX = step((cnoise(vec3(0.0, gl_FragCoord.x / resolution.x * 1.0, time * 600.0)) + 1.0) / 2.0, strengthBlockNoise * 0.6);\n float noiseY = step((cnoise(vec3(0.0, gl_FragCoord.y / resolution.y * 3.0, time * 200.0)) + 1.0) / 2.0, strengthBlockNoise * 0.3);\n float blockNoiseMask = noiseX * noiseY;\n vec4 blockNoise = texture2D(texture, 1.0 - vUv) * blockNoiseMask;\n\n gl_FragColor = zoomColor + whiteNoise + blockNoise;\n }' })); }; PostEffect.prototype.render = function render(time) { this.uniforms.time.value += time; }; PostEffect.prototype.resize = function resize() { this.uniforms.resolution.value.set(window.innerWidth, window.innerHeight); }; return PostEffect; }(); var ConsoleSignature = function () { function ConsoleSignature() { _classCallCheck(this, ConsoleSignature); this.message = 'created by yoichi kobayashi'; this.url = 'http://www.tplh.net'; this.show(); } ConsoleSignature.prototype.show = function show() { if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) { var args = ['\n%c ' + this.message + ' %c%c ' + this.url + ' \n\n', 'color: #fff; background: #222; padding:3px 0;', 'padding:3px 1px;', 'color: #fff; background: #47c; padding:3px 0;']; console.log.apply(console, args); } else if (window.console) { console.log(this.message + ' ' + this.url); } }; return ConsoleSignature; }(); var canvas = document.getElementById('canvas-webgl'); var renderer = new THREE.WebGLRenderer({ antialias: false, canvas: canvas, alpha: true }); var renderBack = new THREE.WebGLRenderTarget(window.innerWidth, window.innerHeight); var scene = new THREE.Scene(); var sceneBack = new THREE.Scene(); var camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); var cameraBack = new ForcePerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 100000); var cameraController = new CameraController(cameraBack); var clock = new THREE.Clock(); var vectorTouchStart = new THREE.Vector2(); var vectorTouchMove = new THREE.Vector2(); var vectorTouchEnd = new THREE.Vector2(); var isDrag = false; // // process for this sketch. // var cubeTexLoader = new THREE.CubeTextureLoader(); cubeTexLoader.setCrossOrigin('anonymous'); var debris = new Debris(); var skybox = new SkyBox(); var postEffect = new PostEffect(renderBack.texture); // // common process //gul var resizeWindow = function resizeWindow() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; cameraBack.aspect = window.innerWidth / window.innerHeight; cameraBack.updateProjectionMatrix(); postEffect.resize(); renderer.setSize(window.innerWidth, window.innerHeight); renderBack.setSize(window.innerWidth, window.innerHeight); }; var render = function render() { var now = clock.getDelta(); cameraController.render(); debris.render(now); skybox.render(now); postEffect.render(now); postEffect.uniforms.strengthZoom.value = cameraController.computeZoomLength(); postEffect.uniforms.strengthGlitch.value = cameraController.computeAcceleration(); renderer.render(sceneBack, cameraBack, renderBack); renderer.render(scene, camera); }; var renderLoop = function renderLoop() { render(); requestAnimationFrame(renderLoop); }; var touchStart = function touchStart(isTouched) { isDrag = true; }; var touchMove = function touchMove(isTouched) { if (isDrag) { cameraController.rotate(vectorTouchStart.x - vectorTouchMove.x, vectorTouchStart.y - vectorTouchMove.y); } }; var touchEnd = function touchEnd(isTouched) { isDrag = false; cameraController.touchEnd(); }; var mouseOut = function mouseOut() { isDrag = false; }; var wheel = function wheel(event) { cameraController.zoom(event.deltaY); }; var on = function on() { window.addEventListener('resize', debounce(function () { resizeWindow(); }), 1000); canvas.addEventListener('mousedown', function (event) { event.preventDefault(); vectorTouchStart.set(event.clientX, event.clientY); normalizeVector2(vectorTouchStart); touchStart(false); }); canvas.addEventListener('mousemove', function (event) { event.preventDefault(); vectorTouchMove.set(event.clientX, event.clientY); normalizeVector2(vectorTouchMove); touchMove(false); }); canvas.addEventListener('mouseup', function (event) { event.preventDefault(); vectorTouchEnd.set(event.clientX, event.clientY); normalizeVector2(vectorTouchEnd); touchEnd(false); }); canvas.addEventListener('mouseout', function (event) { event.preventDefault(); vectorTouchEnd.set(event.clientX, event.clientY); normalizeVector2(vectorTouchEnd); touchEnd(false); }); canvas.addEventListener('wheel', function (event) { event.preventDefault(); wheel(event); }); canvas.addEventListener('touchstart', function (event) { event.preventDefault(); vectorTouchStart.set(event.touches[0].clientX, event.touches[0].clientY); normalizeVector2(vectorTouchStart); touchStart(event.touches[0].clientX, event.touches[0].clientY, true); }); canvas.addEventListener('touchmove', function (event) { event.preventDefault(); vectorTouchMove.set(event.touches[0].clientX, event.touches[0].clientY); normalizeVector2(vectorTouchMove); touchMove(true); }); canvas.addEventListener('touchend', function (event) { event.preventDefault(); vectorTouchEnd.set(event.changedTouches[0].clientX, event.changedTouches[0].clientY); normalizeVector2(vectorTouchEnd); touchEnd(true); }); }; var consoleSignature = new ConsoleSignature(); var init = function init() { renderer.setSize(window.innerWidth, window.innerHeight); renderer.setClearColor(0xeeeeee, 1.0); cubeTexLoader.setPath('http://www.tplh.net/file/skybox/').load(["cubemap_px.png", "cubemap_nx.png", "cubemap_py.png", "cubemap_ny.png", "cubemap_pz.png", "cubemap_nz.png"], function (tex) { debris.init(tex); skybox.init(tex); scene.add(postEffect.obj); sceneBack.add(debris.obj); sceneBack.add(skybox.obj); }); on(); resizeWindow(); renderLoop(); }; init();
CSS
@import url("https://fonts.googleapis.com/css?family=Homenaje"); .p-canvas-webgl { position: fixed; z-index: 1; top: 0; left: 0; } .p-summary { position: absolute; top: 20px; left: 20px; z-index: 2; color: #fff; font-family: 'Homenaje', sans-serif; } .p-summary h1 { margin: 0 0 0.2em; font-size: 42px; font-weight: 400; letter-spacing: 0.05em; } .p-summary p { margin: 0; font-size: 1.1rem; letter-spacing: 0.1em; } .p-summary a { color: #fff; }
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